Commit d8269be5 authored by Fergal Daly's avatar Fergal Daly Committed by Commit Bot

CSS: shadow part map application was off-by-one.

The previous implementation gave the document the ability to forward a
part from sub-component of a component but only the component author
should be able to do that.

Bug: 859446, 805271
Change-Id: I37dc9399646a2db677c350546cbb1cfad7ee2d39
Reviewed-on: https://chromium-review.googlesource.com/1122136Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarAnders Ruud <andruud@chromium.org>
Commit-Queue: Fergal Daly <fergal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#572148}
parent 6d8203f8
......@@ -17,11 +17,11 @@
<span id="green_part" part="partp">This text</span>
</template>
<script>installCustomElement("custom-element-middle", "custom-element-middle-template");</script>
<template id="custom-element-middle-template"><custom-element-inner id="c-e-inner"></custom-element-inner></template>
<template id="custom-element-middle-template"><custom-element-inner id="c-e-inner" partmap="partp part-forwarded1"></custom-element-inner></template>
<script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
<template id="custom-element-outer-template"><custom-element-middle id="c-e-middle" partmap="partp part-forwarded1"></custom-element-middle></template>
<template id="custom-element-outer-template"><custom-element-middle id="c-e-middle" partmap="part-forwarded1 part-forwarded2"></custom-element-middle></template>
The following text should be green:
<custom-element-outer id="c-e-outer" partmap="part-forwarded1 part-forwarded2"></custom-element-outer>
<custom-element-outer id="c-e-outer"></custom-element-outer>
<script type="text/javascript">
"use strict";
const colorGreen = "rgb(0, 128, 0)";
......
......@@ -17,9 +17,9 @@
<span id="part" part="partp">This text</span>
</template>
<script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner"></custom-element-inner></template>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner" partmap="partp part-forwarded"></custom-element-inner></template>
The following text should be green:
<custom-element-outer id="c-e-outer" partmap="partp part-forwarded"></custom-element-outer>
<custom-element-outer id="c-e-outer"></custom-element-outer>
<script type="text/javascript">
"use strict";
test(function() {
......
......@@ -17,15 +17,15 @@
<span id="part" part="partp">This text</span>
</template>
<script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner"></custom-element-inner></template>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner" partmap="partp part-forwarded"></custom-element-inner></template>
The following text should be green:
<custom-element-outer id="c-e-outer" partmap="partp part-forwarded"></custom-element-outer>
<custom-element-outer id="c-e-outer"></custom-element-outer>
<script type="text/javascript">
"use strict";
test(function() {
var part = getElementByShadowIds(document, ["c-e-outer", "c-e-inner", "part"]);
var before = window.getComputedStyle(part).color;
document.getElementById("c-e-outer").setAttribute("partmap", "new-partmap");
getElementByShadowIds(document, ["c-e-outer", "c-e-inner"]).setAttribute("partmap", "new-partmap");
var after = window.getComputedStyle(part).color;
assert_not_equals(before, after);
}, "Part in selected host changed color");
......
......@@ -17,9 +17,9 @@
<span id="part" part="partp">This text</span>
</template>
<script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner"></custom-element-inner></template>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner" partmap="partp part-forwarded"></custom-element-inner></template>
The following text should be green:
<div id="elem"><custom-element-outer id="c-e-outer" partmap="partp part-forwarded"></custom-element-outer></div>
<div id="elem"><custom-element-outer id="c-e-outer"></custom-element-outer></div>
<script type="text/javascript">
"use strict";
test(function() {
......
......@@ -19,10 +19,10 @@
<script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
<template id="custom-element-outer-template">
<style>#c-e-inner::part(partp) { color: red; }</style>
<custom-element-inner id="c-e-inner"></custom-element-inner>
<custom-element-inner id="c-e-inner" partmap="partp part-forwarded"></custom-element-inner>
</template>
The following text should be green:
<custom-element-outer id="c-e-outer" partmap="partp part-forwarded"></custom-element-outer>
<custom-element-outer id="c-e-outer"></custom-element-outer>
<script type="text/javascript">
"use strict";
const colorGreen = "rgb(0, 128, 0)";
......
......@@ -17,9 +17,9 @@
<span id="green_part" part="partp">This text</span>
</template>
<script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner"></custom-element-inner></template>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner" partmap="partp"></custom-element-inner></template>
The following text should be green:
<custom-element-outer id="c-e-outer" partmap="partp"></custom-element-outer>
<custom-element-outer id="c-e-outer"></custom-element-outer>
<script type="text/javascript">
"use strict";
const colorGreen = "rgb(0, 128, 0)";
......
......@@ -17,9 +17,9 @@
<span id="green_part" part="partp">This text</span>
</template>
<script>installCustomElement("custom-element-outer", "custom-element-outer-template");</script>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner"></custom-element-inner></template>
<template id="custom-element-outer-template"><custom-element-inner id="c-e-inner" partmap="partp part-forwarded"></custom-element-inner></template>
The following text should be green:
<custom-element-outer id="c-e-outer" partmap="partp part-forwarded"></custom-element-outer>
<custom-element-outer id="c-e-outer"></custom-element-outer>
<script type="text/javascript">
"use strict";
const colorGreen = "rgb(0, 128, 0)";
......
......@@ -280,17 +280,16 @@ void StyleResolver::MatchPseudoPartRules(const Element& element,
collector.FinishAddingAuthorRulesForTreeScope();
}
// We have reached the top-level document.
if (!(host = host->OwnerShadowHost()))
return;
// After the direct host of the element, if the host doesn't forward any
// parts using partmap= then the element is unreachable from any scope above
// and we can stop.
// If the host doesn't forward any parts using partmap= then the element is
// unreachable from any scope further above and we can stop.
const NamesMap* part_map = host->PartNamesMap();
if (!part_map)
return;
// We have reached the top-level document.
if (!(host = host->OwnerShadowHost()))
return;
current_names.PushMap(*part_map);
}
}
......
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