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

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

Issue 1096813005: Extending the NthIndexCache to support caching for the type of index. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Patch with new design Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/core/dom/NthIndexCache.h » ('j') | Source/core/dom/NthIndexCache.h » ('J')
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 1e008dba5fda36e1c053fe4b5b43ba61e10e51af..9a2e2fdfa11c7bd0751338f3e24f496d7b76b72f 100644
--- a/Source/core/css/SiblingTraversalStrategies.h
+++ b/Source/core/css/SiblingTraversalStrategies.h
@@ -93,6 +93,8 @@ inline int DOMSiblingTraversalStrategy::countElementsBefore(Element& element) co
inline int DOMSiblingTraversalStrategy::countElementsOfTypeBefore(Element& element, const QualifiedName& type) const
{
+ if (NthIndexCache* nthIndexCache = element.document().nthIndexCache())
+ return nthIndexCache->nthChildIndexOfType(element, type) - 1;
int count = 0;
for (const Element* sibling = ElementTraversal::previousSibling(element, HasTagName(type)); sibling; sibling = ElementTraversal::previousSibling(*sibling, HasTagName(type)))
++count;
@@ -112,6 +114,9 @@ inline int DOMSiblingTraversalStrategy::countElementsAfter(Element& element) con
inline int DOMSiblingTraversalStrategy::countElementsOfTypeAfter(Element& element, const QualifiedName& type) const
{
+ if (NthIndexCache* nthIndexCache = element.document().nthIndexCache())
+ return nthIndexCache->nthLastChildIndexOfType(element, type) - 1;
+
int count = 0;
for (const Element* sibling = ElementTraversal::nextSibling(element, HasTagName(type)); sibling; sibling = ElementTraversal::nextSibling(*sibling, HasTagName(type)))
++count;
« no previous file with comments | « no previous file | Source/core/dom/NthIndexCache.h » ('j') | Source/core/dom/NthIndexCache.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698