Title: [287370] trunk/Source/WebCore
Revision
287370
Author
za...@apple.com
Date
2021-12-22 13:03:40 -0800 (Wed, 22 Dec 2021)

Log Message

[LFC][IFC] Soft linebreaks have incorrect bidi paragraph positions
https://bugs.webkit.org/show_bug.cgi?id=234608

Reviewed by Antti Koivisto.

Soft linebreaks are part of the InlineTextBox content and they are appened to the bidi paragraph
together with the rest of the text content (as we append the InlineTextBox content in one block).
We need to handle their positions the same way we do with regular text content i.e. use the inline item's offset
and not the paragraphContentBuilder's length.

* layout/formattingContexts/inline/InlineItemsBuilder.cpp:
(WebCore::Layout::buildBidiParagraph):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287369 => 287370)


--- trunk/Source/WebCore/ChangeLog	2021-12-22 19:44:09 UTC (rev 287369)
+++ trunk/Source/WebCore/ChangeLog	2021-12-22 21:03:40 UTC (rev 287370)
@@ -1,3 +1,18 @@
+2021-12-22  Alan Bujtas  <za...@apple.com>
+
+        [LFC][IFC] Soft linebreaks have incorrect bidi paragraph positions
+        https://bugs.webkit.org/show_bug.cgi?id=234608
+
+        Reviewed by Antti Koivisto.
+
+        Soft linebreaks are part of the InlineTextBox content and they are appened to the bidi paragraph
+        together with the rest of the text content (as we append the InlineTextBox content in one block).
+        We need to handle their positions the same way we do with regular text content i.e. use the inline item's offset
+        and not the paragraphContentBuilder's length.
+
+        * layout/formattingContexts/inline/InlineItemsBuilder.cpp:
+        (WebCore::Layout::buildBidiParagraph):
+
 2021-12-22  Alex Christensen  <achristen...@webkit.org>
 
         Fix compiling with pickier compiler

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp (287369 => 287370)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp	2021-12-22 19:44:09 UTC (rev 287369)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineItemsBuilder.cpp	2021-12-22 21:03:40 UTC (rev 287370)
@@ -215,12 +215,17 @@
         auto& inlineItem = inlineItems[index];
         auto& layoutBox = inlineItem.layoutBox();
 
+        auto appendTextBasedContent = [&] {
+            // Append the entire InlineTextBox content and keep track of individual inline item positions.
+            if (lastInlineTextBox == &layoutBox)
+                return;
+            inlineTextBoxOffset = paragraphContentBuilder.length();
+            replaceNonPreservedNewLineCharactersAndAppend(downcast<InlineTextBox>(layoutBox), paragraphContentBuilder);
+            lastInlineTextBox = &layoutBox;
+        };
+
         if (inlineItem.isText()) {
-            if (lastInlineTextBox != &layoutBox) {
-                inlineTextBoxOffset = paragraphContentBuilder.length();
-                replaceNonPreservedNewLineCharactersAndAppend(downcast<InlineTextBox>(layoutBox), paragraphContentBuilder);
-                lastInlineTextBox = &layoutBox;
-            }
+            appendTextBasedContent();
             inlineItemOffsetList.uncheckedAppend({ inlineTextBoxOffset + downcast<InlineTextItem>(inlineItem).start() });
         } else if (inlineItem.isBox()) {
             inlineItemOffsetList.uncheckedAppend({ paragraphContentBuilder.length() });
@@ -238,7 +243,10 @@
             inlineItemOffsetList.uncheckedAppend({ paragraphContentBuilder.length() });
             auto isEnteringBidi = inlineItem.isInlineBoxStart();
             handleEnterExitBidiContext(paragraphContentBuilder, style.unicodeBidi(), style.isLeftToRightDirection(), isEnteringBidi);
-        } else if (inlineItem.isLineBreak()) {
+        } else if (inlineItem.isSoftLineBreak()) {
+            appendTextBasedContent();
+            inlineItemOffsetList.uncheckedAppend({ inlineTextBoxOffset + downcast<InlineSoftLineBreakItem>(inlineItem).position() });
+        } else if (inlineItem.isHardLineBreak()) {
             inlineItemOffsetList.uncheckedAppend({ paragraphContentBuilder.length() });
             paragraphContentBuilder.append(newlineCharacter);
         } else if (inlineItem.isWordBreakOpportunity()) {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to