Title: [155416] trunk/Source/WebCore
Revision
155416
Author
[email protected]
Date
2013-09-09 22:42:15 -0700 (Mon, 09 Sep 2013)

Log Message

ScriptRunner should have a Document& internally.
<https://webkit.org/b/121072>

Reviewed by Anders Carlsson.

Change ScriptRunner::m_document to a reference since it's tied to
the lifetime of the Document.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (155415 => 155416)


--- trunk/Source/WebCore/ChangeLog	2013-09-10 05:37:51 UTC (rev 155415)
+++ trunk/Source/WebCore/ChangeLog	2013-09-10 05:42:15 UTC (rev 155416)
@@ -1,5 +1,15 @@
 2013-09-09  Andreas Kling  <[email protected]>
 
+        ScriptRunner should have a Document& internally.
+        <https://webkit.org/b/121072>
+
+        Reviewed by Anders Carlsson.
+
+        Change ScriptRunner::m_document to a reference since it's tied to
+        the lifetime of the Document.
+
+2013-09-09  Andreas Kling  <[email protected]>
+
         Ref-ify more stack guards.
         <https://webkit.org/b/121070>
 

Modified: trunk/Source/WebCore/dom/Document.cpp (155415 => 155416)


--- trunk/Source/WebCore/dom/Document.cpp	2013-09-10 05:37:51 UTC (rev 155415)
+++ trunk/Source/WebCore/dom/Document.cpp	2013-09-10 05:42:15 UTC (rev 155416)
@@ -430,7 +430,7 @@
     , m_loadEventFinished(false)
     , m_startTime(monotonicallyIncreasingTimeMS())
     , m_overMinimumLayoutThreshold(false)
-    , m_scriptRunner(ScriptRunner::create(this))
+    , m_scriptRunner(createOwned<ScriptRunner>(*this))
     , m_xmlVersion(ASCIILiteral("1.0"))
     , m_xmlStandalone(StandaloneUnspecified)
     , m_hasXMLDeclaration(0)

Modified: trunk/Source/WebCore/dom/ScriptRunner.cpp (155415 => 155416)


--- trunk/Source/WebCore/dom/ScriptRunner.cpp	2013-09-10 05:37:51 UTC (rev 155415)
+++ trunk/Source/WebCore/dom/ScriptRunner.cpp	2013-09-10 05:42:15 UTC (rev 155416)
@@ -34,21 +34,20 @@
 
 namespace WebCore {
 
-ScriptRunner::ScriptRunner(Document* document)
+ScriptRunner::ScriptRunner(Document& document)
     : m_document(document)
     , m_timer(this, &ScriptRunner::timerFired)
 {
-    ASSERT(document);
 }
 
 ScriptRunner::~ScriptRunner()
 {
     for (size_t i = 0; i < m_scriptsToExecuteSoon.size(); ++i)
-        m_document->decrementLoadEventDelayCount();
+        m_document.decrementLoadEventDelayCount();
     for (size_t i = 0; i < m_scriptsToExecuteInOrder.size(); ++i)
-        m_document->decrementLoadEventDelayCount();
+        m_document.decrementLoadEventDelayCount();
     for (int i = 0; i < m_pendingAsyncScripts.size(); ++i)
-        m_document->decrementLoadEventDelayCount();
+        m_document.decrementLoadEventDelayCount();
 }
 
 void ScriptRunner::queueScriptForExecution(ScriptElement* scriptElement, CachedResourceHandle<CachedScript> cachedScript, ExecutionType executionType)
@@ -60,7 +59,7 @@
     ASSERT(element);
     ASSERT(element->inDocument());
 
-    m_document->incrementLoadEventDelayCount();
+    m_document.incrementLoadEventDelayCount();
 
     switch (executionType) {
     case ASYNC_EXECUTION:
@@ -103,7 +102,7 @@
 {
     ASSERT_UNUSED(timer, timer == &m_timer);
 
-    RefPtr<Document> protect(m_document);
+    Ref<Document> protect(m_document);
 
     Vector<PendingScript> scripts;
     scripts.swap(m_scriptsToExecuteSoon);
@@ -119,7 +118,7 @@
         CachedScript* cachedScript = scripts[i].cachedScript();
         RefPtr<Element> element = scripts[i].releaseElementAndClear();
         toScriptElementIfPossible(element.get())->execute(cachedScript);
-        m_document->decrementLoadEventDelayCount();
+        m_document.decrementLoadEventDelayCount();
     }
 }
 

Modified: trunk/Source/WebCore/dom/ScriptRunner.h (155415 => 155416)


--- trunk/Source/WebCore/dom/ScriptRunner.h	2013-09-10 05:37:51 UTC (rev 155415)
+++ trunk/Source/WebCore/dom/ScriptRunner.h	2013-09-10 05:42:15 UTC (rev 155416)
@@ -44,7 +44,7 @@
 class ScriptRunner {
     WTF_MAKE_NONCOPYABLE(ScriptRunner); WTF_MAKE_FAST_ALLOCATED;
 public:
-    static PassOwnPtr<ScriptRunner> create(Document* document) { return adoptPtr(new ScriptRunner(document)); }
+    explicit ScriptRunner(Document&);
     ~ScriptRunner();
 
     enum ExecutionType { ASYNC_EXECUTION, IN_ORDER_EXECUTION };
@@ -55,11 +55,9 @@
     void notifyScriptReady(ScriptElement*, ExecutionType);
 
 private:
-    explicit ScriptRunner(Document*);
-
     void timerFired(Timer<ScriptRunner>*);
 
-    Document* m_document;
+    Document& m_document;
     Vector<PendingScript> m_scriptsToExecuteInOrder;
     Vector<PendingScript> m_scriptsToExecuteSoon; // http://www.whatwg.org/specs/web-apps/current-work/#set-of-scripts-that-will-execute-as-soon-as-possible
     HashMap<ScriptElement*, PendingScript> m_pendingAsyncScripts;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to