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

Unified Diff: third_party/WebKit/Source/core/dom/NthIndexCache.cpp

Issue 2588643004: Allow positional selectors to match elements without a parent. (Closed)
Patch Set: Allow positional selectors to match elements without a parent. Created 3 years, 11 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 | « third_party/WebKit/Source/core/css/SelectorChecker.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/dom/NthIndexCache.cpp
diff --git a/third_party/WebKit/Source/core/dom/NthIndexCache.cpp b/third_party/WebKit/Source/core/dom/NthIndexCache.cpp
index 723f0c477dfe0716f5df084de45ad6efb692c7ad..59fd8dcef79fc00fb1f2a68ac22ae3f8c61ab89e 100644
--- a/third_party/WebKit/Source/core/dom/NthIndexCache.cpp
+++ b/third_party/WebKit/Source/core/dom/NthIndexCache.cpp
@@ -79,9 +79,8 @@ unsigned uncachedNthLastOfTypeIndex(Element& element, unsigned& siblingCount) {
} // namespace
unsigned NthIndexCache::nthChildIndex(Element& element) {
- if (element.isPseudoElement())
+ if (element.isPseudoElement() || !element.parentNode())
return 1;
- DCHECK(element.parentNode());
NthIndexCache* nthIndexCache = element.document().nthIndexCache();
NthIndexData* nthIndexData = nullptr;
if (nthIndexCache && nthIndexCache->m_parentMap)
@@ -95,9 +94,8 @@ unsigned NthIndexCache::nthChildIndex(Element& element) {
}
unsigned NthIndexCache::nthLastChildIndex(Element& element) {
- if (element.isPseudoElement())
+ if (element.isPseudoElement() && !element.parentNode())
return 1;
- DCHECK(element.parentNode());
NthIndexCache* nthIndexCache = element.document().nthIndexCache();
NthIndexData* nthIndexData = nullptr;
if (nthIndexCache && nthIndexCache->m_parentMap)
@@ -120,7 +118,7 @@ NthIndexData* NthIndexCache::nthTypeIndexDataForParent(Element& element) const {
}
unsigned NthIndexCache::nthOfTypeIndex(Element& element) {
- if (element.isPseudoElement())
+ if (element.isPseudoElement() || !element.parentNode())
return 1;
NthIndexCache* nthIndexCache = element.document().nthIndexCache();
if (nthIndexCache) {
@@ -136,7 +134,7 @@ unsigned NthIndexCache::nthOfTypeIndex(Element& element) {
}
unsigned NthIndexCache::nthLastOfTypeIndex(Element& element) {
- if (element.isPseudoElement())
+ if (element.isPseudoElement() || !element.parentNode())
return 1;
NthIndexCache* nthIndexCache = element.document().nthIndexCache();
if (nthIndexCache) {
« no previous file with comments | « third_party/WebKit/Source/core/css/SelectorChecker.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698