Skip to content

Commit

Permalink
Fix getScreenCTM when parent is transformed.
Browse files Browse the repository at this point in the history
Differential Revision: https://phabricator.services.mozilla.com/D136088

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1610093
gecko-commit: 6c172ec3a6db9476919ca139cdcc821cc369d6ac
gecko-reviewers: emilio
  • Loading branch information
tnikkel authored and moz-wptsync-bot committed Mar 19, 2024
1 parent 906884f commit c726644
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions svg/types/scripted/SVGGraphicsElement.getScreenCTM.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<!DOCTYPE html>
<html>
<head>
<title>SVGGraphicsElement.getScreenCTM</title>
<metadata>
<link rel="help" href="https://svgwg.org/svg2-draft/types.html#InterfaceSVGGraphicsElement"/>
</metadata>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
</head>
<body>
<style>
body {
margin: 8px;
}
#container1 {
transform: translate(50px, 50px);
}
#container2 {
position: absolute;
top: 0;
left: 0;
transform: scale(2, 1);
}
</style>
<div id="container1">
<svg id="svg1" width="150" height="150">
<rect id="rect1" fill="lime" x="50" y="50" width="100" height="100"/>
</svg>
</div>
<div id="container2">
<svg id="svg2" width="100" height="100"/>
</div>
<script>
test(function() {
let pt = DOMPoint.fromPoint({x: 58, y: 58});
let screenCTM = document.getElementById("svg1").getScreenCTM();
assert_equals(screenCTM.a, 1);
assert_equals(screenCTM.d, 1);
assert_equals(screenCTM.e, 58);
assert_equals(screenCTM.f, 58);

let transformedPoint = pt.matrixTransform(screenCTM.inverse());

assert_equals(transformedPoint.x, 0);
assert_equals(transformedPoint.y, 0);
});

test(function() {
let screenCTM = document.getElementById("rect1").getScreenCTM();
assert_equals(screenCTM.a, 1);
assert_equals(screenCTM.d, 1);
assert_equals(screenCTM.e, 58);
assert_equals(screenCTM.f, 58);
});

test(function() {
let screenCTM = document.getElementById("svg2").getScreenCTM();
assert_equals(screenCTM.a, 2);
assert_equals(screenCTM.d, 1);
});

</script>
</body>
</html>

0 comments on commit c726644

Please sign in to comment.