Skip to content

Commit 09aeb32

Browse files
longsonrmoz-wptsync-bot
authored andcommitted
don't scale bbox values by zoom
Differential Revision: https://phabricator.services.mozilla.com/D300620 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=2039355 gecko-commit: a2f72c8cd6c434fcdf157c057b6825da7e0ecec3 gecko-commit-git: c22d9cc75deed6ce8367c1951d9a7f7126c712c9 gecko-reviewers: dholbert, firefox-svg-reviewers
1 parent 48d4e2d commit 09aeb32

1 file changed

Lines changed: 66 additions & 0 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<!DOCTYPE html>
2+
<title>SVGGraphicsElement.prototype.getBBox with CSS zoom</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/geometry.html#Sizing">
6+
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/types.html#__svg__SVGGraphicsElement__getBBox">
7+
<link rel="help" href="https://w3c.github.io/svgwg/svg2-draft/coords.html#BoundingBoxes">
8+
<svg viewBox="0 0 500 500" width="500px" height="500px" style="zoom: 3">
9+
10+
<!-- text -->
11+
<text id="text1" font-size="20px" text-rendering="geometricPrecision" font-family="monospace" x="0" y="50">99</text>
12+
13+
<!-- image -->
14+
<image id="image1" x="150" y="150" width="200" height="200" preserveApectRatio="none"
15+
xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAAAKXRFWHRDcmVhdGlvbiBUaW1lAJCFIDMwIDQgMjAxNCAwOToyODo0MyArMDkwMH73aTcAAAAHdElNRQfeBB4AHhEfV06+AAAACXBIWXMAAB7BAAAewQHDaVRTAAAABGdBTUEAALGPC/xhBQAAABlJREFUeNpjZPj/n4EUwESS6lENoxqGlAYASU8CHux7qQ4AAAAASUVORK5CYII="/>
16+
17+
<!-- path -->
18+
<path id="path1" d="M10,50 L25,100 H110 V50 Q60,0 10,50" stroke="black" stroke-width="8" stroke-miterlimit="1" stroke-linejoin="miter" fill="lightcyan" marker-mid="url(#m_atr)"/>
19+
20+
<!-- foreignObject -->
21+
<foreignObject id="fo1" x="2" y="2" width="200" height="200">
22+
<div xmlns="http://www.w3.org/1999/xhtml" style="background-color:pink;width:100%;height:100%;">
23+
There are issues of dynamic loading required for tiling. According to 'postpone' attribute of Resource Priorities, the dynamic loading is controlled by positional relation with bounding box of embedded contents and container's viewport. However, each bounding boxes of embedded contents should be whole earth basically when this method is used. (green part on Example) Tiling is impossible unless this situation is changed.
24+
</div>
25+
</foreignObject>
26+
27+
</svg>
28+
<svg style="position: absolute; visibility: hidden;"
29+
viewBox="0 0 500 500" width="500px" height="500px">
30+
<text id="text1-ref" font-size="20px" text-rendering="geometricPrecision" font-family="monospace" x="0" y="50">99</text>
31+
</svg>
32+
33+
<script>
34+
function assert_bbox(id, x, y, width, height) {
35+
let bbox = document.getElementById(id).getBBox();
36+
assert_approx_equals(bbox.x, x, 0.1, id + ".getBBox().x");
37+
assert_approx_equals(bbox.y, y, 0.1, id + ".getBBox().y");
38+
assert_approx_equals(bbox.width, width, 0.1, id + ".getBBox().width");
39+
assert_approx_equals(bbox.height, height, 0.1, id + ".getBBox().height");
40+
}
41+
42+
function compare_bbox_size(id1, id2) {
43+
let bbox1 = document.getElementById(id1).getBBox();
44+
let bbox2 = document.getElementById(id2).getBBox();
45+
assert_approx_equals(bbox1.x, bbox2.x, 0.1, id1 + ".getBBox().x");
46+
assert_approx_equals(bbox1.y, bbox2.y, 0.1, id1 + ".getBBox().y");
47+
assert_approx_equals(bbox1.width, bbox2.width, 0.1, id1 + ".getBBox().width");
48+
assert_approx_equals(bbox1.height, bbox2.height, 0.1, id1 + ".getBBox().height");
49+
}
50+
51+
test(t => {
52+
compare_bbox_size("text1", "text1-ref");
53+
}, "text with zoom");
54+
55+
test(t => {
56+
assert_bbox("image1", 150, 150, 200, 200);
57+
}, "image with zoom");
58+
59+
test(t => {
60+
assert_bbox("path1", 10, 25, 100, 75);
61+
}, "path with zoom");
62+
63+
test(t => {
64+
assert_bbox("fo1", 2, 2, 200, 200);
65+
}, "foreignObject with zoom");
66+
</script>

0 commit comments

Comments
 (0)