| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2008, 2010 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com> | 3 * Copyright (C) 2008 David Smith <catfish.man@gmail.com> |
| 4 * | 4 * |
| 5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
| 6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
| 7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
| 8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
| 9 * | 9 * |
| 10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 void clearChildNodeListCache() | 52 void clearChildNodeListCache() |
| 53 { | 53 { |
| 54 if (m_childNodeList) | 54 if (m_childNodeList) |
| 55 m_childNodeList->invalidateCache(); | 55 m_childNodeList->invalidateCache(); |
| 56 } | 56 } |
| 57 | 57 |
| 58 PassRefPtr<ChildNodeList> ensureChildNodeList(Node* node) | 58 PassRefPtr<ChildNodeList> ensureChildNodeList(Node* node) |
| 59 { | 59 { |
| 60 if (m_childNodeList) | 60 if (m_childNodeList) |
| 61 return m_childNodeList; | 61 return m_childNodeList; |
| 62 RefPtr<ChildNodeList> list = ChildNodeList::create(node); | 62 RefPtr<ChildNodeList> list = ChildNodeList::create(adoptRawResult(node))
; |
| 63 m_childNodeList = list.get(); | 63 m_childNodeList = list.get(); |
| 64 return list.release(); | 64 return list.release(); |
| 65 } | 65 } |
| 66 | 66 |
| 67 void removeChildNodeList(ChildNodeList* list) | 67 void removeChildNodeList(ChildNodeList* list) |
| 68 { | 68 { |
| 69 ASSERT(m_childNodeList = list); | 69 ASSERT(m_childNodeList = list); |
| 70 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNo
de())) | 70 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNo
de())) |
| 71 return; | 71 return; |
| 72 m_childNodeList = 0; | 72 m_childNodeList = 0; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 86 typedef HashMap<std::pair<unsigned char, String>, LiveNodeListBase*, WTF::Fa
stAllocator, NodeListCacheMapEntryHash<String> > NodeListNameCacheMap; | 86 typedef HashMap<std::pair<unsigned char, String>, LiveNodeListBase*, WTF::Fa
stAllocator, NodeListCacheMapEntryHash<String> > NodeListNameCacheMap; |
| 87 typedef HashMap<QualifiedName, TagNodeList*> TagNodeListCacheNS; | 87 typedef HashMap<QualifiedName, TagNodeList*> TagNodeListCacheNS; |
| 88 | 88 |
| 89 template<typename T> | 89 template<typename T> |
| 90 PassRefPtr<T> addCacheWithAtomicName(Node* node, CollectionType collectionTy
pe, const AtomicString& name) | 90 PassRefPtr<T> addCacheWithAtomicName(Node* node, CollectionType collectionTy
pe, const AtomicString& name) |
| 91 { | 91 { |
| 92 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(collectionType, name), 0); | 92 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(collectionType, name), 0); |
| 93 if (!result.isNewEntry) | 93 if (!result.isNewEntry) |
| 94 return static_cast<T*>(result.iterator->value); | 94 return static_cast<T*>(result.iterator->value); |
| 95 | 95 |
| 96 RefPtr<T> list = T::create(node, collectionType, name); | 96 RefPtr<T> list = T::create(adoptRawResult(node), collectionType, name); |
| 97 result.iterator->value = list.get(); | 97 result.iterator->value = list.get(); |
| 98 return list.release(); | 98 return list.release(); |
| 99 } | 99 } |
| 100 | 100 |
| 101 // FIXME: This function should be renamed since it doesn't have an atomic na
me. | 101 // FIXME: This function should be renamed since it doesn't have an atomic na
me. |
| 102 template<typename T> | 102 template<typename T> |
| 103 PassRefPtr<T> addCacheWithAtomicName(Node* node, CollectionType collectionTy
pe) | 103 PassRefPtr<T> addCacheWithAtomicName(Node* node, CollectionType collectionTy
pe) |
| 104 { | 104 { |
| 105 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(collectionType, starAtom), 0); | 105 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(collectionType, starAtom), 0); |
| 106 if (!result.isNewEntry) | 106 if (!result.isNewEntry) |
| 107 return static_cast<T*>(result.iterator->value); | 107 return static_cast<T*>(result.iterator->value); |
| 108 | 108 |
| 109 RefPtr<T> list = T::create(node, collectionType); | 109 RefPtr<T> list = T::create(adoptRawResult(node), collectionType); |
| 110 result.iterator->value = list.get(); | 110 result.iterator->value = list.get(); |
| 111 return list.release(); | 111 return list.release(); |
| 112 } | 112 } |
| 113 | 113 |
| 114 template<typename T> | 114 template<typename T> |
| 115 T* cacheWithAtomicName(CollectionType collectionType) | 115 T* cacheWithAtomicName(CollectionType collectionType) |
| 116 { | 116 { |
| 117 return static_cast<T*>(m_atomicNameCaches.get(namedNodeListKey(collectio
nType, starAtom))); | 117 return static_cast<T*>(m_atomicNameCaches.get(namedNodeListKey(collectio
nType, starAtom))); |
| 118 } | 118 } |
| 119 | 119 |
| 120 template<typename T> | 120 template<typename T> |
| 121 PassRefPtr<T> addCacheWithName(Node* node, CollectionType collectionType, co
nst String& name) | 121 PassRefPtr<T> addCacheWithName(Node* node, CollectionType collectionType, co
nst String& name) |
| 122 { | 122 { |
| 123 NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListK
ey(collectionType, name), 0); | 123 NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListK
ey(collectionType, name), 0); |
| 124 if (!result.isNewEntry) | 124 if (!result.isNewEntry) |
| 125 return static_cast<T*>(result.iterator->value); | 125 return static_cast<T*>(result.iterator->value); |
| 126 | 126 |
| 127 RefPtr<T> list = T::create(node, name); | 127 RefPtr<T> list = T::create(adoptRawResult(node), name); |
| 128 result.iterator->value = list.get(); | 128 result.iterator->value = list.get(); |
| 129 return list.release(); | 129 return list.release(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 PassRefPtr<TagNodeList> addCacheWithQualifiedName(Node* node, const AtomicSt
ring& namespaceURI, const AtomicString& localName) | 132 PassRefPtr<TagNodeList> addCacheWithQualifiedName(Node* node, const AtomicSt
ring& namespaceURI, const AtomicString& localName) |
| 133 { | 133 { |
| 134 QualifiedName name(nullAtom, localName, namespaceURI); | 134 QualifiedName name(nullAtom, localName, namespaceURI); |
| 135 TagNodeListCacheNS::AddResult result = m_tagNodeListCacheNS.add(name, 0)
; | 135 TagNodeListCacheNS::AddResult result = m_tagNodeListCacheNS.add(name, 0)
; |
| 136 if (!result.isNewEntry) | 136 if (!result.isNewEntry) |
| 137 return result.iterator->value; | 137 return result.iterator->value; |
| 138 | 138 |
| 139 RefPtr<TagNodeList> list = TagNodeList::create(node, namespaceURI, local
Name); | 139 RefPtr<TagNodeList> list = TagNodeList::create(adoptRawResult(node), nam
espaceURI, localName); |
| 140 result.iterator->value = list.get(); | 140 result.iterator->value = list.get(); |
| 141 return list.release(); | 141 return list.release(); |
| 142 } | 142 } |
| 143 | 143 |
| 144 void removeCacheWithAtomicName(LiveNodeListBase* list, CollectionType collec
tionType, const AtomicString& name = starAtom) | 144 void removeCacheWithAtomicName(LiveNodeListBase* list, CollectionType collec
tionType, const AtomicString& name = starAtom) |
| 145 { | 145 { |
| 146 ASSERT(list == m_atomicNameCaches.get(namedNodeListKey(collectionType, n
ame))); | 146 ASSERT(list == m_atomicNameCaches.get(namedNodeListKey(collectionType, n
ame))); |
| 147 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNo
de())) | 147 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNo
de())) |
| 148 return; | 148 return; |
| 149 m_atomicNameCaches.remove(namedNodeListKey(collectionType, name)); | 149 m_atomicNameCaches.remove(namedNodeListKey(collectionType, name)); |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 334 ownerNode->clearNodeLists(); | 334 ownerNode->clearNodeLists(); |
| 335 return true; | 335 return true; |
| 336 } | 336 } |
| 337 | 337 |
| 338 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow | 338 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow |
| 339 COMPILE_ASSERT(Page::maxNumberOfFrames < 1024, Frame_limit_should_fit_in_rare_da
ta_count); | 339 COMPILE_ASSERT(Page::maxNumberOfFrames < 1024, Frame_limit_should_fit_in_rare_da
ta_count); |
| 340 | 340 |
| 341 } // namespace WebCore | 341 } // namespace WebCore |
| 342 | 342 |
| 343 #endif // NodeRareData_h | 343 #endif // NodeRareData_h |
| OLD | NEW |