Title: [287501] trunk/Source/WebCore
Revision
287501
Author
[email protected]
Date
2022-01-01 07:34:20 -0800 (Sat, 01 Jan 2022)

Log Message

[LFC][IFC] Simple RTL content triggers redundant horizontal positioning
https://bugs.webkit.org/show_bug.cgi?id=234772

Reviewed by Antti Koivisto.

RTL content with inline boxes require a second pass horizontal positioning.
Currently we trigger this second pass even when the content does not have any inline box.
(e.g <div>content<span>with inline box</span></div> <div>content with no inline box</div>)

* layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::processBidiContent): !0 parentDisplayBoxNodeIndex means non-root inline box.
(WebCore::Layout::DisplayBoxTree::hasInlineBox const): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287500 => 287501)


--- trunk/Source/WebCore/ChangeLog	2022-01-01 14:55:43 UTC (rev 287500)
+++ trunk/Source/WebCore/ChangeLog	2022-01-01 15:34:20 UTC (rev 287501)
@@ -1,5 +1,20 @@
 2022-01-01  Alan Bujtas  <[email protected]>
 
+        [LFC][IFC] Simple RTL content triggers redundant horizontal positioning
+        https://bugs.webkit.org/show_bug.cgi?id=234772
+
+        Reviewed by Antti Koivisto.
+
+        RTL content with inline boxes require a second pass horizontal positioning.
+        Currently we trigger this second pass even when the content does not have any inline box.
+        (e.g <div>content<span>with inline box</span></div> <div>content with no inline box</div>)
+
+        * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent): !0 parentDisplayBoxNodeIndex means non-root inline box.
+        (WebCore::Layout::DisplayBoxTree::hasInlineBox const): Deleted.
+
+2022-01-01  Alan Bujtas  <[email protected]>
+
         [LFC][IFC] Incorrect word-spacing gaps between RTL runs
         https://bugs.webkit.org/show_bug.cgi?id=234771
 

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp (287500 => 287501)


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2022-01-01 14:55:43 UTC (rev 287500)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2022-01-01 15:34:20 UTC (rev 287501)
@@ -395,7 +395,6 @@
         m_displayBoxNodes.append({ });
     }
 
-    bool hasInlineBox() const { return m_displayBoxNodes.size() > 1; }
     const Node& root() const { return m_displayBoxNodes.first(); }
     Node& at(size_t index) { return m_displayBoxNodes[index]; }
     const Node& at(size_t index) const { return m_displayBoxNodes[index]; }
@@ -544,6 +543,7 @@
     ancestorStack.push({ }, root());
 
     auto contentStartInVisualOrder = displayLine.left() + displayLine.contentLeft();
+    auto hasInlineBox = false;
     auto createDisplayBoxesInVisualOrder = [&] {
 
         auto contentRightInVisualOrder = contentStartInVisualOrder;
@@ -565,6 +565,7 @@
             };
 
             auto parentDisplayBoxNodeIndex = ensureDisplayBoxForContainer(layoutBox.parent(), displayBoxTree, ancestorStack, boxes);
+            hasInlineBox = hasInlineBox || parentDisplayBoxNodeIndex || lineRun.isInlineBoxStart() || lineRun.isLineSpanningInlineBoxStart();
             if (lineRun.isText()) {
                 auto visualRect = visualRectRelativeToRoot(lineBox.logicalRectForTextRun(lineRun));
                 auto wordSpacingMargin = lineRun.isWordSeparator() ? layoutBox.style().fontCascade().wordSpacing() : 0.0f;
@@ -618,7 +619,10 @@
     };
     createDisplayBoxesInVisualOrder();
 
-    if (displayBoxTree.hasInlineBox()) {
+    auto handleInlineBoxes = [&] {
+        if (!hasInlineBox)
+            return;
+
         IsFirstLastIndexesMap isFirstLastIndexesMap;
         auto computeIsFirstIsLastBox = [&] {
             ASSERT(boxes[0].isRootInlineBox());
@@ -652,7 +656,8 @@
                 adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, displayLine.top(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
         };
         adjustVisualGeometryWithInlineBoxes();
-    }
+    };
+    handleInlineBoxes();
 }
 
 void InlineDisplayContentBuilder::processOverflownRunsForEllipsis(DisplayBoxes& boxes, InlineLayoutUnit lineBoxRight)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to