RESOLVED FIXED311553
SVG getStartPositionOfChar/getEndPositionOfChar should not include dominant-baseline shift in returned position
https://bugs.webkit.org/show_bug.cgi?id=311553
Summary SVG getStartPositionOfChar/getEndPositionOfChar should not include dominant-b...
Karl Dubost
Reported 2026-04-06 01:13:18 PDT
getStartPositionOfChar() and getEndPositionOfChar() return positions that include the dominant-baseline shift baked into the SVG text fragment y-coordinate. Chrome and Firefox return positions without the baseline shift, reflecting the y attribute value rather than the visual rendering position. The issue is in SVGTextLayoutEngine.cpp where the baseline shift from dominant-baseline is applied to the fragment y-position (line 603: y -= baselineShift) and stored in the fragment (line 635: fragment.y = y). The SVGTextQuery API reads directly from fragment.y, so it returns the shifted position. The fix is to store the baseline shift separately in SVGTextFragment and apply it only during painting, not in the stored position. This makes the query APIs return the correct unshifted position matching Chrome/Firefox behavior. Related: Bug 297455 (dominant-baseline inheritance fix exposes this issue more broadly)
Attachments
Radar WebKit Bug Importer
Comment 1 2026-04-06 01:13:34 PDT
Karl Dubost
Comment 2 2026-04-06 02:11:27 PDT
EWS
Comment 3 2026-04-17 07:01:45 PDT
Committed 311450@main (48ca57667b1e): <https://commits.webkit.org/311450@main> Reviewed commits have been landed. Closing PR #62106 and removing active labels.
Karl Dubost
Comment 4 2026-04-17 08:08:18 PDT
Submitted web-platform-tests pull request: https://github.com/web-platform-tests/wpt/pull/59318
Note You need to log in before you can comment on or make changes to this bug.