| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef DocumentOrderedMap_h | 31 #ifndef DocumentOrderedMap_h |
| 32 #define DocumentOrderedMap_h | 32 #define DocumentOrderedMap_h |
| 33 | 33 |
| 34 #include "wtf/HashCountedSet.h" | |
| 35 #include "wtf/HashMap.h" | 34 #include "wtf/HashMap.h" |
| 36 #include "wtf/Vector.h" | 35 #include "wtf/Vector.h" |
| 37 #include "wtf/text/StringImpl.h" | 36 #include "wtf/text/StringImpl.h" |
| 38 | 37 |
| 39 namespace WebCore { | 38 namespace WebCore { |
| 40 | 39 |
| 41 class Element; | 40 class Element; |
| 42 class TreeScope; | 41 class TreeScope; |
| 43 | 42 |
| 44 class DocumentOrderedMap { | 43 class DocumentOrderedMap { |
| 45 public: | 44 public: |
| 46 void add(StringImpl*, Element*); | 45 void add(StringImpl*, Element*); |
| 47 void remove(StringImpl*, Element*); | 46 void remove(StringImpl*, Element*); |
| 48 void clear(); | |
| 49 | 47 |
| 50 bool contains(StringImpl*) const; | 48 bool contains(StringImpl*) const; |
| 51 bool containsMultiple(StringImpl*) const; | 49 bool containsMultiple(StringImpl*) const; |
| 52 // concrete instantiations of the get<>() method template | 50 // concrete instantiations of the get<>() method template |
| 53 Element* getElementById(StringImpl*, const TreeScope*) const; | 51 Element* getElementById(StringImpl*, const TreeScope*) const; |
| 54 const Vector<Element*>& getAllElementsById(StringImpl*, const TreeScope*) co
nst; | 52 const Vector<Element*>& getAllElementsById(StringImpl*, const TreeScope*) co
nst; |
| 55 Element* getElementByMapName(StringImpl*, const TreeScope*) const; | 53 Element* getElementByMapName(StringImpl*, const TreeScope*) const; |
| 56 Element* getElementByLowercasedMapName(StringImpl*, const TreeScope*) const; | 54 Element* getElementByLowercasedMapName(StringImpl*, const TreeScope*) const; |
| 57 Element* getElementByLabelForAttribute(StringImpl*, const TreeScope*) const; | 55 Element* getElementByLabelForAttribute(StringImpl*, const TreeScope*) const; |
| 58 | 56 |
| 59 void checkConsistency() const; | |
| 60 | |
| 61 private: | 57 private: |
| 62 template<bool keyMatches(StringImpl*, Element*)> Element* get(StringImpl*, c
onst TreeScope*) const; | 58 template<bool keyMatches(StringImpl*, Element*)> Element* get(StringImpl*, c
onst TreeScope*) const; |
| 63 | 59 |
| 64 struct MapEntry { | 60 struct MapEntry { |
| 65 explicit MapEntry(Element* firstElement) | 61 explicit MapEntry(Element* firstElement) |
| 66 : element(firstElement) | 62 : element(firstElement) |
| 67 , count(1) | 63 , count(1) |
| 68 { } | 64 { } |
| 69 | 65 |
| 70 Element* element; | 66 Element* element; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 84 | 80 |
| 85 inline bool DocumentOrderedMap::containsMultiple(StringImpl* id) const | 81 inline bool DocumentOrderedMap::containsMultiple(StringImpl* id) const |
| 86 { | 82 { |
| 87 Map::const_iterator it = m_map.find(id); | 83 Map::const_iterator it = m_map.find(id); |
| 88 return it != m_map.end() && it->value->count > 1; | 84 return it != m_map.end() && it->value->count > 1; |
| 89 } | 85 } |
| 90 | 86 |
| 91 } // namespace WebCore | 87 } // namespace WebCore |
| 92 | 88 |
| 93 #endif // DocumentOrderedMap_h | 89 #endif // DocumentOrderedMap_h |
| OLD | NEW |