| 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 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 typedef HashMap<std::pair<unsigned char, StringImpl*>, LiveNodeListBase*, No
deListAtomicCacheMapEntryHash> NodeListAtomicNameCacheMap; | 96 typedef HashMap<std::pair<unsigned char, StringImpl*>, LiveNodeListBase*, No
deListAtomicCacheMapEntryHash> NodeListAtomicNameCacheMap; |
| 97 typedef HashMap<QualifiedName, TagCollection*> TagCollectionCacheNS; | 97 typedef HashMap<QualifiedName, TagCollection*> TagCollectionCacheNS; |
| 98 | 98 |
| 99 template<typename T> | 99 template<typename T> |
| 100 PassRefPtr<T> addCache(ContainerNode* node, CollectionType collectionType, c
onst AtomicString& name) | 100 PassRefPtr<T> addCache(ContainerNode* node, CollectionType collectionType, c
onst AtomicString& name) |
| 101 { | 101 { |
| 102 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(collectionType, name), 0); | 102 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(collectionType, name), 0); |
| 103 if (!result.isNewEntry) | 103 if (!result.isNewEntry) |
| 104 return static_cast<T*>(result.iterator->value); | 104 return static_cast<T*>(result.storedValue->value); |
| 105 | 105 |
| 106 RefPtr<T> list = T::create(node, collectionType, name); | 106 RefPtr<T> list = T::create(node, collectionType, name); |
| 107 result.iterator->value = list.get(); | 107 result.storedValue->value = list.get(); |
| 108 return list.release(); | 108 return list.release(); |
| 109 } | 109 } |
| 110 | 110 |
| 111 template<typename T> | 111 template<typename T> |
| 112 PassRefPtr<T> addCache(ContainerNode* node, CollectionType collectionType) | 112 PassRefPtr<T> addCache(ContainerNode* node, CollectionType collectionType) |
| 113 { | 113 { |
| 114 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(collectionType, starAtom), 0); | 114 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(collectionType, starAtom), 0); |
| 115 if (!result.isNewEntry) | 115 if (!result.isNewEntry) |
| 116 return static_cast<T*>(result.iterator->value); | 116 return static_cast<T*>(result.storedValue->value); |
| 117 | 117 |
| 118 RefPtr<T> list = T::create(node, collectionType); | 118 RefPtr<T> list = T::create(node, collectionType); |
| 119 result.iterator->value = list.get(); | 119 result.storedValue->value = list.get(); |
| 120 return list.release(); | 120 return list.release(); |
| 121 } | 121 } |
| 122 | 122 |
| 123 template<typename T> | 123 template<typename T> |
| 124 T* cached(CollectionType collectionType) | 124 T* cached(CollectionType collectionType) |
| 125 { | 125 { |
| 126 return static_cast<T*>(m_atomicNameCaches.get(namedNodeListKey(collectio
nType, starAtom))); | 126 return static_cast<T*>(m_atomicNameCaches.get(namedNodeListKey(collectio
nType, starAtom))); |
| 127 } | 127 } |
| 128 | 128 |
| 129 PassRefPtr<TagCollection> addCache(ContainerNode* node, const AtomicString&
namespaceURI, const AtomicString& localName) | 129 PassRefPtr<TagCollection> addCache(ContainerNode* node, const AtomicString&
namespaceURI, const AtomicString& localName) |
| 130 { | 130 { |
| 131 QualifiedName name(nullAtom, localName, namespaceURI); | 131 QualifiedName name(nullAtom, localName, namespaceURI); |
| 132 TagCollectionCacheNS::AddResult result = m_tagCollectionCacheNS.add(name
, 0); | 132 TagCollectionCacheNS::AddResult result = m_tagCollectionCacheNS.add(name
, 0); |
| 133 if (!result.isNewEntry) | 133 if (!result.isNewEntry) |
| 134 return result.iterator->value; | 134 return result.storedValue->value; |
| 135 | 135 |
| 136 RefPtr<TagCollection> list = TagCollection::create(node, namespaceURI, l
ocalName); | 136 RefPtr<TagCollection> list = TagCollection::create(node, namespaceURI, l
ocalName); |
| 137 result.iterator->value = list.get(); | 137 result.storedValue->value = list.get(); |
| 138 return list.release(); | 138 return list.release(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 void removeCache(LiveNodeListBase* list, CollectionType collectionType, cons
t AtomicString& name = starAtom) | 141 void removeCache(LiveNodeListBase* list, CollectionType collectionType, cons
t AtomicString& name = starAtom) |
| 142 { | 142 { |
| 143 ASSERT(list == m_atomicNameCaches.get(namedNodeListKey(collectionType, n
ame))); | 143 ASSERT(list == m_atomicNameCaches.get(namedNodeListKey(collectionType, n
ame))); |
| 144 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNo
de())) | 144 if (deleteThisAndUpdateNodeRareDataIfAboutToRemoveLastList(list->ownerNo
de())) |
| 145 return; | 145 return; |
| 146 m_atomicNameCaches.remove(namedNodeListKey(collectionType, name)); | 146 m_atomicNameCaches.remove(namedNodeListKey(collectionType, name)); |
| 147 } | 147 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 ownerNode->clearNodeLists(); | 277 ownerNode->clearNodeLists(); |
| 278 return true; | 278 return true; |
| 279 } | 279 } |
| 280 | 280 |
| 281 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow | 281 // Ensure the 10 bits reserved for the m_connectedFrameCount cannot overflow |
| 282 COMPILE_ASSERT(Page::maxNumberOfFrames < 1024, Frame_limit_should_fit_in_rare_da
ta_count); | 282 COMPILE_ASSERT(Page::maxNumberOfFrames < 1024, Frame_limit_should_fit_in_rare_da
ta_count); |
| 283 | 283 |
| 284 } // namespace WebCore | 284 } // namespace WebCore |
| 285 | 285 |
| 286 #endif // NodeRareData_h | 286 #endif // NodeRareData_h |
| OLD | NEW |