Title: [269817] trunk/Source/WebCore
Revision
269817
Author
[email protected]
Date
2020-11-14 07:26:56 -0800 (Sat, 14 Nov 2020)

Log Message

[LFC][IFC] Display runs generated by boxes should have border box geometries
https://bugs.webkit.org/show_bug.cgi?id=218932

Reviewed by Antti Koivisto.

Layout::Runs/InlineBoxes have margin box geometries, but the Display::Runs should preserve border box instead.
This is mostly interesting in the context of negative vertical margins where such margin values could make the run "empty".

* layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
(WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const):
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::constructContent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (269816 => 269817)


--- trunk/Source/WebCore/ChangeLog	2020-11-14 13:53:44 UTC (rev 269816)
+++ trunk/Source/WebCore/ChangeLog	2020-11-14 15:26:56 UTC (rev 269817)
@@ -1,5 +1,20 @@
 2020-11-14  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC] Display runs generated by boxes should have border box geometries
+        https://bugs.webkit.org/show_bug.cgi?id=218932
+
+        Reviewed by Antti Koivisto.
+
+        Layout::Runs/InlineBoxes have margin box geometries, but the Display::Runs should preserve border box instead.
+        This is mostly interesting in the context of negative vertical margins where such margin values could make the run "empty".
+
+        * layout/integration/LayoutIntegrationInlineContentBuilder.cpp:
+        (WebCore::LayoutIntegration::InlineContentBuilder::createDisplayLineRuns const):
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::constructContent):
+
+2020-11-14  Zalan Bujtas  <[email protected]>
+
         [LFC][IFC] Inline level box with negative vertical margin should not be considered empty
         https://bugs.webkit.org/show_bug.cgi?id=218933
 

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp (269816 => 269817)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp	2020-11-14 13:53:44 UTC (rev 269816)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationInlineContentBuilder.cpp	2020-11-14 15:26:56 UTC (rev 269817)
@@ -210,17 +210,21 @@
     Vector<bool> hasAdjustedTrailingLineList(lines.size(), false);
 
     auto createDisplayBoxRun = [&](auto& lineRun) {
+        auto& layoutBox = lineRun.layoutBox();
         auto lineIndex = lineRun.lineIndex();
         auto& line = lines[lineIndex];
         // Inline boxes are relative to the line box while final Runs need to be relative to the parent Box
         // FIXME: Shouldn't we just leave them be relative to the line box?
         auto runRect = FloatRect { lineRun.logicalRect() };
-        runRect.moveBy({ line.logicalLeft(), line.logicalTop() });
+        // Line runs are margin box based, let's convert them to border box.
+        auto& geometry = m_layoutState.geometryForBox(layoutBox);
+        runRect.moveBy({ line.logicalLeft() + std::max(geometry.marginStart(), 0_lu), line.logicalTop() + geometry.marginBefore() });
+        runRect.setSize({ geometry.borderBoxWidth(), geometry.borderBoxHeight() });
         if (lineLevelVisualAdjustmentsForRuns[lineIndex].needsIntegralPosition)
             runRect.setY(roundToInt(runRect.y()));
         // FIXME: Add support for non-text ink overflow.
         // FIXME: Add support for cases when the run is after ellipsis.
-        inlineContent.runs.append({ lineIndex, lineRun.layoutBox(), runRect, runRect, { }, { } });
+        inlineContent.runs.append({ lineIndex, layoutBox, runRect, runRect, { }, { } });
     };
 
     auto createDisplayTextRunForRange = [&](auto& lineRun, auto startOffset, auto endOffset) {

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (269816 => 269817)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-11-14 13:53:44 UTC (rev 269816)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-11-14 15:26:56 UTC (rev 269817)
@@ -154,11 +154,8 @@
         if (!layoutBox.isReplacedBox())
             continue;
 
-        auto& runRect = run.rect();
         auto& renderer = downcast<RenderBox>(m_boxTree.rendererForLayoutBox(layoutBox));
-        auto& boxGeometry = m_layoutState.geometryForBox(layoutBox);
-        auto borderBoxLocation = FloatPoint { runRect.x() + std::max(boxGeometry.marginStart(), 0_lu), runRect.y() + boxGeometry.marginBefore() };
-        renderer.setLocation(flooredLayoutPoint(borderBoxLocation));
+        renderer.setLocation(flooredLayoutPoint(run.rect().location()));
     }
 
     m_inlineContent->clearGapAfterLastLine = m_inlineFormattingState.clearGapAfterLastLine();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to