Title: [286445] trunk/Source/WebCore
Revision
286445
Author
[email protected]
Date
2021-12-02 12:22:40 -0800 (Thu, 02 Dec 2021)

Log Message

[LFC][IFC] Move inline box geometry (BoxGeometry) update logic to a dedicated function
https://bugs.webkit.org/show_bug.cgi?id=233615

Reviewed by Antti Koivisto.

This is also in preparation for computing the BoxGeometry for bidi inline boxes.

* layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
(WebCore::Layout::InlineDisplayContentBuilder::setInlineBoxGeometry):
(WebCore::Layout::InlineDisplayContentBuilder::appendInlineBoxDisplayBox):
(WebCore::Layout::InlineDisplayContentBuilder::appendSpanningInlineBoxDisplayBox):
* layout/formattingContexts/inline/InlineDisplayContentBuilder.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286444 => 286445)


--- trunk/Source/WebCore/ChangeLog	2021-12-02 20:09:02 UTC (rev 286444)
+++ trunk/Source/WebCore/ChangeLog	2021-12-02 20:22:40 UTC (rev 286445)
@@ -1,3 +1,18 @@
+2021-12-02  Alan Bujtas  <[email protected]>
+
+        [LFC][IFC] Move inline box geometry (BoxGeometry) update logic to a dedicated function
+        https://bugs.webkit.org/show_bug.cgi?id=233615
+
+        Reviewed by Antti Koivisto.
+
+        This is also in preparation for computing the BoxGeometry for bidi inline boxes.
+
+        * layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp:
+        (WebCore::Layout::InlineDisplayContentBuilder::setInlineBoxGeometry):
+        (WebCore::Layout::InlineDisplayContentBuilder::appendInlineBoxDisplayBox):
+        (WebCore::Layout::InlineDisplayContentBuilder::appendSpanningInlineBoxDisplayBox):
+        * layout/formattingContexts/inline/InlineDisplayContentBuilder.h:
+
 2021-12-02  Chris Dumez  <[email protected]>
 
         html/semantics/forms/constraints/input-number-validity-dynamic-value-no-change.html WPT test is failing

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp (286444 => 286445)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-12-02 20:09:02 UTC (rev 286444)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.cpp	2021-12-02 20:22:40 UTC (rev 286445)
@@ -192,6 +192,23 @@
     adjustParentInlineBoxInkOverflow();
 }
 
+void InlineDisplayContentBuilder::setInlineBoxGeometry(const Box& layoutBox, const InlineRect& rect, bool isFirstInlineBoxFragment)
+{
+    auto adjustedSize = LayoutSize { LayoutUnit::fromFloatCeil(rect.width()), LayoutUnit::fromFloatCeil(rect.height()) };
+    auto adjustedRect = Rect { LayoutPoint { rect.topLeft() }, adjustedSize };
+    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
+    if (!isFirstInlineBoxFragment) {
+        auto enclosingBorderBoxRect = BoxGeometry::borderBoxRect(boxGeometry);
+        enclosingBorderBoxRect.expandToContain(adjustedRect);
+        adjustedRect = enclosingBorderBoxRect;
+    }
+    boxGeometry.setLogicalTopLeft(adjustedRect.topLeft());
+    auto contentBoxHeight = adjustedRect.height() - (boxGeometry.verticalBorder() + boxGeometry.verticalPadding().value_or(0_lu));
+    auto contentBoxWidth = adjustedRect.width() - (boxGeometry.horizontalBorder() + boxGeometry.horizontalPadding().value_or(0_lu));
+    boxGeometry.setContentBoxHeight(contentBoxHeight);
+    boxGeometry.setContentBoxWidth(contentBoxWidth);
+}
+
 void InlineDisplayContentBuilder::appendInlineBoxDisplayBox(const Line::Run& lineRun, const InlineLevelBox& inlineBox, const InlineRect& inlineBoxBorderBox, bool linehasContent, DisplayBoxes& boxes)
 {
     ASSERT(lineRun.layoutBox().isInlineBox());
@@ -221,14 +238,7 @@
     }
 
     // This inline box showed up first on this line.
-    auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
-    auto logicalRect = Rect { LayoutPoint { inlineBoxBorderBox.topLeft() }, inlineBoxSize };
-    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
-    boxGeometry.setLogicalTopLeft(logicalRect.topLeft());
-    auto contentBoxHeight = logicalRect.height() - (boxGeometry.verticalBorder() + boxGeometry.verticalPadding().value_or(0_lu));
-    boxGeometry.setContentBoxHeight(contentBoxHeight);
-    auto contentBoxWidth = logicalRect.width() - (boxGeometry.horizontalBorder() + boxGeometry.horizontalPadding().value_or(0_lu));
-    boxGeometry.setContentBoxWidth(contentBoxWidth);
+    setInlineBoxGeometry(layoutBox, inlineBoxBorderBox, true);
 }
 
 void InlineDisplayContentBuilder::appendSpanningInlineBoxDisplayBox(const Line::Run& lineRun, const InlineLevelBox& inlineBox, const InlineRect& inlineBoxBorderBox, DisplayBoxes& boxes)
@@ -255,16 +265,8 @@
         , inlineBox.hasContent()
         , isFirstLastBox(inlineBox) });
 
-    auto inlineBoxSize = LayoutSize { LayoutUnit::fromFloatCeil(inlineBoxBorderBox.width()), LayoutUnit::fromFloatCeil(inlineBoxBorderBox.height()) };
-    auto logicalRect = Rect { LayoutPoint { inlineBoxBorderBox.topLeft() }, inlineBoxSize };
     // Middle or end of the inline box. Let's stretch the box as needed.
-    auto& boxGeometry = formattingState().boxGeometry(layoutBox);
-    auto enclosingBorderBoxRect = BoxGeometry::borderBoxRect(boxGeometry);
-    enclosingBorderBoxRect.expandToContain(logicalRect);
-    boxGeometry.setLogicalLeft(enclosingBorderBoxRect.left());
-
-    boxGeometry.setContentBoxHeight(enclosingBorderBoxRect.height() - (boxGeometry.verticalBorder() + boxGeometry.verticalPadding().value_or(0_lu)));
-    boxGeometry.setContentBoxWidth(enclosingBorderBoxRect.width() - (boxGeometry.horizontalBorder() + boxGeometry.horizontalPadding().value_or(0_lu)));
+    setInlineBoxGeometry(layoutBox, inlineBoxBorderBox, false);
 }
 
 void InlineDisplayContentBuilder::appendInlineBoxDisplayBoxForBidiBoundary(const Box& layoutBox, const InlineRect& inlineBoxRect, DisplayBoxes& boxes)

Modified: trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h (286444 => 286445)


--- trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h	2021-12-02 20:09:02 UTC (rev 286444)
+++ trunk/Source/WebCore/layout/formattingContexts/inline/InlineDisplayContentBuilder.h	2021-12-02 20:22:40 UTC (rev 286445)
@@ -58,6 +58,8 @@
     void appendInlineBoxDisplayBoxForBidiBoundary(const Box&, const InlineRect&, DisplayBoxes&);
     void adjustInlineBoxDisplayBoxForBidiBoundary(InlineDisplay::Box&, const InlineRect&);
 
+    void setInlineBoxGeometry(const Box&, const InlineRect&, bool isFirstInlineBoxFragment);
+
     const ContainerBox& root() const { return m_formattingContextRoot; }
     InlineFormattingState& formattingState() const { return m_formattingState; } 
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to