Changeset 166377 in webkit
- Timestamp:
- Mar 27, 2014, 3:47:15 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166372 r166377 1 2014-03-27 Antti Koivisto <antti@apple.com> 2 3 Remove LiveNodeList::Type 4 https://bugs.webkit.org/show_bug.cgi?id=130866 5 6 Reviewed by Andreas Kling. 7 8 We don't need dynamic type information anymore. 9 10 * dom/ClassNodeList.cpp: 11 (WebCore::ClassNodeList::ClassNodeList): 12 * dom/ContainerNode.cpp: 13 (WebCore::ContainerNode::getElementsByTagName): 14 (WebCore::ContainerNode::getElementsByName): 15 (WebCore::ContainerNode::getElementsByClassName): 16 (WebCore::ContainerNode::radioNodeList): 17 * dom/LiveNodeList.cpp: 18 (WebCore::LiveNodeList::LiveNodeList): 19 * dom/LiveNodeList.h: 20 (WebCore::LiveNodeList::invalidationType): 21 (WebCore::CachedLiveNodeList<NodeListType>::CachedLiveNodeList): 22 (WebCore::LiveNodeList::type): Deleted. 23 * dom/NameNodeList.cpp: 24 (WebCore::NameNodeList::NameNodeList): 25 (WebCore::NameNodeList::nodeMatches): Deleted. 26 * dom/NameNodeList.h: 27 (WebCore::NameNodeList::nodeMatches): 28 * dom/NodeRareData.h: 29 (WebCore::NodeListTypeIdentifier<ClassNodeList>::value): 30 (WebCore::NodeListTypeIdentifier<NameNodeList>::value): 31 (WebCore::NodeListTypeIdentifier<TagNodeList>::value): 32 (WebCore::NodeListTypeIdentifier<HTMLTagNodeList>::value): 33 (WebCore::NodeListTypeIdentifier<RadioNodeList>::value): 34 (WebCore::NodeListTypeIdentifier<LabelsNodeList>::value): 35 36 Get unique id from type for key generation purposes only. 37 38 (WebCore::NodeListsNodeData::addCacheWithAtomicName): 39 (WebCore::NodeListsNodeData::addCacheWithName): 40 (WebCore::NodeListsNodeData::removeCacheWithAtomicName): 41 (WebCore::NodeListsNodeData::removeCacheWithName): 42 (WebCore::NodeListsNodeData::namedNodeListKey): 43 * dom/TagNodeList.cpp: 44 (WebCore::TagNodeList::TagNodeList): 45 (WebCore::HTMLTagNodeList::HTMLTagNodeList): 46 * dom/TagNodeList.h: 47 * html/LabelableElement.cpp: 48 (WebCore::LabelableElement::labels): 49 * html/LabelsNodeList.cpp: 50 (WebCore::LabelsNodeList::LabelsNodeList): 51 * html/LabelsNodeList.h: 52 * html/RadioNodeList.cpp: 53 (WebCore::RadioNodeList::RadioNodeList): 54 * html/RadioNodeList.h: 55 1 56 2014-03-27 Simon Fraser <simon.fraser@apple.com> 2 57 -
trunk/Source/WebCore/dom/ClassNodeList.cpp
r166369 r166377 37 37 38 38 ClassNodeList::ClassNodeList(ContainerNode& rootNode, const String& classNames) 39 : CachedLiveNodeList(rootNode, Type::ClassNodeListType,InvalidateOnClassAttrChange)39 : CachedLiveNodeList(rootNode, InvalidateOnClassAttrChange) 40 40 , m_classNames(classNames, document().inQuirksMode()) 41 41 , m_originalClassNames(classNames) -
trunk/Source/WebCore/dom/ContainerNode.cpp
r166354 r166377 1019 1019 1020 1020 if (document().isHTMLDocument()) 1021 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, LiveNodeList::Type::HTMLTagNodeListType,localName);1022 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(*this, LiveNodeList::Type::TagNodeListType,localName);1021 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<HTMLTagNodeList>(*this, localName); 1022 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<TagNodeList>(*this, localName); 1023 1023 } 1024 1024 … … 1036 1036 PassRefPtr<NodeList> ContainerNode::getElementsByName(const String& elementName) 1037 1037 { 1038 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, LiveNodeList::Type::NameNodeListType,elementName);1038 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<NameNodeList>(*this, elementName); 1039 1039 } 1040 1040 1041 1041 PassRefPtr<NodeList> ContainerNode::getElementsByClassName(const String& classNames) 1042 1042 { 1043 return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(*this, LiveNodeList::Type::ClassNodeListType,classNames);1043 return ensureRareData().ensureNodeLists().addCacheWithName<ClassNodeList>(*this, classNames); 1044 1044 } 1045 1045 … … 1047 1047 { 1048 1048 ASSERT(hasTagName(HTMLNames::formTag) || hasTagName(HTMLNames::fieldsetTag)); 1049 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, LiveNodeList::Type::RadioNodeListType,name);1049 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<RadioNodeList>(*this, name); 1050 1050 } 1051 1051 -
trunk/Source/WebCore/dom/LiveNodeList.cpp
r166369 r166377 32 32 namespace WebCore { 33 33 34 LiveNodeList::LiveNodeList(ContainerNode& ownerNode, Type type,NodeListInvalidationType invalidationType, NodeListRootType rootType)34 LiveNodeList::LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType, NodeListRootType rootType) 35 35 : m_ownerNode(ownerNode) 36 36 , m_rootType(rootType) 37 37 , m_invalidationType(invalidationType) 38 , m_type(static_cast<unsigned>(type))39 38 { 40 39 ASSERT(m_rootType == static_cast<unsigned>(rootType)); 41 40 ASSERT(m_invalidationType == static_cast<unsigned>(invalidationType)); 42 ASSERT(m_type == static_cast<unsigned>(type));43 41 } 44 42 -
trunk/Source/WebCore/dom/LiveNodeList.h
r166369 r166377 47 47 class LiveNodeList : public NodeList { 48 48 public: 49 enum class Type { 50 ClassNodeListType, 51 NameNodeListType, 52 TagNodeListType, 53 HTMLTagNodeListType, 54 RadioNodeListType, 55 LabelsNodeListType, 56 }; 57 58 LiveNodeList(ContainerNode& ownerNode, Type, NodeListInvalidationType, NodeListRootType); 49 LiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType, NodeListRootType); 59 50 virtual Node* namedItem(const AtomicString&) const override final; 60 51 virtual bool nodeMatches(Element*) const = 0; … … 64 55 ALWAYS_INLINE bool isRootedAtDocument() const { return m_rootType == NodeListIsRootedAtDocument; } 65 56 ALWAYS_INLINE NodeListInvalidationType invalidationType() const { return static_cast<NodeListInvalidationType>(m_invalidationType); } 66 ALWAYS_INLINE Type type() const { return static_cast<Type>(m_type); }67 57 ContainerNode& ownerNode() const { return const_cast<ContainerNode&>(m_ownerNode.get()); } 68 58 ALWAYS_INLINE void invalidateCacheForAttribute(const QualifiedName* attrName) const … … 88 78 const unsigned m_rootType : 1; 89 79 const unsigned m_invalidationType : 4; 90 const unsigned m_type : 3;91 80 }; 92 81 … … 111 100 112 101 protected: 113 CachedLiveNodeList(ContainerNode& rootNode, Type,NodeListInvalidationType, NodeListRootType = NodeListIsRootedAtNode);102 CachedLiveNodeList(ContainerNode& rootNode, NodeListInvalidationType, NodeListRootType = NodeListIsRootedAtNode); 114 103 115 104 private: … … 150 139 151 140 template <class NodeListType> 152 CachedLiveNodeList<NodeListType>::CachedLiveNodeList(ContainerNode& ownerNode, Type type,NodeListInvalidationType invalidationType, NodeListRootType rootType)153 : LiveNodeList(ownerNode, type,invalidationType, rootType)141 CachedLiveNodeList<NodeListType>::CachedLiveNodeList(ContainerNode& ownerNode, NodeListInvalidationType invalidationType, NodeListRootType rootType) 142 : LiveNodeList(ownerNode, invalidationType, rootType) 154 143 { 155 144 } -
trunk/Source/WebCore/dom/NameNodeList.cpp
r166369 r166377 31 31 32 32 NameNodeList::NameNodeList(ContainerNode& rootNode, const AtomicString& name) 33 : CachedLiveNodeList(rootNode, Type::NameNodeListType,InvalidateOnNameAttrChange)33 : CachedLiveNodeList(rootNode, InvalidateOnNameAttrChange) 34 34 , m_name(name) 35 35 { … … 41 41 } 42 42 43 bool NameNodeList::nodeMatches(Element* testNode) const44 {45 return testNode->getNameAttribute() == m_name;46 }47 48 43 } // namespace WebCore -
trunk/Source/WebCore/dom/NameNodeList.h
r166369 r166377 34 34 class NameNodeList final : public CachedLiveNodeList<NameNodeList> { 35 35 public: 36 static PassRefPtr<NameNodeList> create(ContainerNode& rootNode, Type type,const AtomicString& name)36 static PassRefPtr<NameNodeList> create(ContainerNode& rootNode, const AtomicString& name) 37 37 { 38 ASSERT_UNUSED(type, type == Type::NameNodeListType);39 38 return adoptRef(new NameNodeList(rootNode, name)); 40 39 } … … 50 49 }; 51 50 51 inline bool NameNodeList::nodeMatches(Element* element) const 52 { 53 return element->getNameAttribute() == m_name; 54 } 55 52 56 } // namespace WebCore 53 57 -
trunk/Source/WebCore/dom/NodeRareData.h
r165546 r166377 50 50 class TreeScope; 51 51 52 template <class ListType> struct NodeListTypeIdentifier; 53 template <> struct NodeListTypeIdentifier<ClassNodeList> { static int value() { return 0; } }; 54 template <> struct NodeListTypeIdentifier<NameNodeList> { static int value() { return 1; } }; 55 template <> struct NodeListTypeIdentifier<TagNodeList> { static int value() { return 2; } }; 56 template <> struct NodeListTypeIdentifier<HTMLTagNodeList> { static int value() { return 3; } }; 57 template <> struct NodeListTypeIdentifier<RadioNodeList> { static int value() { return 4; } }; 58 template <> struct NodeListTypeIdentifier<LabelsNodeList> { static int value() { return 5; } }; 59 52 60 class NodeListsNodeData { 53 61 WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED; … … 111 119 112 120 template<typename T, typename ContainerType> 113 PassRefPtr<T> addCacheWithAtomicName(ContainerType& container, LiveNodeList::Type type,const AtomicString& name)114 { 115 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(namedNodeListKey (type,name), nullptr);121 PassRefPtr<T> addCacheWithAtomicName(ContainerType& container, const AtomicString& name) 122 { 123 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(namedNodeListKey<T>(name), nullptr); 116 124 if (!result.isNewEntry) 117 125 return static_cast<T*>(result.iterator->value); 118 126 119 RefPtr<T> list = T::create(container, type,name);127 RefPtr<T> list = T::create(container, name); 120 128 result.iterator->value = list.get(); 121 129 return list.release(); … … 123 131 124 132 template<typename T> 125 PassRefPtr<T> addCacheWithName(ContainerNode& node, LiveNodeList::Type type,const String& name)126 { 127 NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListKey (type,name), nullptr);133 PassRefPtr<T> addCacheWithName(ContainerNode& node, const String& name) 134 { 135 NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListKey<T>(name), nullptr); 128 136 if (!result.isNewEntry) 129 137 return static_cast<T*>(result.iterator->value); … … 176 184 } 177 185 178 void removeCacheWithAtomicName(LiveNodeList* list, const AtomicString& name = starAtom) 179 { 180 ASSERT(list == m_atomicNameCaches.get(namedNodeListKey(list->type(), name))); 181 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode())) 182 return; 183 m_atomicNameCaches.remove(namedNodeListKey(list->type(), name)); 184 } 185 186 void removeCacheWithName(LiveNodeList* list, const String& name) 187 { 188 ASSERT(list == m_nameCaches.get(namedNodeListKey(list->type(), name))); 189 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode())) 190 return; 191 m_nameCaches.remove(namedNodeListKey(list->type(), name)); 186 template <class NodeListType> 187 void removeCacheWithAtomicName(NodeListType* list, const AtomicString& name = starAtom) 188 { 189 ASSERT(list == m_atomicNameCaches.get(namedNodeListKey<NodeListType>(name))); 190 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode())) 191 return; 192 m_atomicNameCaches.remove(namedNodeListKey<NodeListType>(name)); 193 } 194 195 template <class NodeListType> 196 void removeCacheWithName(NodeListType* list, const String& name) 197 { 198 ASSERT(list == m_nameCaches.get(namedNodeListKey<NodeListType>(name))); 199 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNode())) 200 return; 201 m_nameCaches.remove(namedNodeListKey<NodeListType>(name)); 192 202 } 193 203 … … 260 270 } 261 271 262 std::pair<unsigned char, String> namedNodeListKey(LiveNodeList::Type type, const String& name) 263 { 264 return std::pair<unsigned char, String>(static_cast<unsigned char>(type), name); 272 template <class NodeListType> 273 std::pair<unsigned char, String> namedNodeListKey(const String& name) 274 { 275 return std::pair<unsigned char, String>(NodeListTypeIdentifier<NodeListType>::value(), name); 265 276 } 266 277 -
trunk/Source/WebCore/dom/TagNodeList.cpp
r166369 r166377 30 30 31 31 TagNodeList::TagNodeList(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName) 32 : CachedLiveNodeList(rootNode, Type::TagNodeListType,DoNotInvalidateOnAttributeChanges)32 : CachedLiveNodeList(rootNode, DoNotInvalidateOnAttributeChanges) 33 33 , m_namespaceURI(namespaceURI) 34 34 , m_localName(localName) … … 46 46 47 47 HTMLTagNodeList::HTMLTagNodeList(ContainerNode& rootNode, const AtomicString& localName) 48 : CachedLiveNodeList(rootNode, Type::HTMLTagNodeListType,DoNotInvalidateOnAttributeChanges)48 : CachedLiveNodeList(rootNode, DoNotInvalidateOnAttributeChanges) 49 49 , m_localName(localName) 50 50 , m_loweredLocalName(localName.lower()) -
trunk/Source/WebCore/dom/TagNodeList.h
r166369 r166377 40 40 } 41 41 42 static PassRefPtr<TagNodeList> create(ContainerNode& rootNode, Type type,const AtomicString& localName)42 static PassRefPtr<TagNodeList> create(ContainerNode& rootNode, const AtomicString& localName) 43 43 { 44 ASSERT_UNUSED(type, type == Type::TagNodeListType);45 44 return adoptRef(new TagNodeList(rootNode, starAtom, localName)); 46 45 } … … 68 67 class HTMLTagNodeList final : public CachedLiveNodeList<HTMLTagNodeList> { 69 68 public: 70 static PassRefPtr<HTMLTagNodeList> create(ContainerNode& rootNode, Type type,const AtomicString& localName)69 static PassRefPtr<HTMLTagNodeList> create(ContainerNode& rootNode, const AtomicString& localName) 71 70 { 72 ASSERT_UNUSED(type, type == Type::HTMLTagNodeListType);73 71 return adoptRef(new HTMLTagNodeList(rootNode, localName)); 74 72 } -
trunk/Source/WebCore/html/LabelableElement.cpp
r164654 r166377 46 46 return 0; 47 47 48 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<LabelsNodeList>(*this, LiveNodeList::Type::LabelsNodeListType,starAtom);48 return ensureRareData().ensureNodeLists().addCacheWithAtomicName<LabelsNodeList>(*this, starAtom); 49 49 } 50 50 -
trunk/Source/WebCore/html/LabelsNodeList.cpp
r166369 r166377 35 35 36 36 LabelsNodeList::LabelsNodeList(LabelableElement& forNode) 37 : CachedLiveNodeList(forNode, Type::LabelsNodeListType,InvalidateOnForAttrChange, NodeListIsRootedAtDocument)37 : CachedLiveNodeList(forNode, InvalidateOnForAttrChange, NodeListIsRootedAtDocument) 38 38 { 39 39 } -
trunk/Source/WebCore/html/LabelsNodeList.h
r166369 r166377 33 33 class LabelsNodeList final : public CachedLiveNodeList<LabelsNodeList> { 34 34 public: 35 static PassRef<LabelsNodeList> create(LabelableElement& forNode, Type type,const AtomicString&)35 static PassRef<LabelsNodeList> create(LabelableElement& forNode, const AtomicString&) 36 36 { 37 ASSERT_UNUSED(type, type == Type::LabelsNodeListType);38 37 return adoptRef(*new LabelsNodeList(forNode)); 39 38 } -
trunk/Source/WebCore/html/RadioNodeList.cpp
r166369 r166377 39 39 40 40 RadioNodeList::RadioNodeList(ContainerNode& rootNode, const AtomicString& name) 41 : CachedLiveNodeList(rootNode, Type::RadioNodeListType,InvalidateForFormControls, isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode)41 : CachedLiveNodeList(rootNode, InvalidateForFormControls, isHTMLFormElement(rootNode) ? NodeListIsRootedAtDocument : NodeListIsRootedAtNode) 42 42 , m_name(name) 43 43 { -
trunk/Source/WebCore/html/RadioNodeList.h
r166369 r166377 35 35 class RadioNodeList final : public CachedLiveNodeList<RadioNodeList> { 36 36 public: 37 static PassRefPtr<RadioNodeList> create(ContainerNode& rootNode, Type type,const AtomicString& name)37 static PassRefPtr<RadioNodeList> create(ContainerNode& rootNode, const AtomicString& name) 38 38 { 39 ASSERT_UNUSED(type, type == Type::RadioNodeListType);40 39 return adoptRef(new RadioNodeList(rootNode, name)); 41 40 }
Note:
See TracChangeset
for help on using the changeset viewer.