| 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, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 13 * Library General Public License for more details. | 13 * Library General Public License for more details. |
| 14 * | 14 * |
| 15 * You should have received a copy of the GNU Library General Public License | 15 * You should have received a copy of the GNU Library General Public License |
| 16 * along with this library; see the file COPYING.LIB. If not, write to | 16 * along with this library; see the file COPYING.LIB. If not, write to |
| 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 18 * Boston, MA 02110-1301, USA. | 18 * Boston, MA 02110-1301, USA. |
| 19 * | 19 * |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #ifndef NodeRareData_h | 22 #ifndef NodeRareData_h |
| 23 #define NodeRareData_h | 23 #define NodeRareData_h |
| 24 | 24 |
| 25 #include "ChildNodeList.h" | 25 #include "ChildNodeList.h" |
| 26 #include "ClassNodeList.h" | |
| 27 #include "DOMSettableTokenList.h" | 26 #include "DOMSettableTokenList.h" |
| 28 #include "DynamicNodeList.h" | 27 #include "DynamicNodeList.h" |
| 29 #include "MutationObserverRegistration.h" | 28 #include "MutationObserverRegistration.h" |
| 30 #include "NameNodeList.h" | |
| 31 #include "QualifiedName.h" | 29 #include "QualifiedName.h" |
| 32 #include "TagNodeList.h" | 30 #include "TagNodeList.h" |
| 33 #include "WebKitMutationObserver.h" | 31 #include "WebKitMutationObserver.h" |
| 34 #include <wtf/HashSet.h> | 32 #include <wtf/HashSet.h> |
| 35 #include <wtf/OwnPtr.h> | 33 #include <wtf/OwnPtr.h> |
| 36 #include <wtf/PassOwnPtr.h> | 34 #include <wtf/PassOwnPtr.h> |
| 37 #include <wtf/text/AtomicString.h> | 35 #include <wtf/text/AtomicString.h> |
| 38 #include <wtf/text/StringHash.h> | 36 #include <wtf/text/StringHash.h> |
| 39 | 37 |
| 40 #if ENABLE(MICRODATA) | 38 #if ENABLE(MICRODATA) |
| 41 #include "HTMLPropertiesCollection.h" | 39 #include "HTMLPropertiesCollection.h" |
| 42 #include "MicroDataItemList.h" | 40 #include "MicroDataItemList.h" |
| 43 #endif | 41 #endif |
| 44 | 42 |
| 45 namespace WebCore { | 43 namespace WebCore { |
| 46 | 44 |
| 47 class LabelsNodeList; | 45 class LabelsNodeList; |
| 48 class RadioNodeList; | 46 class RadioNodeList; |
| 49 class TreeScope; | 47 class TreeScope; |
| 50 | 48 |
| 51 struct NodeListsNodeData { | 49 struct NodeListsNodeData { |
| 52 WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED; | 50 WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED; |
| 53 public: | 51 public: |
| 54 typedef HashMap<String, ClassNodeList*> ClassNodeListCache; | 52 typedef HashMap<std::pair<unsigned short, AtomicString>, DynamicSubtreeNodeL
ist*> NodeListAtomicNameCacheMap; |
| 55 ClassNodeListCache m_classNodeListCache; | 53 typedef HashMap<std::pair<unsigned short, String>, DynamicSubtreeNodeList*>
NodeListNameCacheMap; |
| 54 typedef HashMap<QualifiedName, TagNodeList*> TagNodeListCacheNS; |
| 56 | 55 |
| 57 typedef HashMap<String, NameNodeList*> NameNodeListCache; | 56 template<typename T> |
| 58 NameNodeListCache m_nameNodeListCache; | 57 PassRefPtr<T> addCacheWithAtomicName(Node* node, DynamicNodeList::NodeListTy
pe listType, const AtomicString& name) |
| 59 | 58 { |
| 60 typedef HashMap<AtomicString, TagNodeList*> TagNodeListCache; | 59 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(listType, name), 0); |
| 61 TagNodeListCache m_tagNodeListCache; | 60 if (!result.isNewEntry) |
| 61 return static_cast<T*>(result.iterator->second); |
| 62 | 62 |
| 63 typedef HashMap<RefPtr<QualifiedName::QualifiedNameImpl>, TagNodeList*> TagN
odeListCacheNS; | 63 RefPtr<T> list = T::create(node, name); |
| 64 TagNodeListCacheNS m_tagNodeListCacheNS; | 64 result.iterator->second = list.get(); |
| 65 return list.release(); |
| 66 } |
| 65 | 67 |
| 66 #if ENABLE(MICRODATA) | 68 template<typename T> |
| 67 typedef HashMap<String, MicroDataItemList*> MicroDataItemListCache; | 69 PassRefPtr<T> addCacheWithName(Node* node, DynamicNodeList::NodeListType lis
tType, const String& name) |
| 68 MicroDataItemListCache m_microDataItemListCache; | 70 { |
| 69 #endif | 71 NodeListNameCacheMap::AddResult result = m_nameCaches.add(namedNodeListK
ey(listType, name), 0); |
| 72 if (!result.isNewEntry) |
| 73 return static_cast<T*>(result.iterator->second); |
| 70 | 74 |
| 71 LabelsNodeList* m_labelsNodeListCache; | 75 RefPtr<T> list = T::create(node, name); |
| 76 result.iterator->second = list.get(); |
| 77 return list.release(); |
| 78 } |
| 72 | 79 |
| 73 typedef HashMap<String, RadioNodeList*> RadioNodeListCache; | 80 PassRefPtr<TagNodeList> addCacheWithQualifiedName(Node* node, const AtomicSt
ring& namespaceURI, const AtomicString& localName) |
| 74 RadioNodeListCache m_radioNodeListCache; | 81 { |
| 82 QualifiedName name(nullAtom, localName, namespaceURI); |
| 83 TagNodeListCacheNS::AddResult result = m_tagNodeListCacheNS.add(name, 0)
; |
| 84 if (!result.isNewEntry) |
| 85 return result.iterator->second; |
| 86 |
| 87 RefPtr<TagNodeList> list = TagNodeList::create(node, namespaceURI, local
Name); |
| 88 result.iterator->second = list.get(); |
| 89 return list.release(); |
| 90 } |
| 91 |
| 92 void removeCacheWithAtomicName(DynamicSubtreeNodeList* list, DynamicNodeList
::NodeListType listType, const AtomicString& name) |
| 93 { |
| 94 ASSERT_UNUSED(list, list == m_atomicNameCaches.get(namedNodeListKey(list
Type, name))); |
| 95 m_atomicNameCaches.remove(namedNodeListKey(listType, name)); |
| 96 } |
| 97 |
| 98 void removeCacheWithName(DynamicSubtreeNodeList* list, DynamicNodeList::Node
ListType listType, const String& name) |
| 99 { |
| 100 ASSERT_UNUSED(list, list == m_nameCaches.get(namedNodeListKey(listType,
name))); |
| 101 m_nameCaches.remove(namedNodeListKey(listType, name)); |
| 102 } |
| 103 |
| 104 void removeCacheWithQualifiedName(DynamicSubtreeNodeList* list, const Atomic
String& namespaceURI, const AtomicString& localName) |
| 105 { |
| 106 QualifiedName name(nullAtom, localName, namespaceURI); |
| 107 ASSERT_UNUSED(list, list == m_tagNodeListCacheNS.get(name)); |
| 108 m_tagNodeListCacheNS.remove(name); |
| 109 } |
| 75 | 110 |
| 76 static PassOwnPtr<NodeListsNodeData> create() | 111 static PassOwnPtr<NodeListsNodeData> create() |
| 77 { | 112 { |
| 78 return adoptPtr(new NodeListsNodeData); | 113 return adoptPtr(new NodeListsNodeData); |
| 79 } | 114 } |
| 80 | 115 |
| 81 void invalidateCaches(); | 116 void invalidateCaches(const QualifiedName* attrName = 0); |
| 82 void invalidateCachesThatDependOnAttributes(); | 117 bool isEmpty() const |
| 83 | 118 { |
| 84 bool isEmpty() const; | 119 return m_atomicNameCaches.isEmpty() && m_nameCaches.isEmpty() && m_tagNo
deListCacheNS.isEmpty(); |
| 120 } |
| 85 | 121 |
| 86 private: | 122 private: |
| 87 NodeListsNodeData() : m_labelsNodeListCache(0) {} | 123 NodeListsNodeData() { } |
| 124 |
| 125 std::pair<unsigned short, AtomicString> namedNodeListKey(DynamicNodeList::No
deListType listType, const AtomicString& name) |
| 126 { |
| 127 return std::pair<unsigned short, AtomicString>(listType, name); |
| 128 } |
| 129 |
| 130 std::pair<unsigned short, String> namedNodeListKey(DynamicNodeList::NodeList
Type listType, const String& name) |
| 131 { |
| 132 return std::pair<unsigned short, String>(listType, name); |
| 133 } |
| 134 |
| 135 NodeListAtomicNameCacheMap m_atomicNameCaches; |
| 136 NodeListNameCacheMap m_nameCaches; |
| 137 TagNodeListCacheNS m_tagNodeListCacheNS; |
| 88 }; | 138 }; |
| 89 | 139 |
| 90 class NodeRareData { | 140 class NodeRareData { |
| 91 WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED; | 141 WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED; |
| 92 public: | 142 public: |
| 93 NodeRareData() | 143 NodeRareData() |
| 94 : m_treeScope(0) | 144 : m_treeScope(0) |
| 95 , m_childNodeList(0) | 145 , m_childNodeList(0) |
| 96 , m_tabIndex(0) | 146 , m_tabIndex(0) |
| 97 , m_tabIndexWasSetExplicitly(false) | 147 , m_tabIndexWasSetExplicitly(false) |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 #endif | 333 #endif |
| 284 | 334 |
| 285 #if ENABLE(STYLE_SCOPED) | 335 #if ENABLE(STYLE_SCOPED) |
| 286 size_t m_numberOfScopedHTMLStyleChildren; | 336 size_t m_numberOfScopedHTMLStyleChildren; |
| 287 #endif | 337 #endif |
| 288 }; | 338 }; |
| 289 | 339 |
| 290 } // namespace WebCore | 340 } // namespace WebCore |
| 291 | 341 |
| 292 #endif // NodeRareData_h | 342 #endif // NodeRareData_h |
| OLD | NEW |