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

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

Issue 514893002: Lower priority of async scripts (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Moved async script priority to low Created 6 years, 4 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: Source/core/dom/ScriptLoader.cpp
diff --git a/Source/core/dom/ScriptLoader.cpp b/Source/core/dom/ScriptLoader.cpp
index f69e0e63d362e4750b5f16bbce060813de6b7058..4dea7b47e475275550b62de50658a5a59fdaef79 100644
--- a/Source/core/dom/ScriptLoader.cpp
+++ b/Source/core/dom/ScriptLoader.cpp
@@ -65,6 +65,8 @@ ScriptLoader::ScriptLoader(Element* element, bool parserInserted, bool alreadySt
, m_readyToBeParserExecuted(false)
, m_willExecuteWhenDocumentFinishedParsing(false)
, m_forceAsync(!parserInserted)
+ , m_hasAsyncAttribute(false)
+ , m_hasDeferAttribute(false)
, m_willExecuteInOrder(false)
{
ASSERT(m_element);
@@ -100,6 +102,7 @@ void ScriptLoader::handleSourceAttribute(const String& sourceUrl)
void ScriptLoader::handleAsyncAttribute()
{
m_forceAsync = false;
eseidel 2014/09/03 15:18:10 Are these two bools related? Should they be an en
Pat Meenan 2014/09/03 16:16:17 We might be able to use just the existing m_forceA
+ m_hasAsyncAttribute = true;
}
// Helper function
@@ -184,6 +187,9 @@ bool ScriptLoader::prepareScript(const TextPosition& scriptStartPosition, Legacy
if (wasParserInserted && !client->asyncAttributeValue())
m_forceAsync = true;
+ if (client->deferAttributeValue())
+ m_hasDeferAttribute = true;
+
// FIXME: HTML5 spec says we should check that all children are either comments or empty text nodes.
if (!client->hasSourceAttribute() && !m_element->hasChildren())
return false;
@@ -267,6 +273,9 @@ bool ScriptLoader::fetchScript(const String& sourceUrl)
if (scriptPassesCSP)
request.setContentSecurityCheck(DoNotCheckContentSecurityPolicy);
+ if (!m_parserInserted || m_hasAsyncAttribute || m_hasDeferAttribute)
+ request.setExecAsync(true);
+
m_resource = elementDocument->fetcher()->fetchScript(request);
m_isExternalScript = true;
}

Powered by Google App Engine
This is Rietveld 408576698