Commit 05c04af0 authored by tasak@google.com's avatar tasak@google.com

SelectorChecker::parentElement should walk up to ShadowHost only if an element...

SelectorChecker::parentElement should walk up to ShadowHost only if an element is in a shadow tree hosted by the ShadowHost and scope is the ShadowHost.

:host can only match shadow host. :host depends on context.scope with ScopeIsShadowHost behavior.
So only if context.scope is shadow host and context.element's shadow host is context.scope, we need to check the shadow host.

BUG=370303
TEST=fast/dom/shadow/style-with-cat.html, fast/dom/shadow/style-with-hat.html

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

git-svn-id: svn://svn.chromium.org/blink/trunk@173703 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 8fb01019
......@@ -26,6 +26,8 @@ PASS borderColorOf(getNodeInTreeOfTrees("host//host2/target")) is "rgb(0, 128, 0
PASS borderColorOf(getNodeInTreeOfTrees("child")) is not "rgb(255, 0, 0)"
PASS borderColorOf(getNodeInTreeOfTrees("inner/target")) is not "rgb(255, 0, 0)"
PASS borderColorOf(getNodeInTreeOfTrees("host//target")) is "rgb(0, 128, 0)"
PASS borderColorOf(getNodeInTreeOfTrees("host/x-bar-host/x-bar-target")) is not "rgb(255, 0, 0)"
PASS borderColorOf(getNodeInTreeOfTrees("host/x-bar-host/x-zot-host/x-zot-target")) is not "rgb(255, 0, 0)"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -399,6 +399,27 @@ borderColorShouldBe('host//target', 'rgb(0, 128, 0)');
cleanUp();
sandbox.appendChild(
createDOM('div', {'id': 'host'},
createShadowRoot(
createDOM('style', {},
document.createTextNode('* /deep/ .x-bar div { border: 1px solid red; }')),
createDOM('div', {'id': 'x-foo'},
document.createTextNode('x-foo')),
createDOM('div', {},
createDOM('div', {'id': 'x-bar-host', 'class': 'x-bar'},
createShadowRoot(
createDOM('div', {'id': 'x-bar-target'},
document.createTextNode('x-bar')),
createDOM('div', {'id': 'x-zot-host', 'class': 'x-zot'},
createShadowRoot(
createDOM('div', {'id': 'x-zot-target'},
document.createTextNode('x-zot'))))))))));
borderColorShouldNotBe('host/x-bar-host/x-bar-target', 'rgb(255, 0, 0)');
borderColorShouldNotBe('host/x-bar-host/x-zot-host/x-zot-target', 'rgb(255, 0, 0)');
cleanUp();
</script>
</html>
......@@ -26,6 +26,7 @@ PASS borderColorOf(getNodeInTreeOfTrees("host/host2/target")) is "rgb(0, 0, 0)"
PASS borderColorOf(getNodeInTreeOfTrees("host/host2/target")) is "rgb(0, 128, 0)"
PASS borderColorOf(getNodeInTreeOfTrees("host/host2/target")) is "rgb(0, 0, 0)"
PASS borderColorOf(getNodeInTreeOfTrees("host//host2/target")) is "rgb(0, 128, 0)"
PASS borderColorOf(getNodeInTreeOfTrees("host/x-bar-host/x-zot-host/x-zot-target")) is not "rgb(255, 0, 0)"
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -324,6 +324,25 @@ borderColorShouldBe('host//host2/target', 'rgb(0, 128, 0)');
cleanUp();
sandbox.appendChild(
createDOM('div', {'id': 'host'},
createShadowRoot(
createDOM('style', {},
document.createTextNode('.x-bar .x-zot::shadow div { border: 1px solid red; }')),
createDOM('div', {'id': 'x-foo'},
document.createTextNode('x-foo')),
createDOM('div', {'id': 'x-bar-host', 'class': 'x-bar'},
createShadowRoot(
createDOM('div', {'id': 'x-bar-target'},
document.createTextNode('x-bar')),
createDOM('div', {'id': 'x-zot-host', 'class': 'x-zot'},
createShadowRoot(
createDOM('div', {'id': 'x-zot-target'},
document.createTextNode('x-zot')))))))));
borderColorShouldNotBe('host/x-bar-host/x-zot-host/x-zot-target', 'rgb(255, 0, 0)');
cleanUp();
</script>
</html>
......@@ -84,7 +84,7 @@ Element* SelectorChecker::parentElement(const SelectorCheckingContext& context,
return context.element->parentOrShadowHostElement();
// If context.scope is a shadow host, we should walk up from a shadow root to its shadow host.
if (context.behaviorAtBoundary & SelectorChecker::ScopeIsShadowHost)
if ((context.behaviorAtBoundary & SelectorChecker::ScopeIsShadowHost) && context.scope == context.element->shadowHost())
return context.element->parentOrShadowHostElement();
if ((context.behaviorAtBoundary & SelectorChecker::BoundaryBehaviorMask) != SelectorChecker::StaysWithinTreeScope)
......
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