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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 | 42 |
43 namespace WebCore { | 43 namespace WebCore { |
44 | 44 |
45 class LabelsNodeList; | 45 class LabelsNodeList; |
46 class RadioNodeList; | 46 class RadioNodeList; |
47 class TreeScope; | 47 class TreeScope; |
48 | 48 |
49 struct NodeListsNodeData { | 49 struct NodeListsNodeData { |
50 WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED; | 50 WTF_MAKE_NONCOPYABLE(NodeListsNodeData); WTF_MAKE_FAST_ALLOCATED; |
51 public: | 51 public: |
52 typedef HashMap<std::pair<unsigned short, AtomicString>, DynamicSubtreeNodeL
ist*> NodeListAtomicNameCacheMap; | 52 template <typename StringType> |
53 typedef HashMap<std::pair<unsigned short, String>, DynamicSubtreeNodeList*>
NodeListNameCacheMap; | 53 struct NodeListCacheMapEntryHash : public WTF::PairHash<unsigned char, Strin
gType> { |
| 54 static unsigned hash(const std::pair<unsigned char, StringType>& entry) |
| 55 { |
| 56 return DefaultHash<StringType>::Hash::hash(entry.second) + entry.fir
st; |
| 57 } |
| 58 static bool equal(const std::pair<unsigned char, StringType>& a, const s
td::pair<unsigned char, StringType>& b) { return a == b; } |
| 59 static const bool safeToCompareToEmptyOrDeleted = DefaultHash<StringType
>::Hash::safeToCompareToEmptyOrDeleted; |
| 60 }; |
| 61 |
| 62 typedef HashMap<std::pair<unsigned char, AtomicString>, DynamicSubtreeNodeLi
st*, NodeListCacheMapEntryHash<AtomicString> > NodeListAtomicNameCacheMap; |
| 63 typedef HashMap<std::pair<unsigned char, String>, DynamicSubtreeNodeList*, N
odeListCacheMapEntryHash<String> > NodeListNameCacheMap; |
54 typedef HashMap<QualifiedName, TagNodeList*> TagNodeListCacheNS; | 64 typedef HashMap<QualifiedName, TagNodeList*> TagNodeListCacheNS; |
55 | 65 |
56 template<typename T> | 66 template<typename T> |
57 PassRefPtr<T> addCacheWithAtomicName(Node* node, DynamicNodeList::NodeListTy
pe listType, const AtomicString& name) | 67 PassRefPtr<T> addCacheWithAtomicName(Node* node, DynamicNodeList::NodeListTy
pe listType, const AtomicString& name) |
58 { | 68 { |
59 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(listType, name), 0); | 69 NodeListAtomicNameCacheMap::AddResult result = m_atomicNameCaches.add(na
medNodeListKey(listType, name), 0); |
60 if (!result.isNewEntry) | 70 if (!result.isNewEntry) |
61 return static_cast<T*>(result.iterator->second); | 71 return static_cast<T*>(result.iterator->second); |
62 | 72 |
63 RefPtr<T> list = T::create(node, name); | 73 RefPtr<T> list = T::create(node, name); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 } | 154 } |
145 | 155 |
146 if (oldTreeScope) | 156 if (oldTreeScope) |
147 oldTreeScope->removeNodeListCache(); | 157 oldTreeScope->removeNodeListCache(); |
148 newTreeScope->addNodeListCache(); | 158 newTreeScope->addNodeListCache(); |
149 } | 159 } |
150 | 160 |
151 private: | 161 private: |
152 NodeListsNodeData() { } | 162 NodeListsNodeData() { } |
153 | 163 |
154 std::pair<unsigned short, AtomicString> namedNodeListKey(DynamicNodeList::No
deListType listType, const AtomicString& name) | 164 std::pair<unsigned char, AtomicString> namedNodeListKey(DynamicNodeList::Nod
eListType listType, const AtomicString& name) |
155 { | 165 { |
156 return std::pair<unsigned short, AtomicString>(listType, name); | 166 return std::pair<unsigned char, AtomicString>(listType, name); |
157 } | 167 } |
158 | 168 |
159 std::pair<unsigned short, String> namedNodeListKey(DynamicNodeList::NodeList
Type listType, const String& name) | 169 std::pair<unsigned char, String> namedNodeListKey(DynamicNodeList::NodeListT
ype listType, const String& name) |
160 { | 170 { |
161 return std::pair<unsigned short, String>(listType, name); | 171 return std::pair<unsigned char, String>(listType, name); |
162 } | 172 } |
163 | 173 |
164 NodeListAtomicNameCacheMap m_atomicNameCaches; | 174 NodeListAtomicNameCacheMap m_atomicNameCaches; |
165 NodeListNameCacheMap m_nameCaches; | 175 NodeListNameCacheMap m_nameCaches; |
166 TagNodeListCacheNS m_tagNodeListCacheNS; | 176 TagNodeListCacheNS m_tagNodeListCacheNS; |
167 }; | 177 }; |
168 | 178 |
169 class NodeRareData { | 179 class NodeRareData { |
170 WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED; | 180 WTF_MAKE_NONCOPYABLE(NodeRareData); WTF_MAKE_FAST_ALLOCATED; |
171 public: | 181 public: |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 #endif | 372 #endif |
363 | 373 |
364 #if ENABLE(STYLE_SCOPED) | 374 #if ENABLE(STYLE_SCOPED) |
365 size_t m_numberOfScopedHTMLStyleChildren; | 375 size_t m_numberOfScopedHTMLStyleChildren; |
366 #endif | 376 #endif |
367 }; | 377 }; |
368 | 378 |
369 } // namespace WebCore | 379 } // namespace WebCore |
370 | 380 |
371 #endif // NodeRareData_h | 381 #endif // NodeRareData_h |
OLD | NEW |