OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> | 2 * Copyright (C) 1998, 1999 Torben Weis <weis@kde.org> |
3 * 1999 Lars Knoll <knoll@kde.org> | 3 * 1999 Lars Knoll <knoll@kde.org> |
4 * 1999 Antti Koivisto <koivisto@kde.org> | 4 * 1999 Antti Koivisto <koivisto@kde.org> |
5 * 2000 Simon Hausmann <hausmann@kde.org> | 5 * 2000 Simon Hausmann <hausmann@kde.org> |
6 * 2000 Stefan Schimanski <1Stein@gmx.de> | 6 * 2000 Stefan Schimanski <1Stein@gmx.de> |
7 * 2001 George Staikos <staikos@kde.org> | 7 * 2001 George Staikos <staikos@kde.org> |
8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. | 8 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All r ights reserved. |
9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> | 9 * Copyright (C) 2005 Alexey Proskuryakov <ap@nypop.com> |
10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) | 10 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
125 PassRefPtrWillBeRawPtr<LocalFrame> LocalFrame::create(FrameLoaderClient* client, FrameHost* host, FrameOwner* owner) | 125 PassRefPtrWillBeRawPtr<LocalFrame> LocalFrame::create(FrameLoaderClient* client, FrameHost* host, FrameOwner* owner) |
126 { | 126 { |
127 RefPtrWillBeRawPtr<LocalFrame> frame = adoptRefWillBeNoop(new LocalFrame(cli ent, host, owner)); | 127 RefPtrWillBeRawPtr<LocalFrame> frame = adoptRefWillBeNoop(new LocalFrame(cli ent, host, owner)); |
128 InspectorInstrumentation::frameAttachedToParent(frame.get()); | 128 InspectorInstrumentation::frameAttachedToParent(frame.get()); |
129 return frame.release(); | 129 return frame.release(); |
130 } | 130 } |
131 | 131 |
132 void LocalFrame::setView(PassRefPtrWillBeRawPtr<FrameView> view) | 132 void LocalFrame::setView(PassRefPtrWillBeRawPtr<FrameView> view) |
133 { | 133 { |
134 ASSERT(!m_view || m_view != view); | 134 ASSERT(!m_view || m_view != view); |
135 ASSERT(!document() || !document()->isActive()); | |
136 | |
135 detachView(); | 137 detachView(); |
136 | |
137 // Prepare for destruction now, so any unload event handlers get run and the LocalDOMWindow is | |
138 // notified. If we wait until the view is destroyed, then things won't be ho oked up enough for | |
139 // these calls to work. | |
140 if (!view && document() && document()->isActive()) { | |
141 // FIXME: We don't call willRemove here. Why is that OK? | |
142 document()->prepareForDestruction(); | |
143 } | |
144 | |
145 eventHandler().clear(); | 138 eventHandler().clear(); |
146 | 139 |
147 m_view = view; | 140 m_view = view; |
148 } | 141 } |
149 | 142 |
150 void LocalFrame::createView(const IntSize& viewportSize, const Color& background Color, bool transparent, | 143 void LocalFrame::createView(const IntSize& viewportSize, const Color& background Color, bool transparent, |
151 ScrollbarMode horizontalScrollbarMode, bool horizontalLock, | 144 ScrollbarMode horizontalScrollbarMode, bool horizontalLock, |
152 ScrollbarMode verticalScrollbarMode, bool verticalLock) | 145 ScrollbarMode verticalScrollbarMode, bool verticalLock) |
153 { | 146 { |
154 ASSERT(this); | 147 ASSERT(this); |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
260 // detached, so protect a reference to it. | 253 // detached, so protect a reference to it. |
261 RefPtrWillBeRawPtr<LocalFrame> protect(this); | 254 RefPtrWillBeRawPtr<LocalFrame> protect(this); |
262 m_loader.stopAllLoaders(); | 255 m_loader.stopAllLoaders(); |
263 m_loader.dispatchUnloadEvent(); | 256 m_loader.dispatchUnloadEvent(); |
264 detachChildren(); | 257 detachChildren(); |
265 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren() | 258 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren() |
266 // will trigger the unload event handlers of any child frames, and those eve nt | 259 // will trigger the unload event handlers of any child frames, and those eve nt |
267 // handlers might start a new subresource load in this frame. | 260 // handlers might start a new subresource load in this frame. |
268 m_loader.stopAllLoaders(); | 261 m_loader.stopAllLoaders(); |
269 m_loader.detach(); | 262 m_loader.detach(); |
263 { | |
264 ScriptForbiddenScope forbidScript; | |
265 document()->prepareForDestruction(); | |
266 m_loader.clear(); | |
dcheng
2015/04/03 14:35:45
Calling this multiple times appears to be safe, an
| |
267 } | |
270 if (!client()) | 268 if (!client()) |
271 return; | 269 return; |
272 | 270 |
273 client()->willBeDetached(); | 271 client()->willBeDetached(); |
274 // Notify ScriptController that the frame is closing, since its cleanup ends up calling | 272 // Notify ScriptController that the frame is closing, since its cleanup ends up calling |
275 // back to FrameLoaderClient via WindowProxy. | 273 // back to FrameLoaderClient via WindowProxy. |
276 script().clearForClose(); | 274 script().clearForClose(); |
277 ScriptForbiddenScope forbidScript; | 275 ScriptForbiddenScope forbidScript; |
278 setView(nullptr); | 276 setView(nullptr); |
279 willDetachFrameHost(); | 277 willDetachFrameHost(); |
280 InspectorInstrumentation::frameDetachedFromParent(this); | 278 InspectorInstrumentation::frameDetachedFromParent(this); |
281 Frame::detach(); | 279 Frame::detach(); |
282 // Clear the FrameLoader right here rather than during | |
283 // finalization. Too late to access various heap objects at that | |
284 // stage. | |
285 m_loader.clear(); | |
286 | 280 |
287 // Signal frame destruction here rather than in the destructor. | 281 // Signal frame destruction here rather than in the destructor. |
288 // Main motivation is to avoid being dependent on its exact timing (Oilpan.) | 282 // Main motivation is to avoid being dependent on its exact timing (Oilpan.) |
289 LocalFrameLifecycleNotifier::notifyContextDestroyed(); | 283 LocalFrameLifecycleNotifier::notifyContextDestroyed(); |
290 m_supplements.clear(); | 284 m_supplements.clear(); |
291 } | 285 } |
292 | 286 |
293 SecurityContext* LocalFrame::securityContext() const | 287 SecurityContext* LocalFrame::securityContext() const |
294 { | 288 { |
295 return document(); | 289 return document(); |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
839 // We detach the FrameView's custom scroll bars as early as | 833 // We detach the FrameView's custom scroll bars as early as |
840 // possible to prevent m_doc->detach() from messing with the view | 834 // possible to prevent m_doc->detach() from messing with the view |
841 // such that its scroll bars won't be torn down. | 835 // such that its scroll bars won't be torn down. |
842 // | 836 // |
843 // FIXME: We should revisit this. | 837 // FIXME: We should revisit this. |
844 if (m_view) | 838 if (m_view) |
845 m_view->prepareForDetach(); | 839 m_view->prepareForDetach(); |
846 } | 840 } |
847 | 841 |
848 } // namespace blink | 842 } // namespace blink |
OLD | NEW |