Changeset 164242 in webkit


Ignore:
Timestamp:
Feb 17, 2014 12:19:42 PM (10 years ago)
Author:
Antti Koivisto
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):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r164239 r164242  
     12014-02-17  Antti Koivisto  <antti@apple.com>
     2
     3        Rename Document::m_selfOnlyRefCount to m_referencingNodeCount
     4        https://bugs.webkit.org/show_bug.cgi?id=128916
     5
     6        Reviewed by Andreas Kling.
     7
     8        Make the name more informative. Also make it zero based (document is not considered to reference itself).
     9
     10        * dom/Document.cpp:
     11        (WebCore::Document::Document):
     12        (WebCore::Document::removedLastRef):
     13        * dom/Document.h:
     14        (WebCore::Document::increaseReferencingNodeCount):
     15        (WebCore::Document::decreaseReferencingNodeCount):
     16        (WebCore::Node::Node):
     17        * dom/Node.cpp:
     18        (WebCore::Node::~Node):
     19        * dom/TreeScopeAdopter.cpp:
     20        (WebCore::TreeScopeAdopter::moveTreeToNewScope):
     21        (WebCore::TreeScopeAdopter::moveNodeToNewDocument):
     22
    1232014-02-17  ChangSeok Oh  <changseok.oh@collabora.com>
    224
  • trunk/Source/WebCore/dom/Document.cpp

    r164196 r164242  
    401401    , m_touchEventsChangedTimer(this, &Document::touchEventsChangedTimerFired)
    402402#endif
    403     , m_selfOnlyRefCount(1)
     403    , m_referencingNodeCount(0)
    404404    , m_styleResolverThrowawayTimer(this, &Document::styleResolverThrowawayTimerFired, timeBeforeThrowingAwayStyleResolverAfterLastUseInSeconds)
    405405    , m_didCalculateStyleResolver(false)
     
    641641{
    642642    ASSERT(!m_deletionHasBegun);
    643     ASSERT(m_selfOnlyRefCount);
    644     if (m_selfOnlyRefCount > 1) {
    645         // If removing a child removes the last self-only ref, we don't want the scope to be destroyed
    646         // until after removeDetachedChildren returns, so we protect ourselves with an extra self-only ref.
    647         selfOnlyRef();
     643    if (m_referencingNodeCount) {
     644        // If removing a child removes the last node reference, we don't want the scope to be destroyed
     645        // until after removeDetachedChildren returns, so we protect ourselves.
     646        incrementReferencingNodeCount();
    648647
    649648        // We must make sure not to be retaining any of our children through
     
    680679        m_inRemovedLastRefFunction = false;
    681680#endif
    682         selfOnlyDeref();
     681        decrementReferencingNodeCount();
    683682    } else {
    684683#ifndef NDEBUG
  • trunk/Source/WebCore/dom/Document.h

    r164195 r164242  
    264264    virtual ~Document();
    265265
    266     // Nodes belonging to this document hold self-only references -
     266    // Nodes belonging to this document increase referencingNodeCount -
    267267    // these are enough to keep the document from being destroyed, but
    268268    // not enough to keep it from removing its children. This allows a
    269     // node that outlives its scope to still have a valid document
     269    // node that outlives its document to still have a valid document
    270270    // pointer without introducing reference cycles.
    271     void selfOnlyRef()
     271    void incrementReferencingNodeCount()
    272272    {
    273273        ASSERT(!m_deletionHasBegun);
    274         ++m_selfOnlyRefCount;
     274        ++m_referencingNodeCount;
    275275    }
    276276
    277     void selfOnlyDeref()
     277    void decrementReferencingNodeCount()
    278278    {
    279         ASSERT(!m_deletionHasBegun || m_selfOnlyRefCount == 1);
    280         --m_selfOnlyRefCount;
    281         if (m_selfOnlyRefCount == 1 && !refCount()) {
     279        ASSERT(!m_deletionHasBegun || !m_referencingNodeCount);
     280        --m_referencingNodeCount;
     281        if (!m_referencingNodeCount && !refCount()) {
    282282#if !ASSERT_DISABLED
    283283            m_deletionHasBegun = true;
     
    13451345    void styleResolverThrowawayTimerFired(DeferrableOneShotTimer<Document>&);
    13461346
    1347     unsigned m_selfOnlyRefCount;
     1347    unsigned m_referencingNodeCount;
    13481348
    13491349    DeferrableOneShotTimer<Document> m_styleResolverThrowawayTimer;
     
    17161716    , m_next(0)
    17171717{
    1718     document->selfOnlyRef();
     1718    document->incrementReferencingNodeCount();
    17191719
    17201720#if !defined(NDEBUG) || (defined(DUMP_NODE_STATISTICS) && DUMP_NODE_STATISTICS)
  • trunk/Source/WebCore/dom/Node.cpp

    r164195 r164242  
    309309        willBeDeletedFrom(&document());
    310310
    311     document().selfOnlyDeref();
     311    document().decrementReferencingNodeCount();
    312312
    313313    InspectorCounters::decrementCounter(InspectorCounters::NodeCounter);
  • trunk/Source/WebCore/dom/TreeScopeAdopter.cpp

    r164195 r164242  
    4646    bool willMoveToNewDocument = &oldDocument != &newDocument;
    4747    if (willMoveToNewDocument) {
    48         oldDocument.selfOnlyRef();
     48        oldDocument.incrementReferencingNodeCount();
    4949        oldDocument.incDOMTreeVersion();
    5050    }
     
    7878
    7979    if (willMoveToNewDocument)
    80         oldDocument.selfOnlyDeref();
     80        oldDocument.decrementReferencingNodeCount();
    8181}
    8282
     
    113113    ASSERT(!node->inDocument() || oldDocument != newDocument);
    114114
    115     newDocument->selfOnlyRef();
    116     oldDocument->selfOnlyDeref();
     115    newDocument->incrementReferencingNodeCount();
     116    oldDocument->decrementReferencingNodeCount();
    117117
    118118    if (node->hasRareData()) {
Note: See TracChangeset for help on using the changeset viewer.