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

Unified Diff: Source/core/loader/FrameLoader.cpp

Issue 806183005: Remove FrameLoader's checkLoadComplete and checkLoadCompleteForThisFrame (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 11 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
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/loader/FrameLoader.cpp
diff --git a/Source/core/loader/FrameLoader.cpp b/Source/core/loader/FrameLoader.cpp
index 0cd49ca0058ae98282bfc90ea6ceecda93fa5622..aa86b5459bba7b453f560be38923216bac252d64 100644
--- a/Source/core/loader/FrameLoader.cpp
+++ b/Source/core/loader/FrameLoader.cpp
@@ -249,10 +249,10 @@ bool FrameLoader::closeURL()
void FrameLoader::didExplicitOpen()
{
// Calling document.open counts as committing the first real document load.
- if (!m_stateMachine.committedFirstRealDocumentLoad()) {
+ if (!m_stateMachine.committedFirstRealDocumentLoad())
m_stateMachine.advanceTo(FrameLoaderStateMachine::CommittedFirstRealLoad);
- m_progressTracker->progressStarted();
- }
+
+ m_progressTracker->progressStarted();
// Prevent window.open(url) -- eg window.open("about:blank") -- from blowing away results
// from a subsequent window.document.open / window.document.write call.
@@ -446,15 +446,8 @@ void FrameLoader::loadDone()
bool FrameLoader::allChildrenAreComplete() const
{
- for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
- if (!child->isLocalFrame()) {
- if (!child->checkLoadComplete()) {
- return false;
- }
- continue;
- }
- LocalFrame* frame = toLocalFrame(child);
- if (!frame->document()->isLoadCompleted() || frame->loader().m_provisionalDocumentLoader)
+ for (Frame* child = m_frame->tree().firstChild(); child; child = child->tree().traverseNext(m_frame)) {
+ if (child->isLoading())
return false;
}
return true;
@@ -463,15 +456,8 @@ bool FrameLoader::allChildrenAreComplete() const
bool FrameLoader::allAncestorsAreComplete() const
{
for (Frame* ancestor = m_frame; ancestor; ancestor = ancestor->tree().parent()) {
- if (ancestor->isLocalFrame()) {
- if (!toLocalFrame(ancestor)->document()->loadEventFinished())
- return false;
- } else {
- if (!ancestor->checkLoadComplete()) {
- return false;
- }
- }
-
+ if (ancestor->isLoading())
+ return false;
}
return true;
}
@@ -480,9 +466,6 @@ void FrameLoader::checkCompleted()
{
RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
- if (m_frame->document()->isLoadCompleted() && m_stateMachine.committedFirstRealDocumentLoad())
- return;
-
// Are we still parsing?
if (m_frame->document()->parsing() || m_frame->document()->isInDOMContentLoaded())
return;
@@ -516,11 +499,27 @@ void FrameLoader::checkCompleted()
if (m_frame->view())
m_frame->view()->handleLoadCompleted();
+ // FIXME: this if() statement is gross, but all clauses appear to be necessary. In order:
+ // * Don't send stop notifications for inital empty documents, since they don't generate start notifications.
+ // * We might have already sent stop notifications and be re-completing. (this is hopefully fixable)
+ // * The readystatechanged or load event may have disconnected this frame.
+ // * An event might have restarted a child frame.
+ // * An event might have restarted this frame by scheduling a new navigation.
+ // * We might have declined to run the load event due to an imminent content-initiated navigation.
+ if (m_stateMachine.committedFirstRealDocumentLoad() && m_frame->isLoading() && client() && allChildrenAreComplete() && !m_provisionalDocumentLoader && m_frame->document()->loadEventFinished()) {
dcheng 2015/01/09 07:43:55 For readability, it might be nice to split this to
+ m_loadType = FrameLoadTypeStandard;
+ m_progressTracker->progressCompleted();
+ m_frame->localDOMWindow()->finishedLoading();
+
+ // Report mobile vs. desktop page statistics. This will only report on Android.
+ if (m_frame->isMainFrame())
+ m_frame->document()->viewportDescription().reportMobilePageStats(m_frame);
+ client()->dispatchDidFinishLoad();
+ }
+
Frame* parent = m_frame->tree().parent();
if (parent && parent->isLocalFrame())
toLocalFrame(parent)->loader().checkCompleted();
- if (m_frame->page())
- checkLoadComplete();
}
void FrameLoader::checkTimerFired(Timer<FrameLoader>*)
@@ -991,39 +990,6 @@ FrameLoadType FrameLoader::loadType() const
return m_loadType;
}
-bool FrameLoader::checkLoadCompleteForThisFrame()
-{
- ASSERT(client()->hasWebView());
- RefPtrWillBeRawPtr<LocalFrame> protect(m_frame.get());
-
- bool allChildrenAreDoneLoading = true;
- for (RefPtrWillBeRawPtr<Frame> child = m_frame->tree().firstChild(); child; child = child->tree().nextSibling()) {
- allChildrenAreDoneLoading &= child->checkLoadComplete();
- }
- if (!allChildrenAreDoneLoading)
- return false;
-
- if (!m_frame->isLoading())
- return true;
- if (m_provisionalDocumentLoader || !m_documentLoader)
- return false;
- if (!m_frame->document()->loadEventFinished())
- return false;
- if (!m_stateMachine.committedFirstRealDocumentLoad())
- return true;
-
- m_progressTracker->progressCompleted();
- m_frame->localDOMWindow()->finishedLoading();
-
- // Report mobile vs. desktop page statistics. This will only report on Android.
- if (m_frame->isMainFrame())
- m_frame->document()->viewportDescription().reportMobilePageStats(m_frame);
-
- client()->dispatchDidFinishLoad();
- m_loadType = FrameLoadTypeStandard;
- return true;
-}
-
void FrameLoader::restoreScrollPositionAndViewState()
{
FrameView* view = m_frame->view();
@@ -1071,13 +1037,6 @@ void FrameLoader::restoreScrollPositionAndViewState()
}
}
-// Called every time a resource is completely loaded or an error is received.
-void FrameLoader::checkLoadComplete()
-{
- ASSERT(client()->hasWebView());
- m_frame->page()->mainFrame()->checkLoadComplete();
-}
-
String FrameLoader::userAgent(const KURL& url) const
{
String userAgent = client()->userAgent(url);
@@ -1134,10 +1093,7 @@ void FrameLoader::receivedMainResourceError(DocumentLoader* loader, const Resour
m_progressTracker->progressCompleted();
}
}
-
checkCompleted();
- if (m_frame->page())
- checkLoadComplete();
}
bool FrameLoader::shouldPerformFragmentNavigation(bool isFormSubmission, const String& httpMethod, FrameLoadType loadType, const KURL& url)
« no previous file with comments | « Source/core/loader/FrameLoader.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698