[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc

tonyg at chromium.org tonyg at chromium.org
Wed Dec 22 11:47:36 UTC 2010


The following commit has been merged in the debian/experimental branch:
commit 980af9a4dd92fd72066c228ce4aa88cd10af6397
Author: tonyg at chromium.org <tonyg at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 6 22:07:50 2010 +0000

    2010-08-06  Tony Gentilcore  <tonyg at chromium.org>
    
            Reviewed by Eric Seidel.
    
            Factor an AsyncScriptRunner out of Document
            https://bugs.webkit.org/show_bug.cgi?id=43633
    
            This copies the existing implementation exactly. In the future
            this will use PendingScript which handles ref counting without
            the need for those manual ref()/deref()s. This is also currently
            a trivial class, but a little more logic will be added to it to
            support <script async>.
    
            No new tests because no new functionality.
    
            * Android.mk:
            * CMakeLists.txt:
            * GNUmakefile.am:
            * WebCore.gypi:
            * WebCore.pro:
            * WebCore.vcproj/WebCore.vcproj:
            * WebCore.xcodeproj/project.pbxproj:
            * dom/AsyncScriptRunner.cpp: Added.
            (WebCore::AsyncScriptRunner::AsyncScriptRunner):
            (WebCore::AsyncScriptRunner::~AsyncScriptRunner):
            (WebCore::AsyncScriptRunner::executeScriptSoon):
            (WebCore::AsyncScriptRunner::suspend):
            (WebCore::AsyncScriptRunner::resume):
            (WebCore::AsyncScriptRunner::timerFired):
            * dom/AsyncScriptRunner.h: Added.
            (WebCore::AsyncScriptRunner::create):
            (WebCore::AsyncScriptRunner::hasPendingScripts):
            * dom/Document.cpp:
            (WebCore::Document::Document):
            (WebCore::Document::~Document):
            * dom/Document.h:
            (WebCore::Document::asyncScriptRunner):
            * dom/ScriptElement.cpp:
            (WebCore::ScriptElementData::notifyFinished):
            * page/PageGroupLoadDeferrer.cpp:
            (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer):
            (WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer):
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@64873 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/Android.mk b/WebCore/Android.mk
index d7c7029..e3eabbe 100644
--- a/WebCore/Android.mk
+++ b/WebCore/Android.mk
@@ -98,6 +98,7 @@ LOCAL_SRC_FILES := $(LOCAL_SRC_FILES) \
 	css/WebKitCSSTransformValue.cpp \
 	\
 	dom/ActiveDOMObject.cpp \
+	dom/AsyncScriptRunner.cpp \
 	dom/Attr.cpp \
 	dom/Attribute.cpp \
 	dom/BeforeTextInsertedEvent.cpp \
diff --git a/WebCore/CMakeLists.txt b/WebCore/CMakeLists.txt
index 04161bc..1b14899 100644
--- a/WebCore/CMakeLists.txt
+++ b/WebCore/CMakeLists.txt
@@ -773,6 +773,7 @@ SET(WebCore_SOURCES
     css/WebKitCSSTransformValue.cpp
 
     dom/ActiveDOMObject.cpp
+    dom/AsyncScriptRunner.cpp
     dom/Attr.cpp
     dom/Attribute.cpp
     dom/BeforeTextInsertedEvent.cpp
diff --git a/WebCore/ChangeLog b/WebCore/ChangeLog
index aef1c3c..1ea6a8c 100644
--- a/WebCore/ChangeLog
+++ b/WebCore/ChangeLog
@@ -1,3 +1,46 @@
+2010-08-06  Tony Gentilcore  <tonyg at chromium.org>
+
+        Reviewed by Eric Seidel.
+
+        Factor an AsyncScriptRunner out of Document
+        https://bugs.webkit.org/show_bug.cgi?id=43633
+
+        This copies the existing implementation exactly. In the future
+        this will use PendingScript which handles ref counting without
+        the need for those manual ref()/deref()s. This is also currently
+        a trivial class, but a little more logic will be added to it to
+        support <script async>.
+
+        No new tests because no new functionality.
+
+        * Android.mk:
+        * CMakeLists.txt:
+        * GNUmakefile.am:
+        * WebCore.gypi:
+        * WebCore.pro:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/AsyncScriptRunner.cpp: Added.
+        (WebCore::AsyncScriptRunner::AsyncScriptRunner):
+        (WebCore::AsyncScriptRunner::~AsyncScriptRunner):
+        (WebCore::AsyncScriptRunner::executeScriptSoon):
+        (WebCore::AsyncScriptRunner::suspend):
+        (WebCore::AsyncScriptRunner::resume):
+        (WebCore::AsyncScriptRunner::timerFired):
+        * dom/AsyncScriptRunner.h: Added.
+        (WebCore::AsyncScriptRunner::create):
+        (WebCore::AsyncScriptRunner::hasPendingScripts):
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::~Document):
+        * dom/Document.h:
+        (WebCore::Document::asyncScriptRunner):
+        * dom/ScriptElement.cpp:
+        (WebCore::ScriptElementData::notifyFinished):
+        * page/PageGroupLoadDeferrer.cpp:
+        (WebCore::PageGroupLoadDeferrer::PageGroupLoadDeferrer):
+        (WebCore::PageGroupLoadDeferrer::~PageGroupLoadDeferrer):
+
 2010-08-06  James Robinson  <jamesr at chromium.org>
 
         Reviewed by Dimitri Glazkov.
diff --git a/WebCore/GNUmakefile.am b/WebCore/GNUmakefile.am
index 5e880f2..03329ee 100644
--- a/WebCore/GNUmakefile.am
+++ b/WebCore/GNUmakefile.am
@@ -969,6 +969,8 @@ webcore_sources += \
 	WebCore/css/WebKitCSSTransformValue.h \
 	WebCore/dom/ActiveDOMObject.cpp \
 	WebCore/dom/ActiveDOMObject.h \
+	WebCore/dom/AsyncScriptRunner.cpp \
+	WebCore/dom/AsyncScriptRunner.h \
 	WebCore/dom/Attr.cpp \
 	WebCore/dom/Attr.h \
 	WebCore/dom/Attribute.cpp \
diff --git a/WebCore/WebCore.gypi b/WebCore/WebCore.gypi
index 6ff4928..33efa82 100644
--- a/WebCore/WebCore.gypi
+++ b/WebCore/WebCore.gypi
@@ -1075,6 +1075,8 @@
             'dom/default/PlatformMessagePortChannel.h',
             'dom/ActiveDOMObject.cpp',
             'dom/ActiveDOMObject.h',
+            'dom/AsyncScriptRunner.cpp',
+            'dom/AsyncScriptRunner.h',
             'dom/Attr.cpp',
             'dom/Attr.h',
             'dom/Attribute.cpp',
diff --git a/WebCore/WebCore.pro b/WebCore/WebCore.pro
index 7addfa1..6e1a79b 100644
--- a/WebCore/WebCore.pro
+++ b/WebCore/WebCore.pro
@@ -459,6 +459,7 @@ SOURCES += \
     css/WebKitCSSMatrix.cpp \
     css/WebKitCSSTransformValue.cpp \
     dom/ActiveDOMObject.cpp \
+    dom/AsyncScriptRunner.cpp \
     dom/Attr.cpp \
     dom/Attribute.cpp \
     dom/BeforeProcessEvent.cpp \
diff --git a/WebCore/WebCore.vcproj/WebCore.vcproj b/WebCore/WebCore.vcproj/WebCore.vcproj
index bb9a2c9..995a3d5 100644
--- a/WebCore/WebCore.vcproj/WebCore.vcproj
+++ b/WebCore/WebCore.vcproj/WebCore.vcproj
@@ -32529,6 +32529,14 @@
 				>
 			</File>
 			<File
+				RelativePath="..\dom\AsyncScriptRunner.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\dom\AsyncScriptRunner.h"
+				>
+			</File>
+			<File
 				RelativePath="..\dom\Attr.cpp"
 				>
 			</File>
diff --git a/WebCore/WebCore.xcodeproj/project.pbxproj b/WebCore/WebCore.xcodeproj/project.pbxproj
index 02c93df..4b2064e 100644
--- a/WebCore/WebCore.xcodeproj/project.pbxproj
+++ b/WebCore/WebCore.xcodeproj/project.pbxproj
@@ -2356,6 +2356,8 @@
 		89CD029311C85B870070B791 /* JSBlobBuilder.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 89CD029111C85B870070B791 /* JSBlobBuilder.cpp */; };
 		89CD029411C85B870070B791 /* JSBlobBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 89CD029211C85B870070B791 /* JSBlobBuilder.h */; };
 		8A12E35D11FA33280025836A /* DocumentLoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A12E35C11FA33280025836A /* DocumentLoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		8A413AE01207BBA50082016E /* AsyncScriptRunner.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		8A413AE11207BBA50082016E /* AsyncScriptRunner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */; };
 		8A7CC96B12076D73001D4588 /* PendingScript.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A7CC96A12076D73001D4588 /* PendingScript.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		8A7CC97012076F8A001D4588 /* PendingScript.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 8A7CC96F12076F8A001D4588 /* PendingScript.cpp */; };
 		8A81BF8511DCFD9000DA2B98 /* ResourceLoadTiming.h in Headers */ = {isa = PBXBuildFile; fileRef = 8A81BF8411DCFD9000DA2B98 /* ResourceLoadTiming.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -8159,6 +8161,8 @@
 		89CD029111C85B870070B791 /* JSBlobBuilder.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSBlobBuilder.cpp; sourceTree = "<group>"; };
 		89CD029211C85B870070B791 /* JSBlobBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBlobBuilder.h; sourceTree = "<group>"; };
 		8A12E35C11FA33280025836A /* DocumentLoadTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentLoadTiming.h; sourceTree = "<group>"; };
+		8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AsyncScriptRunner.h; sourceTree = "<group>"; };
+		8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AsyncScriptRunner.cpp; sourceTree = "<group>"; };
 		8A7CC96A12076D73001D4588 /* PendingScript.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PendingScript.h; sourceTree = "<group>"; };
 		8A7CC96F12076F8A001D4588 /* PendingScript.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PendingScript.cpp; sourceTree = "<group>"; };
 		8A81BF8411DCFD9000DA2B98 /* ResourceLoadTiming.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ResourceLoadTiming.h; sourceTree = "<group>"; };
@@ -17081,6 +17085,8 @@
 			children = (
 				E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */,
 				E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */,
+				8A413ADE1207BBA50082016E /* AsyncScriptRunner.h */,
+				8A413ADF1207BBA50082016E /* AsyncScriptRunner.cpp */,
 				A8C4A7FC09D563270003AC8D /* Attr.cpp */,
 				A8C4A7FB09D563270003AC8D /* Attr.h */,
 				93EEC1E509C2877700C515D1 /* Attr.idl */,
@@ -20082,6 +20088,7 @@
 				E1BE512E0CF6C512002EA959 /* XSLTUnicodeSort.h in Headers */,
 				97DD4D870FDF4D6E00ECF9A4 /* XSSAuditor.h in Headers */,
 				CE172E011136E8CE0062A533 /* ZoomMode.h in Headers */,
+				8A413AE01207BBA50082016E /* AsyncScriptRunner.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -22498,6 +22505,7 @@
 				93F19B0508245E59001E9ABC /* XSLTProcessorLibxslt.cpp in Sources */,
 				E1BE512D0CF6C512002EA959 /* XSLTUnicodeSort.cpp in Sources */,
 				97DD4D860FDF4D6E00ECF9A4 /* XSSAuditor.cpp in Sources */,
+				8A413AE11207BBA50082016E /* AsyncScriptRunner.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/WebCore/dom/AsyncScriptRunner.cpp b/WebCore/dom/AsyncScriptRunner.cpp
new file mode 100644
index 0000000..96036a1
--- /dev/null
+++ b/WebCore/dom/AsyncScriptRunner.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#include "config.h"
+#include "AsyncScriptRunner.h"
+
+#include "CachedScript.h"
+#include "Element.h"
+#include "ScriptElement.h"
+
+namespace WebCore {
+
+AsyncScriptRunner::AsyncScriptRunner()
+    : m_timer(this, &AsyncScriptRunner::timerFired)
+{
+}
+
+AsyncScriptRunner::~AsyncScriptRunner()
+{
+    for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i)
+         m_scriptsToExecuteSoon[i].first->element()->deref(); // Balances ref() in executeScriptSoon().
+}
+
+void AsyncScriptRunner::executeScriptSoon(ScriptElementData* data, CachedResourceHandle<CachedScript> cachedScript)
+{
+    ASSERT_ARG(data, data);
+
+    Element* element = data->element();
+    ASSERT(element);
+    ASSERT(element->inDocument());
+
+    m_scriptsToExecuteSoon.append(make_pair(data, cachedScript));
+    element->ref(); // Balanced by deref()s in timerFired() and dtor.
+    if (!m_timer.isActive())
+        m_timer.startOneShot(0);
+}
+
+void AsyncScriptRunner::suspend()
+{
+    m_timer.stop();
+}
+
+void AsyncScriptRunner::resume()
+{
+    if (hasPendingScripts())
+        m_timer.startOneShot(0);
+}
+
+void AsyncScriptRunner::timerFired(Timer<AsyncScriptRunner>* timer)
+{
+    ASSERT_UNUSED(timer, timer == &m_timer);
+
+    Vector<pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > scripts;
+    scripts.swap(m_scriptsToExecuteSoon);
+    size_t size = scripts.size();
+    for (size_t i = 0; i < size; ++i) {
+        scripts[i].first->execute(scripts[i].second.get());
+        scripts[i].first->element()->deref(); // Balances ref() in executeScriptSoon().
+    }
+}
+
+}
diff --git a/WebCore/dom/AsyncScriptRunner.h b/WebCore/dom/AsyncScriptRunner.h
new file mode 100644
index 0000000..8b75e06
--- /dev/null
+++ b/WebCore/dom/AsyncScriptRunner.h
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2010 Google, Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
+ */
+
+#ifndef AsyncScriptRunner_h
+#define AsyncScriptRunner_h
+
+#include "CachedResourceHandle.h"
+#include "Timer.h"
+#include <wtf/Noncopyable.h>
+#include <wtf/PassRefPtr.h>
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+class CachedScript;
+class ScriptElementData;
+    
+class AsyncScriptRunner : public Noncopyable {
+public:
+    static PassOwnPtr<AsyncScriptRunner> create() { return new AsyncScriptRunner(); }
+    ~AsyncScriptRunner();
+
+    void executeScriptSoon(ScriptElementData*, CachedResourceHandle<CachedScript>);
+    bool hasPendingScripts() const { return !m_scriptsToExecuteSoon.isEmpty(); }
+    void suspend();
+    void resume();
+
+private:
+    AsyncScriptRunner();
+
+    void timerFired(Timer<AsyncScriptRunner>*);
+
+    Vector<std::pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon;
+    Timer<AsyncScriptRunner> m_timer;
+};
+
+}
+
+#endif
diff --git a/WebCore/dom/Document.cpp b/WebCore/dom/Document.cpp
index 8493b0f..bed319d 100644
--- a/WebCore/dom/Document.cpp
+++ b/WebCore/dom/Document.cpp
@@ -28,6 +28,7 @@
 
 #include "AXObjectCache.h"
 #include "AnimationController.h"
+#include "AsyncScriptRunner.h"
 #include "Attr.h"
 #include "Attribute.h"
 #include "CDATASection.h"
@@ -373,7 +374,7 @@ Document::Document(Frame* frame, const KURL& url, bool isXHTML, bool isHTML)
     , m_startTime(currentTime())
     , m_overMinimumLayoutThreshold(false)
     , m_extraLayoutDelay(0)
-    , m_executeScriptSoonTimer(this, &Document::executeScriptSoonTimerFired)
+    , m_asyncScriptRunner(AsyncScriptRunner::create())
     , m_xmlVersion("1.0")
     , m_xmlStandalone(false)
 #if ENABLE(XBL)
@@ -522,8 +523,7 @@ Document::~Document()
     ASSERT(m_ranges.isEmpty());
     ASSERT(!m_styleRecalcTimer.isActive());
 
-    for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i)
-        m_scriptsToExecuteSoon[i].first->element()->deref(); // Balances ref() in executeScriptSoon().
+    m_asyncScriptRunner.clear();
 
     removeAllEventListeners();
 
@@ -4831,45 +4831,6 @@ void Document::updateFocusAppearanceTimerFired(Timer<Document>*)
         element->updateFocusAppearance(m_updateFocusAppearanceRestoresSelection);
 }
 
-void Document::executeScriptSoonTimerFired(Timer<Document>* timer)
-{
-    ASSERT_UNUSED(timer, timer == &m_executeScriptSoonTimer);
-
-    Vector<pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > scripts;
-    scripts.swap(m_scriptsToExecuteSoon);
-    size_t size = scripts.size();
-    for (size_t i = 0; i < size; ++i) {
-        scripts[i].first->execute(scripts[i].second.get());
-        scripts[i].first->element()->deref(); // Balances ref() in executeScriptSoon().
-    }
-}
-
-void Document::executeScriptSoon(ScriptElementData* data, CachedResourceHandle<CachedScript> cachedScript)
-{
-    ASSERT_ARG(data, data);
-
-    Element* element = data->element();
-    ASSERT(element);
-    ASSERT(element->document() == this);
-    ASSERT(element->inDocument());
-
-    m_scriptsToExecuteSoon.append(make_pair(data, cachedScript));
-    element->ref(); // Balanced by deref()s in executeScriptSoonTimerFired() and ~Document().
-    if (!m_executeScriptSoonTimer.isActive())
-        m_executeScriptSoonTimer.startOneShot(0);
-}
-
-void Document::suspendExecuteScriptSoonTimer()
-{
-    m_executeScriptSoonTimer.stop();
-}
-
-void Document::resumeExecuteScriptSoonTimer()
-{
-    if (!m_scriptsToExecuteSoon.isEmpty())
-        m_executeScriptSoonTimer.startOneShot(0);
-}
-
 // FF method for accessing the selection added for compatibility.
 DOMSelection* Document::getSelection() const
 {
diff --git a/WebCore/dom/Document.h b/WebCore/dom/Document.h
index 8e42aad..463cec3 100644
--- a/WebCore/dom/Document.h
+++ b/WebCore/dom/Document.h
@@ -48,6 +48,7 @@
 
 namespace WebCore {
 
+    class AsyncScriptRunner;
     class Attr;
     class AXObjectCache;
     class CDATASection;
@@ -841,11 +842,8 @@ public:
     Document* topDocument() const;
 
     int docID() const { return m_docID; }
-
-    void executeScriptSoon(ScriptElementData*, CachedResourceHandle<CachedScript>);
-
-    void suspendExecuteScriptSoonTimer();
-    void resumeExecuteScriptSoonTimer();
+    
+    AsyncScriptRunner* asyncScriptRunner() { return m_asyncScriptRunner.get(); }
 
 #if ENABLE(XSLT)
     void applyXSLTransform(ProcessingInstruction* pi);
@@ -1050,8 +1048,6 @@ private:
 
     String encoding() const;
 
-    void executeScriptSoonTimerFired(Timer<Document>*);
-
     void updateTitle();
     void updateFocusAppearanceTimerFired(Timer<Document>*);
     void updateBaseURL();
@@ -1201,10 +1197,9 @@ private:
     // using setExtraLayoutDelay to modify the minimum delay used at different
     // points during the lifetime of the Document.
     int m_extraLayoutDelay;
-
-    Vector<std::pair<ScriptElementData*, CachedResourceHandle<CachedScript> > > m_scriptsToExecuteSoon;
-    Timer<Document> m_executeScriptSoonTimer;
     
+    OwnPtr<AsyncScriptRunner> m_asyncScriptRunner;
+
 #if ENABLE(XSLT)
     OwnPtr<TransformSource> m_transformSource;
     RefPtr<Document> m_transformSourceDocument;
diff --git a/WebCore/dom/ScriptElement.cpp b/WebCore/dom/ScriptElement.cpp
index dab8f8c..0262e48 100644
--- a/WebCore/dom/ScriptElement.cpp
+++ b/WebCore/dom/ScriptElement.cpp
@@ -24,6 +24,7 @@
 #include "config.h"
 #include "ScriptElement.h"
 
+#include "AsyncScriptRunner.h"
 #include "CachedScript.h"
 #include "DocLoader.h"
 #include "Document.h"
@@ -246,7 +247,7 @@ void ScriptElementData::execute(CachedScript* cachedScript)
 void ScriptElementData::notifyFinished(CachedResource* o)
 {
     ASSERT_UNUSED(o, o == m_cachedScript);
-    m_element->document()->executeScriptSoon(this, m_cachedScript);
+    m_element->document()->asyncScriptRunner()->executeScriptSoon(this, m_cachedScript);
     m_cachedScript = 0;
 }
 
diff --git a/WebCore/page/PageGroupLoadDeferrer.cpp b/WebCore/page/PageGroupLoadDeferrer.cpp
index ced8f36..a01422f 100644
--- a/WebCore/page/PageGroupLoadDeferrer.cpp
+++ b/WebCore/page/PageGroupLoadDeferrer.cpp
@@ -21,6 +21,7 @@
 #include "config.h"
 #include "PageGroupLoadDeferrer.h"
 
+#include "AsyncScriptRunner.h"
 #include "Frame.h"
 #include "Page.h"
 #include "PageGroup.h"
@@ -45,7 +46,7 @@ PageGroupLoadDeferrer::PageGroupLoadDeferrer(Page* page, bool deferSelf)
             // windows or sheets, which is exactly when PageGroupLoadDeferrer is used.
             for (Frame* frame = otherPage->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
                 frame->document()->suspendActiveDOMObjects();
-                frame->document()->suspendExecuteScriptSoonTimer();
+                frame->document()->asyncScriptRunner()->suspend();
             }
         }
     }
@@ -64,7 +65,7 @@ PageGroupLoadDeferrer::~PageGroupLoadDeferrer()
 
             for (Frame* frame = page->mainFrame(); frame; frame = frame->tree()->traverseNext()) {
                 frame->document()->resumeActiveDOMObjects();
-                frame->document()->resumeExecuteScriptSoonTimer();
+                frame->document()->asyncScriptRunner()->resume();
             }
         }
     }

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list