Title: [164242] trunk/Source/WebCore
Revision
164242
Author
[email protected]
Date
2014-02-17 12:19:42 -0800 (Mon, 17 Feb 2014)

Log Message

Rename Document::m_selfOnlyRefCount to m_referencingNodeCount
https://bugs.webkit.org/show_bug.cgi?id=128916

Reviewed by Andreas Kling.

Make the name more informative. Also make it zero based (document is not considered to reference itself).

* dom/Document.cpp:
(WebCore::Document::Document):
(WebCore::Document::removedLastRef):
* dom/Document.h:
(WebCore::Document::increaseReferencingNodeCount):
(WebCore::Document::decreaseReferencingNodeCount):
(WebCore::Node::Node):
* dom/Node.cpp:
(WebCore::Node::~Node):
* dom/TreeScopeAdopter.cpp:
(WebCore::TreeScopeAdopter::moveTreeToNewScope):
(WebCore::TreeScopeAdopter::moveNodeToNewDocument):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (164241 => 164242)


--- trunk/Source/WebCore/ChangeLog	2014-02-17 20:07:35 UTC (rev 164241)
+++ trunk/Source/WebCore/ChangeLog	2014-02-17 20:19:42 UTC (rev 164242)
@@ -1,3 +1,25 @@
+2014-02-17  Antti Koivisto  <[email protected]>
+
+        Rename Document::m_selfOnlyRefCount to m_referencingNodeCount
+        https://bugs.webkit.org/show_bug.cgi?id=128916
+
+        Reviewed by Andreas Kling.
+
+        Make the name more informative. Also make it zero based (document is not considered to reference itself).
+
+        * dom/Document.cpp:
+        (WebCore::Document::Document):
+        (WebCore::Document::removedLastRef):
+        * dom/Document.h:
+        (WebCore::Document::increaseReferencingNodeCount):
+        (WebCore::Document::decreaseReferencingNodeCount):
+        (WebCore::Node::Node):
+        * dom/Node.cpp:
+        (WebCore::Node::~Node):
+        * dom/TreeScopeAdopter.cpp:
+        (WebCore::TreeScopeAdopter::moveTreeToNewScope):
+        (WebCore::TreeScopeAdopter::moveNodeToNewDocument):
+
 2014-02-17  ChangSeok Oh  <[email protected]>
 
         [GTK] Build failure caused by missing jsmin module

Modified: trunk/Source/WebCore/dom/Document.cpp (164241 => 164242)


--- trunk/Source/WebCore/dom/Document.cpp	2014-02-17 20:07:35 UTC (rev 164241)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-02-17 20:19:42 UTC (rev 164242)
@@ -400,7 +400,7 @@
     , m_touchEventRegionsDirty(false)
     , m_touchEventsChangedTimer(this, &Document::touchEventsChangedTimerFired)
 #endif
-    , m_selfOnlyRefCount(1)
+    , m_referencingNodeCount(0)
     , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimerFired, timeBeforeThrowingAwayStyleResolverAfterLastUseInSeconds)
     , m_didCalculateStyleResolver(false)
     , m_hasNodesWithPlaceholderStyle(false)
@@ -640,11 +640,10 @@
 void Document::removedLastRef()
 {
     ASSERT(!m_deletionHasBegun);
-    ASSERT(m_selfOnlyRefCount);
-    if (m_selfOnlyRefCount > 1) {
-        // If removing a child removes the last self-only ref, we don't want the scope to be destroyed
-        // until after removeDetachedChildren returns, so we protect ourselves with an extra self-only ref.
-        selfOnlyRef();
+    if (m_referencingNodeCount) {
+        // If removing a child removes the last node reference, we don't want the scope to be destroyed
+        // until after removeDetachedChildren returns, so we protect ourselves.
+        incrementReferencingNodeCount();
 
         // We must make sure not to be retaining any of our children through
         // these extra pointers or we will create a reference cycle.
@@ -679,7 +678,7 @@
         // We need to do this right now since selfOnlyDeref() can delete this.
         m_inRemovedLastRefFunction = false;
 #endif
-        selfOnlyDeref();
+        decrementReferencingNodeCount();
     } else {
 #ifndef NDEBUG
         m_inRemovedLastRefFunction = false;

Modified: trunk/Source/WebCore/dom/Document.h (164241 => 164242)


--- trunk/Source/WebCore/dom/Document.h	2014-02-17 20:07:35 UTC (rev 164241)
+++ trunk/Source/WebCore/dom/Document.h	2014-02-17 20:19:42 UTC (rev 164242)
@@ -263,22 +263,22 @@
 
     virtual ~Document();
 
-    // Nodes belonging to this document hold self-only references -
+    // Nodes belonging to this document increase referencingNodeCount -
     // these are enough to keep the document from being destroyed, but
     // not enough to keep it from removing its children. This allows a
-    // node that outlives its scope to still have a valid document
+    // node that outlives its document to still have a valid document
     // pointer without introducing reference cycles.
-    void selfOnlyRef()
+    void incrementReferencingNodeCount()
     {
         ASSERT(!m_deletionHasBegun);
-        ++m_selfOnlyRefCount;
+        ++m_referencingNodeCount;
     }
 
-    void selfOnlyDeref()
+    void decrementReferencingNodeCount()
     {
-        ASSERT(!m_deletionHasBegun || m_selfOnlyRefCount == 1);
-        --m_selfOnlyRefCount;
-        if (m_selfOnlyRefCount == 1 && !refCount()) {
+        ASSERT(!m_deletionHasBegun || !m_referencingNodeCount);
+        --m_referencingNodeCount;
+        if (!m_referencingNodeCount && !refCount()) {
 #if !ASSERT_DISABLED
             m_deletionHasBegun = true;
 #endif
@@ -1344,7 +1344,7 @@
 
     void styleResolverThrowawayTimerFired(DeferrableOneShotTimer<Document>&);
 
-    unsigned m_selfOnlyRefCount;
+    unsigned m_referencingNodeCount;
 
     DeferrableOneShotTimer<Document> m_styleResolverThrowawayTimer;
 
@@ -1715,7 +1715,7 @@
     , m_previous(0)
     , m_next(0)
 {
-    document->selfOnlyRef();
+    document->incrementReferencingNodeCount();
 
 #if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
     trackForDebugging();

Modified: trunk/Source/WebCore/dom/Node.cpp (164241 => 164242)


--- trunk/Source/WebCore/dom/Node.cpp	2014-02-17 20:07:35 UTC (rev 164241)
+++ trunk/Source/WebCore/dom/Node.cpp	2014-02-17 20:19:42 UTC (rev 164242)
@@ -308,7 +308,7 @@
     if (!isContainerNode())
         willBeDeletedFrom(&document());
 
-    document().selfOnlyDeref();
+    document().decrementReferencingNodeCount();
 
     InspectorCounters::decrementCounter(InspectorCounters::NodeCounter);
 }

Modified: trunk/Source/WebCore/dom/TreeScopeAdopter.cpp (164241 => 164242)


--- trunk/Source/WebCore/dom/TreeScopeAdopter.cpp	2014-02-17 20:07:35 UTC (rev 164241)
+++ trunk/Source/WebCore/dom/TreeScopeAdopter.cpp	2014-02-17 20:19:42 UTC (rev 164242)
@@ -45,7 +45,7 @@
     Document& newDocument = m_newScope.documentScope();
     bool willMoveToNewDocument = &oldDocument != &newDocument;
     if (willMoveToNewDocument) {
-        oldDocument.selfOnlyRef();
+        oldDocument.incrementReferencingNodeCount();
         oldDocument.incDOMTreeVersion();
     }
 
@@ -77,7 +77,7 @@
     }
 
     if (willMoveToNewDocument)
-        oldDocument.selfOnlyDeref();
+        oldDocument.decrementReferencingNodeCount();
 }
 
 void TreeScopeAdopter::moveShadowTreeToNewDocument(ShadowRoot* shadowRoot, Document* oldDocument, Document* newDocument) const
@@ -112,8 +112,8 @@
 {
     ASSERT(!node->inDocument() || oldDocument != newDocument);
 
-    newDocument->selfOnlyRef();
-    oldDocument->selfOnlyDeref();
+    newDocument->incrementReferencingNodeCount();
+    oldDocument->decrementReferencingNodeCount();
 
     if (node->hasRareData()) {
         NodeRareData* rareData = node->rareData();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to