OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 bool contains(AtomicStringImpl*) const; | 49 bool contains(AtomicStringImpl*) const; |
50 bool containsMultiple(AtomicStringImpl*) const; | 50 bool containsMultiple(AtomicStringImpl*) const; |
51 // concrete instantiations of the get<>() method template | 51 // concrete instantiations of the get<>() method template |
52 Element* getElementById(AtomicStringImpl*, const TreeScope*) const; | 52 Element* getElementById(AtomicStringImpl*, const TreeScope*) const; |
53 Element* getElementByMapName(AtomicStringImpl*, const TreeScope*) const; | 53 Element* getElementByMapName(AtomicStringImpl*, const TreeScope*) const; |
54 Element* getElementByLowercasedMapName(AtomicStringImpl*, const TreeScope*)
const; | 54 Element* getElementByLowercasedMapName(AtomicStringImpl*, const TreeScope*)
const; |
55 Element* getElementByLabelForAttribute(AtomicStringImpl*, const TreeScope*)
const; | 55 Element* getElementByLabelForAttribute(AtomicStringImpl*, const TreeScope*)
const; |
56 | 56 |
57 void checkConsistency() const; | 57 void checkConsistency() const; |
58 | 58 |
59 void reportMemoryUsage(MemoryObjectInfo*) const; | |
60 | |
61 private: | 59 private: |
62 template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicSt
ringImpl*, const TreeScope*) const; | 60 template<bool keyMatches(AtomicStringImpl*, Element*)> Element* get(AtomicSt
ringImpl*, const TreeScope*) const; |
63 | 61 |
64 typedef HashMap<AtomicStringImpl*, Element*> Map; | 62 typedef HashMap<AtomicStringImpl*, Element*> Map; |
65 | 63 |
66 // We maintain the invariant that m_duplicateCounts is the count of all elem
ents with a given key | 64 // We maintain the invariant that m_duplicateCounts is the count of all elem
ents with a given key |
67 // excluding the one referenced in m_map, if any. This means it one less tha
n the total count | 65 // excluding the one referenced in m_map, if any. This means it one less tha
n the total count |
68 // when the first node with a given key is cached, otherwise the same as the
total count. | 66 // when the first node with a given key is cached, otherwise the same as the
total count. |
69 mutable Map m_map; | 67 mutable Map m_map; |
70 mutable HashCountedSet<AtomicStringImpl*> m_duplicateCounts; | 68 mutable HashCountedSet<AtomicStringImpl*> m_duplicateCounts; |
71 }; | 69 }; |
72 | 70 |
73 inline bool DocumentOrderedMap::contains(AtomicStringImpl* id) const | 71 inline bool DocumentOrderedMap::contains(AtomicStringImpl* id) const |
74 { | 72 { |
75 return m_map.contains(id) || m_duplicateCounts.contains(id); | 73 return m_map.contains(id) || m_duplicateCounts.contains(id); |
76 } | 74 } |
77 | 75 |
78 inline bool DocumentOrderedMap::containsMultiple(AtomicStringImpl* id) const | 76 inline bool DocumentOrderedMap::containsMultiple(AtomicStringImpl* id) const |
79 { | 77 { |
80 return m_duplicateCounts.contains(id); | 78 return m_duplicateCounts.contains(id); |
81 } | 79 } |
82 | 80 |
83 } // namespace WebCore | 81 } // namespace WebCore |
84 | 82 |
85 #endif // DocumentOrderedMap_h | 83 #endif // DocumentOrderedMap_h |
OLD | NEW |