Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index d721e4f70ef5cc5e9ed19d164121c13196463f12..b1e8f2e877fd7186efd27a8ef859384784a6db48 100644 |
--- a/Source/core/dom/Document.cpp |
+++ b/Source/core/dom/Document.cpp |
@@ -489,7 +489,7 @@ Document::Document(const DocumentInit& initializer, DocumentClassFlags documentC |
, m_contextDocument(initializer.contextDocument()) |
, m_hasFullscreenElementStack(false) |
, m_loadEventDelayCount(0) |
- , m_loadEventDelayTimer(this, &Document::loadEventDelayTimerFired) |
+ , m_loadEventTimer(this, &Document::loadEventTimerFired) |
, m_pluginLoadingTimer(this, &Document::pluginLoadingTimerFired) |
, m_didSetReferrerPolicy(false) |
, m_referrerPolicy(ReferrerPolicyDefault) |
@@ -2509,15 +2509,19 @@ void Document::implicitClose() |
ASSERT(!inStyleRecalc()); |
bool wasLocationChangePending = frame() && frame()->navigationScheduler().locationChangePending(); |
- bool doload = !parsing() && m_parser && !processingLoadEvent() && !wasLocationChangePending; |
- |
// If the load was blocked because of a pending location change and the location change triggers a same document |
// navigation, don't fire load events after the same document navigation completes (unless there's an explicit open). |
- m_loadEventProgress = LoadEventTried; |
- |
- if (!doload) |
+ if (parsing() || !m_parser || processingLoadEvent() || wasLocationChangePending) { |
+ m_loadEventProgress = LoadEventTried; |
return; |
+ } |
+ |
+ m_loadEventProgress = LoadEventScheduled; |
+ m_loadEventTimer.startOneShot(0, FROM_HERE); |
+} |
+void Document::loadEventTimerFired(Timer<Document>*) |
+{ |
// The call to dispatchWindowLoadEvent can detach the LocalDOMWindow and cause it (and its |
// attached Document) to be destroyed. |
RefPtrWillBeRawPtr<LocalDOMWindow> protectedWindow(this->domWindow()); |
@@ -2603,6 +2607,12 @@ void Document::implicitClose() |
if (svgExtensions()) |
accessSVGExtensions().startAnimations(); |
+ |
+ if (frame()) { |
+ if (Frame* parent = frame()->tree().parent()) |
+ toLocalFrame(parent)->loader().checkCompleted(); |
+ frame()->loader().checkLoadComplete(); |
+ } |
} |
bool Document::dispatchBeforeUnloadEvent(Chrome& chrome, bool& didAllowNavigation) |
@@ -5149,13 +5159,13 @@ void Document::decrementLoadEventDelayCount() |
--m_loadEventDelayCount; |
if (!m_loadEventDelayCount) |
- checkLoadEventSoon(); |
+ checkLoadEvent(); |
} |
-void Document::checkLoadEventSoon() |
+void Document::checkLoadEvent() |
{ |
- if (frame() && !m_loadEventDelayTimer.isActive()) |
- m_loadEventDelayTimer.startOneShot(0, FROM_HERE); |
+ if (frame()) |
+ frame()->loader().checkCompleted(); |
} |
bool Document::isDelayingLoadEvent() |
@@ -5167,18 +5177,11 @@ bool Document::isDelayingLoadEvent() |
// Node destructors. |
if (ThreadState::current()->isSweepInProgress()) { |
if (!m_loadEventDelayCount) |
- checkLoadEventSoon(); |
+ checkLoadEvent(); |
return true; |
} |
#endif |
- return m_loadEventDelayCount; |
-} |
- |
- |
-void Document::loadEventDelayTimerFired(Timer<Document>*) |
-{ |
- if (frame()) |
- frame()->loader().checkCompleted(); |
+ return m_loadEventDelayCount || m_loadEventTimer.isActive(); |
} |
void Document::loadPluginsSoon() |