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

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

Issue 496443008: Transfer pending async script loader to new document. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Robustify new test wrt expected output 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
« no previous file with comments | « Source/core/dom/ScriptRunner.h ('k') | Source/core/html/HTMLScriptElement.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/ScriptRunner.cpp
diff --git a/Source/core/dom/ScriptRunner.cpp b/Source/core/dom/ScriptRunner.cpp
index 11e99b83b0d954af2f766cc4a11f715d76a002ec..bc1a7a5d9171c6e0f22256a015f296582d954907 100644
--- a/Source/core/dom/ScriptRunner.cpp
+++ b/Source/core/dom/ScriptRunner.cpp
@@ -46,6 +46,12 @@ ScriptRunner::~ScriptRunner()
{
}
+void ScriptRunner::addPendingAsyncScript(ScriptLoader* scriptLoader, const PendingScript& pendingScript)
+{
+ m_document->incrementLoadEventDelayCount();
+ m_pendingAsyncScripts.add(scriptLoader, pendingScript);
+}
+
void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, ResourcePtr<ScriptResource> resource, ExecutionType executionType)
{
ASSERT(scriptLoader);
@@ -55,14 +61,13 @@ void ScriptRunner::queueScriptForExecution(ScriptLoader* scriptLoader, ResourceP
ASSERT(element);
ASSERT(element->inDocument());
- m_document->incrementLoadEventDelayCount();
-
switch (executionType) {
case ASYNC_EXECUTION:
- m_pendingAsyncScripts.add(scriptLoader, PendingScript(element, resource.get()));
+ addPendingAsyncScript(scriptLoader, PendingScript(element, resource.get()));
break;
case IN_ORDER_EXECUTION:
+ m_document->incrementLoadEventDelayCount();
m_scriptsToExecuteInOrder.append(PendingScript(element, resource.get()));
break;
}
@@ -109,6 +114,14 @@ void ScriptRunner::notifyScriptLoadError(ScriptLoader* scriptLoader, ExecutionTy
}
}
+void ScriptRunner::movePendingAsyncScript(ScriptRunner* newRunner, ScriptLoader* scriptLoader)
+{
+ if (m_pendingAsyncScripts.contains(scriptLoader)) {
+ newRunner->addPendingAsyncScript(scriptLoader, m_pendingAsyncScripts.take(scriptLoader));
+ m_document->decrementLoadEventDelayCount();
+ }
+}
+
void ScriptRunner::timerFired(Timer<ScriptRunner>* timer)
{
ASSERT_UNUSED(timer, timer == &m_timer);
« no previous file with comments | « Source/core/dom/ScriptRunner.h ('k') | Source/core/html/HTMLScriptElement.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698