Title: [273723] trunk/Source/WebCore
Revision
273723
Author
[email protected]
Date
2021-03-01 21:00:55 -0800 (Mon, 01 Mar 2021)

Log Message

[LFC][IFC] Move simplified baseline alignment to a dedicated function
https://bugs.webkit.org/show_bug.cgi?id=222564

Reviewed by Antti Koivisto.

This is in preparation for supporting non-atomic inline level boxes.

* layout/inlineformatting/InlineFormattingContextGeometry.cpp:
(WebCore::Layout::LineBoxBuilder::simplifiedAlignInlineBoxIfApplicable const):
(WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273722 => 273723)


--- trunk/Source/WebCore/ChangeLog	2021-03-02 04:21:47 UTC (rev 273722)
+++ trunk/Source/WebCore/ChangeLog	2021-03-02 05:00:55 UTC (rev 273723)
@@ -1,5 +1,18 @@
 2021-03-01  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] Move simplified baseline alignment to a dedicated function
+        https://bugs.webkit.org/show_bug.cgi?id=222564
+
+        Reviewed by Antti Koivisto.
+
+        This is in preparation for supporting non-atomic inline level boxes.
+
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        (WebCore::Layout::LineBoxBuilder::simplifiedAlignInlineBoxIfApplicable const):
+        (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
+
+2021-03-01  Zalan Bujtas  <[email protected]>
+
         [LFC][IFC] Move simplified vertical alignment computation to struct SimplifiedVerticalAlignment
         https://bugs.webkit.org/show_bug.cgi?id=222562
 

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (273722 => 273723)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2021-03-02 04:21:47 UTC (rev 273722)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2021-03-02 05:00:55 UTC (rev 273723)
@@ -211,6 +211,27 @@
     InlineLayoutUnit rootInlineBoxLogicalTop() const { return m_rootInlineBoxLogicalTop; }
     InlineLayoutUnit lineBoxHeight() const { return m_lineBoxLogicalBottom - m_lineBoxLogicalTop; }
 
+    bool alignInlineLevelBoxIfApplicable(LineBox::InlineLevelBox& inlineLevelBox, const BoxGeometry& inlineLevelBoxGeometry)
+    {
+        if (inlineLevelBox.isAtomicInlineLevelBox()) {
+            // Baseline aligned, non-stretchy direct children are considered to be simple for now.
+            auto& layoutBox = inlineLevelBox.layoutBox();
+            auto isConsideredSimple = &layoutBox.parent() == &m_rootInlineBox.layoutBox()
+                && layoutBox.style().verticalAlign() == VerticalAlign::Baseline
+                && !inlineLevelBoxGeometry.marginBefore()
+                && !inlineLevelBoxGeometry.marginAfter()
+                && inlineLevelBoxGeometry.marginBoxHeight() <= m_rootInlineBox.baseline();
+            if (!isConsideredSimple)
+                return false;
+            // Only baseline alignment for now.
+            inlineLevelBox.setLogicalTop(m_rootInlineBox.baseline() - inlineLevelBox.baseline());
+            adjust(inlineLevelBox);
+            return true;
+        }
+        ASSERT_NOT_IMPLEMENTED_YET();
+        return false;
+    }
+private:
     void adjust(const LineBox::InlineLevelBox& inlineLevelBox)
     {
         auto layoutBoundsLogicalTop = m_rootInlineBox.layoutBounds().ascent - inlineLevelBox.layoutBounds().ascent;
@@ -219,7 +240,6 @@
         m_rootInlineBoxLogicalTop = std::max(m_rootInlineBoxLogicalTop, inlineLevelBox.layoutBounds().ascent - m_rootInlineBox.baseline());
     }
 
-private:
     const LineBox::InlineLevelBox& m_rootInlineBox;
 
     InlineLayoutUnit m_lineBoxLogicalTop { 0 };
@@ -226,6 +246,7 @@
     InlineLayoutUnit m_lineBoxLogicalBottom { 0 };
     InlineLayoutUnit m_rootInlineBoxLogicalTop { 0 };
 };
+
 void LineBoxBuilder::constructInlineLevelBoxes(LineBox& lineBox, const Line::RunList& runs)
 {
     auto& rootInlineBox = lineBox.rootInlineBox();
@@ -317,26 +338,10 @@
             auto atomicInlineLevelBox = LineBox::InlineLevelBox::createAtomicInlineLevelBox(layoutBox, logicalLeft, { inlineLevelBoxGeometry.borderBoxWidth(), marginBoxHeight });
             atomicInlineLevelBox->setBaseline(ascent);
             atomicInlineLevelBox->setLayoutBounds(LineBox::InlineLevelBox::LayoutBounds { ascent, marginBoxHeight - ascent });
-            // Let's pre-compute the logical top so that we can avoid running the alignment on simple inline boxes.
-            auto alignInlineBoxIfEligible = [&] {
-                if (!m_useSimplifiedVerticalAlignment)
-                    return;
-                // Baseline aligned, non-stretchy direct children are considered to be simple for now.
-                auto isConsideredSimple = &layoutBox.parent() == &rootBox()
-                    && layoutBox.style().verticalAlign() == VerticalAlign::Baseline
-                    && !inlineLevelBoxGeometry.marginBefore()
-                    && !inlineLevelBoxGeometry.marginAfter()
-                    && marginBoxHeight <= rootInlineBox.baseline();
-                if (!isConsideredSimple) {
-                    m_useSimplifiedVerticalAlignment = false;
-                    return;
-                }
-                // Only baseline alignment for now.
-                auto logicalTop = rootInlineBox.baseline() - ascent;
-                atomicInlineLevelBox->setLogicalTop(logicalTop);
-                simplifiedVerticalAlignment.adjust(*atomicInlineLevelBox);
-            };
-            alignInlineBoxIfEligible();
+            if (m_useSimplifiedVerticalAlignment) {
+                // Let's pre-compute the logical top so that we can avoid running the alignment on simple inline level boxes.
+                m_useSimplifiedVerticalAlignment = simplifiedVerticalAlignment.alignInlineLevelBoxIfApplicable(*atomicInlineLevelBox, inlineLevelBoxGeometry);
+            }
             lineBox.addInlineLevelBox(WTFMove(atomicInlineLevelBox));
             continue;
         }

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h (273722 => 273723)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2021-03-02 04:21:47 UTC (rev 273722)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBox.h	2021-03-02 05:00:55 UTC (rev 273723)
@@ -39,6 +39,7 @@
 class BoxGeometry;
 class InlineFormattingContext;
 class LineBoxBuilder;
+struct SimplifiedVerticalAlignment;
 
 //   ____________________________________________________________ Line Box
 // |                                    --------------------
@@ -103,6 +104,7 @@
         InlineLevelBox() = default;
 
     private:
+        friend struct SimplifiedVerticalAlignment;
         friend class LineBoxBuilder;
         friend class LineBox;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to