Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: Source/core/frame/LocalFrame.cpp

Issue 645623004: Reland "Streamline frame detach" (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 // A lot of the following steps can result in the current frame being 168 // A lot of the following steps can result in the current frame being
169 // detached, so protect a reference to it. 169 // detached, so protect a reference to it.
170 RefPtrWillBeRawPtr<LocalFrame> protect(this); 170 RefPtrWillBeRawPtr<LocalFrame> protect(this);
171 m_loader.stopAllLoaders(); 171 m_loader.stopAllLoaders();
172 m_loader.closeURL(); 172 m_loader.closeURL();
173 detachChildren(); 173 detachChildren();
174 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren() 174 // stopAllLoaders() needs to be called after detachChildren(), because detac hChildren()
175 // will trigger the unload event handlers of any child frames, and those eve nt 175 // will trigger the unload event handlers of any child frames, and those eve nt
176 // handlers might start a new subresource load in this frame. 176 // handlers might start a new subresource load in this frame.
177 m_loader.stopAllLoaders(); 177 m_loader.stopAllLoaders();
178 m_loader.detachFromParent(); 178 if (!client())
179 return;
180 m_loader.detach();
181 setView(nullptr);
182 willDetachFrameHost();
183 // Notify ScriptController that the frame is closing, since its cleanup ends up calling
184 // back to FrameLoaderClient via WindowProxy.
185 script().clearForClose();
186 InspectorInstrumentation::frameDetachedFromParent(this);
187 Frame::detach();
179 } 188 }
180 189
181 bool LocalFrame::inScope(TreeScope* scope) const 190 bool LocalFrame::inScope(TreeScope* scope) const
182 { 191 {
183 ASSERT(scope); 192 ASSERT(scope);
184 Document* doc = document(); 193 Document* doc = document();
185 if (!doc) 194 if (!doc)
186 return false; 195 return false;
187 // FIXME: This check is broken in for OOPI. 196 // FIXME: This check is broken in for OOPI.
188 HTMLFrameOwnerElement* owner = doc->ownerElement(); 197 HTMLFrameOwnerElement* owner = doc->ownerElement();
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 m_destructionObservers.add(observer); 327 m_destructionObservers.add(observer);
319 } 328 }
320 329
321 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer) 330 void LocalFrame::removeDestructionObserver(FrameDestructionObserver* observer)
322 { 331 {
323 m_destructionObservers.remove(observer); 332 m_destructionObservers.remove(observer);
324 } 333 }
325 334
326 void LocalFrame::willDetachFrameHost() 335 void LocalFrame::willDetachFrameHost()
327 { 336 {
328 // We should never be detatching the page during a Layout.
329 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout());
330
331 Frame* parent = tree().parent();
332 if (parent && parent->isLocalFrame())
333 toLocalFrame(parent)->loader().checkLoadComplete();
334 337
335 WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::iterat or stop = m_destructionObservers.end(); 338 WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::iterat or stop = m_destructionObservers.end();
336 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::i terator it = m_destructionObservers.begin(); it != stop; ++it) 339 for (WillBeHeapHashSet<RawPtrWillBeWeakMember<FrameDestructionObserver> >::i terator it = m_destructionObservers.begin(); it != stop; ++it)
337 (*it)->willDetachFrameHost(); 340 (*it)->willDetachFrameHost();
338 341
339 // FIXME: Page should take care of updating focus/scrolling instead of Frame . 342 // FIXME: Page should take care of updating focus/scrolling instead of Frame .
340 // FIXME: It's unclear as to why this is called more than once, but it is, 343 // FIXME: It's unclear as to why this is called more than once, but it is,
341 // so page() could be null. 344 // so page() could be null.
342 if (page() && page()->focusController().focusedFrame() == this) 345 if (page() && page()->focusController().focusedFrame() == this)
343 page()->focusController().setFocusedFrame(nullptr); 346 page()->focusController().setFocusedFrame(nullptr);
344 script().clearScriptObjects(); 347 script().clearScriptObjects();
345 348
346 if (page() && page()->scrollingCoordinator() && m_view) 349 if (page() && page()->scrollingCoordinator() && m_view)
347 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get()); 350 page()->scrollingCoordinator()->willDestroyScrollableArea(m_view.get());
348 } 351 }
349 352
350 void LocalFrame::detachFromFrameHost()
351 {
352 // We should never be detaching the page during a Layout.
353 RELEASE_ASSERT(!m_view || !m_view->isInPerformLayout());
354 m_host = nullptr;
355 }
356
357 String LocalFrame::documentTypeString() const 353 String LocalFrame::documentTypeString() const
358 { 354 {
359 if (DocumentType* doctype = document()->doctype()) 355 if (DocumentType* doctype = document()->doctype())
360 return createMarkup(doctype); 356 return createMarkup(doctype);
361 357
362 return String(); 358 return String();
363 } 359 }
364 360
365 String LocalFrame::selectedText() const 361 String LocalFrame::selectedText() const
366 { 362 {
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
583 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) { 579 for (RefPtrWillBeRawPtr<Frame> child = tree().firstChild(); child; child = c hild->tree().nextSibling()) {
584 if (child->isLocalFrame()) 580 if (child->isLocalFrame())
585 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged(); 581 toLocalFrame(child.get())->deviceOrPageScaleFactorChanged();
586 } 582 }
587 } 583 }
588 584
589 bool LocalFrame::isURLAllowed(const KURL& url) const 585 bool LocalFrame::isURLAllowed(const KURL& url) const
590 { 586 {
591 // We allow one level of self-reference because some sites depend on that, 587 // We allow one level of self-reference because some sites depend on that,
592 // but we don't allow more than one. 588 // but we don't allow more than one.
593 if (page()->subframeCount() >= Page::maxNumberOfFrames) 589 if (host()->frameCount() >= FrameHost::maxNumberOfFrames)
594 return false; 590 return false;
595 bool foundSelfReference = false; 591 bool foundSelfReference = false;
596 for (const Frame* frame = this; frame; frame = frame->tree().parent()) { 592 for (const Frame* frame = this; frame; frame = frame->tree().parent()) {
597 if (!frame->isLocalFrame()) 593 if (!frame->isLocalFrame())
598 continue; 594 continue;
599 if (equalIgnoringFragmentIdentifier(toLocalFrame(frame)->document()->url (), url)) { 595 if (equalIgnoringFragmentIdentifier(toLocalFrame(frame)->document()->url (), url)) {
600 if (foundSelfReference) 596 if (foundSelfReference)
601 return false; 597 return false;
602 foundSelfReference = true; 598 foundSelfReference = true;
603 } 599 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 737
742 return curFrame; 738 return curFrame;
743 } 739 }
744 740
745 void LocalFrame::setPagePopupOwner(Element& owner) 741 void LocalFrame::setPagePopupOwner(Element& owner)
746 { 742 {
747 m_pagePopupOwner = &owner; 743 m_pagePopupOwner = &owner;
748 } 744 }
749 745
750 } // namespace blink 746 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698