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

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

Issue 1108783002: Don't cache nth-indices of pseudo elements. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Early return for pseudo elements in NthIndexCache. Created 5 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 | « Source/core/dom/NthIndexCache.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "config.h" 5 #include "config.h"
6 #include "core/dom/NthIndexCache.h" 6 #include "core/dom/NthIndexCache.h"
7 7
8 #include "core/dom/Document.h" 8 #include "core/dom/Document.h"
9 9
10 namespace blink { 10 namespace blink {
(...skipping 19 matching lines...) Expand all
30 ParentMap::AddResult addResult = m_parentMap->add(&parent, nullptr); 30 ParentMap::AddResult addResult = m_parentMap->add(&parent, nullptr);
31 if (addResult.isNewEntry) 31 if (addResult.isNewEntry)
32 addResult.storedValue->value = adoptPtrWillBeNoop(new NthIndexData()); 32 addResult.storedValue->value = adoptPtrWillBeNoop(new NthIndexData());
33 33
34 ASSERT(addResult.storedValue->value); 34 ASSERT(addResult.storedValue->value);
35 return *addResult.storedValue->value; 35 return *addResult.storedValue->value;
36 } 36 }
37 37
38 unsigned NthIndexCache::NthIndexData::cacheNthIndices(Element& element) 38 unsigned NthIndexCache::NthIndexData::cacheNthIndices(Element& element)
39 { 39 {
40 ASSERT(!element.isPseudoElement());
40 unsigned index = 0; 41 unsigned index = 0;
41 // The frequency at which we cache the nth-index for a set of siblings. 42 // The frequency at which we cache the nth-index for a set of siblings.
42 // A spread value of 3 means every third Element will have its nth-index cac hed. 43 // A spread value of 3 means every third Element will have its nth-index cac hed.
43 // Using a spread value > 1 is done to save memory. Looking up the nth-index will 44 // Using a spread value > 1 is done to save memory. Looking up the nth-index will
44 // still be done in constant time in terms of sibling count, at most 'spread ' 45 // still be done in constant time in terms of sibling count, at most 'spread '
45 // elements will be traversed. 46 // elements will be traversed.
46 const unsigned spread = 3; 47 const unsigned spread = 3;
47 unsigned count = 0; 48 unsigned count = 0;
48 for (Element* sibling = ElementTraversal::firstChild(*element.parentNode()); sibling; sibling = ElementTraversal::nextSibling(*sibling)) { 49 for (Element* sibling = ElementTraversal::firstChild(*element.parentNode()); sibling; sibling = ElementTraversal::nextSibling(*sibling)) {
49 if (!(++count % spread)) 50 if (!(++count % spread))
(...skipping 13 matching lines...) Expand all
63 #endif 64 #endif
64 } 65 }
65 66
66 #if !ENABLE(OILPAN) 67 #if !ENABLE(OILPAN)
67 NthIndexCache::NthIndexData::~NthIndexData() 68 NthIndexCache::NthIndexData::~NthIndexData()
68 { 69 {
69 } 70 }
70 #endif 71 #endif
71 72
72 } // namespace blink 73 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/dom/NthIndexCache.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698