Bug 309035

Summary: rounding issue for svg rect height with em and percentage
Product: WebKit Reporter: Karl Dubost <karlcow>
Component: SVGAssignee: Karl Dubost <karlcow>
Status: RESOLVED FIXED    
Severity: Normal CC: sabouhallawa, webkit-bug-importer, zimmermann
Priority: P2 Keywords: InRadar, WPTImpact
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
URL: http://wpt.live/svg/geometry/svg-baseval-in-display-none.html
See Also: https://github.com/web-platform-tests/wpt/pull/60194

Karl Dubost
Reported 2026-03-02 20:56:52 PST
http://wpt.live/svg/geometry/svg-baseval-in-display-none.html https://wpt.fyi/results/svg/geometry/svg-baseval-in-display-none.html https://codepen.io/webcompat/pen/ogzjVyQ?editors=1010 <svg width="0" height="0"> <svg width="600" height="400" font-size="5"> <symbol width="40em" height="20em"> <g font-size="10px"> <rect id="r1" x="5em" y="6em" width="20%" height="30%"></rect> <circle id="c1" cx="5em" cy="6em" r="10em"></circle> </g> </symbol> <g font-size="10px" style="display:none"> <rect id="r2" x="5em" y="6em" width="20%" height="30%"></rect> <circle id="c2" cx="5em" cy="6em" r="10em"></circle> </g> </svg> </svg> Test Results: SAFARI r1.width = 120 (120) r1.height = 120.00000762939453 (120) r2.width = 120 (120) r2.height = 120.00000762939453 (120) CHROME/FIREFOX r1.width = 120 (120) r1.height = 120 (120) r2.width = 120 (120) r2.height = 120 (120)
Attachments
Radar WebKit Bug Importer
Comment 1 2026-03-02 20:57:41 PST
Karl Dubost
Comment 2 2026-03-17 00:56:38 PDT
The fact that this is failing only for height is pure luck. Width has the same issue. We should probably modify the tests that it is able to fail in the same way for width. The float parameter in convertValueFromPercentageToUserUnits(float value, ...) truncates the double result of value / 100.0 before multiplying by the viewport dimension. The fix needs to keep the computation in double precision through the multiplication, only casting to float at the end.
Karl Dubost
Comment 3 2026-03-17 00:58:15 PDT
EWS
Comment 4 2026-05-26 19:18:20 PDT
Committed 313935@main (5ed9fc92e49b): <https://commits.webkit.org/313935@main> Reviewed commits have been landed. Closing PR #60750 and removing active labels.
Karl Dubost
Comment 5 2026-05-26 19:35:55 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/60194
Note You need to log in before you can comment on or make changes to this bug.