Changeset 166461 in webkit
- Timestamp:
- Mar 30, 2014 3:48:32 AM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r166460 r166461 1 2014-03-30 Andreas Kling <akling@apple.com> 2 3 Make NodeList and HTMLCollection caching helpers use PassRef. 4 <https://webkit.org/b/130943> 5 6 Tweak the helpers in NodeListsNodeData to return PassRef instead of 7 PassRefPtr. This knocks 2 branches off of some pretty hot code on 8 Dromaeo/dom-query. 9 10 Reviewed by Antti Koivisto. 11 12 * dom/ChildNodeList.h: 13 * dom/ClassNodeList.h: 14 * dom/NameNodeList.h: 15 * dom/NodeRareData.h: 16 (WebCore::NodeListsNodeData::ensureChildNodeList): 17 (WebCore::NodeListsNodeData::ensureEmptyChildNodeList): 18 (WebCore::NodeListsNodeData::addCacheWithAtomicName): 19 (WebCore::NodeListsNodeData::addCacheWithName): 20 (WebCore::NodeListsNodeData::addCacheWithQualifiedName): 21 (WebCore::NodeListsNodeData::addCachedCollection): 22 * dom/TagNodeList.h: 23 * html/HTMLCollection.cpp: 24 (WebCore::HTMLCollection::create): 25 * html/HTMLCollection.h: 26 * html/HTMLFormControlsCollection.cpp: 27 (WebCore::HTMLFormControlsCollection::create): 28 * html/HTMLFormControlsCollection.h: 29 * html/RadioNodeList.h: 30 1 31 2014-03-29 Antti Koivisto <antti@apple.com> 2 32 -
trunk/Source/WebCore/dom/ChildNodeList.h
r166460 r166461 36 36 class EmptyNodeList final : public NodeList { 37 37 public: 38 static PassRef Ptr<EmptyNodeList> create(Node& owner)38 static PassRef<EmptyNodeList> create(Node& owner) 39 39 { 40 return adoptRef( new EmptyNodeList(owner));40 return adoptRef(*new EmptyNodeList(owner)); 41 41 } 42 42 virtual ~EmptyNodeList(); … … 59 59 class ChildNodeList final : public NodeList { 60 60 public: 61 static PassRef Ptr<ChildNodeList> create(ContainerNode& parent)61 static PassRef<ChildNodeList> create(ContainerNode& parent) 62 62 { 63 return adoptRef( new ChildNodeList(parent));63 return adoptRef(*new ChildNodeList(parent)); 64 64 } 65 65 -
trunk/Source/WebCore/dom/ClassNodeList.h
r166407 r166461 40 40 class ClassNodeList final : public CachedLiveNodeList<ClassNodeList> { 41 41 public: 42 static PassRef Ptr<ClassNodeList> create(ContainerNode& rootNode, const String& classNames)42 static PassRef<ClassNodeList> create(ContainerNode& rootNode, const String& classNames) 43 43 { 44 return adoptRef( new ClassNodeList(rootNode, classNames));44 return adoptRef(*new ClassNodeList(rootNode, classNames)); 45 45 } 46 46 -
trunk/Source/WebCore/dom/NameNodeList.h
r166407 r166461 34 34 class NameNodeList final : public CachedLiveNodeList<NameNodeList> { 35 35 public: 36 static PassRef Ptr<NameNodeList> create(ContainerNode& rootNode, const AtomicString& name)36 static PassRef<NameNodeList> create(ContainerNode& rootNode, const AtomicString& name) 37 37 { 38 return adoptRef( new NameNodeList(rootNode, name));38 return adoptRef(*new NameNodeList(rootNode, name)); 39 39 } 40 40 -
trunk/Source/WebCore/dom/NodeRareData.h
r166377 r166461 67 67 } 68 68 69 PassRef Ptr<ChildNodeList> ensureChildNodeList(ContainerNode& node)69 PassRef<ChildNodeList> ensureChildNodeList(ContainerNode& node) 70 70 { 71 71 ASSERT(!m_emptyChildNodeList); 72 72 if (m_childNodeList) 73 return m_childNodeList;74 RefPtr<ChildNodeList>list = ChildNodeList::create(node);75 m_childNodeList = list.get();76 return list .release();73 return *m_childNodeList; 74 auto list = ChildNodeList::create(node); 75 m_childNodeList = &list.get(); 76 return list; 77 77 } 78 78 … … 85 85 } 86 86 87 PassRef Ptr<EmptyNodeList> ensureEmptyChildNodeList(Node& node)87 PassRef<EmptyNodeList> ensureEmptyChildNodeList(Node& node) 88 88 { 89 89 ASSERT(!m_childNodeList); 90 90 if (m_emptyChildNodeList) 91 return m_emptyChildNodeList;92 RefPtr<EmptyNodeList>list = EmptyNodeList::create(node);93 m_emptyChildNodeList = list.get();94 return list .release();91 return *m_emptyChildNodeList; 92 auto list = EmptyNodeList::create(node); 93 m_emptyChildNodeList = &list.get(); 94 return list; 95 95 } 96 96 … … 119 119 120 120 template<typename T, typename ContainerType> 121 PassRef Ptr<T> addCacheWithAtomicName(ContainerType& container, const AtomicString& name)121 PassRef<T> addCacheWithAtomicName(ContainerType& container, const AtomicString& name) 122 122 { 123 123 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(namedNodeListKey<T>(name), nullptr); 124 124 if (!result.isNewEntry) 125 return static_cast<T *>(result.iterator->value);126 127 RefPtr<T>list = T::create(container, name);128 result.iterator->value = list.get();129 return list .release();125 return static_cast<T&>(*result.iterator->value); 126 127 auto list = T::create(container, name); 128 result.iterator->value = &list.get(); 129 return list; 130 130 } 131 131 132 132 template<typename T> 133 PassRef Ptr<T> addCacheWithName(ContainerNode& node, const String& name)133 PassRef<T> addCacheWithName(ContainerNode& node, const String& name) 134 134 { 135 135 NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListKey<T>(name), nullptr); 136 136 if (!result.isNewEntry) 137 return static_cast<T *>(result.iterator->value);138 139 RefPtr<T>list = T::create(node, name);140 result.iterator->value = list.get();141 return list .release();142 } 143 144 PassRef Ptr<TagNodeList> addCacheWithQualifiedName(ContainerNode& node, const AtomicString& namespaceURI, const AtomicString& localName)137 return static_cast<T&>(*result.iterator->value); 138 139 auto list = T::create(node, name); 140 result.iterator->value = &list.get(); 141 return list; 142 } 143 144 PassRef<TagNodeList> addCacheWithQualifiedName(ContainerNode& node, const AtomicString& namespaceURI, const AtomicString& localName) 145 145 { 146 146 QualifiedName name(nullAtom, localName, namespaceURI); 147 147 TagNodeListCacheNS::AddResult result = m_tagNodeListCacheNS.add(name, nullptr); 148 148 if (!result.isNewEntry) 149 return result.iterator->value;150 151 RefPtr<TagNodeList>list = TagNodeList::create(node, namespaceURI, localName);152 result.iterator->value = list.get();153 return list .release();149 return *result.iterator->value; 150 151 auto list = TagNodeList::create(node, namespaceURI, localName); 152 result.iterator->value = &list.get(); 153 return list; 154 154 } 155 155 156 156 template<typename T, typename ContainerType> 157 PassRef Ptr<T> addCachedCollection(ContainerType& container, CollectionType collectionType, const AtomicString& name)157 PassRef<T> addCachedCollection(ContainerType& container, CollectionType collectionType, const AtomicString& name) 158 158 { 159 159 CollectionCacheMap::AddResult result = m_cachedCollections.add(namedCollectionKey(collectionType, name), nullptr); 160 160 if (!result.isNewEntry) 161 return static_cast<T *>(result.iterator->value);162 163 RefPtr<T>list = T::create(container, collectionType, name);164 result.iterator->value = list.get();165 return list .release();161 return static_cast<T&>(*result.iterator->value); 162 163 auto list = T::create(container, collectionType, name); 164 result.iterator->value = &list.get(); 165 return list; 166 166 } 167 167 168 168 template<typename T, typename ContainerType> 169 PassRef Ptr<T> addCachedCollection(ContainerType& container, CollectionType collectionType)169 PassRef<T> addCachedCollection(ContainerType& container, CollectionType collectionType) 170 170 { 171 171 CollectionCacheMap::AddResult result = m_cachedCollections.add(namedCollectionKey(collectionType, starAtom), nullptr); 172 172 if (!result.isNewEntry) 173 return static_cast<T *>(result.iterator->value);174 175 RefPtr<T>list = T::create(container, collectionType);176 result.iterator->value = list.get();177 return list .release();173 return static_cast<T&>(*result.iterator->value); 174 175 auto list = T::create(container, collectionType); 176 result.iterator->value = &list.get(); 177 return list; 178 178 } 179 179 -
trunk/Source/WebCore/dom/TagNodeList.h
r166407 r166461 34 34 class TagNodeList final : public CachedLiveNodeList<TagNodeList> { 35 35 public: 36 static PassRef Ptr<TagNodeList> create(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName)36 static PassRef<TagNodeList> create(ContainerNode& rootNode, const AtomicString& namespaceURI, const AtomicString& localName) 37 37 { 38 38 ASSERT(namespaceURI != starAtom); 39 return adoptRef( new TagNodeList(rootNode, namespaceURI, localName));39 return adoptRef(*new TagNodeList(rootNode, namespaceURI, localName)); 40 40 } 41 41 42 static PassRef Ptr<TagNodeList> create(ContainerNode& rootNode, const AtomicString& localName)42 static PassRef<TagNodeList> create(ContainerNode& rootNode, const AtomicString& localName) 43 43 { 44 return adoptRef( new TagNodeList(rootNode, starAtom, localName));44 return adoptRef(*new TagNodeList(rootNode, starAtom, localName)); 45 45 } 46 46 … … 68 68 class HTMLTagNodeList final : public CachedLiveNodeList<HTMLTagNodeList> { 69 69 public: 70 static PassRef Ptr<HTMLTagNodeList> create(ContainerNode& rootNode, const AtomicString& localName)70 static PassRef<HTMLTagNodeList> create(ContainerNode& rootNode, const AtomicString& localName) 71 71 { 72 return adoptRef( new HTMLTagNodeList(rootNode, localName));72 return adoptRef(*new HTMLTagNodeList(rootNode, localName)); 73 73 } 74 74 -
trunk/Source/WebCore/html/HTMLCollection.cpp
r166460 r166461 146 146 } 147 147 148 PassRef Ptr<HTMLCollection> HTMLCollection::create(ContainerNode& base, CollectionType type)149 { 150 return adoptRef( new HTMLCollection(base, type));148 PassRef<HTMLCollection> HTMLCollection::create(ContainerNode& base, CollectionType type) 149 { 150 return adoptRef(*new HTMLCollection(base, type)); 151 151 } 152 152 -
trunk/Source/WebCore/html/HTMLCollection.h
r166460 r166461 87 87 class HTMLCollection : public ScriptWrappable, public RefCounted<HTMLCollection> { 88 88 public: 89 static PassRef Ptr<HTMLCollection> create(ContainerNode& base, CollectionType);89 static PassRef<HTMLCollection> create(ContainerNode& base, CollectionType); 90 90 virtual ~HTMLCollection(); 91 91 -
trunk/Source/WebCore/html/HTMLFormControlsCollection.cpp
r165103 r166461 44 44 } 45 45 46 PassRef Ptr<HTMLFormControlsCollection> HTMLFormControlsCollection::create(ContainerNode& ownerNode, CollectionType)46 PassRef<HTMLFormControlsCollection> HTMLFormControlsCollection::create(ContainerNode& ownerNode, CollectionType) 47 47 { 48 return adoptRef( new HTMLFormControlsCollection(ownerNode));48 return adoptRef(*new HTMLFormControlsCollection(ownerNode)); 49 49 } 50 50 -
trunk/Source/WebCore/html/HTMLFormControlsCollection.h
r165103 r166461 38 38 class HTMLFormControlsCollection : public HTMLCollection { 39 39 public: 40 static PassRef Ptr<HTMLFormControlsCollection> create(ContainerNode&, CollectionType);40 static PassRef<HTMLFormControlsCollection> create(ContainerNode&, CollectionType); 41 41 42 42 virtual ~HTMLFormControlsCollection(); -
trunk/Source/WebCore/html/RadioNodeList.h
r166407 r166461 36 36 class RadioNodeList final : public CachedLiveNodeList<RadioNodeList> { 37 37 public: 38 static PassRef Ptr<RadioNodeList> create(ContainerNode& rootNode, const AtomicString& name)38 static PassRef<RadioNodeList> create(ContainerNode& rootNode, const AtomicString& name) 39 39 { 40 return adoptRef( new RadioNodeList(rootNode, name));40 return adoptRef(*new RadioNodeList(rootNode, name)); 41 41 } 42 42
Note: See TracChangeset
for help on using the changeset viewer.