Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: e502e18a549c34cb199f788608b35e97b6a1565c
https://github.com/WebKit/WebKit/commit/e502e18a549c34cb199f788608b35e97b6a1565c
Author: Chris Dumez <[email protected]>
Date: 2026-04-06 (Mon, 06 Apr 2026)
Changed paths:
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-autospace/text-autospace-supplementary-ideograph-expected.html
A
LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-autospace/text-autospace-supplementary-ideograph.html
M LayoutTests/platform/glib/TestExpectations
M Source/WTF/wtf/text/StringView.h
M Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp
M Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp
M Source/WebCore/platform/graphics/WidthIterator.cpp
Log Message:
-----------
text-autospace should handle supplementary Unicode characters
https://bugs.webkit.org/show_bug.cgi?id=311517
Reviewed by Darin Adler.
Text autospacing between ideographs and alphabetic/numeric characters
failed for supplementary-plane characters (e.g. CJK Extension B,
U+20000+). Four call sites read individual char16_t code units instead
of decoding full char32_t code points, so surrogate halves were passed
to TextSpacing::characterClass(), which returned Undefined instead of
Ideograph, and no autospacing was applied.
1. TextUtil::lastBaseCharacterFromText() used StringView::characterAt()
to iterate backwards, returning lone surrogates for supplementary
characters. Rewrite using reversed codePoints() iteration to properly
decode surrogate pairs.
2-3. InlineItemsBuilder: two calls to characterAt() for the first
character of a text item (within-text-node path and span-boundary
path). Replace with characterStartingAt() which assembles surrogate
pairs into code points.
4. WidthIterator::applyTextAutospaceIfNeededAndGetCharacterClass()
used TextRun::operator[] which returns char16_t. Replace with
TextRun::text().characterStartingAt() to get the full code point.
To support reversed iteration over code points, upgrade
StringView::CodePoints::Iterator from a forward iterator to a
bidirectional iterator by adding operator--, post-increment/decrement
operators, a default constructor, and storing the begin pointer for
bounds checking.
Test:
imported/w3c/web-platform-tests/css/css-text/text-autospace/text-autospace-supplementary-ideograph.html
- This test is failing in shipping Safari but passing in Chrome and Firefox.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-autospace/text-autospace-supplementary-ideograph-expected.html:
Added.
*
LayoutTests/imported/w3c/web-platform-tests/css/css-text/text-autospace/text-autospace-supplementary-ideograph.html:
Added.
* LayoutTests/platform/glib/TestExpectations:
* Source/WTF/wtf/text/StringView.h:
(WTF::StringView::CodePoints::Iterator::operator--):
(WTF::StringView::CodePoints::Iterator::operator++(int)):
(WTF::StringView::CodePoints::Iterator::operator--(int)):
* Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::InlineItemsBuilder::computeInlineBoxBoundaryTextSpacings):
(WebCore::Layout::handleTextSpacing):
* Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp:
(WebCore::Layout::TextUtil::lastBaseCharacterFromText):
* Source/WebCore/platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::applyTextAutospaceIfNeededAndGetCharacterClass):
Canonical link: https://commits.webkit.org/310633@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications