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

Unified Diff: Source/core/loader/FrameLoader.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, 9 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 side-by-side diff with in-line comments
Download patch
Index: Source/core/loader/FrameLoader.cpp
diff --git a/Source/core/loader/FrameLoader.cpp b/Source/core/loader/FrameLoader.cpp
index 922fb8214a549fff262e326be04cf7f61258e42b..32729f6cd1a2f100b0d8963858c94a6e786e3dd4 100644
--- a/Source/core/loader/FrameLoader.cpp
+++ b/Source/core/loader/FrameLoader.cpp
@@ -242,7 +242,6 @@ void FrameLoader::clear()
m_frame->editor().clear();
m_frame->document()->cancelParsing();
- m_frame->document()->prepareForDestruction();
m_frame->document()->removeFocusedElementOfSubtree(m_frame->document());
m_frame->selection().prepareForDestruction();
m_frame->eventHandler().clear();
@@ -279,9 +278,11 @@ void FrameLoader::replaceDocumentWhileExecutingJavaScriptURL(const String& sourc
init.withNewRegistrationContext();
stopAllLoaders();
+ m_frame->detachChildren();
+ m_frame->document()->prepareForDestruction();
clear();
- // clear() potentially detaches the frame from the document. The
+ // detachChildren() potentially detaches the frame from the document. The
// loading cannot continue in that case.
if (!m_frame->page())
return;
@@ -964,7 +965,14 @@ void FrameLoader::commitProvisionalLoad()
client()->dispatchWillClose();
dispatchUnloadEvent();
}
- m_frame->detachChildren();
+ if (m_frame->document()) {
+ m_frame->detachChildren();
Nate Chapin 2015/04/03 20:42:32 It's clear to me why detachChildren() is a noop if
dcheng 2015/04/03 20:47:20 The idea is if there's no document, there should b
+ m_frame->document()->prepareForDestruction();
+ } else {
+ // If there is no document, this is the creation of the initial empty
+ // doc, and there should be no child frames.
+ ASSERT(m_frame->tree().childCount() == 0);
Nate Chapin 2015/04/03 20:42:32 Maybe drop this else{} clause and ASSERT this unco
dcheng 2015/04/03 20:47:20 Done.
+ }
if (pdl != m_provisionalDocumentLoader)
return;
if (m_documentLoader)

Powered by Google App Engine
This is Rietveld 408576698