Skip to content

Commit fd3fcf8

Browse files
lilleschromium-wpt-export-bot
authored andcommitted
Make SVGSymbolElement an SVGGraphicsElement
Inheritance per SVG2 spec: https://svgwg.org/svg2-draft/single-page.html#struct-InterfaceSVGSymbolElement This is also in preparation for using a <symbol> element, not <svg>, when cloning <symbol> into a <use> shadow tree. Bug: 40168102, 4055003 Change-Id: I5fcbf98e47a7bdee15f6e2e82df81c92ad4655ee Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7084498 Reviewed-by: Chris Harrelson <chrishtr@chromium.org> Commit-Queue: Rune Lillesveen <futhark@chromium.org> Cr-Commit-Position: refs/heads/main@{#1537447}
1 parent 074aa63 commit fd3fcf8

File tree

2 files changed

+62
-0
lines changed

2 files changed

+62
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<title>SVG Test: &lt;g&gt; and &lt;symbol&gt; are SVGGraphicsElements</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<svg>
6+
<g transform="translate(200, 0)">
7+
<rect width="100" height="100"></rect>
8+
</g>
9+
<symbol transform="translate(100, 0)">
10+
<rect width="100" height="100"></rect>
11+
</symbol>
12+
</svg>
13+
<script>
14+
const g = document.querySelector("g");
15+
const symbol = document.querySelector("symbol");
16+
test(() => {
17+
assert_equals(getComputedStyle(g).transform, "matrix(1, 0, 0, 1, 200, 0)");
18+
}, "<g> element has transform presentation style from being an SVGGraphicsElement");
19+
test(() => {
20+
assert_equals(getComputedStyle(symbol).transform, "matrix(1, 0, 0, 1, 100, 0)");
21+
}, "<symbol> element has transform presentation style from being an SVGGraphicsElement");
22+
</script>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<title>SVGGraphicsElement.prototype.getBBox for non-rendered elements</title>
3+
<link rel="help" href="https://svgwg.org/svg2-draft/coords.html#BoundingBoxes">
4+
<script src="/resources/testharness.js"></script>
5+
<script src="/resources/testharnessreport.js"></script>
6+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 500 500" width="500px" height="500px">
7+
<symbol id="symbol1">
8+
<rect id="symbol1_rect" x="50" y="60" width="100" height="150"></rect>
9+
</symbol>
10+
<g id="g_none" style="display:none">
11+
<rect id="g_none_rect" x="70" y="80" width="200" height="250"></rect>
12+
</g>
13+
<rect id="none_rect" x="90" y="100" width="20" height="25" display="none"></rect>
14+
</svg>
15+
<script>
16+
function assert_bbox(id, opt, x, y, width, height, epsilon) {
17+
if (epsilon == undefined) {
18+
epsilon = 0.1;
19+
}
20+
let bbox = document.getElementById(id).getBBox();
21+
assert_approx_equals(bbox.x, x, epsilon, id + ".getBBox().x " + JSON.stringify(opt));
22+
assert_approx_equals(bbox.y, y, epsilon, id + ".getBBox().y " + JSON.stringify(opt));
23+
assert_approx_equals(bbox.width, width, epsilon, id + ".getBBox().width " + JSON.stringify(opt));
24+
assert_approx_equals(bbox.height, height, epsilon, id + ".getBBox().height " + JSON.stringify(opt));
25+
}
26+
27+
test(() => {
28+
assert_bbox("symbol1", {}, 0, 0, 0, 0);
29+
assert_bbox("symbol1_rect", {}, 50, 60, 100, 150);
30+
}, "Non-rendered symbol with rect");
31+
32+
test(() => {
33+
assert_bbox("g_none", {}, 0, 0, 0, 0);
34+
assert_bbox("g_none_rect", {}, 70, 80, 200, 250);
35+
}, "display:none <g> with rect");
36+
37+
test(() => {
38+
assert_bbox("none_rect", {}, 90, 100, 20, 25);
39+
}, "display:none <rect>");
40+
</script>

0 commit comments

Comments
 (0)