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

Side by Side Diff: Source/core/dom/Document.cpp

Issue 1052993006: Refactor frame navigation/detach state cleanup to be more sane. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Port comment over Created 5 years, 8 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org) 5 * (C) 2006 Alexey Proskuryakov (ap@webkit.org)
6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved. 6 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2011, 2012 Apple Inc. All r ights reserved.
7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/) 7 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. (http://www.t orchmobile.com/)
8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved. 8 * Copyright (C) 2008, 2009, 2011, 2012 Google Inc. All rights reserved.
9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies) 9 * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies)
10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. 10 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved.
(...skipping 2143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 // notifyContextDestroyed() for a document that doesn't get detached. 2154 // notifyContextDestroyed() for a document that doesn't get detached.
2155 // If such a document has any observer, the observer won't get 2155 // If such a document has any observer, the observer won't get
2156 // a contextDestroyed() notification. This can happen for a document 2156 // a contextDestroyed() notification. This can happen for a document
2157 // created by DOMImplementation::createDocument(). 2157 // created by DOMImplementation::createDocument().
2158 DocumentLifecycleNotifier::notifyContextDestroyed(); 2158 DocumentLifecycleNotifier::notifyContextDestroyed();
2159 ExecutionContext::notifyContextDestroyed(); 2159 ExecutionContext::notifyContextDestroyed();
2160 } 2160 }
2161 2161
2162 void Document::prepareForDestruction() 2162 void Document::prepareForDestruction()
2163 { 2163 {
2164 m_markers->prepareForDestruction(); 2164 ASSERT(!m_frame || m_frame->tree().childCount() == 0);
2165 disconnectDescendantFrames();
2166 2165
2167 // The process of disconnecting descendant frames could have already detache d us.
2168 if (!isActive()) 2166 if (!isActive())
2169 return; 2167 return;
2170 2168
2169 ScriptForbiddenScope forbidScript;
2170 // We detach the FrameView's custom scroll bars as early as
2171 // possible to prevent detach() from messing with the view
2172 // such that its scroll bars won't be torn down.
2173 //
2174 // FIXME: We should revisit this.
dcheng 2015/04/03 20:37:21 I moved this logic over from LocalFrame::detachVie
2175 view()->prepareForDetach();
2176 m_markers->prepareForDestruction();
2171 if (LocalDOMWindow* window = this->domWindow()) 2177 if (LocalDOMWindow* window = this->domWindow())
2172 window->willDetachDocumentFromFrame(); 2178 window->willDetachDocumentFromFrame();
2173 detach(); 2179 detach();
2174 } 2180 }
2175 2181
2176 void Document::removeAllEventListeners() 2182 void Document::removeAllEventListeners()
2177 { 2183 {
2178 ContainerNode::removeAllEventListeners(); 2184 ContainerNode::removeAllEventListeners();
2179 2185
2180 if (LocalDOMWindow* domWindow = this->domWindow()) 2186 if (LocalDOMWindow* domWindow = this->domWindow())
(...skipping 3516 matching lines...) Expand 10 before | Expand all | Expand 10 after
5697 #ifndef NDEBUG 5703 #ifndef NDEBUG
5698 using namespace blink; 5704 using namespace blink;
5699 void showLiveDocumentInstances() 5705 void showLiveDocumentInstances()
5700 { 5706 {
5701 WeakDocumentSet& set = liveDocumentSet(); 5707 WeakDocumentSet& set = liveDocumentSet();
5702 fprintf(stderr, "There are %u documents currently alive:\n", set.size()); 5708 fprintf(stderr, "There are %u documents currently alive:\n", set.size());
5703 for (Document* document : set) 5709 for (Document* document : set)
5704 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data()); 5710 fprintf(stderr, "- Document %p URL: %s\n", document, document->url().str ing().utf8().data());
5705 } 5711 }
5706 #endif 5712 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698