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

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

Issue 1850413002: Improve DEFINE_STATIC_LOCAL()'s handling of Blink GCed objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: address compilation failure Created 4 years, 8 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 Apple Inc. All rights reserv ed.
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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 157
158 Element* DocumentOrderedMap::getElementById(const AtomicString& key, const TreeS cope* scope) const 158 Element* DocumentOrderedMap::getElementById(const AtomicString& key, const TreeS cope* scope) const
159 { 159 {
160 return get<keyMatchesId>(key, scope); 160 return get<keyMatchesId>(key, scope);
161 } 161 }
162 162
163 const HeapVector<Member<Element>>& DocumentOrderedMap::getAllElementsById(const AtomicString& key, const TreeScope* scope) const 163 const HeapVector<Member<Element>>& DocumentOrderedMap::getAllElementsById(const AtomicString& key, const TreeScope* scope) const
164 { 164 {
165 ASSERT(key); 165 ASSERT(key);
166 ASSERT(scope); 166 ASSERT(scope);
167 DEFINE_STATIC_LOCAL(Persistent<HeapVector<Member<Element>>>, emptyVector, (n ew HeapVector<Member<Element>>())); 167 DEFINE_STATIC_LOCAL(HeapVector<Member<Element>>, emptyVector, (new HeapVecto r<Member<Element>>));
168 168
169 Map::iterator it = m_map.find(key); 169 Map::iterator it = m_map.find(key);
170 if (it == m_map.end()) 170 if (it == m_map.end())
171 return *emptyVector; 171 return emptyVector;
172 172
173 Member<MapEntry>& entry = it->value; 173 Member<MapEntry>& entry = it->value;
174 ASSERT(entry->count); 174 ASSERT(entry->count);
175 175
176 if (entry->orderedList.isEmpty()) { 176 if (entry->orderedList.isEmpty()) {
177 entry->orderedList.reserveCapacity(entry->count); 177 entry->orderedList.reserveCapacity(entry->count);
178 for (Element* element = entry->element ? entry->element.get() : ElementT raversal::firstWithin(scope->rootNode()); entry->orderedList.size() < entry->cou nt; element = ElementTraversal::next(*element)) { 178 for (Element* element = entry->element ? entry->element.get() : ElementT raversal::firstWithin(scope->rootNode()); entry->orderedList.size() < entry->cou nt; element = ElementTraversal::next(*element)) {
179 ASSERT(element); 179 ASSERT(element);
180 if (!keyMatchesId(key, *element)) 180 if (!keyMatchesId(key, *element))
181 continue; 181 continue;
(...skipping 30 matching lines...) Expand all
212 212
213 DEFINE_TRACE(DocumentOrderedMap::MapEntry) 213 DEFINE_TRACE(DocumentOrderedMap::MapEntry)
214 { 214 {
215 visitor->trace(element); 215 visitor->trace(element);
216 #if ENABLE(OILPAN) 216 #if ENABLE(OILPAN)
217 visitor->trace(orderedList); 217 visitor->trace(orderedList);
218 #endif 218 #endif
219 } 219 }
220 220
221 } // namespace blink 221 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/Document.cpp ('k') | third_party/WebKit/Source/core/dom/Element.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698