Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 75322e6f014a74fd4d150fcb1f11028a540f8e8c
https://github.com/WebKit/WebKit/commit/75322e6f014a74fd4d150fcb1f11028a540f8e8c
Author: Ahmad Saleem <[email protected]>
Date: 2026-06-17 (Wed, 17 Jun 2026)
Changed paths:
A LayoutTests/svg/text/surrogate-pair-addressable-character-expected.txt
A LayoutTests/svg/text/surrogate-pair-addressable-character.html
M Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
M Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp
Log Message:
-----------
[SVG] Non-BMP character before a tspan boundary shifts the x/y value list by
one
https://bugs.webkit.org/show_bug.cgi?id=315942
rdar://178360036
Reviewed by Taher Ali.
This patch aligns WebKit with Gecko / Firefox and Blink / Chromium.
Inspired by:
https://flagged.apple.com:443/proxy?t2=DW9N2L8kR9&o=aHR0cHM6Ly9jaHJvbWl1bS5nb29nbGVzb3VyY2UuY29tL2Nocm9taXVtL3NyYy5naXQvKy85MzMxMjExYzIyYWVlN2I0OTkxMzFhYTFjNThjZTUxNWRlY2VlYjQ1&emid=02ee363e-cded-4fc6-8d77-395604816a10&c=11
Value list positions (x/y/dx/dy/rotate) advance once
per character, not
per UTF-16 code unit. The value list lookup in SVGTextMetricsBuilder
already mapped a glyph's code-unit position to a character ordinal, but
the map keys were built by counting code units in
SVGTextLayoutAttributesBuilder, and the position carried to the next
renderer was code-unit based too. A non-BMP character (a surrogate pair)
therefore desynced the two across a renderer boundary, so an x/y list
spanning a surrogate pair into a sibling/child tspan placed the
following glyph one slot off (e.g. <text x="0 100">𑀏<tspan>
𑀏</tspan></text> failed to put the tspan glyph at x=100).
Count code points, not code units, when building value list keys, and
carry a
character-based position across renderers.
* Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
(WebCore::processRenderSVGInlineText):
* Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp:
(WebCore::SVGTextMetricsBuilder::measureTextRendererWithIterator):
*
LayoutTests/svg/text/surrogate-pair-addressable-character-expected.txt: Added.
* LayoutTests/svg/text/surrogate-pair-addressable-character.html: Added.
Canonical link:
https://flagged.apple.com:443/proxy?t2=DZ0l2T2Gw5&o=aHR0cHM6Ly9jb21taXRzLndlYmtpdC5vcmcvMzE1NDE4QG1haW4=&emid=02ee363e-cded-4fc6-8d77-395604816a10&c=11
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications