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

Unified Diff: third_party/WebKit/Source/core/dom/Document.cpp

Issue 2836103003: Revert of Move most of FrameLoader::CheckCompleted() to Document (Closed)
Patch Set: Created 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/DocumentTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/Document.cpp
diff --git a/third_party/WebKit/Source/core/dom/Document.cpp b/third_party/WebKit/Source/core/dom/Document.cpp
index 3de8c5c17c52a9d1f2f54b6c522aa896b04d0adb..019d228e16e8560e2a587c2fdf95ec8f42e634cb 100644
--- a/third_party/WebKit/Source/core/dom/Document.cpp
+++ b/third_party/WebKit/Source/core/dom/Document.cpp
@@ -488,7 +488,7 @@
this,
&Document::UpdateFocusAppearanceTimerFired),
css_target_(nullptr),
- load_event_progress_(kLoadEventCompleted),
+ load_event_progress_(kLoadEventNotRun),
start_time_(CurrentTime()),
script_runner_(ScriptRunner::Create(this)),
xml_version_("1.0"),
@@ -2770,6 +2770,9 @@
if (frame_)
frame_->Loader().DidExplicitOpen();
+ if (load_event_progress_ != kLoadEventInProgress &&
+ PageDismissalEventBeingDispatched() == kNoDismissal)
+ load_event_progress_ = kLoadEventNotRun;
}
void Document::DetachParser() {
@@ -2784,11 +2787,12 @@
DetachParser();
SetParsingState(kFinishedParsing);
SetReadyState(kComplete);
- SuppressLoadEvent();
}
DocumentParser* Document::ImplicitOpen(
ParserSynchronizationPolicy parser_sync_policy) {
+ DetachParser();
+
RemoveChildren();
DCHECK(!focused_element_);
@@ -2802,16 +2806,11 @@
parser_sync_policy = kForceSynchronousParsing;
}
- DetachParser();
parser_sync_policy_ = parser_sync_policy;
parser_ = CreateParser();
DocumentParserTiming::From(*this).MarkParserStart();
SetParsingState(kParsing);
SetReadyState(kLoading);
- if (load_event_progress_ != kLoadEventInProgress &&
- PageDismissalEventBeingDispatched() == kNoDismissal) {
- load_event_progress_ = kLoadEventNotRun;
- }
return parser_;
}
@@ -2953,15 +2952,30 @@
!GetScriptableDocumentParser()->IsParsing())
return;
- parser_->Finish();
- if (!parser_ || !parser_->IsParsing())
- SetReadyState(kComplete);
- CheckCompleted();
+ if (DocumentParser* parser = parser_)
+ parser->Finish();
+
+ if (!frame_) {
+ // Because we have no frame, we don't know if all loading has completed,
+ // so we just call implicitClose() immediately. FIXME: This might fire
+ // the load event prematurely
+ // <http://bugs.webkit.org/show_bug.cgi?id=14568>.
+ ImplicitClose();
+ return;
+ }
+
+ frame_->Loader().CheckCompleted();
}
void Document::ImplicitClose() {
DCHECK(!InStyleRecalc());
- DCHECK(parser_);
+ if (ProcessingLoadEvent() || !parser_)
+ return;
+ if (GetFrame() &&
+ GetFrame()->GetNavigationScheduler().LocationChangePending()) {
+ SuppressLoadEvent();
+ return;
+ }
load_event_progress_ = kLoadEventInProgress;
@@ -3041,69 +3055,6 @@
if (SvgExtensions())
AccessSVGExtensions().StartAnimations();
-}
-
-static bool AllDescendantsAreComplete(Frame* frame) {
- if (!frame)
- return true;
- for (Frame* child = frame->Tree().FirstChild(); child;
- child = child->Tree().TraverseNext(frame)) {
- if (child->IsLoading())
- return false;
- }
- return true;
-}
-
-bool Document::ShouldComplete() {
- return parsing_state_ == kFinishedParsing && HaveImportsLoaded() &&
- !fetcher_->BlockingRequestCount() && !IsDelayingLoadEvent() &&
- load_event_progress_ != kLoadEventInProgress &&
- AllDescendantsAreComplete(frame_);
-}
-
-void Document::CheckCompleted() {
- if (!ShouldComplete())
- return;
-
- if (frame_) {
- frame_->Client()->RunScriptsAtDocumentIdle();
-
- // Injected scripts may have disconnected this frame.
- if (!frame_)
- return;
-
- // Check again, because runScriptsAtDocumentIdle() may have delayed the load
- // event.
- if (!ShouldComplete())
- return;
- }
-
- // OK, completed. Fire load completion events as needed.
- SetReadyState(kComplete);
- if (LoadEventStillNeeded())
- ImplicitClose();
-
- // The readystatechanged or load event may have disconnected this frame.
- if (!frame_ || !frame_->IsAttached())
- return;
- frame_->GetNavigationScheduler().StartTimer();
- View()->HandleLoadCompleted();
- // The document itself is complete, but if a child frame was restarted due to
- // an event, this document is still considered to be in progress.
- if (!AllDescendantsAreComplete(frame_))
- return;
-
- // No need to repeat if we've already notified this load as finished.
- if (!Loader()->SentDidFinishLoad()) {
- if (frame_->IsMainFrame())
- ViewportDescription().ReportMobilePageStats(frame_);
- Loader()->SetSentDidFinishLoad();
- frame_->Client()->DispatchDidFinishLoad();
- if (!frame_)
- return;
- }
-
- frame_->Loader().DidFinishNavigation();
}
bool Document::DispatchBeforeUnloadEvent(ChromeClient& chrome_client,
@@ -6029,8 +5980,8 @@
DCHECK(load_event_delay_count_);
--load_event_delay_count_;
- if (!load_event_delay_count_)
- CheckCompleted();
+ if (!load_event_delay_count_ && GetFrame())
+ GetFrame()->Loader().CheckCompleted();
}
void Document::CheckLoadEventSoon() {
@@ -6052,7 +6003,8 @@
}
void Document::LoadEventDelayTimerFired(TimerBase*) {
- CheckCompleted();
+ if (GetFrame())
+ GetFrame()->Loader().CheckCompleted();
}
void Document::LoadPluginsSoon() {
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.h ('k') | third_party/WebKit/Source/core/dom/DocumentTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698