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

Unified Diff: Source/core/css/SiblingTraversalStrategies.h

Issue 16629006: Revert 151996 "Avoid N^2 walk placing renderers when building th..." (Closed) Base URL: svn://svn.chromium.org/blink/
Patch Set: Update to head Created 7 years, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/SelectorChecker.cpp ('k') | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/SiblingTraversalStrategies.h
diff --git a/Source/core/css/SiblingTraversalStrategies.h b/Source/core/css/SiblingTraversalStrategies.h
index f4e185b2ef32dfb577c58338a8eac59959ec16a4..660a6c5edd3201bb12fbc303dbca15da6c5113de 100644
--- a/Source/core/css/SiblingTraversalStrategies.h
+++ b/Source/core/css/SiblingTraversalStrategies.h
@@ -79,11 +79,14 @@ inline bool DOMSiblingTraversalStrategy::isLastOfType(Element* element, const Qu
inline int DOMSiblingTraversalStrategy::countElementsBefore(Element* element) const
{
int count = 0;
- // We can't use the same early return as is present in countElementsAfter due
- // to the order we resolve style; if a new element is inserted into the middle,
- // we'd end up using a stale cached childIndex.
- for (const Element* sibling = element->previousElementSibling(); sibling; sibling = sibling->previousElementSibling())
- ++count;
+ for (const Element* sibling = element->previousElementSibling(); sibling; sibling = sibling->previousElementSibling()) {
+ unsigned index = sibling->childIndex();
+ if (index) {
+ count += index;
+ break;
+ }
+ count++;
+ }
return count;
}
@@ -102,16 +105,8 @@ inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element* eleme
inline int DOMSiblingTraversalStrategy::countElementsAfter(Element* element) const
{
int count = 0;
- // We can use an early return here because we resolve style from lastChild to
- // firstChild, so we're guaranteed to not have stale cached childIndices.
- for (const Element* sibling = element->nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) {
- unsigned index = sibling->childIndex();
- if (index) {
- count += index;
- break;
- }
+ for (const Element* sibling = element->nextElementSibling(); sibling; sibling = sibling->nextElementSibling())
++count;
- }
return count;
}
« no previous file with comments | « Source/core/css/SelectorChecker.cpp ('k') | Source/core/css/resolver/StyleResolver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698