Changeset 140784 in webkit


Ignore:
Timestamp:
Jan 24, 2013 10:45:39 PM (11 years ago)
Author:
morrita@google.com
Message:

Refactoring: The name ContainerNode::removeChildren and ContainerNde::removeAllChilren() is confusing
https://bugs.webkit.org/show_bug.cgi?id=107640

Reviewed by Eric Seidel.

This change renames unsafe removeAllChilren() function to
removeDetachedChildren() and move it to protected visibility.

In theory, the removed nodes should be detached() before. But some
tests violates that assumption. It should be fixed.

No new tests. No behavior change.

  • dom/ContainerNode.cpp:

(WebCore::ContainerNode::removeDetachedChildren):
(WebCore::ContainerNode::takeAllChildrenFrom):
(WebCore::ContainerNode::~ContainerNode):

  • dom/ContainerNode.h:

(ContainerNode):

  • dom/ContainerNodeAlgorithms.h:

(WebCore::removeDetachedChildrenInContainer):
(WebCore):

  • dom/Document.cpp:

(WebCore::Document::removedLastRef):

  • dom/ShadowRoot.cpp:

(WebCore::ShadowRoot::~ShadowRoot):

  • svg/SVGElementInstance.cpp:

(WebCore::SVGElementInstance::detach):

  • svg/SVGElementInstance.h:

(SVGElementInstance):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140778 r140784  
     12013-01-24  Hajime Morrita  <morrita@google.com>
     2
     3        Refactoring: The name ContainerNode::removeChildren and ContainerNde::removeAllChilren() is confusing
     4        https://bugs.webkit.org/show_bug.cgi?id=107640
     5
     6        Reviewed by Eric Seidel.
     7
     8        This change renames unsafe removeAllChilren() function to
     9        removeDetachedChildren() and move it to protected visibility.
     10
     11        In theory, the removed nodes should be detached() before. But some
     12        tests violates that assumption. It should be fixed.
     13
     14        No new tests. No behavior change.
     15
     16        * dom/ContainerNode.cpp:
     17        (WebCore::ContainerNode::removeDetachedChildren):
     18        (WebCore::ContainerNode::takeAllChildrenFrom):
     19        (WebCore::ContainerNode::~ContainerNode):
     20        * dom/ContainerNode.h:
     21        (ContainerNode):
     22        * dom/ContainerNodeAlgorithms.h:
     23        (WebCore::removeDetachedChildrenInContainer):
     24        (WebCore):
     25        * dom/Document.cpp:
     26        (WebCore::Document::removedLastRef):
     27        * dom/ShadowRoot.cpp:
     28        (WebCore::ShadowRoot::~ShadowRoot):
     29        * svg/SVGElementInstance.cpp:
     30        (WebCore::SVGElementInstance::detach):
     31        * svg/SVGElementInstance.h:
     32        (SVGElementInstance):
     33
    1342013-01-24  Keishi Hattori  <keishi@webkit.org>
    235
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r140633 r140784  
    9191}
    9292
    93 void ContainerNode::removeAllChildren()
    94 {
    95     removeAllChildrenInContainer<Node, ContainerNode>(this);
     93void ContainerNode::removeDetachedChildren()
     94{
     95    // FIXME: We should be able to ASSERT(!attached()) here: https://bugs.webkit.org/show_bug.cgi?id=107801
     96    removeDetachedChildrenInContainer<Node, ContainerNode>(this);
    9697}
    9798
     
    100101    NodeVector children;
    101102    getChildNodes(oldParent, children);
    102     oldParent->removeAllChildren();
     103    oldParent->removeDetachedChildren();
    103104
    104105    for (unsigned i = 0; i < children.size(); ++i) {
     
    124125        documentInternal()->axObjectCache()->remove(this);
    125126
    126     removeAllChildren();
     127    removeDetachedChildren();
    127128}
    128129
  • trunk/Source/WebCore/dom/ContainerNode.h

    r138448 r140784  
    102102    void parserInsertBefore(PassRefPtr<Node> newChild, Node* refChild);
    103103
    104     // FIXME: It's not good to have two functions with such similar names, especially public functions.
    105     // How do removeChildren and removeAllChildren differ?
    106104    void removeChildren();
    107     void removeAllChildren();
    108 
    109105    void takeAllChildrenFrom(ContainerNode*);
    110106
     
    155151    friend void Private::addChildNodesToDeletionQueue(GenericNode*& head, GenericNode*& tail, GenericNodeContainer*);
    156152
     153    void removeDetachedChildren();
    157154    void setFirstChild(Node* child) { m_firstChild = child; }
    158155    void setLastChild(Node* child) { m_lastChild = child; }
  • trunk/Source/WebCore/dom/ContainerNodeAlgorithms.h

    r140090 r140784  
    7979// This applies to 'ContainerNode' and 'SVGElementInstance'
    8080template<class GenericNode, class GenericNodeContainer>
    81 inline void removeAllChildrenInContainer(GenericNodeContainer* container)
     81inline void removeDetachedChildrenInContainer(GenericNodeContainer* container)
    8282{
    8383    // List of nodes to be deleted.
     
    121121}
    122122
    123 // Helper methods for removeAllChildrenInContainer, hidden from WebCore namespace
     123// Helper methods for removeDetachedChildrenInContainer, hidden from WebCore namespace
    124124namespace Private {
    125125
  • trunk/Source/WebCore/dom/Document.cpp

    r140614 r140784  
    657657        // If removing a child removes the last self-only ref, we don't
    658658        // want the scope to be destructed until after
    659         // removeAllChildren returns, so we guard ourselves with an
     659        // removeDetachedChildren returns, so we guard ourselves with an
    660660        // extra self-only ref.
    661661        guardRef();
     
    678678        detachParser();
    679679
    680         // removeAllChildren() doesn't always unregister IDs,
     680        // removeDetachedChildren() doesn't always unregister IDs,
    681681        // so tear down scope information upfront to avoid having stale references in the map.
    682682        destroyTreeScopeData();
    683         removeAllChildren();
     683        removeDetachedChildren();
    684684
    685685        m_markers->detach();
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r139198 r140784  
    8787    // runs so we don't go through TreeScopeAdopter for each child with a
    8888    // destructed tree scope in each descendant.
    89     removeAllChildren();
     89    removeDetachedChildren();
    9090
    9191    // We must call clearRareData() here since a ShadowRoot class inherits TreeScope
  • trunk/Source/WebCore/svg/SVGElementInstance.cpp

    r139751 r140784  
    102102    m_correspondingUseElement = 0;
    103103
    104     removeAllChildrenInContainer<SVGElementInstance, SVGElementInstance>(this);
     104    removeDetachedChildrenInContainer<SVGElementInstance, SVGElementInstance>(this);
    105105}
    106106
  • trunk/Source/WebCore/svg/SVGElementInstance.h

    r139751 r140784  
    162162
    163163    template<class GenericNode, class GenericNodeContainer>
    164     friend void removeAllChildrenInContainer(GenericNodeContainer* container);
     164    friend void removeDetachedChildrenInContainer(GenericNodeContainer*);
    165165
    166166    template<class GenericNode, class GenericNodeContainer>
Note: See TracChangeset for help on using the changeset viewer.