Changeset 85650 in webkit


Ignore:
Timestamp:
May 3, 2011 1:35:39 PM (13 years ago)
Author:
rolandsteiner@chromium.org
Message:

2011-05-03 Roland Steiner <rolandsteiner@chromium.org>

Reviewed by Dimitri Glazkov.

Update node list cache count on the containing TreeScope rather than the Document
https://bugs.webkit.org/show_bug.cgi?id=59983

Change code to call add/removeNodeListCache() and hasNodeListCaches() on the proper tree scope.
Move updating of the node list cache count from setDocument() to setTreeScopeRecursively().
Make setDocument() and setDocumentRecursively() private.

No new tests. (refactoring)

  • dom/ContainerNode.cpp: (WebCore::ContainerNode::childrenChanged):
  • dom/Node.cpp: (WebCore::Node::~Node): (WebCore::Node::setDocument): (WebCore::Node::setTreeScopeRecursively): (WebCore::Node::childNodes): (WebCore::Node::registerDynamicNodeList): (WebCore::Node::unregisterDynamicNodeList): (WebCore::Node::notifyLocalNodeListsAttributeChanged): (WebCore::Node::notifyLocalNodeListsChildrenChanged): (WebCore::Node::getElementsByTagName): (WebCore::Node::getElementsByTagNameNS): (WebCore::Node::getElementsByName): (WebCore::Node::getElementsByClassName):
  • dom/Node.h:
  • html/HTMLFormControlElement.cpp: (WebCore::HTMLFormControlElement::labels):
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r85649 r85650  
     12011-05-03  Roland Steiner  <rolandsteiner@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Update node list cache count on the containing TreeScope rather than the Document
     6        https://bugs.webkit.org/show_bug.cgi?id=59983
     7
     8        Change code to call add/removeNodeListCache() and hasNodeListCaches() on the proper tree scope.
     9        Move updating of the node list cache count from setDocument() to setTreeScopeRecursively().
     10        Make setDocument() and setDocumentRecursively() private.
     11
     12        No new tests. (refactoring)
     13
     14        * dom/ContainerNode.cpp:
     15        (WebCore::ContainerNode::childrenChanged):
     16        * dom/Node.cpp:
     17        (WebCore::Node::~Node):
     18        (WebCore::Node::setDocument):
     19        (WebCore::Node::setTreeScopeRecursively):
     20        (WebCore::Node::childNodes):
     21        (WebCore::Node::registerDynamicNodeList):
     22        (WebCore::Node::unregisterDynamicNodeList):
     23        (WebCore::Node::notifyLocalNodeListsAttributeChanged):
     24        (WebCore::Node::notifyLocalNodeListsChildrenChanged):
     25        (WebCore::Node::getElementsByTagName):
     26        (WebCore::Node::getElementsByTagNameNS):
     27        (WebCore::Node::getElementsByName):
     28        (WebCore::Node::getElementsByClassName):
     29        * dom/Node.h:
     30        * html/HTMLFormControlElement.cpp:
     31        (WebCore::HTMLFormControlElement::labels):
     32
    1332011-05-03  Ryosuke Niwa  <rniwa@webkit.org>
    234
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r84701 r85650  
    794794    if (!changedByParser && childCountDelta)
    795795        document()->nodeChildrenChanged(this);
    796     if (document()->hasNodeListCaches())
     796    if (treeScope()->hasNodeListCaches())
    797797        notifyNodeListsChildrenChanged();
    798798}
  • trunk/Source/WebCore/dom/Node.cpp

    r85644 r85650  
    389389        ASSERT(!NodeRareData::rareDataMap().contains(this));
    390390    else {
    391         if (m_document && rareData()->nodeLists())
    392             m_document->removeNodeListCache();
     391        if (treeScope() && rareData()->nodeLists())
     392            treeScope()->removeNodeListCache();
    393393       
    394394        NodeRareData::NodeRareDataMap& dataMap = NodeRareData::rareDataMap();
     
    452452    willMoveToNewOwnerDocument();
    453453    ASSERT(willMoveToNewOwnerDocumentWasCalled);
    454 
    455     if (hasRareData() && rareData()->nodeLists()) {
    456         if (m_document)
    457             m_document->removeNodeListCache();
    458         document->addNodeListCache();
    459     }
    460454
    461455    if (m_document) {
     
    509503            node->ensureRareData()->setTreeScope(newTreeScope);
    510504
     505        if (hasRareData() && rareData()->nodeLists()) {
     506            if (currentTreeScope)
     507                currentTreeScope->removeNodeListCache();
     508            newTreeScope->addNodeListCache();
     509        }
     510
    511511        node->setDocument(newDocument);
    512512
     
    605605    if (!data->nodeLists()) {
    606606        data->setNodeLists(NodeListsNodeData::create());
    607         if (document())
    608             document()->addNodeListCache();
     607        if (treeScope())
     608            treeScope()->addNodeListCache();
    609609    }
    610610
     
    977977    if (!data->nodeLists()) {
    978978        data->setNodeLists(NodeListsNodeData::create());
    979         document()->addNodeListCache();
    980     } else if (!m_document || !m_document->hasNodeListCaches()) {
     979        treeScope()->addNodeListCache();
     980    } else if (!treeScope() || !treeScope()->hasNodeListCaches()) {
    981981        // We haven't been receiving notifications while there were no registered lists, so the cache is invalid now.
    982982        data->nodeLists()->invalidateCaches();
     
    996996        if (data->nodeLists()->isEmpty()) {
    997997            data->clearNodeLists();
    998             if (document())
    999                 document()->removeNodeListCache();
     998            if (treeScope())
     999                treeScope()->removeNodeListCache();
    10001000        }
    10011001    }
     
    10171017    if (data->nodeLists()->isEmpty()) {
    10181018        data->clearNodeLists();
    1019         document()->removeNodeListCache();
     1019        treeScope()->removeNodeListCache();
    10201020    }
    10211021}
     
    10431043    if (data->nodeLists()->isEmpty()) {
    10441044        data->clearNodeLists();
    1045         document()->removeNodeListCache();
     1045        treeScope()->removeNodeListCache();
    10461046    }
    10471047}
     
    17731773    if (!data->nodeLists()) {
    17741774        data->setNodeLists(NodeListsNodeData::create());
    1775         document()->addNodeListCache();
     1775        treeScope()->addNodeListCache();
    17761776    }
    17771777
     
    18021802    if (!data->nodeLists()) {
    18031803        data->setNodeLists(NodeListsNodeData::create());
    1804         document()->addNodeListCache();
     1804        treeScope()->addNodeListCache();
    18051805    }
    18061806
     
    18251825    if (!data->nodeLists()) {
    18261826        data->setNodeLists(NodeListsNodeData::create());
    1827         document()->addNodeListCache();
     1827        treeScope()->addNodeListCache();
    18281828    }
    18291829
     
    18421842    if (!data->nodeLists()) {
    18431843        data->setNodeLists(NodeListsNodeData::create());
    1844         document()->addNodeListCache();
     1844        treeScope()->addNodeListCache();
    18451845    }
    18461846
  • trunk/Source/WebCore/dom/Node.h

    r85256 r85650  
    632632    Node(Document*, ConstructionType);
    633633
    634     // Do not use this method to change the document of a node until after the node has been
    635     // removed from its previous document.
    636     void setDocument(Document*);
    637     void setDocumentRecursively(Document*);
    638 
    639634    virtual void willMoveToNewOwnerDocument();
    640635    virtual void didMoveToNewOwnerDocument();
     
    650645
    651646private:
     647    // Do not use this method to change the document of a node until after the node has been
     648    // removed from its previous document.
     649    void setDocumentRecursively(Document*);
     650    void setDocument(Document*);
     651
    652652    enum EditableLevel { Editable, RichlyEditable };
    653653    bool rendererIsEditable(EditableLevel) const;
  • trunk/Source/WebCore/html/HTMLFormControlElement.cpp

    r85373 r85650  
    469469    if (!data->nodeLists()) {
    470470        data->setNodeLists(NodeListsNodeData::create());
    471         document()->addNodeListCache();
     471        treeScope()->addNodeListCache();
    472472    }
    473473
Note: See TracChangeset for help on using the changeset viewer.