Skip to content

Commit 06b3899

Browse files
Divyansh Mangalchromium-wpt-export-bot
authored andcommitted
[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}
1 parent 2835fc2 commit 06b3899

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<title>non-scaling-stroke doesn't lose precision with large viewBox coordinates</title>
3+
<link rel="author" title="Divyansh Mangal" href="mailto:dmangal@microsoft.com">
4+
<link rel="mismatch" href="about:blank">
5+
<link rel="help" href="https://issues.chromium.org/issues/40718465">
6+
<link rel="help" href="https://svgwg.org/svg2-draft/painting.html#PaintingVectorEffects">
7+
<svg width="618" height="344" viewBox="2172660 0 90 0.375" preserveAspectRatio="none">
8+
<path stroke="black" fill="none" vector-effect="non-scaling-stroke"
9+
d="M 2172732 0.1
10+
v 0.15
11+
"></path>
12+
</svg>

0 commit comments

Comments
 (0)