Commit ad270fbe authored by chrishtr@chromium.org's avatar chrishtr@chromium.org

Only support AddFeatures invalidation set mode for :host or

:any in selector components to the right of the rightmost
descendant relation.

This fixes a bug that caused this to be the case accidentally in cases such as:

:host(.foo) #bar

when #bar is not (yet) supported for the style invalidation
tree walk.

BUG=358704

Review URL: https://codereview.chromium.org/221643002

git-svn-id: svn://svn.chromium.org/blink/trunk@170637 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 3893eed2
PASS getComputedStyle(foo).backgroundColor is "rgb(0, 128, 0)"
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<div></div>
<script>
if (window.testRunner)
testRunner.dumpAsText();
var host = document.querySelector('div');
var root = host.createShadowRoot();
root.innerHTML = '<style>:host(.enabled) #foo { background: green;}</style><div id="foo"></div>';
var foo = root.querySelector("#foo");
host.classList.add('enabled');
shouldBe('getComputedStyle(foo).backgroundColor', '"rgb(0, 128, 0)"');
</script>
\ No newline at end of file
...@@ -103,7 +103,7 @@ static bool isSkippableComponentForInvalidation(const CSSSelector& selector) ...@@ -103,7 +103,7 @@ static bool isSkippableComponentForInvalidation(const CSSSelector& selector)
} }
// This method is somewhat conservative in what it accepts. // This method is somewhat conservative in what it accepts.
RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInvalidation(const CSSSelector& selector) RuleFeatureSet::InvalidationSetMode RuleFeatureSet::invalidationSetModeForSelector(const CSSSelector& selector)
{ {
bool foundDescendantRelation = false; bool foundDescendantRelation = false;
bool foundIdent = false; bool foundIdent = false;
...@@ -116,10 +116,10 @@ RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval ...@@ -116,10 +116,10 @@ RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval
} else if (component->pseudoType() == CSSSelector::PseudoHost || component->pseudoType() == CSSSelector::PseudoAny) { } else if (component->pseudoType() == CSSSelector::PseudoHost || component->pseudoType() == CSSSelector::PseudoAny) {
if (const CSSSelectorList* selectorList = component->selectorList()) { if (const CSSSelectorList* selectorList = component->selectorList()) {
for (const CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(*selector)) { for (const CSSSelector* selector = selectorList->first(); selector; selector = CSSSelectorList::next(*selector)) {
InvalidationSetMode hostMode = supportsClassDescendantInvalidation(*selector); InvalidationSetMode hostMode = invalidationSetModeForSelector(*selector);
if (hostMode == UseSubtreeStyleChange) if (hostMode == UseSubtreeStyleChange)
return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeStyleChange; return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeStyleChange;
if (hostMode == AddFeatures) if (!foundDescendantRelation && hostMode == AddFeatures)
foundIdent = true; foundIdent = true;
} }
} }
...@@ -172,7 +172,7 @@ DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS ...@@ -172,7 +172,7 @@ DescendantInvalidationSet* RuleFeatureSet::invalidationSetForSelector(const CSSS
RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector) RuleFeatureSet::InvalidationSetMode RuleFeatureSet::updateInvalidationSets(const CSSSelector& selector)
{ {
InvalidationSetMode mode = supportsClassDescendantInvalidation(selector); InvalidationSetMode mode = invalidationSetModeForSelector(selector);
if (mode != AddFeatures) if (mode != AddFeatures)
return mode; return mode;
......
...@@ -129,7 +129,7 @@ private: ...@@ -129,7 +129,7 @@ private:
UseSubtreeStyleChange UseSubtreeStyleChange
}; };
static InvalidationSetMode supportsClassDescendantInvalidation(const CSSSelector&); static InvalidationSetMode invalidationSetModeForSelector(const CSSSelector&);
void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&, InvalidationSetMode); void collectFeaturesFromSelector(const CSSSelector&, FeatureMetadata&, InvalidationSetMode);
void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata&, InvalidationSetMode); void collectFeaturesFromSelectorList(const CSSSelectorList*, FeatureMetadata&, InvalidationSetMode);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment