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

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

Issue 208933006: Only :host and :ancestor should ever match the host in a ShadowRoot (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add a test for :first-child too Created 6 years, 9 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/CSSSelector.h ('k') | Source/core/css/parser/BisonCSSParser-in.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/SelectorChecker.cpp
diff --git a/Source/core/css/SelectorChecker.cpp b/Source/core/css/SelectorChecker.cpp
index c6e5f46eba9d06c503786e076d7f3c0d0e4f9f35..ecf72ea982c41883ca4523dd4988d3b942dac9ae 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -491,18 +491,20 @@ bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib
bool elementIsHostInItsShadowTree = isHostInItsShadowTree(element, context.behaviorAtBoundary, context.scope);
+ // Only :host and :ancestor should match the host: http://drafts.csswg.org/css-scoping/#host-element
+ if (elementIsHostInItsShadowTree && !selector.isHostPseudoClass())
+ return false;
+
if (selector.m_match == CSSSelector::Tag)
- return SelectorChecker::tagMatches(element, selector.tagQName()) && !elementIsHostInItsShadowTree;
+ return SelectorChecker::tagMatches(element, selector.tagQName());
if (selector.m_match == CSSSelector::Class)
- return element.hasClass() && element.classNames().contains(selector.value()) && !elementIsHostInItsShadowTree;
+ return element.hasClass() && element.classNames().contains(selector.value());
if (selector.m_match == CSSSelector::Id)
- return element.hasID() && element.idForStyleResolution() == selector.value() && !elementIsHostInItsShadowTree;
+ return element.hasID() && element.idForStyleResolution() == selector.value();
if (selector.isAttributeSelector()) {
- if (elementIsHostInItsShadowTree)
- return false;
if (!anyAttributeMatches(element, static_cast<CSSSelector::Match>(selector.m_match), selector))
return false;
}
« no previous file with comments | « Source/core/css/CSSSelector.h ('k') | Source/core/css/parser/BisonCSSParser-in.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698