Skip to content

Commit cdb001a

Browse files
longsonrmoz-wptsync-bot
authored andcommitted
Fix ellipse tests in SVGGraphicsElement.getBBox-03.html
Specifying a negative value for rx or ry would result in it taking the other value ry=rx or rx=ry so we need to use 0 to ensure we get a degenerate ellipse. Differential Revision: https://phabricator.services.mozilla.com/D294700 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=2032517 gecko-commit: fa4459c8d78755629126278d27d6e4549d9af61b gecko-commit-git: e2bba9b9b4394fbf0fb2c13d70d6880a9771ba4e gecko-reviewers: dholbert
1 parent 83f3479 commit cdb001a

1 file changed

Lines changed: 22 additions & 3 deletions

File tree

svg/types/scripted/SVGGraphicsElement.getBBox-03.html

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,19 @@
66
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/types.html#__svg__SVGGraphicsElement__getBBox">
77
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/coords.html#BoundingBoxes">
88
<svg>
9+
<!-- negative values are errors, auto will be substituted, which for width,
10+
height and r is 0 -->
911
<rect id="rect1" x="1" y="2" width="-10" height="20"/>
1012
<rect id="rect2" x="1" y="2" width="10" height="-20"/>
1113
<circle id="circle" cx="1" cy="2" r="-10"/>
14+
<!-- specifying a negative value for rx or ry is invalid so the other valid
15+
radius will be substituted only 0 will produce a degenerate ellipse -->
1216
<ellipse id="ellipse1" cx="1" cy="12" rx="-5" ry="10"/>
1317
<ellipse id="ellipse2" cx="6" cy="2" rx="5" ry="-10"/>
18+
<circle id="ellipse1-ref" cx="1" cy="12" r="10"/>
19+
<circle id="ellipse2-ref" cx="6" cy="2" r="5"/>
20+
<ellipse id="ellipse3" cx="1" cy="12" rx="0" ry="10"/>
21+
<ellipse id="ellipse4" cx="6" cy="2" rx="5" ry="0"/>
1422
<image id="image1" x="1" y="2" width="-10" height="20" href="/images/green-100x50.png"/>
1523
<image id="image2" x="1" y="2" width="10" height="-20" href="/images/green-100x50.png"/>
1624
<image id="image3" x="1" y="2" width="-10" height="20"/>
@@ -20,24 +28,35 @@
2028
</svg>
2129
<script>
2230
function assertBBox(id, x, y, width, height) {
23-
var bbox = document.getElementById(id).getBBox();
31+
let bbox = document.getElementById(id).getBBox();
2432
assert_equals(bbox.x, x, id + ': x');
2533
assert_equals(bbox.y, y, id + ': y');
2634
assert_equals(bbox.width, width, id + ': width');
2735
assert_equals(bbox.height, height, id + ': height');
2836
}
2937

38+
function assertSameBBox(id1, id2) {
39+
let bbox = document.getElementById(id2).getBBox();
40+
assertBBox(id1, bbox.x, bbox.y, bbox.width, bbox.height);
41+
}
42+
3043
function testBBox(id, x, y, width, height) {
3144
test(() => { assertBBox(id, x, y, width, height) }, id);
3245
}
3346

47+
function testSameBBox(id1, id2) {
48+
test(() => { assertSameBBox(id1, id2) }, id1);
49+
}
50+
3451
// Per resolution (issue #1018): if a shape is not rendered (negative or
3552
// zero dimension), getBBox returns (0, 0, 0, 0).
3653
testBBox('rect1', 0, 0, 0, 0);
3754
testBBox('rect2', 0, 0, 0, 0);
3855
testBBox('circle', 0, 0, 0, 0);
39-
testBBox('ellipse1', 0, 0, 0, 0);
40-
testBBox('ellipse2', 0, 0, 0, 0);
56+
testSameBBox('ellipse1', 'ellipse1-ref');
57+
testSameBBox('ellipse2', 'ellipse2-ref');
58+
testBBox('ellipse3', 0, 0, 0, 0);
59+
testBBox('ellipse4', 0, 0, 0, 0);
4160
testBBox('image3', 0, 0, 0, 0);
4261
testBBox('image4', 0, 0, 0, 0);
4362
testBBox('foreign1', 0, 0, 0, 0);

0 commit comments

Comments
 (0)