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

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, 10 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 {
11 11
12 NthIndexCache::NthIndexCache(Document& document) 12 NthIndexCache::NthIndexCache(Document& document)
13 : m_document(&document) 13 : m_document(&document)
14 #if ENABLE(ASSERT) 14 #if ENABLE(ASSERT)
15 , m_domTreeVersion(document.domTreeVersion()) 15 , m_domTreeVersion(document.domTreeVersion())
16 #endif 16 #endif
17 { 17 {
18 document.setNthIndexCache(this); 18 document.setNthIndexCache(this);
19 } 19 }
20 20
21 NthIndexCache::~NthIndexCache() 21 NthIndexCache::~NthIndexCache()
22 { 22 {
23 ASSERT(m_domTreeVersion == m_document->domTreeVersion()); 23 ASSERT(m_domTreeVersion == m_document->domTreeVersion());
24 m_document->setNthIndexCache(nullptr); 24 m_document->setNthIndexCache(nullptr);
25 } 25 }
26 26
27 NthIndexData& NthIndexCache::ensureNthIndexDataFor(Node& parent) 27 NthIndexData& NthIndexCache::ensureNthIndexDataFor(Node& parent)
28 { 28 {
29 if (!m_parentMap) 29 if (!m_parentMap)
30 m_parentMap = adoptPtrWillBeNoop(new ParentMap()); 30 m_parentMap = (new ParentMap());
31 31
32 ParentMap::AddResult addResult = m_parentMap->add(&parent, nullptr); 32 ParentMap::AddResult addResult = m_parentMap->add(&parent, nullptr);
33 if (addResult.isNewEntry) 33 if (addResult.isNewEntry)
34 addResult.storedValue->value = adoptPtrWillBeNoop(new NthIndexData()); 34 addResult.storedValue->value = (new NthIndexData());
35 35
36 ASSERT(addResult.storedValue->value); 36 ASSERT(addResult.storedValue->value);
37 return *addResult.storedValue->value; 37 return *addResult.storedValue->value;
38 } 38 }
39 39
40 NthIndexCache::IndexByType& NthIndexCache::ensureTypeIndexMap(Node& parent) 40 NthIndexCache::IndexByType& NthIndexCache::ensureTypeIndexMap(Node& parent)
41 { 41 {
42 if (!m_parentMapForType) 42 if (!m_parentMapForType)
43 m_parentMapForType = adoptPtrWillBeNoop(new ParentMapForType()); 43 m_parentMapForType = (new ParentMapForType());
44 44
45 ParentMapForType::AddResult addResult = m_parentMapForType->add(&parent, nul lptr); 45 ParentMapForType::AddResult addResult = m_parentMapForType->add(&parent, nul lptr);
46 if (addResult.isNewEntry) 46 if (addResult.isNewEntry)
47 addResult.storedValue->value = adoptPtrWillBeNoop(new IndexByType()); 47 addResult.storedValue->value = (new IndexByType());
48 48
49 ASSERT(addResult.storedValue->value); 49 ASSERT(addResult.storedValue->value);
50 return *addResult.storedValue->value; 50 return *addResult.storedValue->value;
51 } 51 }
52 52
53 NthIndexData& NthIndexCache::nthIndexDataWithTagName(Element& element) 53 NthIndexData& NthIndexCache::nthIndexDataWithTagName(Element& element)
54 { 54 {
55 IndexByType::AddResult addResult = ensureTypeIndexMap(*element.parentNode()) .add(element.tagName(), nullptr); 55 IndexByType::AddResult addResult = ensureTypeIndexMap(*element.parentNode()) .add(element.tagName(), nullptr);
56 if (addResult.isNewEntry) 56 if (addResult.isNewEntry)
57 addResult.storedValue->value = adoptPtrWillBeNoop(new NthIndexData()); 57 addResult.storedValue->value = (new NthIndexData());
58 return *addResult.storedValue->value; 58 return *addResult.storedValue->value;
59 } 59 }
60 60
61 unsigned NthIndexData::nthIndex(Element& element) 61 unsigned NthIndexData::nthIndex(Element& element)
62 { 62 {
63 if (element.isPseudoElement()) 63 if (element.isPseudoElement())
64 return 1; 64 return 1;
65 if (!m_count) 65 if (!m_count)
66 return cacheNthIndices(element); 66 return cacheNthIndices(element);
67 67
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 #endif 158 #endif
159 } 159 }
160 160
161 #if !ENABLE(OILPAN) 161 #if !ENABLE(OILPAN)
162 NthIndexData::~NthIndexData() 162 NthIndexData::~NthIndexData()
163 { 163 {
164 } 164 }
165 #endif 165 #endif
166 166
167 } // namespace blink 167 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698