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

Side by Side Diff: third_party/WebKit/Source/core/dom/DocumentOrderedMap.h

Issue 2905043002: Make DocumentOrderedMap take a const reference for scope (Closed)
Patch Set: Created 3 years, 7 months 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 | third_party/WebKit/Source/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 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are 6 * modification, are permitted provided that the following conditions are
7 * met: 7 * met:
8 * 8 *
9 * * Redistributions of source code must retain the above copyright 9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 class DocumentOrderedMap : public GarbageCollected<DocumentOrderedMap> { 49 class DocumentOrderedMap : public GarbageCollected<DocumentOrderedMap> {
50 public: 50 public:
51 static DocumentOrderedMap* Create(); 51 static DocumentOrderedMap* Create();
52 52
53 void Add(const AtomicString&, Element*); 53 void Add(const AtomicString&, Element*);
54 void Remove(const AtomicString&, Element*); 54 void Remove(const AtomicString&, Element*);
55 55
56 bool Contains(const AtomicString&) const; 56 bool Contains(const AtomicString&) const;
57 bool ContainsMultiple(const AtomicString&) const; 57 bool ContainsMultiple(const AtomicString&) const;
58 // concrete instantiations of the get<>() method template 58 // concrete instantiations of the get<>() method template
59 Element* GetElementById(const AtomicString&, const TreeScope*) const; 59 Element* GetElementById(const AtomicString&, const TreeScope&) const;
60 const HeapVector<Member<Element>>& GetAllElementsById(const AtomicString&, 60 const HeapVector<Member<Element>>& GetAllElementsById(const AtomicString&,
61 const TreeScope*) const; 61 const TreeScope&) const;
62 Element* GetElementByMapName(const AtomicString&, const TreeScope*) const; 62 Element* GetElementByMapName(const AtomicString&, const TreeScope&) const;
63 HTMLSlotElement* GetSlotByName(const AtomicString&, const TreeScope*) const; 63 HTMLSlotElement* GetSlotByName(const AtomicString&, const TreeScope&) const;
64 64
65 DECLARE_TRACE(); 65 DECLARE_TRACE();
66 66
67 #if DCHECK_IS_ON() 67 #if DCHECK_IS_ON()
68 // While removing a ContainerNode, ID lookups won't be precise should the tree 68 // While removing a ContainerNode, ID lookups won't be precise should the tree
69 // have elements with duplicate IDs contained in the element being removed. 69 // have elements with duplicate IDs contained in the element being removed.
70 // Rare trees, but ID lookups may legitimately fail across such removals; 70 // Rare trees, but ID lookups may legitimately fail across such removals;
71 // this scope object informs DocumentOrderedMaps about the transitory 71 // this scope object informs DocumentOrderedMaps about the transitory
72 // state of the underlying tree. 72 // state of the underlying tree.
73 class RemoveScope { 73 class RemoveScope {
(...skipping 10 matching lines...) Expand all
84 public: 84 public:
85 RemoveScope() {} 85 RemoveScope() {}
86 ~RemoveScope() {} 86 ~RemoveScope() {}
87 }; 87 };
88 #endif 88 #endif
89 89
90 private: 90 private:
91 DocumentOrderedMap(); 91 DocumentOrderedMap();
92 92
93 template <bool keyMatches(const AtomicString&, const Element&)> 93 template <bool keyMatches(const AtomicString&, const Element&)>
94 Element* Get(const AtomicString&, const TreeScope*) const; 94 Element* Get(const AtomicString&, const TreeScope&) const;
95 95
96 class MapEntry : public GarbageCollected<MapEntry> { 96 class MapEntry : public GarbageCollected<MapEntry> {
97 public: 97 public:
98 explicit MapEntry(Element* first_element) 98 explicit MapEntry(Element* first_element)
99 : element(first_element), count(1) {} 99 : element(first_element), count(1) {}
100 100
101 DECLARE_TRACE(); 101 DECLARE_TRACE();
102 102
103 Member<Element> element; 103 Member<Element> element;
104 unsigned count; 104 unsigned count;
(...skipping 10 matching lines...) Expand all
115 } 115 }
116 116
117 inline bool DocumentOrderedMap::ContainsMultiple(const AtomicString& id) const { 117 inline bool DocumentOrderedMap::ContainsMultiple(const AtomicString& id) const {
118 Map::const_iterator it = map_.find(id); 118 Map::const_iterator it = map_.find(id);
119 return it != map_.end() && it->value->count > 1; 119 return it != map_.end() && it->value->count > 1;
120 } 120 }
121 121
122 } // namespace blink 122 } // namespace blink
123 123
124 #endif // DocumentOrderedMap_h 124 #endif // DocumentOrderedMap_h
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/DocumentOrderedMap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698