Skip to content

Commit 5116221

Browse files
Fredrik Söderquistchromium-wpt-export-bot
authored andcommitted
Mark SVG element references as tree-scope dependent
SVG element references (url(#foo)) are dependent on the tree-scope for looking up the referenced element. This means a resolved style which contains an element reference can't be cached in the MPC. This was not a problem before 5c2e1f921ce1c11c2952ff98c81806bb55db1894, because SVG elements wouldn't be cacheable in the MPC at all. Set the has-tree-scoped-reference for local element references to signal that the resolved style in which they participate cannot be cached in the MPC. Funnel all calls to ElementStyleResources::GetSVGResourceFromValue through a helper in StyleResolverState::GetSVGResource to allow handling this in a single place. Fixed: 393395935 Change-Id: I758ac5aeef9c1917275dc26962fa89bcb4518b13 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6309244 Reviewed-by: Rune Lillesveen <[email protected]> Commit-Queue: Fredrik Söderquist <[email protected]> Cr-Commit-Position: refs/heads/main@{#1426194}
1 parent 46cd2c7 commit 5116221

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<title>Same clip-path id's in different tree scopes</title>
3+
<link rel="help" href="https://drafts.csswg.org/css-values/#local-urls">
4+
<link rel="help" href="https://drafts.csswg.org/css-scoping-1/#css-tree-scoped-reference">
5+
<link rel="match" href="reference/green-box.html">
6+
<style>
7+
div.container {
8+
position: absolute;
9+
width: 100px;
10+
height: 100px;
11+
}
12+
div.one {
13+
background-color: red;
14+
}
15+
</style>
16+
<p>Test passes if you see a single 100px by 100px green box below.</p>
17+
<div class="container one">
18+
<svg style="display: block; width: 100%; height: 100%">
19+
<rect width="100" height="100" fill="green" clip-path="url(#clip)"/>
20+
<clipPath id="clip">
21+
<rect width="50" height="100"/>
22+
</clipPath>
23+
</svg>
24+
</div>
25+
<div class="container two"></div>
26+
<script>
27+
const scoped = document.querySelector('div.two');
28+
scoped.attachShadow({ mode: 'open' });
29+
scoped.shadowRoot.innerHTML = `
30+
<svg style="display: block; width: 100%; height: 100%">
31+
<rect width="100" height="100" fill="green" clip-path="url(#clip)"/>
32+
<clipPath id="clip">
33+
<rect x="50" width="50" height="100"/>
34+
</clipPath>
35+
</svg>`;
36+
</script>

0 commit comments

Comments
 (0)