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

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

Issue 383833002: All selectors in :-webkit-any must have an invalidation set feature. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Avoid eventSender Created 6 years, 4 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/css/invalidation/webkit-any-universal.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/RuleFeature.cpp
diff --git a/Source/core/css/RuleFeature.cpp b/Source/core/css/RuleFeature.cpp
index 4d684e9be2156d84322f107762da3d161389ca9b..0a91ffe656f8e63d530c024d6851e5b166ae762c 100644
--- a/Source/core/css/RuleFeature.cpp
+++ b/Source/core/css/RuleFeature.cpp
@@ -128,16 +128,44 @@ RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelect
if (component->match() == CSSSelector::Class || component->match() == CSSSelector::Id
|| (component->match() == CSSSelector::Tag && component->tagQName().localName() != starAtom)
|| component->isAttributeSelector() || component->isCustomPseudoElement()) {
- if (!foundCombinator)
+ if (!foundCombinator) {
+ // We have found an invalidation set feature in the rightmost compound selector.
foundIdent = true;
+ }
} else if (component->pseudoType() == CSSSelector::PseudoHost || component->pseudoType() == CSSSelector::PseudoAny) {
if (const CSSSelectorList* selectorList = component->selectorList()) {
+ bool foundUniversal = false;
for (const CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(*selector)) {
- InvalidationSetMode hostMode = invalidationSetModeForSelector(*selector);
- if (hostMode == UseSubtreeStyleChange)
+ // Find the invalidation set mode for each of the selectors in the selector list
+ // of a :not(), :host(), etc. For instance, ".x :-webkit-any(.a, .b)" yields an
+ // AddFeatures mode for both ".a" and ".b". ":-webkit-any(.a, *)" yields AddFeatures
+ // for ".a", but UseSubtreeStyleChange for "*". One sub-selector without invalidation
+ // set features is sufficient to cause the selector to be a universal selector as far
+ // the invalidation set is concerned.
+ InvalidationSetMode subSelectorMode = invalidationSetModeForSelector(*selector);
+
+ // The sub-selector contained something unskippable, fall back to whole subtree
+ // recalcs in collectFeaturesFromSelector. subSelectorMode will return
+ // UseSubtreeStyleChange since there are no combinators inside the selector list,
+ // so translate it to UseLocalStyleChange if a combinator has been seen in the
+ // outer context.
+ //
+ // FIXME: Is UseSubtreeStyleChange ever needed as input to collectFeaturesFromSelector?
+ // That is, are there any selectors for which we need to use SubtreeStyleChange for
+ // changing features when present in the rightmost compound selector?
+ if (subSelectorMode == UseSubtreeStyleChange)
return foundCombinator ? UseLocalStyleChange : UseSubtreeStyleChange;
- if (!foundCombinator && hostMode == AddFeatures)
- foundIdent = true;
+
+ // We found no features in the sub-selector, only skippable ones (foundIdent was
+ // false at the end of this method). That is a universal selector as far as the
+ // invalidation set is concerned.
+ if (subSelectorMode == UseLocalStyleChange)
+ foundUniversal = true;
+ }
+ if (!foundUniversal && !foundCombinator) {
+ // All sub-selectors contained invalidation set features and
+ // we are in the rightmost compound selector.
+ foundIdent = true;
}
}
} else if (!isSkippableComponentForInvalidation(*component)) {
« no previous file with comments | « LayoutTests/fast/css/invalidation/webkit-any-universal.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698