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

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

Issue 1686483002: Oilpan: Remove most WillBe types from the code base (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "core/dom/NthIndexCache.h" 5 #include "core/dom/NthIndexCache.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/ElementTraversal.h" 8 #include "core/dom/ElementTraversal.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 unsigned index = uncachedNthLastOfTypeIndex(element, siblingCount); 149 unsigned index = uncachedNthLastOfTypeIndex(element, siblingCount);
150 if (nthIndexCache && siblingCount > kCachedSiblingCountLimit) 150 if (nthIndexCache && siblingCount > kCachedSiblingCountLimit)
151 nthIndexCache->cacheNthOfTypeIndexDataForParent(element); 151 nthIndexCache->cacheNthOfTypeIndexDataForParent(element);
152 return index; 152 return index;
153 } 153 }
154 154
155 void NthIndexCache::cacheNthIndexDataForParent(Element& element) 155 void NthIndexCache::cacheNthIndexDataForParent(Element& element)
156 { 156 {
157 ASSERT(element.parentNode()); 157 ASSERT(element.parentNode());
158 if (!m_parentMap) 158 if (!m_parentMap)
159 m_parentMap = adoptPtrWillBeNoop(new ParentMap()); 159 m_parentMap = new ParentMap();
160 160
161 ParentMap::AddResult addResult = m_parentMap->add(element.parentNode(), null ptr); 161 ParentMap::AddResult addResult = m_parentMap->add(element.parentNode(), null ptr);
162 ASSERT(addResult.isNewEntry); 162 ASSERT(addResult.isNewEntry);
163 addResult.storedValue->value = adoptPtrWillBeNoop(new NthIndexData(*element. parentNode())); 163 addResult.storedValue->value = new NthIndexData(*element.parentNode());
164 } 164 }
165 165
166 NthIndexCache::IndexByType& NthIndexCache::ensureTypeIndexMap(ContainerNode& par ent) 166 NthIndexCache::IndexByType& NthIndexCache::ensureTypeIndexMap(ContainerNode& par ent)
167 { 167 {
168 if (!m_parentMapForType) 168 if (!m_parentMapForType)
169 m_parentMapForType = adoptPtrWillBeNoop(new ParentMapForType()); 169 m_parentMapForType = new ParentMapForType();
170 170
171 ParentMapForType::AddResult addResult = m_parentMapForType->add(&parent, nul lptr); 171 ParentMapForType::AddResult addResult = m_parentMapForType->add(&parent, nul lptr);
172 if (addResult.isNewEntry) 172 if (addResult.isNewEntry)
173 addResult.storedValue->value = adoptPtrWillBeNoop(new IndexByType()); 173 addResult.storedValue->value = new IndexByType();
174 174
175 ASSERT(addResult.storedValue->value); 175 ASSERT(addResult.storedValue->value);
176 return *addResult.storedValue->value; 176 return *addResult.storedValue->value;
177 } 177 }
178 178
179 void NthIndexCache::cacheNthOfTypeIndexDataForParent(Element& element) 179 void NthIndexCache::cacheNthOfTypeIndexDataForParent(Element& element)
180 { 180 {
181 ASSERT(element.parentNode()); 181 ASSERT(element.parentNode());
182 IndexByType::AddResult addResult = ensureTypeIndexMap(*element.parentNode()) .add(element.tagName(), nullptr); 182 IndexByType::AddResult addResult = ensureTypeIndexMap(*element.parentNode()) .add(element.tagName(), nullptr);
183 ASSERT(addResult.isNewEntry); 183 ASSERT(addResult.isNewEntry);
184 addResult.storedValue->value = adoptPtrWillBeNoop(new NthIndexData(*element. parentNode(), element.tagQName())); 184 addResult.storedValue->value = new NthIndexData(*element.parentNode(), eleme nt.tagQName());
185 } 185 }
186 186
187 unsigned NthIndexData::nthIndex(Element& element) const 187 unsigned NthIndexData::nthIndex(Element& element) const
188 { 188 {
189 ASSERT(!element.isPseudoElement()); 189 ASSERT(!element.isPseudoElement());
190 190
191 unsigned index = 0; 191 unsigned index = 0;
192 for (Element* sibling = &element; sibling; sibling = ElementTraversal::previ ousSibling(*sibling), index++) { 192 for (Element* sibling = &element; sibling; sibling = ElementTraversal::previ ousSibling(*sibling), index++) {
193 auto it = m_elementIndexMap.find(sibling); 193 auto it = m_elementIndexMap.find(sibling);
194 if (it != m_elementIndexMap.end()) 194 if (it != m_elementIndexMap.end())
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 #endif 261 #endif
262 } 262 }
263 263
264 #if !ENABLE(OILPAN) 264 #if !ENABLE(OILPAN)
265 NthIndexData::~NthIndexData() 265 NthIndexData::~NthIndexData()
266 { 266 {
267 } 267 }
268 #endif 268 #endif
269 269
270 } // namespace blink 270 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/dom/NthIndexCache.h ('k') | third_party/WebKit/Source/core/dom/ParentNode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698