-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix getScreenCTM when parent is transformed.
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
1 parent
906884f
commit c726644
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |