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

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

Issue 1532103002: Better handling of DocumentOrderedMap same-ID lookups during tree removals (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: spelling Created 5 years 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
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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 bool containsMultiple(const AtomicString&) const; 55 bool containsMultiple(const AtomicString&) const;
56 // concrete instantiations of the get<>() method template 56 // concrete instantiations of the get<>() method template
57 Element* getElementById(const AtomicString&, const TreeScope*) const; 57 Element* getElementById(const AtomicString&, const TreeScope*) const;
58 const WillBeHeapVector<RawPtrWillBeMember<Element>>& getAllElementsById(cons t AtomicString&, const TreeScope*) const; 58 const WillBeHeapVector<RawPtrWillBeMember<Element>>& getAllElementsById(cons t AtomicString&, const TreeScope*) const;
59 Element* getElementByMapName(const AtomicString&, const TreeScope*) const; 59 Element* getElementByMapName(const AtomicString&, const TreeScope*) const;
60 Element* getElementByLowercasedMapName(const AtomicString&, const TreeScope* ) const; 60 Element* getElementByLowercasedMapName(const AtomicString&, const TreeScope* ) const;
61 Element* getElementByLabelForAttribute(const AtomicString&, const TreeScope* ) const; 61 Element* getElementByLabelForAttribute(const AtomicString&, const TreeScope* ) const;
62 62
63 DECLARE_TRACE(); 63 DECLARE_TRACE();
64 64
65 #if ENABLE(ASSERT)
66 void willBeRemovingId(const AtomicString*);
esprehn 2015/12/18 00:42:26 willRemoveId() no "Be"
sof 2015/12/18 07:31:53 Renamed to willRemoveId().
67 #endif
68
65 private: 69 private:
70 DocumentOrderedMap();
esprehn 2015/12/18 00:42:26 we should declare the destructor too
sof 2015/12/18 07:31:53 Done, but see below.
71
66 template<bool keyMatches(const AtomicString&, const Element&)> 72 template<bool keyMatches(const AtomicString&, const Element&)>
67 Element* get(const AtomicString&, const TreeScope*) const; 73 Element* get(const AtomicString&, const TreeScope*) const;
68 74
69 class MapEntry : public NoBaseWillBeGarbageCollected<MapEntry> { 75 class MapEntry : public NoBaseWillBeGarbageCollected<MapEntry> {
70 public: 76 public:
71 explicit MapEntry(Element* firstElement) 77 explicit MapEntry(Element* firstElement)
72 : element(firstElement) 78 : element(firstElement)
73 , count(1) 79 , count(1)
74 { 80 {
75 } 81 }
76 82
77 DECLARE_TRACE(); 83 DECLARE_TRACE();
78 84
79 RawPtrWillBeMember<Element> element; 85 RawPtrWillBeMember<Element> element;
80 unsigned count; 86 unsigned count;
81 WillBeHeapVector<RawPtrWillBeMember<Element>> orderedList; 87 WillBeHeapVector<RawPtrWillBeMember<Element>> orderedList;
82 }; 88 };
83 89
84 using Map = WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<MapEntry>>; 90 using Map = WillBeHeapHashMap<AtomicString, OwnPtrWillBeMember<MapEntry>>;
85 91
86 mutable Map m_map; 92 mutable Map m_map;
93 #if ENABLE(ASSERT)
94 const AtomicString* m_removingId;
tkent 2015/12/18 00:30:57 Can you make this |AtomicString| and check AtomicS
esprehn 2015/12/18 00:42:26 +1
sof 2015/12/18 07:31:53 Done that; slight downside with such a design is i
95 #endif
87 }; 96 };
88 97
89 inline bool DocumentOrderedMap::contains(const AtomicString& id) const 98 inline bool DocumentOrderedMap::contains(const AtomicString& id) const
90 { 99 {
91 return m_map.contains(id); 100 return m_map.contains(id);
92 } 101 }
93 102
94 inline bool DocumentOrderedMap::containsMultiple(const AtomicString& id) const 103 inline bool DocumentOrderedMap::containsMultiple(const AtomicString& id) const
95 { 104 {
96 Map::const_iterator it = m_map.find(id); 105 Map::const_iterator it = m_map.find(id);
97 return it != m_map.end() && it->value->count > 1; 106 return it != m_map.end() && it->value->count > 1;
98 } 107 }
99 108
100 } // namespace blink 109 } // namespace blink
101 110
102 #endif // DocumentOrderedMap_h 111 #endif // DocumentOrderedMap_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698