2 * Copyright (C) 2003 Apple Computer, Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
13 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
17 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 #import "KWQPageState.h"
28 #import <JavaScriptCore/property_map.h>
30 #import "dom_docimpl.h"
32 #import "kjs_window.h"
34 #import "KWQAssertions.h"
35 #import "KWQFoundationExtras.h"
36 #import "KWQKHTMLPart.h"
38 using DOM::DocumentImpl;
40 using khtml::RenderObject;
42 using KJS::SavedProperties;
43 using KJS::SavedBuiltins;
45 @implementation KWQPageState
47 - initWithDocument:(DocumentImpl *)doc URL:(const KURL &)u windowProperties:(SavedProperties *)wp locationProperties:(SavedProperties *)lp interpreterBuiltins:(SavedBuiltins *)ib
52 document->setInPageCache(YES);
53 parseMode = document->parseMode();
54 document->view()->ref();
55 mousePressNode = static_cast<KWQKHTMLPart *>(document->part())->mousePressNode();
57 mousePressNode->ref();
60 windowProperties = wp;
61 locationProperties = lp;
62 interpreterBuiltins = ib;
66 - (DOM::DocumentImpl::ParseMode)parseMode { return parseMode; }
68 - (void)setPausedActions: (QMap<int, KJS::ScheduledAction*> *)pa
73 - (QMap<int, KJS::ScheduledAction*> *)pausedActions
78 - (void)_cleanupPausedActions
81 QMapIterator<int,KJS::ScheduledAction*> it;
82 for (it = pausedActions->begin(); it != pausedActions->end(); ++it) {
83 KJS::ScheduledAction *action = *it;
89 QObject::clearPausedTimers(self);
99 delete windowProperties;
100 windowProperties = 0;
101 delete locationProperties;
102 locationProperties = 0;
103 delete interpreterBuiltins;
104 interpreterBuiltins = 0;
105 [self _cleanupPausedActions];
110 // Should only ever invalidate once.
112 ASSERT(document->view());
113 ASSERT(!document->inPageCache());
115 if (document && document->view()) {
116 document->view()->deref();
126 ASSERT(document->inPageCache());
127 ASSERT(document->view());
129 KHTMLView *view = document->view();
131 KWQKHTMLPart::clearTimers(view);
133 bool detached = document->renderer() == 0;
134 document->setInPageCache(NO);
137 document->removeAllEventListenersFromAllNodes();
141 if (mousePressNode) {
142 mousePressNode->deref();
158 // FIXME: This work really should not be done at deallocation time.
159 // We need to do it at some well-defined time instead.
162 ASSERT(document->inPageCache());
163 ASSERT(document->view());
165 KHTMLView *view = document->view();
167 KWQKHTMLPart::clearTimers(view);
169 bool detached = document->renderer() == 0;
170 document->setInPageCache(NO);
173 document->removeAllEventListenersFromAllNodes();
188 - (DocumentImpl *)document
193 - (DOM::NodeImpl *)mousePressNode
195 return mousePressNode;
203 - (SavedProperties *)windowProperties
205 return windowProperties;
208 - (SavedProperties *)locationProperties
210 return locationProperties;
213 - (SavedBuiltins *)interpreterBuiltins
215 return interpreterBuiltins;