Title: [287317] trunk/Source/WebCore
Revision
287317
Author
[email protected]
Date
2021-12-21 08:46:39 -0800 (Tue, 21 Dec 2021)

Log Message

[LFC][IFC] Start using Display::Line geometry in InlineDisplayContentBuilder
https://bugs.webkit.org/show_bug.cgi?id=234532

Reviewed by Antti Koivisto.

This is in preparation for using Display::Line geometry for things like contentStartInVisualOrder in InlineDisplayContentBuilder.

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287316 => 287317)


--- trunk/Source/WebCore/ChangeLog	2021-12-21 16:28:42 UTC (rev 287316)
+++ trunk/Source/WebCore/ChangeLog	2021-12-21 16:46:39 UTC (rev 287317)
@@ -1,5 +1,20 @@
 2021-12-21  Alan Bujtas  <[email protected]>
 
+        [LFC][IFC] Start using Display::Line geometry in InlineDisplayContentBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=234532
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for using Display::Line geometry for things like contentStartInVisualOrder in InlineDisplayContentBuilder.
+
+        * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::build):
+        (WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent):
+        (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+        * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h:
+
+2021-12-21  Alan Bujtas  <[email protected]>
+
         [LFC][IFC] Display content builder should take Display::Line
         https://bugs.webkit.org/show_bug.cgi?id=234527
 

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2021-12-21 16:28:42 UTC (rev 287316)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2021-12-21 16:46:39 UTC (rev 287317)
@@ -87,7 +87,7 @@
 {
 }
 
-DisplayBoxes InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line displayLine, const size_t lineIndex)
+DisplayBoxes InlineDisplayContentBuilder::build(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line& displayLine, const size_t lineIndex)
 {
     DisplayBoxes boxes;
     boxes.reserveInitialCapacity(lineContent.runs.size() + lineBox.nonRootInlineLevelBoxes().size() + 1);
@@ -101,9 +101,9 @@
 
     auto contentNeedsBidiReordering = !lineContent.visualOrderList.isEmpty();
     if (contentNeedsBidiReordering)
-        processBidiContent(lineContent, lineBox, lineBoxRect.topLeft(), boxes);
+        processBidiContent(lineContent, lineBox, displayLine, boxes);
     else
-        processNonBidiContent(lineContent, lineBox, lineBoxRect.topLeft(), boxes);
+        processNonBidiContent(lineContent, lineBox, displayLine, boxes);
     processOverflownRunsForEllipsis(boxes, lineBoxRect.right());
     collectInkOverflowForInlineBoxes(boxes);
     return boxes;
@@ -317,19 +317,17 @@
     });
 }
 
-void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxTopLeft, DisplayBoxes& boxes)
+void InlineDisplayContentBuilder::processNonBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line& displayLine, DisplayBoxes& boxes)
 {
-    auto rootInlineBoxWidth = lineBox.logicalRectForRootInlineBox().width();
-    auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
-    auto needsDirectionAdjustment = !root().style().isLeftToRightDirection();
+    ASSERT(root().style().isLeftToRightDirection());
+    auto lineBoxRect = displayLine.lineBoxRect();
+    auto contentStartInVisualOrder = lineBoxRect.left() + displayLine.contentLeft();
 
     for (auto& lineRun : lineContent.runs) {
         auto& layoutBox = lineRun.layoutBox();
 
         auto visualRectRelativeToRoot = [&](auto logicalRect) {
-            // When the logical order == visual order, RTL inline direction is just an offset.
-            auto horizontalOffset = needsDirectionAdjustment ? lineContent.lineLogicalWidth - rootInlineBoxWidth - rootInlineBoxAlignmentOffset : rootInlineBoxAlignmentOffset;
-            logicalRect.moveBy({ lineBoxTopLeft.x() + horizontalOffset, lineBoxTopLeft.y() });
+            logicalRect.moveBy({ contentStartInVisualOrder, lineBoxRect.top() });
             return logicalRect;
         };
 
@@ -531,7 +529,7 @@
         displayBox.setHasContent();
 }
 
-void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineLayoutPoint& lineBoxTopLeft, DisplayBoxes& boxes)
+void InlineDisplayContentBuilder::processBidiContent(const LineBuilder::LineContent& lineContent, const LineBox& lineBox, const InlineDisplay::Line& displayLine, DisplayBoxes& boxes)
 {
     ASSERT(lineContent.visualOrderList.size() <= lineContent.runs.size());
 
@@ -539,12 +537,14 @@
     auto displayBoxTree = DisplayBoxTree { };
     ancestorStack.push({ }, root());
 
-    auto rootInlineBoxAlignmentOffset = lineBox.rootInlineBoxAlignmentOffset();
-    auto contentStartInVisualOrder = rootInlineBoxAlignmentOffset;
+    auto lineBoxRect = displayLine.lineBoxRect();
+    auto contentStartInVisualOrder = lineBoxRect.left() + displayLine.contentLeft();
     auto createDisplayBoxesInVisualOrder = [&] {
         // First visual run's initial content position depends on the block's inline direction.
-        if (!root().style().isLeftToRightDirection())
-            contentStartInVisualOrder = lineContent.lineLogicalWidth - lineBox.logicalRectForRootInlineBox().width() - rootInlineBoxAlignmentOffset;
+        if (!root().style().isLeftToRightDirection()) {
+            // FIXME: Turn display line's contentLeft to visual and just use that value.
+            contentStartInVisualOrder = lineBoxRect.width() - displayLine.contentWidth() - displayLine.contentLeft();
+        }
 
         auto contentRightInVisualOrder = contentStartInVisualOrder;
         auto& runs = lineContent.runs;
@@ -560,7 +560,7 @@
 
             auto visualRectRelativeToRoot = [&](auto logicalRect) {
                 logicalRect.setLeft(contentRightInVisualOrder);
-                logicalRect.moveBy(lineBoxTopLeft);
+                logicalRect.moveVertically(lineBoxRect.top());
                 return logicalRect;
             };
 
@@ -638,10 +638,10 @@
         computeIsFirstIsLastBox();
 
         auto adjustVisualGeometryWithInlineBoxes = [&] {
-            auto contentRightInVisualOrder = lineBoxTopLeft.x() + contentStartInVisualOrder;
+            auto contentRightInVisualOrder = contentStartInVisualOrder;
 
             for (auto childDisplayBoxNodeIndex : displayBoxTree.root().children)
-                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxTopLeft.y(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
+                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxRect.top(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
         };
         adjustVisualGeometryWithInlineBoxes();
     }

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h (287316 => 287317)


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h	2021-12-21 16:28:42 UTC (rev 287316)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.h	2021-12-21 16:46:39 UTC (rev 287317)
@@ -44,13 +44,13 @@
 public:
     InlineDisplayContentBuilder(const ContainerBox& formattingContextRoot, InlineFormattingState&);
 
-    DisplayBoxes build(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line displayLine, const size_t lineIndex);
+    DisplayBoxes build(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line&, const size_t lineIndex);
 
     static void computeIsFirstIsLastBoxForInlineContent(DisplayBoxes&);
 
 private:
-    void processNonBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineLayoutPoint& lineBoxTopLeft, DisplayBoxes&);
-    void processBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineLayoutPoint& lineBoxTopLeft, DisplayBoxes&);
+    void processNonBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line&, DisplayBoxes&);
+    void processBidiContent(const LineBuilder::LineContent&, const LineBox&, const InlineDisplay::Line&, DisplayBoxes&);
     void processOverflownRunsForEllipsis(DisplayBoxes&, InlineLayoutUnit lineBoxRight);
     void collectInkOverflowForInlineBoxes(DisplayBoxes&);
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to