Title: [287515] trunk/Source/WebCore
Revision
287515
Author
za...@apple.com
Date
2022-01-02 07:07:58 -0800 (Sun, 02 Jan 2022)

Log Message

InlineTextItems should never split inside surrogate pairs
https://bugs.webkit.org/show_bug.cgi?id=234791

Reviewed by Antti Koivisto.

This check was added (r285016) to handle the case if the start position in TextUtil::breakWord is
inside a surrogate pair. However we should never have surrogate pairs split across InlineTextItems.
This incorrect state was caused by the bogus "let's keep the first character on the current line" logic
-which could also lead to a visually broken rendering.
(Note that fast/text/word-break-letter-spacing-utf16-surrogates.html passes without the early return)

* layout/formattingContexts/inline/text/TextUtil.cpp:
(WebCore::Layout::TextUtil::breakWord):
(WebCore::Layout::TextUtil::firstUserPerceivedCharacterLength):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287514 => 287515)


--- trunk/Source/WebCore/ChangeLog	2022-01-02 15:05:28 UTC (rev 287514)
+++ trunk/Source/WebCore/ChangeLog	2022-01-02 15:07:58 UTC (rev 287515)
@@ -1,5 +1,22 @@
 2022-01-02  Alan Bujtas  <za...@apple.com>
 
+        InlineTextItems should never split inside surrogate pairs
+        https://bugs.webkit.org/show_bug.cgi?id=234791
+
+        Reviewed by Antti Koivisto.
+
+        This check was added (r285016) to handle the case if the start position in TextUtil::breakWord is
+        inside a surrogate pair. However we should never have surrogate pairs split across InlineTextItems.
+        This incorrect state was caused by the bogus "let's keep the first character on the current line" logic
+        -which could also lead to a visually broken rendering. 
+        (Note that fast/text/word-break-letter-spacing-utf16-surrogates.html passes without the early return)
+
+        * layout/formattingContexts/inline/text/TextUtil.cpp:
+        (WebCore::Layout::TextUtil::breakWord):
+        (WebCore::Layout::TextUtil::firstUserPerceivedCharacterLength):
+
+2022-01-02  Alan Bujtas  <za...@apple.com>
+
         [LFC][IFC] Nested inline box continuation fails to omit margin/border/padding start/end values
         https://bugs.webkit.org/show_bug.cgi?id=234789
 

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp (287514 => 287515)


--- trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp	2022-01-02 15:05:28 UTC (rev 287514)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/text/TextUtil.cpp	2022-01-02 15:07:58 UTC (rev 287515)
@@ -178,8 +178,7 @@
             // When the substring does not fit, the right side is supposed to be the start of the surrogate pair if applicable, unless startPosition falls between surrogate pair.
             right = middle;
             U16_SET_CP_START(text, 0, right);
-            if (right < startPosition)
-                return { };
+            ASSERT(right >= startPosition);
         } else {
             right = middle + 1;
             leftSideWidth = width;
@@ -285,9 +284,10 @@
         return 1;
     if (inlineTextBox.canUseSimpleFontCodePath()) {
         UChar32 character;
-        size_t endOfCodePoint = 0;
+        size_t endOfCodePoint = inlineTextItem.start();
         U16_NEXT(textContent.characters16(), endOfCodePoint, textContent.length(), character);
-        return endOfCodePoint;
+        ASSERT(endOfCodePoint > inlineTextItem.start());
+        return endOfCodePoint - inlineTextItem.start();
     }
     auto graphemeClustersIterator = NonSharedCharacterBreakIterator { textContent };
     auto nextPosition = ubrk_following(graphemeClustersIterator, inlineTextItem.start());
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to