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

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

Issue 774033002: Run Microtasks before dispatching onload (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add comment Created 6 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index b92a8112c0063ca79affb5a4686305a1ec804699..d3967a4567c62c1bfd4b06c41c6f65b674913af8 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -77,6 +77,7 @@
#include "core/dom/ExceptionCode.h"
#include "core/dom/ExecutionContextTask.h"
#include "core/dom/MainThreadTaskRunner.h"
+#include "core/dom/Microtask.h"
#include "core/dom/MutationObserver.h"
#include "core/dom/NodeChildRemovalTracker.h"
#include "core/dom/NodeFilter.h"
@@ -4616,12 +4617,25 @@ void Document::finishedParsing()
ASSERT(!scriptableDocumentParser() || !m_parser->isParsing());
ASSERT(!scriptableDocumentParser() || m_readyState != Loading);
setParsingState(InDOMContentLoaded);
+
+ // FIXME: DOMContentLoaded should be dispatched in a queued task,
dominicc (has gone to gerrit) 2015/01/05 07:29:39 I think a good FIXME does three things: 1. Keeps
kouhei (in TOK) 2015/01/06 01:37:05 Done.
+ // but we are dispatching this synchronously at the moment.
+ // Spec: Section 12.2.6 "The end" step 4 and 5:
+ // https://html.spec.whatwg.org/multipage/syntax.html#the-end
+ // See https://crbug.com/425790
if (!m_documentTiming.domContentLoadedEventStart)
m_documentTiming.domContentLoadedEventStart = monotonicallyIncreasingTime();
dispatchEvent(Event::createBubble(EventTypeNames::DOMContentLoaded));
if (!m_documentTiming.domContentLoadedEventEnd)
m_documentTiming.domContentLoadedEventEnd = monotonicallyIncreasingTime();
setParsingState(FinishedParsing);
+ // Perform microtask checkpoint here as a partial fix to make this closer to spec.
+ // FIXME: This should be removed once the above dispatchEvent(DOMContentLoaded) is done asynchronously.
+ // Spec: Section 12.2.6 "Spin the event loop" step 5 says we should spin the event loop here:
+ // https://html.spec.whatwg.org/multipage/syntax.html#the-end
+ // Spinning the event loop includes performing a microtask checkpoint:
+ // https://html.spec.whatwg.org/multipage/webappapis.html#spin-the-event-loop
+ Microtask::performCheckpoint();
// The loader's finishedParsing() method may invoke script that causes this object to
// be dereferenced (when this document is in an iframe and the onload causes the iframe's src to change).
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698