Title: [282779] trunk/Source/WebCore
Revision
282779
Author
za...@apple.com
Date
2021-09-20 13:58:04 -0700 (Mon, 20 Sep 2021)

Log Message

[LFC][IFC] Incorrect surrogate handling when dealing with short lines
https://bugs.webkit.org/show_bug.cgi?id=230487

Reviewed by Antti Koivisto.

Do not use 1 as the content length when dealing with text where even the first glyph does not fit the line.
(This functionality is mostly disabled by the missing font fallback feature. see webkit.org/b/228685 and imported/w3c/web-platform-tests/css/css-text/word-break/word-break-break-all-014.html)

* layout/formattingContexts/inline/InlineContentBreaker.cpp:
(WebCore::Layout::InlineContentBreaker::processOverflowingContent const): this matches InlineIterator::incrementByCodePointInTextNode

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (282778 => 282779)


--- trunk/Source/WebCore/ChangeLog	2021-09-20 20:56:19 UTC (rev 282778)
+++ trunk/Source/WebCore/ChangeLog	2021-09-20 20:58:04 UTC (rev 282779)
@@ -1,3 +1,16 @@
+2021-09-20  Alan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] Incorrect surrogate handling when dealing with short lines
+        https://bugs.webkit.org/show_bug.cgi?id=230487
+
+        Reviewed by Antti Koivisto.
+
+        Do not use 1 as the content length when dealing with text where even the first glyph does not fit the line.
+        (This functionality is mostly disabled by the missing font fallback feature. see webkit.org/b/228685 and imported/w3c/web-platform-tests/css/css-text/word-break/word-break-break-all-014.html)
+
+        * layout/formattingContexts/inline/InlineContentBreaker.cpp:
+        (WebCore::Layout::InlineContentBreaker::processOverflowingContent const): this matches InlineIterator::incrementByCodePointInTextNode
+
 2021-09-20  Youenn Fablet  <you...@apple.com>
 
         Make sure RTCRtpSender.setParameters returns an exception with a valid type

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp (282778 => 282779)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp	2021-09-20 20:56:19 UTC (rev 282778)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineContentBreaker.cpp	2021-09-20 20:58:04 UTC (rev 282779)
@@ -217,13 +217,24 @@
                 // 2. Keep the first glyph on the empty line (or keep the whole run if it has only one glyph/completely empty).
                 if (lineStatus.hasContent)
                     return Result { Result::Action::Wrap, IsEndOfLine::Yes };
+
                 auto leadingTextRunIndex = *firstTextRunIndex(continuousContent);
                 auto& inlineTextItem = downcast<InlineTextItem>(continuousContent.runs()[leadingTextRunIndex].inlineItem);
-                if (inlineTextItem.length() <= 1)
+                auto firstCodePointLength = [&]() -> size_t {
+                    auto textContent = inlineTextItem.inlineTextBox().content();
+                    if (textContent.is8Bit())
+                        return 1;
+                    UChar32 character;
+                    size_t endOfCodePoint = 0;
+                    U16_NEXT(textContent.characters16(), endOfCodePoint, textContent.length(), character);
+                    return endOfCodePoint;
+                }();
+
+                if (inlineTextItem.length() <= firstCodePointLength)
                     return Result { Result::Action::Keep, IsEndOfLine::Yes };
-                auto firstCharacterWidth = TextUtil::width(inlineTextItem, inlineTextItem.start(), inlineTextItem.start() + 1, lineStatus.contentLogicalRight);
-                auto firstCharacterRun = PartialRun { 1, firstCharacterWidth };
-                return Result { Result::Action::Break, IsEndOfLine::Yes, Result::PartialTrailingContent { leadingTextRunIndex, firstCharacterRun } };
+
+                auto firstCodePointWidth = TextUtil::width(inlineTextItem, inlineTextItem.start(), inlineTextItem.start() + firstCodePointLength, lineStatus.contentLogicalRight);
+                return Result { Result::Action::Break, IsEndOfLine::Yes, Result::PartialTrailingContent { leadingTextRunIndex, PartialRun { firstCodePointLength, firstCodePointWidth } } };
             }
             if (trailingContent->overflows && lineStatus.hasContent) {
                 // We managed to break a run with overflow but the line already has content. Let's wrap it to the next line.
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to