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

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

Issue 2696653004: [Script Spec Annotation] Annotate and refactor script element's flags (Closed)
Patch Set: Created 3 years, 10 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: third_party/WebKit/Source/core/dom/ScriptLoader.cpp
diff --git a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
index 50498e1534f96ceec3bf953f249a08a64a8a168c..f2269ed1d585a27f5a3a933ab132cae8045a2abe 100644
--- a/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
+++ b/third_party/WebKit/Source/core/dom/ScriptLoader.cpp
@@ -66,14 +66,29 @@ ScriptLoader::ScriptLoader(Element* element,
bool createdDuringDocumentWrite)
: m_element(element),
m_startLineNumber(WTF::OrdinalNumber::beforeFirst()),
+
+ // https://html.spec.whatwg.org/#already-started
+ // "Initially, script elements must have this flag unset"
+ // "The cloning steps for script elements must set the "already started"
+ // flag on the copy if it is set on the element being cloned."
kouhei (in TOK) 2017/02/13 21:31:08 My understanding is that cloning steps are impleme
hiroshige 2017/02/13 21:46:52 Agree. Added TODO.
+ m_alreadyStarted(alreadyStarted),
+
+ // https://html.spec.whatwg.org/#parser-inserted
+ // "Initially, script elements must have this flag unset."
+ // "It is set by the HTML parser and the XML parser on script elements
+ // they insert"
m_parserInserted(parserInserted),
+
+ // https://html.spec.whatwg.org/#non-blocking
+ // "Initially, script elements must have this flag set."
+ // "It is unset by the HTML parser and the XML parser on script
+ // elements they insert.
+ m_nonBlocking(!parserInserted),
+
m_isExternalScript(false),
- m_alreadyStarted(alreadyStarted),
m_haveFiredLoad(false),
m_willBeParserExecuted(false),
- m_readyToBeParserExecuted(false),
m_willExecuteWhenDocumentFinishedParsing(false),
- m_forceAsync(!parserInserted),
m_createdDuringDocumentWrite(createdDuringDocumentWrite),
m_asyncExecType(ScriptRunner::None),
m_documentWriteIntervention(
@@ -118,7 +133,11 @@ void ScriptLoader::handleSourceAttribute(const String& sourceUrl) {
}
void ScriptLoader::handleAsyncAttribute() {
- m_forceAsync = false;
+ // https://html.spec.whatwg.org/#non-blocking
+ // "In addition, whenever a script element whose "non-blocking" flag is set
+ // has an async content attribute added, the element's "non-blocking" flag
+ // must be unset."
+ m_nonBlocking = false;
}
void ScriptLoader::detach() {
@@ -216,7 +235,7 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition,
}
if (wasParserInserted && !client->asyncAttributeValue())
- m_forceAsync = true;
+ m_nonBlocking = true;
// FIXME: HTML5 spec says we should check that all children are either
// comments or empty text nodes.
@@ -231,7 +250,7 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition,
if (wasParserInserted) {
m_parserInserted = true;
- m_forceAsync = false;
+ m_nonBlocking = false;
}
m_alreadyStarted = true;
@@ -287,7 +306,7 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition,
m_willBeParserExecuted = true;
m_readyToBeParserExecuted = true;
} else if (client->hasSourceAttribute() && !client->asyncAttributeValue() &&
- !m_forceAsync) {
+ !m_nonBlocking) {
m_pendingScript = PendingScript::create(m_element, m_resource.get());
m_asyncExecType = ScriptRunner::InOrder;
contextDocument->scriptRunner()->queueScriptForExecution(this,

Powered by Google App Engine
This is Rietveld 408576698