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

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

Issue 203303002: SelectorChecker should update scope and behaviorAtBoundary for /content/ in SharingRules mode (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fixed regression caused by reverting /content/ 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 | « LayoutTests/fast/dom/shadow/style-sharing-with-content-and-host-expected.html ('k') | no next file » | 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 36d9f5f8c2ddee0301070505f5bd4d84b48fe9e4..48febf898bf217051ffcd11ad298892fcd5af2e7 100644
--- a/Source/core/css/SelectorChecker.cpp
+++ b/Source/core/css/SelectorChecker.cpp
@@ -356,7 +356,10 @@ SelectorChecker::Match SelectorChecker::matchForShadowDistributed(const Element*
// If a given scope is a shadow host of an insertion point but behaviorAtBoundary doesn't have ScopeIsShadowHost,
// we need to update behaviorAtBoundary to make selectors like ":host > ::content" work correctly.
- if (scope == insertionPoints[i]->containingShadowRoot()->shadowHost() && !(behaviorAtBoundary & ScopeIsShadowHost))
+ if (m_mode == SharingRules) {
+ nextContext.behaviorAtBoundary = static_cast<BehaviorAtBoundary>(behaviorAtBoundary | ScopeIsShadowHost);
+ nextContext.scope = insertionPoints[i]->containingShadowRoot()->shadowHost();
+ } else if (scope == insertionPoints[i]->containingShadowRoot()->shadowHost() && !(behaviorAtBoundary & ScopeIsShadowHost))
nextContext.behaviorAtBoundary = static_cast<BehaviorAtBoundary>(behaviorAtBoundary | ScopeIsShadowHost);
else
nextContext.behaviorAtBoundary = behaviorAtBoundary;
@@ -366,7 +369,7 @@ SelectorChecker::Match SelectorChecker::matchForShadowDistributed(const Element*
if (match(nextContext, siblingTraversalStrategy, result) == SelectorMatches)
return SelectorMatches;
}
- return SelectorFailsCompletely;
+ return SelectorFailsLocally;
}
static inline bool containsHTMLSpace(const AtomicString& string)
@@ -521,6 +524,10 @@ bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib
// We select between :visited and :link when applying. We don't know which one applied (or not) yet.
if (subContext.selector->pseudoType() == CSSSelector::PseudoVisited || (subContext.selector->pseudoType() == CSSSelector::PseudoLink && subContext.visitedMatchType == VisitedMatchEnabled))
return true;
+ // context.scope is not available if m_mode == SharingRules.
+ // We cannot determine whether :host or :scope matches a given element or not.
+ if (m_mode == SharingRules && (subContext.selector->isHostPseudoClass() || subContext.selector->pseudoType() == CSSSelector::PseudoScope))
+ return true;
if (!checkOne(subContext, DOMSiblingTraversalStrategy()))
return true;
}
@@ -860,6 +867,8 @@ bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib
case CSSSelector::PseudoScope:
{
+ if (m_mode == SharingRules)
+ return true;
const Node* contextualReferenceNode = !context.scope ? element.document().documentElement() : context.scope;
if (element == contextualReferenceNode)
return true;
@@ -874,6 +883,8 @@ bool SelectorChecker::checkOne(const SelectorCheckingContext& context, const Sib
case CSSSelector::PseudoHost:
case CSSSelector::PseudoAncestor:
{
+ if (m_mode == SharingRules)
+ return true;
// :host only matches a shadow host when :host is in a shadow tree of the shadow host.
if (!context.scope)
return false;
« no previous file with comments | « LayoutTests/fast/dom/shadow/style-sharing-with-content-and-host-expected.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698