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

Unified Diff: third_party/WebKit/Source/core/css/SelectorChecker.cpp

Issue 1655993005: Only cache nth-indices when child count > 32. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed constant 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/NthIndexCache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/css/SelectorChecker.cpp
diff --git a/third_party/WebKit/Source/core/css/SelectorChecker.cpp b/third_party/WebKit/Source/core/css/SelectorChecker.cpp
index 771468302c6177825cb2a1575bbdfb6f0a2807ac..54bdea3e302aa62b729635c33aac86f49e86cf0b 100644
--- a/third_party/WebKit/Source/core/css/SelectorChecker.cpp
+++ b/third_party/WebKit/Source/core/css/SelectorChecker.cpp
@@ -180,50 +180,6 @@ static bool isLastOfType(Element& element, const QualifiedName& type)
return !ElementTraversal::nextSibling(element, HasTagName(type));
}
-static int nthChildIndex(Element& element)
-{
- if (NthIndexCache* nthIndexCache = element.document().nthIndexCache())
- return nthIndexCache->nthChildIndex(element);
-
- int index = 1;
- for (const Element* sibling = ElementTraversal::previousSibling(element); sibling; sibling = ElementTraversal::previousSibling(*sibling))
- index++;
-
- return index;
-}
-
-static int nthOfTypeIndex(Element& element, const QualifiedName& type)
-{
- if (NthIndexCache* nthIndexCache = element.document().nthIndexCache())
- return nthIndexCache->nthChildIndexOfType(element, type);
- int index = 1;
- for (const Element* sibling = ElementTraversal::previousSibling(element, HasTagName(type)); sibling; sibling = ElementTraversal::previousSibling(*sibling, HasTagName(type)))
- ++index;
- return index;
-}
-
-static int nthLastChildIndex(Element& element)
-{
- if (NthIndexCache* nthIndexCache = element.document().nthIndexCache())
- return nthIndexCache->nthLastChildIndex(element);
-
- int index = 1;
- for (const Element* sibling = ElementTraversal::nextSibling(element); sibling; sibling = ElementTraversal::nextSibling(*sibling))
- ++index;
- return index;
-}
-
-static int nthLastOfTypeIndex(Element& element, const QualifiedName& type)
-{
- if (NthIndexCache* nthIndexCache = element.document().nthIndexCache())
- return nthIndexCache->nthLastChildIndexOfType(element, type);
-
- int index = 1;
- for (const Element* sibling = ElementTraversal::nextSibling(element, HasTagName(type)); sibling; sibling = ElementTraversal::nextSibling(*sibling, HasTagName(type)))
- ++index;
- return index;
-}
-
// Recursive check of selectors and combinators
// It can return 4 different values:
// * SelectorMatches - the selector matches the element e
@@ -770,14 +726,14 @@ bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context, M
if (ContainerNode* parent = element.parentElementOrDocumentFragment()) {
if (m_mode == ResolvingStyle)
parent->setChildrenAffectedByForwardPositionalRules();
- return selector.matchNth(nthChildIndex(element));
+ return selector.matchNth(NthIndexCache::nthChildIndex(element));
}
break;
case CSSSelector::PseudoNthOfType:
if (ContainerNode* parent = element.parentElementOrDocumentFragment()) {
if (m_mode == ResolvingStyle)
parent->setChildrenAffectedByForwardPositionalRules();
- return selector.matchNth(nthOfTypeIndex(element, element.tagQName()));
+ return selector.matchNth(NthIndexCache::nthOfTypeIndex(element));
}
break;
case CSSSelector::PseudoNthLastChild:
@@ -786,7 +742,7 @@ bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context, M
parent->setChildrenAffectedByBackwardPositionalRules();
if (!parent->isFinishedParsingChildren())
return false;
- return selector.matchNth(nthLastChildIndex(element));
+ return selector.matchNth(NthIndexCache::nthLastChildIndex(element));
}
break;
case CSSSelector::PseudoNthLastOfType:
@@ -795,7 +751,7 @@ bool SelectorChecker::checkPseudoClass(const SelectorCheckingContext& context, M
parent->setChildrenAffectedByBackwardPositionalRules();
if (!parent->isFinishedParsingChildren())
return false;
- return selector.matchNth(nthLastOfTypeIndex(element, element.tagQName()));
+ return selector.matchNth(NthIndexCache::nthLastOfTypeIndex(element));
}
break;
case CSSSelector::PseudoTarget:
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/dom/NthIndexCache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698