Commit 566212b2 authored by rune@opera.com's avatar rune@opera.com

Support invalidation sets for shadow combinators.

We bailed out of invalidation set support for selectors containing /shadow/
or /shadow-deep/. For invalidation sets they now work like descendant/child
combinators do.

R=esprehn@chromium.org, chrishtr@chromium.org
BUG=335247

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

git-svn-id: svn://svn.chromium.org/blink/trunk@169706 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 7ec6cdc4
Check that targeted class invalidation works for /shadow/ and /shadow-deep/ combinators.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS getComputedStyle(match1, null).backgroundColor is transparent
PASS getComputedStyle(match2, null).backgroundColor is transparent
PASS internals.updateStyleAndReturnAffectedElementCount() is 2
PASS getComputedStyle(match1, null).backgroundColor is green
PASS internals.updateStyleAndReturnAffectedElementCount() is 2
PASS getComputedStyle(match2, null).backgroundColor is green
PASS successfullyParsed is true
TEST COMPLETE
<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<style>
.t1 #host1 /shadow/ .match { background-color: green; }
.t2 /shadow-deep/ .match { background-color: green; }
</style>
<div id="t1">
<div id="host1"></div>
<div></div>
</div>
<div id="t2">
<div id="host2"></div>
<div></div>
</div>
<script>
description("Check that targeted class invalidation works for /shadow/ and /shadow-deep/ combinators.");
// Create shadow trees
var host1 = document.getElementById("host1");
var match1 = host1.createShadowRoot().appendChild(document.createElement("div"));
match1.className = "match";
var host2 = document.getElementById("host2");
var innerHost = host2.createShadowRoot().appendChild(document.createElement("div"));
var match2 = innerHost.createShadowRoot().appendChild(document.createElement("div"));
match2.className = "match";
var transparent = "rgba(0, 0, 0, 0)";
var green = "rgb(0, 128, 0)";
shouldBe("getComputedStyle(match1, null).backgroundColor", "transparent");
shouldBe("getComputedStyle(match2, null).backgroundColor", "transparent");
document.body.offsetLeft; // force style recalc.
document.getElementById("t1").className = "t1";
if (window.internals)
shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2");
shouldBe("getComputedStyle(match1, null).backgroundColor", "green");
document.body.offsetLeft; // force style recalc.
document.getElementById("t2").className = "t2";
if (window.internals)
shouldBe("internals.updateStyleAndReturnAffectedElementCount()", "2");
shouldBe("getComputedStyle(match2, null).backgroundColor", "green");
</script>
...@@ -122,10 +122,11 @@ RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval ...@@ -122,10 +122,11 @@ RuleFeatureSet::InvalidationSetMode RuleFeatureSet::supportsClassDescendantInval
} else if (!isSkippableComponentForInvalidation(*component)) { } else if (!isSkippableComponentForInvalidation(*component)) {
return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeStyleChange; return foundDescendantRelation ? UseLocalStyleChange : UseSubtreeStyleChange;
} }
// FIXME: We can probably support ShadowAll and ShadowDeep.
switch (component->relation()) { switch (component->relation()) {
case CSSSelector::Descendant: case CSSSelector::Descendant:
case CSSSelector::Child: case CSSSelector::Child:
case CSSSelector::Shadow:
case CSSSelector::ShadowDeep:
foundDescendantRelation = true; foundDescendantRelation = true;
// Fall through! // Fall through!
case CSSSelector::SubSelector: case CSSSelector::SubSelector:
......
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