Bug 1930125 - Make SVGGeometryElement::LocalTransform return CSS rather than device pixels. r=longsonr, a=dmeehan

Differential Revision: https://phabricator.services.mozilla.com/D228598
This commit is contained in:
Emilio Cobos Álvarez 2024-11-12 08:38:50 +00:00
parent 3db4b90b64
commit 054f25fbee
4 changed files with 21 additions and 3 deletions

View File

@ -248,14 +248,14 @@ gfx::Matrix SVGGeometryElement::LocalTransform() const {
return result;
}
nsStyleTransformMatrix::TransformReferenceBox refBox(f);
const float a2d = f->PresContext()->AppUnitsPerDevPixel();
nsDisplayTransform::FrameTransformProperties props(f, refBox, a2d);
const float a2css = AppUnitsPerCSSPixel();
nsDisplayTransform::FrameTransformProperties props(f, refBox, a2css);
if (!props.HasTransform()) {
return result;
}
auto matrix = nsStyleTransformMatrix::ReadTransforms(
props.mTranslate, props.mRotate, props.mScale,
props.mMotion.ptrOr(nullptr), props.mTransform, refBox, a2d);
props.mMotion.ptrOr(nullptr), props.mTransform, refBox, a2css);
if (!matrix.IsIdentity()) {
std::ignore = matrix.CanDraw2D(&result);
}

View File

@ -124,6 +124,7 @@ fuzzy(0-1,0-15) == textpath.svg textpath-ref.svg
== textpath-after-anchor-end.svg textpath-after-anchor-end-ref.svg
== textpath-reset-position.svg textpath-reset-position-ref.svg
== textpath-inherit-position.svg textpath-inherit-position-ref.svg
fails-if(useDrawSnapshot) == textpath-transform-zoom.html textpath-transform-zoom-ref.html # drawSnapshot doesn't deal with zoom properly.
== textLength.svg textLength-ref.svg
fuzzy(0-1,0-200) == textLength-2.svg textLength-2-ref.svg

View File

@ -0,0 +1,8 @@
<!doctype html>
<style>body { margin: 0 }</style>
<svg width="400" height="400" viewBox="0 0 400 400" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path id="guide" d="M 20 200 H 400" stroke="black" stroke-width="4" />
<text x="0" y="0">
<textPath xlink:href="#guide" font-size="40">XXXX</textPath>
</text>
</svg>

View File

@ -0,0 +1,9 @@
<!doctype html>
<html reftest-zoom="2">
<style>body { margin: 0 }</style>
<svg width="200" height="200" viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<path id="guide" d="M 0 100 H 200" stroke="black" stroke-width="2" transform="translate(10, 0)" />
<text x="0" y="0">
<textPath xlink:href="#guide" font-size="20">XXXX</textPath>
</text>
</svg>