Skip to content

merge_pr_55856

Choose a tag to compare

@github-actions github-actions released this 05 Nov 06:58

[SVG] Fix precision loss in non-scaling-stroke with large coordinate
translations

When SVG paths use vector-effect="non-scaling-stroke" with large
viewBox coordinate translations (e.g. viewBox="2137678 0 96 50"),
vertical lines would disappear due to floating-point precision loss
in the transform calculations.

The issue occurred because ComputeNonScalingStrokeTransform() was
zeroing out translation components (SetE(0), SetF(0)) under the
assumption that "stroke width is independent of translation."
While this is true for stroke width calculation, removing
translation can lead to large coordinate values, increasing the
risk of precision loss as seen in the bug.

In this CL, we preserve translation components in the
non-scaling-stroke transform. This mitigates the precision loss
caused by large offset but we only preserve this translation for
non-scaling-stroke-path and not in general.

Bug: 40718465
Change-Id: Id92acf5c5798eab264df33d8a4af4759376483f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7106499
Reviewed-by: Fredrik Söderquist fs@opera.com
Reviewed-by: Vinay Singh vinaysingh@microsoft.com
Commit-Queue: Divyansh Mangal dmangal@microsoft.com
Cr-Commit-Position: refs/heads/main@{#1540470}