Title: [87079] trunk/Source/WebCore
Revision
87079
Author
[email protected]
Date
2011-05-23 10:47:46 -0700 (Mon, 23 May 2011)

Log Message

2011-05-23  Roland Steiner  <[email protected]>

        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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (87078 => 87079)


--- trunk/Source/WebCore/ChangeLog	2011-05-23 17:28:34 UTC (rev 87078)
+++ trunk/Source/WebCore/ChangeLog	2011-05-23 17:47:46 UTC (rev 87079)
@@ -1,3 +1,35 @@
+2011-05-23  Roland Steiner  <[email protected]>
+
+        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):
+
 2011-05-23  Yury Semikhatsky  <[email protected]>
 
         Reviewed by Pavel Feldman.

Modified: trunk/Source/WebCore/dom/ContainerNode.cpp (87078 => 87079)


--- trunk/Source/WebCore/dom/ContainerNode.cpp	2011-05-23 17:28:34 UTC (rev 87078)
+++ trunk/Source/WebCore/dom/ContainerNode.cpp	2011-05-23 17:47:46 UTC (rev 87079)
@@ -812,7 +812,7 @@
     Node::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
     if (!changedByParser && childCountDelta)
         document()->nodeChildrenChanged(this);
-    if (document()->hasNodeListCaches())
+    if (treeScope()->hasNodeListCaches())
         notifyNodeListsChildrenChanged();
 }
 

Modified: trunk/Source/WebCore/dom/Node.cpp (87078 => 87079)


--- trunk/Source/WebCore/dom/Node.cpp	2011-05-23 17:28:34 UTC (rev 87078)
+++ trunk/Source/WebCore/dom/Node.cpp	2011-05-23 17:47:46 UTC (rev 87079)
@@ -390,8 +390,8 @@
     if (!hasRareData())
         ASSERT(!NodeRareData::rareDataMap().contains(this));
     else {
-        if (m_document && rareData()->nodeLists())
-            m_document->removeNodeListCache();
+        if (treeScope() && rareData()->nodeLists())
+            treeScope()->removeNodeListCache();
         
         NodeRareData::NodeRareDataMap& dataMap = NodeRareData::rareDataMap();
         NodeRareData::NodeRareDataMap::iterator it = dataMap.find(this);
@@ -454,12 +454,6 @@
     willMoveToNewOwnerDocument();
     ASSERT(willMoveToNewOwnerDocumentWasCalled);
 
-    if (hasRareData() && rareData()->nodeLists()) {
-        if (m_document)
-            m_document->removeNodeListCache();
-        document->addNodeListCache();
-    }
-
     if (m_document) {
         m_document->moveNodeIteratorsToNewDocument(this, document);
         m_document->guardDeref();
@@ -510,6 +504,12 @@
         } else
             node->ensureRareData()->setTreeScope(newTreeScope);
 
+        if (node->hasRareData() && node->rareData()->nodeLists()) {
+            if (currentTreeScope)
+                currentTreeScope->removeNodeListCache();
+            newTreeScope->addNodeListCache();
+        }
+
         node->setDocument(newDocument);
 
         if (!node->isElementNode())
@@ -606,8 +606,8 @@
     NodeRareData* data = ""
     if (!data->nodeLists()) {
         data->setNodeLists(NodeListsNodeData::create());
-        if (document())
-            document()->addNodeListCache();
+        if (treeScope())
+            treeScope()->addNodeListCache();
     }
 
     return ChildNodeList::create(this, data->nodeLists()->m_childNodeListCaches.get());
@@ -978,8 +978,8 @@
     NodeRareData* data = ""
     if (!data->nodeLists()) {
         data->setNodeLists(NodeListsNodeData::create());
-        document()->addNodeListCache();
-    } else if (!m_document || !m_document->hasNodeListCaches()) {
+        treeScope()->addNodeListCache();
+    } else if (!treeScope() || !treeScope()->hasNodeListCaches()) {
         // We haven't been receiving notifications while there were no registered lists, so the cache is invalid now.
         data->nodeLists()->invalidateCaches();
     }
@@ -997,8 +997,8 @@
         data->nodeLists()->m_listsWithCaches.remove(list);
         if (data->nodeLists()->isEmpty()) {
             data->clearNodeLists();
-            if (document())
-                document()->removeNodeListCache();
+            if (treeScope())
+                treeScope()->removeNodeListCache();
         }
     }
 }
@@ -1018,7 +1018,7 @@
 
     if (data->nodeLists()->isEmpty()) {
         data->clearNodeLists();
-        document()->removeNodeListCache();
+        treeScope()->removeNodeListCache();
     }
 }
 
@@ -1044,7 +1044,7 @@
 
     if (data->nodeLists()->isEmpty()) {
         data->clearNodeLists();
-        document()->removeNodeListCache();
+        treeScope()->removeNodeListCache();
     }
 }
 
@@ -1822,7 +1822,7 @@
     NodeRareData* data = ""
     if (!data->nodeLists()) {
         data->setNodeLists(NodeListsNodeData::create());
-        document()->addNodeListCache();
+        treeScope()->addNodeListCache();
     }
 
     String name = localName;
@@ -1851,7 +1851,7 @@
     NodeRareData* data = ""
     if (!data->nodeLists()) {
         data->setNodeLists(NodeListsNodeData::create());
-        document()->addNodeListCache();
+        treeScope()->addNodeListCache();
     }
 
     String name = localName;
@@ -1874,7 +1874,7 @@
     NodeRareData* data = ""
     if (!data->nodeLists()) {
         data->setNodeLists(NodeListsNodeData::create());
-        document()->addNodeListCache();
+        treeScope()->addNodeListCache();
     }
 
     pair<NodeListsNodeData::NameNodeListCache::iterator, bool> result = data->nodeLists()->m_nameNodeListCache.add(elementName, 0);
@@ -1891,7 +1891,7 @@
     NodeRareData* data = ""
     if (!data->nodeLists()) {
         data->setNodeLists(NodeListsNodeData::create());
-        document()->addNodeListCache();
+        treeScope()->addNodeListCache();
     }
 
     pair<NodeListsNodeData::ClassNodeListCache::iterator, bool> result = data->nodeLists()->m_classNodeListCache.add(classNames, 0);

Modified: trunk/Source/WebCore/dom/Node.h (87078 => 87079)


--- trunk/Source/WebCore/dom/Node.h	2011-05-23 17:28:34 UTC (rev 87078)
+++ trunk/Source/WebCore/dom/Node.h	2011-05-23 17:47:46 UTC (rev 87079)
@@ -636,11 +636,6 @@
     };
     Node(Document*, ConstructionType);
 
-    // Do not use this method to change the document of a node until after the node has been
-    // removed from its previous document.
-    void setDocument(Document*);
-    void setDocumentRecursively(Document*);
-
     virtual void willMoveToNewOwnerDocument();
     virtual void didMoveToNewOwnerDocument();
     
@@ -654,6 +649,11 @@
     NodeRareData* ensureRareData();
 
 private:
+    // Do not use this method to change the document of a node until after the node has been
+    // removed from its previous document.
+    void setDocumentRecursively(Document*);
+    void setDocument(Document*);
+
     enum EditableLevel { Editable, RichlyEditable };
     bool rendererIsEditable(EditableLevel) const;
 

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.cpp (87078 => 87079)


--- trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2011-05-23 17:28:34 UTC (rev 87078)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.cpp	2011-05-23 17:47:46 UTC (rev 87079)
@@ -487,7 +487,7 @@
     NodeRareData* data = ""
     if (!data->nodeLists()) {
         data->setNodeLists(NodeListsNodeData::create());
-        document()->addNodeListCache();
+        treeScope()->addNodeListCache();
     }
 
     if (data->nodeLists()->m_labelsNodeListCache)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to