Changeset 102834 in webkit
- Timestamp:
- Dec 14, 2011 3:18:26 PM (12 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 19 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r102830 r102834 1 2011-12-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 NodeChildList shouldn't be in NodeListNodeData 4 https://bugs.webkit.org/show_bug.cgi?id=73969 5 6 Added a regression test for ChildNodeList; it catches a bug caught in the review process. 7 8 * fast/dom/childnode-item-after-itemname-expected.txt: Added. 9 * fast/dom/childnode-item-after-itemname.html: Added. 10 1 11 2011-12-14 Ethan Malasky <emalasky@adobe.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r102833 r102834 1 2011-12-14 Ryosuke Niwa <rniwa@webkit.org> 2 3 NodeChildList shouldn't be in NodeListNodeData 4 https://bugs.webkit.org/show_bug.cgi?id=73969 5 6 Reviewed by Sam Weinig. 7 8 Move NodeChildList out of NodeListNodeData to separate it from the other node lists in order to 9 resolve the bug 73853. Unlike other DynamicNodeList, we don't need to invalidate NodeChildList 10 on ancestors when children change. Moving ChildNodeList out of NodeListNodeData makes this difference 11 apparent and makes DynamicNodeList::Caches in NodeListNodeData always held by a DynamicSubtreeNodeList, 12 eliminating the need for hasOwnCaches() checks in various places. 13 14 Also renamed the existing DynamicNodeList to DynamicSubtreeNodeList and re-introduced DynamicNodeList 15 from which DynamicSubtreeNodeList and ChildNodeList both inherit to share the code for itemWithName. 16 17 In addition, renamed registerDynamicNodeList and unregisterDynamicNodeList, which updates a counter for 18 TreeScope::hasNodeListCaches, to registerDynamicSubtreeNodeList and unregisterDynamicSubtreeNodeList 19 respectively. They are no longer called by ChildNodeList in order to avoid walking up the DOM tree 20 inside invalidateNodeListsCacheAfterAttributeChanged and invalidateNodeListsCacheAfterChildrenChanged. 21 22 Test: fast/dom/childnode-item-after-itemname.html 23 24 * bindings/js/JSNodeListCustom.cpp: 25 (WebCore::JSNodeListOwner::isReachableFromOpaqueRoots): 26 * dom/ChildNodeList.cpp: 27 (WebCore::ChildNodeList::ChildNodeList): 28 (WebCore::ChildNodeList::length): 29 (WebCore::ChildNodeList::item): 30 (WebCore::ChildNodeList::nodeMatches): 31 * dom/ChildNodeList.h: 32 * dom/ClassNodeList.cpp: 33 (WebCore::ClassNodeList::ClassNodeList): 34 (WebCore::ClassNodeList::~ClassNodeList): 35 * dom/ClassNodeList.h: 36 * dom/ContainerNode.cpp: 37 (WebCore::ContainerNode::childrenChanged): 38 * dom/DynamicNodeList.cpp: 39 (WebCore::DynamicSubtreeNodeList::DynamicSubtreeNodeList): 40 (WebCore::DynamicSubtreeNodeList::~DynamicSubtreeNodeList): 41 (WebCore::DynamicSubtreeNodeList::length): 42 (WebCore::DynamicSubtreeNodeList::itemForwardsFromCurrent): 43 (WebCore::DynamicSubtreeNodeList::itemBackwardsFromCurrent): 44 (WebCore::DynamicSubtreeNodeList::item): 45 (WebCore::DynamicNodeList::itemWithName): 46 (WebCore::DynamicSubtreeNodeList::isDynamicNodeList): 47 (WebCore::DynamicSubtreeNodeList::invalidateCache): 48 (WebCore::DynamicSubtreeNodeList::Caches::Caches): 49 (WebCore::DynamicSubtreeNodeList::Caches::create): 50 (WebCore::DynamicSubtreeNodeList::Caches::reset): 51 * dom/DynamicNodeList.h: 52 (WebCore::DynamicNodeList::DynamicNodeList): 53 (WebCore::DynamicNodeList::~DynamicNodeList): 54 (WebCore::DynamicNodeList::node): 55 (WebCore::DynamicSubtreeNodeList::rootNode): 56 * dom/NameNodeList.cpp: 57 (WebCore::NameNodeList::NameNodeList): 58 (WebCore::NameNodeList::~NameNodeList): 59 * dom/NameNodeList.h: 60 * dom/Node.cpp: 61 (WebCore::Node::childNodes): 62 (WebCore::Node::registerDynamicSubtreeNodeList): 63 (WebCore::Node::unregisterDynamicSubtreeNodeList): 64 (WebCore::Node::invalidateNodeListsCacheAfterAttributeChanged): 65 (WebCore::Node::invalidateNodeListsCacheAfterChildrenChanged): 66 (WebCore::Node::removeCachedClassNodeList): 67 (WebCore::Node::removeCachedNameNodeList): 68 (WebCore::Node::removeCachedTagNodeList): 69 (WebCore::Node::removeCachedLabelsNodeList): 70 (WebCore::NodeListsNodeData::invalidateCaches): 71 (WebCore::NodeListsNodeData::isEmpty): 72 (WebCore::NodeRareData::clearChildNodeListCache): 73 * dom/Node.h: 74 * dom/NodeRareData.h: 75 (WebCore::NodeRareData::nodeLists): 76 (WebCore::NodeRareData::ensureChildNodeListCache): 77 * dom/TagNodeList.cpp: 78 (WebCore::TagNodeList::TagNodeList): 79 (WebCore::TagNodeList::~TagNodeList): 80 * dom/TagNodeList.h: 81 * html/LabelsNodeList.cpp: 82 (WebCore::LabelsNodeList::LabelsNodeList): 83 * html/LabelsNodeList.h: 84 1 85 2011-12-14 Ryosuke Niwa <rniwa@webkit.org> 2 86 -
trunk/Source/WebCore/bindings/js/JSNodeListCustom.cpp
r95203 r102834 44 44 if (!jsNodeList->impl()->isDynamicNodeList()) 45 45 return false; 46 return visitor.containsOpaqueRoot(root(static_cast<DynamicNodeList*>(jsNodeList->impl())-> rootNode()));46 return visitor.containsOpaqueRoot(root(static_cast<DynamicNodeList*>(jsNodeList->impl())->node())); 47 47 } 48 48 -
trunk/Source/WebCore/dom/ChildNodeList.cpp
r37037 r102834 28 28 namespace WebCore { 29 29 30 ChildNodeList::ChildNodeList(PassRefPtr<Node> rootNode, DynamicNodeList::Caches* info) 31 : DynamicNodeList(rootNode, info) 30 ChildNodeList::ChildNodeList(PassRefPtr<Node> node, DynamicNodeList::Caches* caches) 31 : DynamicNodeList(node) 32 , m_caches(caches) 32 33 { 33 34 } … … 39 40 40 41 unsigned len = 0; 41 for (Node* n = m_rootNode->firstChild(); n; n = n->nextSibling())42 for (Node* n = node()->firstChild(); n; n = n->nextSibling()) 42 43 len++; 43 44 … … 51 52 { 52 53 unsigned int pos = 0; 53 Node* n = m_rootNode->firstChild();54 Node* n = node()->firstChild(); 54 55 55 56 if (m_caches->isItemCacheValid) { … … 72 73 unsigned dist = abs(diff); 73 74 if (dist > m_caches->cachedLength - 1 - index) { 74 n = m_rootNode->lastChild();75 n = node()->lastChild(); 75 76 pos = m_caches->cachedLength - 1; 76 77 } … … 104 105 // this function will be called only by DynamicNodeList::itemWithName, 105 106 // for an element that was located with getElementById. 106 return testNode->parentNode() == m_rootNode;107 return testNode->parentNode() == node(); 107 108 } 108 109 -
trunk/Source/WebCore/dom/ChildNodeList.h
r37037 r102834 44 44 45 45 virtual bool nodeMatches(Element*) const; 46 47 mutable RefPtr<DynamicNodeList::Caches> m_caches; 46 48 }; 47 49 -
trunk/Source/WebCore/dom/ClassNodeList.cpp
r66247 r102834 37 37 38 38 ClassNodeList::ClassNodeList(PassRefPtr<Node> rootNode, const String& classNames) 39 : Dynamic NodeList(rootNode)40 , m_classNames(classNames, m_rootNode->document()->inQuirksMode())39 : DynamicSubtreeNodeList(rootNode) 40 , m_classNames(classNames, node()->document()->inQuirksMode()) 41 41 , m_originalClassNames(classNames) 42 42 { … … 45 45 ClassNodeList::~ClassNodeList() 46 46 { 47 m_rootNode->removeCachedClassNodeList(this, m_originalClassNames);47 rootNode()->removeCachedClassNodeList(this, m_originalClassNames); 48 48 } 49 49 -
trunk/Source/WebCore/dom/ClassNodeList.h
r69437 r102834 37 37 namespace WebCore { 38 38 39 class ClassNodeList : public Dynamic NodeList {39 class ClassNodeList : public DynamicSubtreeNodeList { 40 40 public: 41 41 static PassRefPtr<ClassNodeList> create(PassRefPtr<Node> rootNode, const String& classNames) -
trunk/Source/WebCore/dom/ContainerNode.cpp
r102431 r102834 845 845 if (!changedByParser && childCountDelta) 846 846 document()->updateRangesAfterChildrenChanged(this); 847 if (treeScope()->hasNodeListCaches()) 848 invalidateNodeListsCacheAfterChildrenChanged(); 847 invalidateNodeListsCacheAfterChildrenChanged(); 849 848 } 850 849 -
trunk/Source/WebCore/dom/DynamicNodeList.cpp
r85617 r102834 29 29 namespace WebCore { 30 30 31 Dynamic NodeList::DynamicNodeList(PassRefPtr<Node> rootNode)32 : m_rootNode(rootNode)31 DynamicSubtreeNodeList::DynamicSubtreeNodeList(PassRefPtr<Node> node) 32 : DynamicNodeList(node) 33 33 , m_caches(Caches::create()) 34 , m_ownsCaches(true)35 34 { 36 m_rootNode->registerDynamicNodeList(this); 37 } 38 39 DynamicNodeList::DynamicNodeList(PassRefPtr<Node> rootNode, DynamicNodeList::Caches* caches) 40 : m_rootNode(rootNode) 41 , m_caches(caches) 42 , m_ownsCaches(false) 43 { 44 m_rootNode->registerDynamicNodeList(this); 45 } 46 47 DynamicNodeList::~DynamicNodeList() 48 { 49 m_rootNode->unregisterDynamicNodeList(this); 35 rootNode()->registerDynamicSubtreeNodeList(this); 50 36 } 51 37 52 unsigned DynamicNodeList::length() const 38 DynamicSubtreeNodeList::~DynamicSubtreeNodeList() 39 { 40 rootNode()->unregisterDynamicSubtreeNodeList(this); 41 } 42 43 unsigned DynamicSubtreeNodeList::length() const 53 44 { 54 45 if (m_caches->isLengthCacheValid) … … 57 48 unsigned length = 0; 58 49 59 for (Node* n = m_rootNode->firstChild(); n; n = n->traverseNextNode(m_rootNode.get()))50 for (Node* n = node()->firstChild(); n; n = n->traverseNextNode(rootNode())) 60 51 length += n->isElementNode() && nodeMatches(static_cast<Element*>(n)); 61 52 … … 66 57 } 67 58 68 Node* Dynamic NodeList::itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const59 Node* DynamicSubtreeNodeList::itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const 69 60 { 70 61 ASSERT(remainingOffset >= 0); 71 for (Node* n = start; n; n = n->traverseNextNode( m_rootNode.get())) {62 for (Node* n = start; n; n = n->traverseNextNode(rootNode())) { 72 63 if (n->isElementNode() && nodeMatches(static_cast<Element*>(n))) { 73 64 if (!remainingOffset) { … … 84 75 } 85 76 86 Node* Dynamic NodeList::itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const77 Node* DynamicSubtreeNodeList::itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const 87 78 { 88 79 ASSERT(remainingOffset < 0); 89 for (Node* n = start; n; n = n->traversePreviousNode( m_rootNode.get())) {80 for (Node* n = start; n; n = n->traversePreviousNode(rootNode())) { 90 81 if (n->isElementNode() && nodeMatches(static_cast<Element*>(n))) { 91 82 if (!remainingOffset) { … … 102 93 } 103 94 104 Node* Dynamic NodeList::item(unsigned offset) const95 Node* DynamicSubtreeNodeList::item(unsigned offset) const 105 96 { 106 97 int remainingOffset = offset; 107 Node* start = m_rootNode->firstChild();98 Node* start = node()->firstChild(); 108 99 if (m_caches->isItemCacheValid) { 109 100 if (offset == m_caches->lastItemOffset) … … 122 113 Node* DynamicNodeList::itemWithName(const AtomicString& elementId) const 123 114 { 124 if (m_rootNode->isDocumentNode() || m_rootNode->inDocument()) { 125 Element* node = m_rootNode->treeScope()->getElementById(elementId); 126 if (node && nodeMatches(node)) { 127 for (ContainerNode* p = node->parentNode(); p; p = p->parentNode()) { 128 if (p == m_rootNode) 129 return node; 130 } 131 } 115 if (node()->isDocumentNode() || node()->inDocument()) { 116 Element* node = this->node()->treeScope()->getElementById(elementId); 117 if (node && nodeMatches(node) && node->isDescendantOf(this->node())) 118 return node; 132 119 if (!node) 133 120 return 0; … … 146 133 } 147 134 148 bool Dynamic NodeList::isDynamicNodeList() const135 bool DynamicSubtreeNodeList::isDynamicNodeList() const 149 136 { 150 137 return true; 151 138 } 152 139 153 void Dynamic NodeList::invalidateCache()140 void DynamicSubtreeNodeList::invalidateCache() 154 141 { 155 // This should only be called for node lists that own their own caches.156 ASSERT(m_ownsCaches);157 142 m_caches->reset(); 158 143 } 159 144 160 Dynamic NodeList::Caches::Caches()145 DynamicSubtreeNodeList::Caches::Caches() 161 146 : lastItem(0) 162 147 , isLengthCacheValid(false) … … 165 150 } 166 151 167 PassRefPtr<Dynamic NodeList::Caches> DynamicNodeList::Caches::create()152 PassRefPtr<DynamicSubtreeNodeList::Caches> DynamicSubtreeNodeList::Caches::create() 168 153 { 169 154 return adoptRef(new Caches()); 170 155 } 171 156 172 void Dynamic NodeList::Caches::reset()157 void DynamicSubtreeNodeList::Caches::reset() 173 158 { 174 159 lastItem = 0; -
trunk/Source/WebCore/dom/DynamicNodeList.h
r84309 r102834 32 32 namespace WebCore { 33 33 34 35 34 class Element; 35 class Node; 36 36 37 class DynamicNodeList : public NodeList { 38 public: 39 struct Caches : RefCounted<Caches> { 40 static PassRefPtr<Caches> create(); 41 void reset(); 37 class DynamicNodeList : public NodeList { 38 public: 39 struct Caches : RefCounted<Caches> { 40 static PassRefPtr<Caches> create(); 41 void reset(); 42 43 unsigned cachedLength; 44 Node* lastItem; 45 unsigned lastItemOffset; 46 bool isLengthCacheValid : 1; 47 bool isItemCacheValid : 1; 48 protected: 49 Caches(); 50 }; 51 DynamicNodeList(PassRefPtr<Node> node) 52 : m_node(node) 53 { } 54 virtual ~DynamicNodeList() { } 42 55 43 unsigned cachedLength; 44 Node* lastItem; 45 unsigned lastItemOffset; 46 bool isLengthCacheValid : 1; 47 bool isItemCacheValid : 1; 48 protected: 49 Caches(); 50 }; 56 // DOM methods & attributes for NodeList 57 virtual unsigned length() const = 0; 58 virtual Node* item(unsigned index) const = 0; 59 virtual Node* itemWithName(const AtomicString&) const; 51 60 52 virtual ~DynamicNodeList(); 61 // Other methods (not part of DOM) 62 Node* node() const { return m_node.get(); } 53 63 54 bool hasOwnCaches() const { return m_ownsCaches; } 64 protected: 65 virtual bool nodeMatches(Element*) const = 0; 66 RefPtr<Node> m_node; 67 }; 55 68 56 // DOM methods & attributes for NodeList 57 virtual unsigned length() const; 58 virtual Node* item(unsigned index) const; 59 virtual Node* itemWithName(const AtomicString&) const; 69 class DynamicSubtreeNodeList : public DynamicNodeList { 70 public: 71 virtual ~DynamicSubtreeNodeList(); 72 virtual unsigned length() const OVERRIDE; 73 virtual Node* item(unsigned index) const OVERRIDE; 74 void invalidateCache(); 75 Node* rootNode() const { return node(); } 60 76 61 // Other methods (not part of DOM) 62 void invalidateCache();63 Node* rootNode() const { return m_rootNode.get(); }77 protected: 78 DynamicSubtreeNodeList(PassRefPtr<Node> rootNode); 79 mutable RefPtr<Caches> m_caches; 64 80 65 protected: 66 DynamicNodeList(PassRefPtr<Node> rootNode); 67 DynamicNodeList(PassRefPtr<Node> rootNode, Caches*); 68 69 virtual bool nodeMatches(Element*) const = 0; 70 71 RefPtr<Node> m_rootNode; 72 mutable RefPtr<Caches> m_caches; 73 bool m_ownsCaches; 74 75 private: 76 virtual bool isDynamicNodeList() const; 77 Node* itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const; 78 Node* itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const; 79 }; 81 private: 82 virtual bool isDynamicNodeList() const; 83 Node* itemForwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const; 84 Node* itemBackwardsFromCurrent(Node* start, unsigned offset, int remainingOffset) const; 85 }; 80 86 81 87 } // namespace WebCore -
trunk/Source/WebCore/dom/NameNodeList.cpp
r94427 r102834 33 33 34 34 NameNodeList::NameNodeList(PassRefPtr<Node> rootNode, const String& name) 35 : Dynamic NodeList(rootNode)35 : DynamicSubtreeNodeList(rootNode) 36 36 , m_nodeName(name) 37 37 { … … 40 40 NameNodeList::~NameNodeList() 41 41 { 42 m_rootNode->removeCachedNameNodeList(this, m_nodeName);42 rootNode()->removeCachedNameNodeList(this, m_nodeName); 43 43 } 44 44 -
trunk/Source/WebCore/dom/NameNodeList.h
r65077 r102834 32 32 33 33 // NodeList which lists all Nodes in a Element with a given "name" attribute 34 class NameNodeList : public Dynamic NodeList {34 class NameNodeList : public DynamicSubtreeNodeList { 35 35 public: 36 36 static PassRefPtr<NameNodeList> create(PassRefPtr<Node> rootNode, const String& name) -
trunk/Source/WebCore/dom/Node.cpp
r102721 r102834 624 624 PassRefPtr<NodeList> Node::childNodes() 625 625 { 626 NodeListsNodeData* nodeLists = ensureRareData()->ensureNodeLists(this); 627 if (!nodeLists->m_childNodeListCaches) 628 nodeLists->m_childNodeListCaches = DynamicNodeList::Caches::create(); 629 return ChildNodeList::create(this, nodeLists->m_childNodeListCaches.get()); 626 return ChildNodeList::create(this, ensureRareData()->ensureChildNodeListCache()); 630 627 } 631 628 … … 1005 1002 } 1006 1003 1007 void Node::registerDynamic NodeList(DynamicNodeList* list)1004 void Node::registerDynamicSubtreeNodeList(DynamicSubtreeNodeList* list) 1008 1005 { 1009 1006 NodeRareData* data = ensureRareData(); … … 1012 1009 data->nodeLists()->invalidateCaches(); 1013 1010 1014 if (list->hasOwnCaches()) 1015 data->ensureNodeLists(this)->m_listsWithCaches.add(list); 1016 } 1017 1018 void Node::unregisterDynamicNodeList(DynamicNodeList* list) 1019 { 1020 ASSERT(rareData()); 1011 data->ensureNodeLists(this)->m_listsWithCaches.add(list); 1012 } 1013 1014 void Node::unregisterDynamicSubtreeNodeList(DynamicSubtreeNodeList* list) 1015 { 1016 ASSERT(hasRareData()); 1021 1017 ASSERT(rareData()->nodeLists()); 1022 if (list->hasOwnCaches()) { 1018 NodeRareData* data = rareData(); 1019 data->nodeLists()->m_listsWithCaches.remove(list); 1020 removeNodeListCacheIfPossible(this, data); 1021 } 1022 1023 void Node::invalidateNodeListsCacheAfterAttributeChanged() 1024 { 1025 if (hasRareData() && isAttributeNode()) { 1023 1026 NodeRareData* data = rareData(); 1024 data->nodeLists()->m_listsWithCaches.remove(list); 1025 removeNodeListCacheIfPossible(this, data); 1026 } 1027 } 1028 1029 void Node::invalidateNodeListsCacheAfterAttributeChanged() 1030 { 1027 ASSERT(!data->nodeLists()); 1028 data->clearChildNodeListCache(); 1029 } 1030 1031 if (!treeScope()->hasNodeListCaches()) 1032 return; 1033 1034 for (Node* node = this; node; node = node->parentNode()) { 1035 ASSERT(this == node || !node->isAttributeNode()); 1036 if (!node->hasRareData()) 1037 continue; 1038 NodeRareData* data = node->rareData(); 1039 if (!data->nodeLists()) 1040 continue; 1041 1042 data->nodeLists()->invalidateCachesThatDependOnAttributes(); 1043 removeNodeListCacheIfPossible(node, data); 1044 } 1045 } 1046 1047 void Node::invalidateNodeListsCacheAfterChildrenChanged() 1048 { 1049 if (hasRareData()) 1050 rareData()->clearChildNodeListCache(); 1051 1052 if (!treeScope()->hasNodeListCaches()) 1053 return; 1031 1054 for (Node* node = this; node; node = node->parentNode()) { 1032 1055 if (!node->hasRareData()) … … 1036 1059 continue; 1037 1060 1038 // For attribute nodes, we need to invalidate childNodes as well.1039 if (node->isAttributeNode())1040 data->nodeLists()->invalidateCaches();1041 else1042 data->nodeLists()->invalidateCachesThatDependOnAttributes();1043 1044 removeNodeListCacheIfPossible(node, data);1045 }1046 }1047 1048 void Node::invalidateNodeListsCacheAfterChildrenChanged()1049 {1050 for (Node* node = this; node; node = node->parentNode()) {1051 if (!node->hasRareData())1052 continue;1053 NodeRareData* data = node->rareData();1054 if (!data->nodeLists())1055 continue;1056 1057 1061 data->nodeLists()->invalidateCaches(); 1058 1062 … … 1081 1085 ASSERT(rareData()); 1082 1086 ASSERT(rareData()->nodeLists()); 1083 ASSERT_UNUSED(list, list->hasOwnCaches());1084 1087 1085 1088 NodeListsNodeData* data = rareData()->nodeLists(); … … 1092 1095 ASSERT(rareData()); 1093 1096 ASSERT(rareData()->nodeLists()); 1094 ASSERT_UNUSED(list, list->hasOwnCaches());1095 1097 1096 1098 NodeListsNodeData* data = rareData()->nodeLists(); … … 1103 1105 ASSERT(rareData()); 1104 1106 ASSERT(rareData()->nodeLists()); 1105 ASSERT_UNUSED(list, list->hasOwnCaches());1106 1107 1107 1108 NodeListsNodeData* data = rareData()->nodeLists(); … … 1114 1115 ASSERT(rareData()); 1115 1116 ASSERT(rareData()->nodeLists()); 1116 ASSERT_UNUSED(list, list->hasOwnCaches());1117 1117 1118 1118 NodeListsNodeData* data = rareData()->nodeLists(); … … 1121 1121 } 1122 1122 1123 void Node::removeCachedLabelsNodeList(Dynamic NodeList* list)1123 void Node::removeCachedLabelsNodeList(DynamicSubtreeNodeList* list) 1124 1124 { 1125 1125 ASSERT(rareData()); 1126 1126 ASSERT(rareData()->nodeLists()); 1127 ASSERT_UNUSED(list, list->hasOwnCaches()); 1128 1127 1129 1128 NodeListsNodeData* data = rareData()->nodeLists(); 1129 ASSERT_UNUSED(list, list == data->m_labelsNodeListCache); 1130 1130 data->m_labelsNodeListCache = 0; 1131 1131 } … … 2390 2390 void NodeListsNodeData::invalidateCaches() 2391 2391 { 2392 if (m_childNodeListCaches) {2393 if (m_childNodeListCaches->hasOneRef())2394 m_childNodeListCaches.clear();2395 else2396 m_childNodeListCaches->reset();2397 }2398 2399 2392 if (m_labelsNodeListCache) 2400 2393 m_labelsNodeListCache->invalidateCache(); … … 2437 2430 { 2438 2431 if (!m_listsWithCaches.isEmpty()) 2439 return false;2440 2441 if (m_childNodeListCaches)2442 2432 return false; 2443 2433 … … 3010 3000 } 3011 3001 3002 void NodeRareData::clearChildNodeListCache() 3003 { 3004 if (!m_childNodeListCache) 3005 return; 3006 3007 if (m_childNodeListCache->hasOneRef()) 3008 m_childNodeListCache.clear(); 3009 else 3010 m_childNodeListCache->reset(); 3011 } 3012 3012 3013 } // namespace WebCore 3013 3014 -
trunk/Source/WebCore/dom/Node.h
r102721 r102834 51 51 class DOMSettableTokenList; 52 52 class Document; 53 class Dynamic NodeList;53 class DynamicSubtreeNodeList; 54 54 class Element; 55 55 class Event; … … 518 518 #endif 519 519 520 void registerDynamic NodeList(DynamicNodeList*);521 void unregisterDynamic NodeList(DynamicNodeList*);520 void registerDynamicSubtreeNodeList(DynamicSubtreeNodeList*); 521 void unregisterDynamicSubtreeNodeList(DynamicSubtreeNodeList*); 522 522 void invalidateNodeListsCacheAfterAttributeChanged(); 523 523 void invalidateNodeListsCacheAfterChildrenChanged(); … … 528 528 void removeCachedTagNodeList(TagNodeList*, const AtomicString&); 529 529 void removeCachedTagNodeList(TagNodeList*, const QualifiedName&); 530 void removeCachedLabelsNodeList(Dynamic NodeList*);530 void removeCachedLabelsNodeList(DynamicSubtreeNodeList*); 531 531 532 532 PassRefPtr<NodeList> getElementsByTagName(const AtomicString&); -
trunk/Source/WebCore/dom/NodeRareData.h
r102431 r102834 23 23 #define NodeRareData_h 24 24 25 #include "ChildNodeList.h" 25 26 #include "ClassNodeList.h" 26 27 #include "DOMSettableTokenList.h" … … 50 51 WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED; 51 52 public: 52 typedef HashSet<Dynamic NodeList*> NodeListSet;53 typedef HashSet<DynamicSubtreeNodeList*> NodeListSet; 53 54 NodeListSet m_listsWithCaches; 54 55 RefPtr<DynamicNodeList::Caches> m_childNodeListCaches; 56 55 57 56 typedef HashMap<String, ClassNodeList*> ClassNodeListCache; 58 57 ClassNodeListCache m_classNodeListCache; … … 127 126 void setNodeLists(PassOwnPtr<NodeListsNodeData> lists) { m_nodeLists = lists; } 128 127 NodeListsNodeData* nodeLists() const { return m_nodeLists.get(); } 129 130 128 NodeListsNodeData* ensureNodeLists(Node* node) 131 129 { … … 133 131 createNodeLists(node); 134 132 return m_nodeLists.get(); 133 } 134 void clearChildNodeListCache(); 135 DynamicNodeList::Caches* ensureChildNodeListCache() 136 { 137 if (!m_childNodeListCache) 138 m_childNodeListCache = DynamicNodeList::Caches::create(); 139 return m_childNodeListCache.get(); 135 140 } 136 141 … … 237 242 TreeScope* m_treeScope; 238 243 OwnPtr<NodeListsNodeData> m_nodeLists; 244 RefPtr<DynamicNodeList::Caches> m_childNodeListCache; 239 245 OwnPtr<EventTargetData> m_eventTargetData; 240 246 short m_tabIndex; -
trunk/Source/WebCore/dom/TagNodeList.cpp
r84586 r102834 31 31 32 32 TagNodeList::TagNodeList(PassRefPtr<Node> rootNode, const AtomicString& namespaceURI, const AtomicString& localName) 33 : Dynamic NodeList(rootNode)33 : DynamicSubtreeNodeList(rootNode) 34 34 , m_namespaceURI(namespaceURI) 35 35 , m_localName(localName) … … 41 41 { 42 42 if (m_namespaceURI == starAtom) 43 m_rootNode->removeCachedTagNodeList(this, m_localName);43 rootNode()->removeCachedTagNodeList(this, m_localName); 44 44 else 45 m_rootNode->removeCachedTagNodeList(this, QualifiedName(nullAtom, m_localName, m_namespaceURI));45 rootNode()->removeCachedTagNodeList(this, QualifiedName(nullAtom, m_localName, m_namespaceURI)); 46 46 } 47 47 -
trunk/Source/WebCore/dom/TagNodeList.h
r65077 r102834 31 31 32 32 // NodeList that limits to a particular tag. 33 class TagNodeList : public Dynamic NodeList {33 class TagNodeList : public DynamicSubtreeNodeList { 34 34 public: 35 35 static PassRefPtr<TagNodeList> create(PassRefPtr<Node> rootNode, const AtomicString& namespaceURI, const AtomicString& localName) -
trunk/Source/WebCore/html/LabelsNodeList.cpp
r95901 r102834 34 34 35 35 LabelsNodeList::LabelsNodeList(Node* forNode ) 36 : Dynamic NodeList(forNode->document()) , m_forNode(forNode)36 : DynamicSubtreeNodeList(forNode->document()) , m_forNode(forNode) 37 37 { 38 38 } -
trunk/Source/WebCore/html/LabelsNodeList.h
r95901 r102834 31 31 namespace WebCore { 32 32 33 class LabelsNodeList : public Dynamic NodeList {33 class LabelsNodeList : public DynamicSubtreeNodeList { 34 34 public: 35 35 static PassRefPtr<LabelsNodeList> create(Node* forNode)
Note: See TracChangeset
for help on using the changeset viewer.