Changeset 87079 in webkit


Ignore:
Timestamp:
May 23, 2011 10:47:46 AM (13 years ago)
Author:
rolandsteiner@chromium.org
Message:

2011-05-23 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

    r87074 r87079  
     12011-05-23  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-23  Yury Semikhatsky  <yurys@chromium.org>
    234
  • trunk/Source/WebCore/dom/ContainerNode.cpp

    r86358 r87079  
    813813    if (!changedByParser && childCountDelta)
    814814        document()->nodeChildrenChanged(this);
    815     if (document()->hasNodeListCaches())
     815    if (treeScope()->hasNodeListCaches())
    816816        notifyNodeListsChildrenChanged();
    817817}
  • trunk/Source/WebCore/dom/Node.cpp

    r87067 r87079  
    391391        ASSERT(!NodeRareData::rareDataMap().contains(this));
    392392    else {
    393         if (m_document && rareData()->nodeLists())
    394             m_document->removeNodeListCache();
     393        if (treeScope() && rareData()->nodeLists())
     394            treeScope()->removeNodeListCache();
    395395       
    396396        NodeRareData::NodeRareDataMap& dataMap = NodeRareData::rareDataMap();
     
    454454    willMoveToNewOwnerDocument();
    455455    ASSERT(willMoveToNewOwnerDocumentWasCalled);
    456 
    457     if (hasRareData() && rareData()->nodeLists()) {
    458         if (m_document)
    459             m_document->removeNodeListCache();
    460         document->addNodeListCache();
    461     }
    462456
    463457    if (m_document) {
     
    511505            node->ensureRareData()->setTreeScope(newTreeScope);
    512506
     507        if (node->hasRareData() && node->rareData()->nodeLists()) {
     508            if (currentTreeScope)
     509                currentTreeScope->removeNodeListCache();
     510            newTreeScope->addNodeListCache();
     511        }
     512
    513513        node->setDocument(newDocument);
    514514
     
    607607    if (!data->nodeLists()) {
    608608        data->setNodeLists(NodeListsNodeData::create());
    609         if (document())
    610             document()->addNodeListCache();
     609        if (treeScope())
     610            treeScope()->addNodeListCache();
    611611    }
    612612
     
    979979    if (!data->nodeLists()) {
    980980        data->setNodeLists(NodeListsNodeData::create());
    981         document()->addNodeListCache();
    982     } else if (!m_document || !m_document->hasNodeListCaches()) {
     981        treeScope()->addNodeListCache();
     982    } else if (!treeScope() || !treeScope()->hasNodeListCaches()) {
    983983        // We haven't been receiving notifications while there were no registered lists, so the cache is invalid now.
    984984        data->nodeLists()->invalidateCaches();
     
    998998        if (data->nodeLists()->isEmpty()) {
    999999            data->clearNodeLists();
    1000             if (document())
    1001                 document()->removeNodeListCache();
     1000            if (treeScope())
     1001                treeScope()->removeNodeListCache();
    10021002        }
    10031003    }
     
    10191019    if (data->nodeLists()->isEmpty()) {
    10201020        data->clearNodeLists();
    1021         document()->removeNodeListCache();
     1021        treeScope()->removeNodeListCache();
    10221022    }
    10231023}
     
    10451045    if (data->nodeLists()->isEmpty()) {
    10461046        data->clearNodeLists();
    1047         document()->removeNodeListCache();
     1047        treeScope()->removeNodeListCache();
    10481048    }
    10491049}
     
    18231823    if (!data->nodeLists()) {
    18241824        data->setNodeLists(NodeListsNodeData::create());
    1825         document()->addNodeListCache();
     1825        treeScope()->addNodeListCache();
    18261826    }
    18271827
     
    18521852    if (!data->nodeLists()) {
    18531853        data->setNodeLists(NodeListsNodeData::create());
    1854         document()->addNodeListCache();
     1854        treeScope()->addNodeListCache();
    18551855    }
    18561856
     
    18751875    if (!data->nodeLists()) {
    18761876        data->setNodeLists(NodeListsNodeData::create());
    1877         document()->addNodeListCache();
     1877        treeScope()->addNodeListCache();
    18781878    }
    18791879
     
    18921892    if (!data->nodeLists()) {
    18931893        data->setNodeLists(NodeListsNodeData::create());
    1894         document()->addNodeListCache();
     1894        treeScope()->addNodeListCache();
    18951895    }
    18961896
  • trunk/Source/WebCore/dom/Node.h

    r87067 r87079  
    637637    Node(Document*, ConstructionType);
    638638
    639     // Do not use this method to change the document of a node until after the node has been
    640     // removed from its previous document.
    641     void setDocument(Document*);
    642     void setDocumentRecursively(Document*);
    643 
    644639    virtual void willMoveToNewOwnerDocument();
    645640    virtual void didMoveToNewOwnerDocument();
     
    655650
    656651private:
     652    // Do not use this method to change the document of a node until after the node has been
     653    // removed from its previous document.
     654    void setDocumentRecursively(Document*);
     655    void setDocument(Document*);
     656
    657657    enum EditableLevel { Editable, RichlyEditable };
    658658    bool rendererIsEditable(EditableLevel) const;
  • trunk/Source/WebCore/html/HTMLFormControlElement.cpp

    r86988 r87079  
    488488    if (!data->nodeLists()) {
    489489        data->setNodeLists(NodeListsNodeData::create());
    490         document()->addNodeListCache();
     490        treeScope()->addNodeListCache();
    491491    }
    492492
Note: See TracChangeset for help on using the changeset viewer.