Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 902137b2d3663adddcc236e22e935743a9969cb8
https://github.com/WebKit/WebKit/commit/902137b2d3663adddcc236e22e935743a9969cb8
Author: Karl Dubost <[email protected]>
Date: 2026-09-19 (Sat, 19 Sep 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-char-positions-expected.txt
A
LayoutTests/imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-char-positions.html
M
LayoutTests/imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-expected.txt
M
LayoutTests/imported/w3c/web-platform-tests/svg/text/scripted/w3c-import.log
M LayoutTests/platform/glib/TestExpectations
R
LayoutTests/platform/glib/imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-expected.txt
M LayoutTests/platform/ios/TestExpectations
R LayoutTests/svg/text/lengthAdjust-text-metrics-expected.txt
R LayoutTests/svg/text/lengthAdjust-text-metrics.html
M Source/WebCore/rendering/svg/SVGTextFragment.h
M Source/WebCore/rendering/svg/SVGTextQuery.cpp
Log Message:
-----------
getComputedTextLength() and the character-position methods ignore
lengthAdjust="spacingAndGlyphs"
https://bugs.webkit.org/show_bug.cgi?id=324242
rdar://187473448
Reviewed by Nikolas Zimmermann.
getComputedTextLength(), getSubStringLength(), getStartPositionOfChar(),
getEndPositionOfChar() and getExtentOfChar() reported pre-stretch
numbers under lengthAdjust="spacingAndGlyphs". For "ABCD" in Ahem at
20px with textLength="200", WebKit answered 80 where Chrome and Firefox
answer 200, although getBBox() was already 200.
SVGTextFragment stores the glyph scale in a matrix of its own,
lengthAdjustTransform, and every query callback called
buildFragmentTransform with TransformIgnoringTextLength, which leaves
that matrix out.
Only spacingAndGlyphs fills that matrix in. spacing moves fragment.x
instead. It widens the gaps between characters, which adds no advance,
and these methods return a sum of advances. All three engines agree
there.
Fix by passing TransformRespectingTextLength in the position and extent
callbacks, and by multiplying the two length callbacks by the scale read
back out of lengthAdjustTransform.
getRotationOfChar keeps ignoring it, because scaling along the inline
axis turns no glyph.
getCharNumAtPosition changes too, since it shares
calculateGlyphBoundaries with getExtentOfChar. It already contradicted
itself: it tested the query point against a stretched fragment box, then
against unstretched glyph boxes, so a point on a visible letter could
return -1.
svg/text/lengthAdjust-text-metrics.html tested the same methods. It
moves to WPT as lengthadjust-char-positions.html.
Two reasons not to import it as it stood. It measured Arial, which glib
and ios lack, so both ports marked it Failure; the replacement uses Ahem
and runs everywhere. And it worked around this very bug, dividing the
stretch back out of getComputedTextLength() and reapplying it in
JavaScript to every length, point and rect it checked.
Test:
imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-char-positions.html
*
LayoutTests/imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-char-positions-expected.txt:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-char-positions.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-expected.txt:
*
LayoutTests/platform/glib/imported/w3c/web-platform-tests/svg/text/scripted/lengthadjust-expected.txt:
Removed.
* LayoutTests/imported/w3c/web-platform-tests/svg/text/scripted/w3c-import.log:
* LayoutTests/platform/glib/TestExpectations:
* LayoutTests/platform/ios/TestExpectations:
* LayoutTests/svg/text/lengthAdjust-text-metrics-expected.txt: Removed.
* LayoutTests/svg/text/lengthAdjust-text-metrics.html: Removed.
* Source/WebCore/rendering/svg/SVGTextFragment.h:
* Source/WebCore/rendering/svg/SVGTextQuery.cpp:
(WebCore::lengthAdjustInlineScale):
(WebCore::SVGTextQuery::textLengthCallback const):
(WebCore::SVGTextQuery::subStringLengthCallback const):
(WebCore::SVGTextQuery::startPositionOfCharacterCallback const):
(WebCore::SVGTextQuery::endPositionOfCharacterCallback const):
(WebCore::SVGTextQuery::rotationOfCharacterCallback const):
(WebCore::calculateGlyphBoundaries):
Canonical link: https://commits.webkit.org/321445@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications