Title: [271566] trunk/Source/WebCore
Revision
271566
Author
[email protected]
Date
2021-01-17 16:06:28 -0800 (Sun, 17 Jan 2021)

Log Message

[LFC][IFC] Add the root inline collapsing case to simplified vertical alignment
https://bugs.webkit.org/show_bug.cgi?id=220685

Reviewed by Antti Koivisto.

Let's produce a 0 height line box when there are no runs on the line as part of the simplified vertical alignment optimization.

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (271565 => 271566)


--- trunk/Source/WebCore/ChangeLog	2021-01-17 23:51:38 UTC (rev 271565)
+++ trunk/Source/WebCore/ChangeLog	2021-01-18 00:06:28 UTC (rev 271566)
@@ -1,3 +1,15 @@
+2021-01-17  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Add the root inline collapsing case to simplified vertical alignment
+        https://bugs.webkit.org/show_bug.cgi?id=220685
+
+        Reviewed by Antti Koivisto.
+
+        Let's produce a 0 height line box when there are no runs on the line as part of the simplified vertical alignment optimization.
+
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        (WebCore::Layout::LineBoxBuilder::constructInlineLevelBoxes):
+
 2021-01-17  Wenson Hsieh  <[email protected]>
 
         Unreviewed, fix the internal iOS build after r271559

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (271565 => 271566)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2021-01-17 23:51:38 UTC (rev 271565)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2021-01-18 00:06:28 UTC (rev 271566)
@@ -211,16 +211,21 @@
         InlineLayoutUnit rootInlineBoxLogicalTop { 0 };
     };
     auto simplifiedVerticalAlignment = SimplifiedVerticalAlignment { };
-    // Empty root inline boxes require special collapsing.
-    m_inlineLevelBoxesNeedVerticalAlignment = m_inlineLevelBoxesNeedVerticalAlignment || runs.isEmpty();
 
     auto createRootInlineBox = [&] {
         auto rootInlineBox = LineBox::InlineLevelBox::createRootInlineBox(rootBox(), horizontalAligmentOffset, lineBox.logicalWidth());
         setVerticalGeometryForInlineBox(*rootInlineBox);
-        simplifiedVerticalAlignment = { { } , rootInlineBox->layoutBounds().height(), rootInlineBox->layoutBounds().ascent - rootInlineBox->baseline() };
         lineBox.addRootInlineBox(WTFMove(rootInlineBox));
     };
     createRootInlineBox();
+    // Set the initial simplified vertical alignment if applicable.
+    auto& rootInlineBox = lineBox.rootInlineBox();
+    if (!m_inlineLevelBoxesNeedVerticalAlignment) {
+        auto lineHasNoContent = runs.isEmpty();
+        auto lineBoxBottom = lineHasNoContent ? InlineLayoutUnit(0.0f) : rootInlineBox.layoutBounds().height();
+        auto rootInlineBoxLogicalTop = lineHasNoContent ? -rootInlineBox.baseline() : rootInlineBox.layoutBounds().ascent - rootInlineBox.baseline();
+        simplifiedVerticalAlignment = { { }, lineBoxBottom, rootInlineBoxLogicalTop };
+    }
 
     auto createWrappedInlineBoxes = [&] {
         if (runs.isEmpty())
@@ -257,7 +262,6 @@
         }
     };
     createWrappedInlineBoxes();
-    auto& rootInlineBox = lineBox.rootInlineBox();
     for (auto& run : runs) {
         auto& layoutBox = run.layoutBox();
         auto logicalLeft = horizontalAligmentOffset + run.logicalLeft();
@@ -288,7 +292,7 @@
             auto atomicInlineLevelBox = LineBox::InlineLevelBox::createAtomicInlineLevelBox(layoutBox, logicalLeft, { run.logicalWidth(), marginBoxHeight });
             atomicInlineLevelBox->setBaseline(ascent);
             atomicInlineLevelBox->setLayoutBounds(LineBox::InlineLevelBox::LayoutBounds { ascent, marginBoxHeight - ascent });
-            // Let's estimate the logical top so that we can avoid running the alignment on simple inline boxes.
+            // Let's pre-compute the logical top so that we can avoid running the alignment on simple inline boxes.
             auto alignInlineBoxIfEligible = [&] {
                 if (m_inlineLevelBoxesNeedVerticalAlignment)
                     return;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to