Title: [289499] trunk/Source/WebCore
Revision
289499
Author
[email protected]
Date
2022-02-09 12:53:53 -0800 (Wed, 09 Feb 2022)

Log Message

[LFC][IFC] Vertical writing mode with RTL text content has incorrect advances
https://bugs.webkit.org/show_bug.cgi?id=236345

Reviewed by Antti Koivisto.

contentRightInInlineDirectionVisualOrder is the visual offset of the adjoining runs ignoring the writing mode (horizontal vs. vertical).
It's visual in the inline direction sense (right to left vs. left to right), but it's not transformed in the context of writing mode, i.e. width and height are not flipped.

* layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (289498 => 289499)


--- trunk/Source/WebCore/ChangeLog	2022-02-09 20:48:11 UTC (rev 289498)
+++ trunk/Source/WebCore/ChangeLog	2022-02-09 20:53:53 UTC (rev 289499)
@@ -1,3 +1,16 @@
+2022-02-09  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Vertical writing mode with RTL text content has incorrect advances
+        https://bugs.webkit.org/show_bug.cgi?id=236345
+
+        Reviewed by Antti Koivisto.
+
+        contentRightInInlineDirectionVisualOrder is the visual offset of the adjoining runs ignoring the writing mode (horizontal vs. vertical).
+        It's visual in the inline direction sense (right to left vs. left to right), but it's not transformed in the context of writing mode, i.e. width and height are not flipped.
+
+        * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+
 2022-02-09  Antoine Quint  <[email protected]>
 
         Dialog element only animates once

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2022-02-09 20:48:11 UTC (rev 289498)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2022-02-09 20:53:53 UTC (rev 289499)
@@ -459,7 +459,7 @@
     std::optional<size_t> last;
 };
 using IsFirstLastIndexesMap = HashMap<const Box*, IsFirstLastIndex>;
-void InlineDisplayContentBuilder::adjustVisualGeometryForDisplayBox(size_t displayBoxNodeIndex, InlineLayoutUnit& contentRightInVisualOrder, InlineLayoutUnit lineBoxTop, const DisplayBoxTree& displayBoxTree, DisplayBoxes& boxes, const LineBox& lineBox, const IsFirstLastIndexesMap& isFirstLastIndexesMap)
+void InlineDisplayContentBuilder::adjustVisualGeometryForDisplayBox(size_t displayBoxNodeIndex, InlineLayoutUnit& contentRightInInlineDirectionVisualOrder, InlineLayoutUnit lineBoxTop, const DisplayBoxTree& displayBoxTree, DisplayBoxes& boxes, const LineBox& lineBox, const IsFirstLastIndexesMap& isFirstLastIndexesMap)
 {
     // Non-inline box display boxes just need a horizontal adjustment while
     // inline box type of display boxes need
@@ -475,15 +475,15 @@
             auto boxMarginLeft = marginLeft(boxGeometry, isLeftToRightDirection);
             auto boxMarginRight = marginRight(boxGeometry, isLeftToRightDirection);
 
-            auto borderBoxLeft = LayoutUnit { contentRightInVisualOrder + boxMarginLeft };
+            auto borderBoxLeft = LayoutUnit { contentRightInInlineDirectionVisualOrder + boxMarginLeft };
             boxGeometry.setLogicalLeft(borderBoxLeft);
             displayBox.setLeft(borderBoxLeft);
 
-            contentRightInVisualOrder += boxMarginLeft + displayBox.width() + boxMarginRight;
+            contentRightInInlineDirectionVisualOrder += boxMarginLeft + displayBox.width() + boxMarginRight;
         } else {
             auto wordSpacingMargin = displayBox.isWordSeparator() ? layoutBox.style().fontCascade().wordSpacing() : 0.0f;
-            displayBox.setLeft(contentRightInVisualOrder + wordSpacingMargin);
-            contentRightInVisualOrder += displayBox.width() + wordSpacingMargin;
+            displayBox.setLeft(contentRightInInlineDirectionVisualOrder + wordSpacingMargin);
+            contentRightInInlineDirectionVisualOrder += displayBox.width() + wordSpacingMargin;
         }
         return;
     }
@@ -495,29 +495,29 @@
     auto isLastBox = isFirstLastIndexes.last && *isFirstLastIndexes.last == displayBoxNodeIndex;
     auto beforeInlineBoxContent = [&] {
         auto logicalRect = lineBox.logicalBorderBoxForInlineBox(layoutBox, boxGeometry);
-        auto visualRect = InlineRect { lineBoxTop + logicalRect.top(), contentRightInVisualOrder, { }, logicalRect.height() };
+        auto visualRect = InlineRect { lineBoxTop + logicalRect.top(), contentRightInInlineDirectionVisualOrder, { }, logicalRect.height() };
         auto shouldApplyLeftSide = (isLeftToRightDirection && isFirstBox) || (!isLeftToRightDirection && isLastBox);
         if (!shouldApplyLeftSide)
             return displayBox.setRect(visualRect, visualRect);
 
-        contentRightInVisualOrder += marginLeft(boxGeometry, isLeftToRightDirection);
-        auto visualRectWithMarginLeft = InlineRect { visualRect.top(), contentRightInVisualOrder, visualRect.width(), visualRect.height() };
+        contentRightInInlineDirectionVisualOrder += marginLeft(boxGeometry, isLeftToRightDirection);
+        auto visualRectWithMarginLeft = InlineRect { visualRect.top(), contentRightInInlineDirectionVisualOrder, visualRect.width(), visualRect.height() };
         displayBox.setRect(visualRectWithMarginLeft, visualRectWithMarginLeft);
-        contentRightInVisualOrder += borderLeft(boxGeometry, isLeftToRightDirection) + paddingLeft(boxGeometry, isLeftToRightDirection);
+        contentRightInInlineDirectionVisualOrder += borderLeft(boxGeometry, isLeftToRightDirection) + paddingLeft(boxGeometry, isLeftToRightDirection);
     };
     beforeInlineBoxContent();
 
     for (auto childDisplayBoxNodeIndex : displayBoxTree.at(displayBoxNodeIndex).children)
-        adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxTop, displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
+        adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInInlineDirectionVisualOrder, lineBoxTop, displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
 
     auto afterInlineBoxContent = [&] {
         auto shouldApplyRightSide = (isLeftToRightDirection && isLastBox) || (!isLeftToRightDirection && isFirstBox);
         if (!shouldApplyRightSide)
-            return displayBox.setRight(contentRightInVisualOrder);
+            return displayBox.setRight(contentRightInInlineDirectionVisualOrder);
 
-        contentRightInVisualOrder += borderRight(boxGeometry, isLeftToRightDirection) + paddingRight(boxGeometry, isLeftToRightDirection);
-        displayBox.setRight(contentRightInVisualOrder);
-        contentRightInVisualOrder += marginRight(boxGeometry, isLeftToRightDirection);
+        contentRightInInlineDirectionVisualOrder += borderRight(boxGeometry, isLeftToRightDirection) + paddingRight(boxGeometry, isLeftToRightDirection);
+        displayBox.setRight(contentRightInInlineDirectionVisualOrder);
+        contentRightInInlineDirectionVisualOrder += marginRight(boxGeometry, isLeftToRightDirection);
     };
     afterInlineBoxContent();
 
@@ -542,11 +542,11 @@
     ancestorStack.push({ }, root());
 
     auto writingMode = root().style().writingMode();
-    auto contentStartInVisualOrder = displayLine.left() + displayLine.contentLogicalOffset();
+    auto contentStartInInlineDirectionVisualOrder = (WebCore::isHorizontalWritingMode(writingMode) ? displayLine.left() : displayLine.top()) + displayLine.contentLogicalOffset();
     auto hasInlineBox = false;
     auto createDisplayBoxesInVisualOrder = [&] {
 
-        auto contentRightInVisualOrder = contentStartInVisualOrder;
+        auto contentRightInInlineDirectionVisualOrder = contentStartInInlineDirectionVisualOrder;
         auto& runs = lineContent.runs;
         for (auto visualOrder : lineContent.visualOrderList) {
             ASSERT(runs[visualOrder].bidiLevel() != InlineItem::opaqueBidiLevel);
@@ -561,9 +561,9 @@
             auto visualRectRelativeToRoot = [&](auto logicalRect) {
                 auto visualRect = flipLogicalRectToVisualForWritingModeWithinLine(logicalRect, lineBox.logicalRect(), writingMode);
                 if (WebCore::isHorizontalWritingMode(writingMode))
-                    visualRect.setLeft(contentRightInVisualOrder);
+                    visualRect.setLeft(contentRightInInlineDirectionVisualOrder);
                 else
-                    visualRect.setTop(contentRightInVisualOrder);
+                    visualRect.setTop(contentRightInInlineDirectionVisualOrder);
                 visualRect.moveVertically(displayLine.top());
                 return visualRect;
             };
@@ -571,12 +571,13 @@
             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 logicalRect = lineBox.logicalRectForTextRun(lineRun);
+                auto visualRect = visualRectRelativeToRoot(logicalRect);
                 auto wordSpacingMargin = lineRun.isWordSeparator() ? layoutBox.style().fontCascade().wordSpacing() : 0.0f;
 
                 visualRect.moveHorizontally(wordSpacingMargin);
                 appendTextDisplayBox(lineRun, visualRect, boxes);
-                contentRightInVisualOrder += visualRect.width() + wordSpacingMargin;
+                contentRightInInlineDirectionVisualOrder += logicalRect.width() + wordSpacingMargin;
                 displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
                 continue;
             }
@@ -594,13 +595,14 @@
             }
             if (lineRun.isBox()) {
                 auto& boxGeometry = formattingState().boxGeometry(layoutBox);
-                auto visualRect = visualRectRelativeToRoot(lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, boxGeometry));
+                auto logicalRect = lineBox.logicalBorderBoxForAtomicInlineLevelBox(layoutBox, boxGeometry);
+                auto visualRect = visualRectRelativeToRoot(logicalRect);
 
                 auto isLeftToRightDirection = layoutBox.parent().style().isLeftToRightDirection();
                 auto boxMarginLeft = marginLeft(boxGeometry, isLeftToRightDirection);
                 visualRect.moveHorizontally(boxMarginLeft);
                 appendAtomicInlineLevelDisplayBox(lineRun, visualRect, boxes);
-                contentRightInVisualOrder += boxMarginLeft + visualRect.width() + marginRight(boxGeometry, isLeftToRightDirection);
+                contentRightInInlineDirectionVisualOrder += boxMarginLeft + logicalRect.width() + marginRight(boxGeometry, isLeftToRightDirection);
                 displayBoxTree.append(parentDisplayBoxNodeIndex, boxes.size() - 1);
                 continue;
             }
@@ -654,10 +656,10 @@
         computeIsFirstIsLastBox();
 
         auto adjustVisualGeometryWithInlineBoxes = [&] {
-            auto contentRightInVisualOrder = contentStartInVisualOrder;
+            auto contentRightInInlineDirectionVisualOrder = contentStartInInlineDirectionVisualOrder;
 
             for (auto childDisplayBoxNodeIndex : displayBoxTree.root().children)
-                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, displayLine.top(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
+                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInInlineDirectionVisualOrder, displayLine.top(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
         };
         adjustVisualGeometryWithInlineBoxes();
     };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to