Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / dom / ScriptRunner.cpp
index 11e99b8..bc1a7a5 100644 (file)
@@ -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);