Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(360)

Side by Side Diff: sky/engine/core/dom/DocumentOrderedMap.h

Issue 705473004: Remove most of DocumentOrderedMap. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sky/engine/core/dom/DocumentOrderedMap.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 "platform/heap/Handle.h"
35 #include "wtf/Forward.h" 34 #include "wtf/Forward.h"
36 #include "wtf/HashMap.h" 35 #include "wtf/HashMap.h"
37 #include "wtf/text/AtomicString.h" 36 #include "wtf/text/AtomicString.h"
38 #include "wtf/text/AtomicStringHash.h" 37 #include "wtf/text/AtomicStringHash.h"
39 #include "wtf/text/StringImpl.h"
40 38
41 namespace blink { 39 namespace blink {
42 40
43 class Element; 41 class Element;
44 class TreeScope; 42 class TreeScope;
45 43
46 class DocumentOrderedMap : public DummyBase<DocumentOrderedMap> { 44 class DocumentOrderedMap {
47 public: 45 public:
48 static PassOwnPtr<DocumentOrderedMap> create(); 46 static PassOwnPtr<DocumentOrderedMap> create();
47
49 void add(const AtomicString&, Element*); 48 void add(const AtomicString&, Element*);
50 void remove(const AtomicString&, Element*); 49 void remove(const AtomicString&, Element*);
51 50
52 bool contains(const AtomicString&) const;
53 bool containsMultiple(const AtomicString&) const;
54 // concrete instantiations of the get<>() method template
55 Element* getElementById(const AtomicString&, const TreeScope*) const; 51 Element* getElementById(const AtomicString&, const TreeScope*) const;
56 const Vector<RawPtr<Element> >& getAllElementsById(const AtomicString&, cons t TreeScope*) const;
57 Element* getElementByMapName(const AtomicString&, const TreeScope*) const;
58 Element* getElementByLowercasedMapName(const AtomicString&, const TreeScope* ) const;
59 Element* getElementByLabelForAttribute(const AtomicString&, const TreeScope* ) const;
60
61 void trace(Visitor*);
62 52
63 private: 53 private:
64 template<bool keyMatches(const AtomicString&, const Element&)> 54 class MapEntry {
65 Element* get(const AtomicString&, const TreeScope*) const;
66
67 class MapEntry : public DummyBase<MapEntry> {
68 public: 55 public:
69 explicit MapEntry(Element* firstElement) 56 explicit MapEntry(Element* element)
70 : element(firstElement) 57 : element(element)
71 , count(1) 58 , count(1)
72 { 59 {
73 } 60 }
74 61
75 void trace(Visitor*); 62 Element* element;
76
77 RawPtr<Element> element;
78 unsigned count; 63 unsigned count;
79 Vector<RawPtr<Element> > orderedList;
80 }; 64 };
81 65
82 typedef HashMap<AtomicString, OwnPtr<MapEntry> > Map; 66 typedef HashMap<AtomicString, OwnPtr<MapEntry> > Map;
83 67 Map m_map;
84 mutable Map m_map;
85 }; 68 };
86 69
87 inline bool DocumentOrderedMap::contains(const AtomicString& id) const
88 {
89 return m_map.contains(id);
90 }
91
92 inline bool DocumentOrderedMap::containsMultiple(const AtomicString& id) const
93 {
94 Map::const_iterator it = m_map.find(id);
95 return it != m_map.end() && it->value->count > 1;
96 }
97
98 } // namespace blink 70 } // namespace blink
99 71
100 #endif // DocumentOrderedMap_h 72 #endif // DocumentOrderedMap_h
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/dom/DocumentOrderedMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698