Title: [287476] trunk/Source/WebCore
Revision
287476
Author
za...@apple.com
Date
2021-12-28 13:43:43 -0800 (Tue, 28 Dec 2021)

Log Message

[LFC][IFC] Do not let Layout geometry types leak into InlineDisplay::Line
https://bugs.webkit.org/show_bug.cgi?id=234729

Reviewed by Antti Koivisto.

InlineLayoutUnit -> float
InlineRect -> FloatRect
(This is also where we will eventually do some pixel snapping)

* layout/formattingContexts/block/BlockFormattingGeometry.cpp:
(WebCore::Layout::BlockFormattingGeometry::inFlowNonReplacedContentHeightAndMargin const):
* layout/formattingContexts/inline/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::usedContentHeight const):
(WebCore::Layout::InlineFormattingContext::computeStaticPositionForOutOfFlowContent):
* layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
(WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes):
* layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::build):
(WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent):
(WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
* layout/formattingContexts/inline/display/InlineDisplayLine.h:
(WebCore::InlineDisplay::Line::left const):
(WebCore::InlineDisplay::Line::right const):
(WebCore::InlineDisplay::Line::top const):
(WebCore::InlineDisplay::Line::bottom const):
(WebCore::InlineDisplay::Line::topLeft const):
(WebCore::InlineDisplay::Line::lineBoxRect const):
(WebCore::InlineDisplay::Line::scrollableOverflow const):
(WebCore::InlineDisplay::Line::baseline const):
(WebCore::InlineDisplay::Line::contentLeft const):
(WebCore::InlineDisplay::Line::contentWidth const):
(WebCore::InlineDisplay::Line::moveVertically):
(WebCore::InlineDisplay::Line::Line):
* layout/layouttree/LayoutTreeBuilder.cpp:
(WebCore::Layout::showInlineTreeAndRuns):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (287475 => 287476)


--- trunk/Source/WebCore/ChangeLog	2021-12-28 21:16:11 UTC (rev 287475)
+++ trunk/Source/WebCore/ChangeLog	2021-12-28 21:43:43 UTC (rev 287476)
@@ -1,5 +1,43 @@
 2021-12-28  Alan Bujtas  <za...@apple.com>
 
+        [LFC][IFC] Do not let Layout geometry types leak into InlineDisplay::Line
+        https://bugs.webkit.org/show_bug.cgi?id=234729
+
+        Reviewed by Antti Koivisto.
+
+        InlineLayoutUnit -> float
+        InlineRect -> FloatRect
+        (This is also where we will eventually do some pixel snapping)
+
+        * layout/formattingContexts/block/BlockFormattingGeometry.cpp:
+        (WebCore::Layout::BlockFormattingGeometry::inFlowNonReplacedContentHeightAndMargin const):
+        * layout/formattingContexts/inline/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::usedContentHeight const):
+        (WebCore::Layout::InlineFormattingContext::computeStaticPositionForOutOfFlowContent):
+        * layout/formattingContexts/inline/InlineLineBoxBuilder.cpp:
+        (WebCore::Layout::LineBoxBuilder::constructAndAlignInlineLevelBoxes):
+        * layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::build):
+        (WebCore::Layout::InlineDisplayContentBuilder::processNonBidiContent):
+        (WebCore::Layout::InlineDisplayContentBuilder::processBidiContent):
+        * layout/formattingContexts/inline/display/InlineDisplayLine.h:
+        (WebCore::InlineDisplay::Line::left const):
+        (WebCore::InlineDisplay::Line::right const):
+        (WebCore::InlineDisplay::Line::top const):
+        (WebCore::InlineDisplay::Line::bottom const):
+        (WebCore::InlineDisplay::Line::topLeft const):
+        (WebCore::InlineDisplay::Line::lineBoxRect const):
+        (WebCore::InlineDisplay::Line::scrollableOverflow const):
+        (WebCore::InlineDisplay::Line::baseline const):
+        (WebCore::InlineDisplay::Line::contentLeft const):
+        (WebCore::InlineDisplay::Line::contentWidth const):
+        (WebCore::InlineDisplay::Line::moveVertically):
+        (WebCore::InlineDisplay::Line::Line):
+        * layout/layouttree/LayoutTreeBuilder.cpp:
+        (WebCore::Layout::showInlineTreeAndRuns):
+
+2021-12-28  Alan Bujtas  <za...@apple.com>
+
         [LFC][IFC] Do not let Layout geometry types leak into InlineDisplay::Box
         https://bugs.webkit.org/show_bug.cgi?id=234728
 

Modified: trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp (287475 => 287476)


--- trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp	2021-12-28 21:16:11 UTC (rev 287475)
+++ trunk/Source/WebCore/layout/formattingContexts/block/BlockFormattingGeometry.cpp	2021-12-28 21:43:43 UTC (rev 287476)
@@ -87,7 +87,7 @@
             auto& lines = inlineFormattingState.lines();
             // Even empty containers generate one line. 
             ASSERT(!lines.isEmpty());
-            return { toLayoutUnit(lines.last().lineBoxRect().bottom() + inlineFormattingState.clearGapAfterLastLine()) - borderAndPaddingTop, nonCollapsedMargin };
+            return { toLayoutUnit(lines.last().bottom() + inlineFormattingState.clearGapAfterLastLine()) - borderAndPaddingTop, nonCollapsedMargin };
         }
 
         // 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp (287475 => 287476)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp	2021-12-28 21:16:11 UTC (rev 287475)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineFormattingContext.cpp	2021-12-28 21:43:43 UTC (rev 287476)
@@ -186,8 +186,8 @@
     auto& lines = formattingState().lines();
     // Even empty content generates a line.
     ASSERT(!lines.isEmpty());
-    auto top = LayoutUnit { lines.first().lineBoxRect().top() };
-    auto bottom = LayoutUnit { lines.last().lineBoxRect().bottom() + formattingState().clearGapAfterLastLine() };
+    auto top = LayoutUnit { lines.first().top() };
+    auto bottom = LayoutUnit { lines.last().bottom() + formattingState().clearGapAfterLastLine() };
 
     auto floatingContext = FloatingContext { *this, formattingState().floatingState() };
     if (auto floatBottom = floatingContext.bottom()) {
@@ -306,7 +306,7 @@
             // This is the first (non-float)child. Let's place it to the left of the first box.
             // <div><img style="position: absolute">text content</div>
             ASSERT(boxes.size());
-            outOfFlowGeometry.setLogicalTopLeft({ boxes[0].left(), lines[0].lineBoxRect().top() });
+            outOfFlowGeometry.setLogicalTopLeft({ boxes[0].left(), lines[0].top() });
             continue;
         }
 
@@ -347,7 +347,7 @@
                         ? BoxGeometry::borderBoxLeft(inlineBoxBoxGeometry) + inlineBoxBoxGeometry.contentBoxLeft()
                         : BoxGeometry::borderBoxRect(inlineBoxBoxGeometry).right();
                 }
-                outOfFlowGeometry.setLogicalTopLeft({ left, lines[previousBox.lineIndex()].lineBoxRect().top() });
+                outOfFlowGeometry.setLogicalTopLeft({ left, lines[previousBox.lineIndex()].top() });
                 return;
             }
 
@@ -354,20 +354,20 @@
             if (nextBox) {
                 // The out of flow box is placed at the beginning of the next line (where the first box on the line is).
                 // <div>text<br><img style="position: absolute"><img style="position: absolute">content</div>
-                outOfFlowGeometry.setLogicalTopLeft({ nextBox->left(), lines[nextBox->lineIndex()].lineBoxRect().top() });
+                outOfFlowGeometry.setLogicalTopLeft({ nextBox->left(), lines[nextBox->lineIndex()].top() });
                 return;
             }
 
-            auto& lastLineLogicalRect = lines[previousBox.lineIndex()].lineBoxRect();
+            auto& lastLine = lines[previousBox.lineIndex()];
             // This out-of-flow box is the last box.
             // FIXME: Use isLineBreak instead to cover preserved new lines too.
             if (previousBox.layoutBox().isLineBreakBox()) {
                 // <div>text<br><img style="position: absolute"><img style="position: absolute"></div>
-                outOfFlowGeometry.setLogicalTopLeft({ lastLineLogicalRect.left(), lastLineLogicalRect.bottom() });
+                outOfFlowGeometry.setLogicalTopLeft({ lastLine.left(), lastLine.bottom() });
                 return;
             }
             // FIXME: We may need to check if this box actually fits the last line and move it over to the "next" line.
-            outOfFlowGeometry.setLogicalTopLeft({ previousBox.right(), lastLineLogicalRect.top() });
+            outOfFlowGeometry.setLogicalTopLeft({ previousBox.right(), lastLine.top() });
         };
         placeOutOfFlowBoxAfterPreviousInFlowBox();
     }

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp (287475 => 287476)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp	2021-12-28 21:16:11 UTC (rev 287475)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineLineBoxBuilder.cpp	2021-12-28 21:43:43 UTC (rev 287476)
@@ -262,7 +262,7 @@
                 else {
                     auto& formattingState = layoutState().formattingStateForInlineFormattingContext(downcast<ContainerBox>(layoutBox));
                     auto& lastLine = formattingState.lines().last();
-                    auto inlineBlockBaseline = lastLine.lineBoxRect().top() + lastLine.baseline();
+                    auto inlineBlockBaseline = lastLine.top() + lastLine.baseline();
                     ascent = inlineLevelBoxGeometry.marginBefore() + inlineLevelBoxGeometry.borderBefore() + inlineLevelBoxGeometry.paddingBefore().value_or(0) + inlineBlockBaseline;
                 }
             } else if (layoutBox.isReplacedBox())

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


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2021-12-28 21:16:11 UTC (rev 287475)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayContentBuilder.cpp	2021-12-28 21:43:43 UTC (rev 287476)
@@ -93,10 +93,9 @@
     boxes.reserveInitialCapacity(lineContent.runs.size() + lineBox.nonRootInlineLevelBoxes().size() + 1);
 
     m_lineIndex = lineIndex;
-    auto lineBoxRect = displayLine.lineBoxRect();
     // Every line starts with a root box, even the empty ones.
     auto rootInlineBoxRect = lineBox.logicalRectForRootInlineBox();
-    rootInlineBoxRect.moveBy(lineBoxRect.topLeft());
+    rootInlineBoxRect.moveBy(displayLine.topLeft());
     boxes.append({ m_lineIndex, InlineDisplay::Box::Type::RootInlineBox, root(), UBIDI_DEFAULT_LTR, rootInlineBoxRect, rootInlineBoxRect, { }, { }, lineBox.rootInlineBox().hasContent() });
 
     auto contentNeedsBidiReordering = !lineContent.visualOrderList.isEmpty();
@@ -104,7 +103,7 @@
         processBidiContent(lineContent, lineBox, displayLine, boxes);
     else
         processNonBidiContent(lineContent, lineBox, displayLine, boxes);
-    processOverflownRunsForEllipsis(boxes, lineBoxRect.right());
+    processOverflownRunsForEllipsis(boxes, displayLine.right());
     collectInkOverflowForInlineBoxes(boxes);
     return boxes;
 }
@@ -325,14 +324,13 @@
         hasContent = hasContent || lineRun.isText() || lineRun.isBox();
     ASSERT(root().style().isLeftToRightDirection() || !hasContent);
 #endif
-    auto lineBoxRect = displayLine.lineBoxRect();
-    auto contentStartInVisualOrder = lineBoxRect.left() + displayLine.contentLeft();
+    auto contentStartInVisualOrder = displayLine.left() + displayLine.contentLeft();
 
     for (auto& lineRun : lineContent.runs) {
         auto& layoutBox = lineRun.layoutBox();
 
         auto visualRectRelativeToRoot = [&](auto logicalRect) {
-            logicalRect.moveBy({ contentStartInVisualOrder, lineBoxRect.top() });
+            logicalRect.moveBy({ contentStartInVisualOrder, displayLine.top() });
             return logicalRect;
         };
 
@@ -542,8 +540,7 @@
     auto displayBoxTree = DisplayBoxTree { };
     ancestorStack.push({ }, root());
 
-    auto lineBoxRect = displayLine.lineBoxRect();
-    auto contentStartInVisualOrder = lineBoxRect.left() + displayLine.contentLeft();
+    auto contentStartInVisualOrder = displayLine.left() + displayLine.contentLeft();
     auto createDisplayBoxesInVisualOrder = [&] {
 
         auto contentRightInVisualOrder = contentStartInVisualOrder;
@@ -560,7 +557,7 @@
 
             auto visualRectRelativeToRoot = [&](auto logicalRect) {
                 logicalRect.setLeft(contentRightInVisualOrder);
-                logicalRect.moveVertically(lineBoxRect.top());
+                logicalRect.moveVertically(displayLine.top());
                 return logicalRect;
             };
 
@@ -646,7 +643,7 @@
             auto contentRightInVisualOrder = contentStartInVisualOrder;
 
             for (auto childDisplayBoxNodeIndex : displayBoxTree.root().children)
-                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, lineBoxRect.top(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
+                adjustVisualGeometryForDisplayBox(childDisplayBoxNodeIndex, contentRightInVisualOrder, displayLine.top(), displayBoxTree, boxes, lineBox, isFirstLastIndexesMap);
         };
         adjustVisualGeometryWithInlineBoxes();
     }

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLine.h (287475 => 287476)


--- trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLine.h	2021-12-28 21:16:11 UTC (rev 287475)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/display/InlineDisplayLine.h	2021-12-28 21:43:43 UTC (rev 287476)
@@ -37,37 +37,44 @@
 public:
     struct EnclosingTopAndBottom {
         // This values encloses the root inline box and any other inline level box's border box.
-        Layout::InlineLayoutUnit top { 0 };
-        Layout::InlineLayoutUnit bottom { 0 };
+        float top { 0 };
+        float bottom { 0 };
     };
-    Line(const Layout::InlineRect& lineBoxRect, const Layout::InlineRect& scrollableOverflow, EnclosingTopAndBottom, Layout::InlineLayoutUnit aligmentBaseline, Layout::InlineLayoutUnit contentLeft, Layout::InlineLayoutUnit contentWidth);
+    Line(const FloatRect& lineBoxRect, const FloatRect& scrollableOverflow, EnclosingTopAndBottom, float aligmentBaseline, float contentLeft, float contentWidth);
 
-    const Layout::InlineRect& lineBoxRect() const { return m_lineBoxRect; }
-    const Layout::InlineRect& scrollableOverflow() const { return m_scrollableOverflow; }
+    float left() const { return m_lineBoxRect.x(); }
+    float right() const { return m_lineBoxRect.maxX(); }
+    float top() const { return m_lineBoxRect.y(); }
+    float bottom() const { return m_lineBoxRect.maxY(); }
 
+    FloatPoint topLeft() const { return m_lineBoxRect.location(); }
+
+    const FloatRect& lineBoxRect() const { return m_lineBoxRect; }
+    const FloatRect& scrollableOverflow() const { return m_scrollableOverflow; }
+
     EnclosingTopAndBottom enclosingTopAndBottom() const { return m_enclosingTopAndBottom; }
 
-    Layout::InlineLayoutUnit baseline() const { return m_aligmentBaseline; }
+    float baseline() const { return m_aligmentBaseline; }
 
-    Layout::InlineLayoutUnit contentLeft() const { return m_contentLeft; }
-    Layout::InlineLayoutUnit contentWidth() const { return m_contentWidth; }
+    float contentLeft() const { return m_contentLeft; }
+    float contentWidth() const { return m_contentWidth; }
 
-    void moveVertically(Layout::InlineLayoutUnit offset) { m_lineBoxRect.moveVertically(offset); }
+    void moveVertically(float offset) { m_lineBoxRect.move({ { }, offset }); }
 
 private:
     // This is line box geometry (see https://www.w3.org/TR/css-inline-3/#line-box).
-    Layout::InlineRect m_lineBoxRect;
-    Layout::InlineRect m_scrollableOverflow;
+    FloatRect m_lineBoxRect;
+    FloatRect m_scrollableOverflow;
     // Enclosing top and bottom includes all inline level boxes (border box) vertically.
     // While the line box usually enclose them as well, its vertical geometry is based on
     // the layout bounds of the inline level boxes which may be different when line-height is present.
     EnclosingTopAndBottom m_enclosingTopAndBottom;
-    Layout::InlineLayoutUnit m_aligmentBaseline { 0 };
-    Layout::InlineLayoutUnit m_contentLeft { 0 };
-    Layout::InlineLayoutUnit m_contentWidth { 0 };
+    float m_aligmentBaseline { 0 };
+    float m_contentLeft { 0 };
+    float m_contentWidth { 0 };
 };
 
-inline Line::Line(const Layout::InlineRect& lineBoxRect, const Layout::InlineRect& scrollableOverflow, EnclosingTopAndBottom enclosingTopAndBottom, Layout::InlineLayoutUnit aligmentBaseline, Layout::InlineLayoutUnit contentLeft, Layout::InlineLayoutUnit contentWidth)
+inline Line::Line(const FloatRect& lineBoxRect, const FloatRect& scrollableOverflow, EnclosingTopAndBottom enclosingTopAndBottom, float aligmentBaseline, float contentLeft, float contentWidth)
     : m_lineBoxRect(lineBoxRect)
     , m_scrollableOverflow(scrollableOverflow)
     , m_enclosingTopAndBottom(enclosingTopAndBottom)

Modified: trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp (287475 => 287476)


--- trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2021-12-28 21:16:11 UTC (rev 287475)
+++ trunk/Source/WebCore/layout/layouttree/LayoutTreeBuilder.cpp	2021-12-28 21:43:43 UTC (rev 287476)
@@ -376,7 +376,7 @@
         auto& line = lines[lineIndex];
         auto& lineBoxRect = line.lineBoxRect();
         auto enclosingTopAndBottom = line.enclosingTopAndBottom();
-        stream << "line at (" << lineBoxRect.left() << "," << lineBoxRect.top() << ") size (" << lineBoxRect.width() << "x" << lineBoxRect.height() << ") baseline (" << line.baseline() << ") enclosing top (" << enclosingTopAndBottom.top << ") bottom (" << enclosingTopAndBottom.bottom << ")";
+        stream << "line at (" << lineBoxRect.x() << "," << lineBoxRect.y() << ") size (" << lineBoxRect.width() << "x" << lineBoxRect.height() << ") baseline (" << line.baseline() << ") enclosing top (" << enclosingTopAndBottom.top << ") bottom (" << enclosingTopAndBottom.bottom << ")";
         stream.nextLine();
 
         addSpacing();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to