Title: [268985] trunk/Source/WebCore
Revision
268985
Author
za...@apple.com
Date
2020-10-26 10:52:23 -0700 (Mon, 26 Oct 2020)

Log Message

[LFC][Integration] Account for margin start when setting the renderer's border box location
https://bugs.webkit.org/show_bug.cgi?id=218190

Reviewed by Antti Koivisto.

After r268950 replaced runs start at the margin box logical left. Let's offset the border box
location with the margin value.

* layout/inlineformatting/InlineLine.cpp:
(WebCore::Layout::Line::appendInlineContainerStart): <span> should take negative margins into account as well.
(WebCore::Layout::Line::appendNonReplacedInlineBox): rename.
* layout/integration/LayoutIntegrationLineLayout.cpp:
(WebCore::LayoutIntegration::LineLayout::constructContent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (268984 => 268985)


--- trunk/Source/WebCore/ChangeLog	2020-10-26 17:49:27 UTC (rev 268984)
+++ trunk/Source/WebCore/ChangeLog	2020-10-26 17:52:23 UTC (rev 268985)
@@ -1,3 +1,19 @@
+2020-10-26  Zalan Bujtas  <za...@apple.com>
+
+        [LFC][Integration] Account for margin start when setting the renderer's border box location
+        https://bugs.webkit.org/show_bug.cgi?id=218190
+
+        Reviewed by Antti Koivisto.
+
+        After r268950 replaced runs start at the margin box logical left. Let's offset the border box
+        location with the margin value.
+
+        * layout/inlineformatting/InlineLine.cpp:
+        (WebCore::Layout::Line::appendInlineContainerStart): <span> should take negative margins into account as well.
+        (WebCore::Layout::Line::appendNonReplacedInlineBox): rename.
+        * layout/integration/LayoutIntegrationLineLayout.cpp:
+        (WebCore::LayoutIntegration::LineLayout::constructContent):
+
 2020-10-26  Youenn Fablet  <you...@apple.com>
 
         Use a WeakHashSet for Document::m_captionPreferencesChangedElements

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp (268984 => 268985)


--- trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2020-10-26 17:49:27 UTC (rev 268984)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLine.cpp	2020-10-26 17:52:23 UTC (rev 268985)
@@ -244,7 +244,9 @@
 void Line::appendInlineContainerStart(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
 {
     // This is really just a placeholder to mark the start of the inline level container <span>.
-    appendNonBreakableSpace(inlineItem, contentLogicalWidth(), logicalWidth);
+    auto& boxGeometry = formattingContext().geometryForBox(inlineItem.layoutBox());
+    auto adjustedRunStart = contentLogicalWidth() + std::min(boxGeometry.marginStart(), 0_lu);
+    appendNonBreakableSpace(inlineItem, adjustedRunStart, logicalWidth);
 }
 
 void Line::appendInlineContainerEnd(const InlineItem& inlineItem, InlineLayoutUnit logicalWidth)
@@ -318,8 +320,8 @@
 {
     auto& boxGeometry = formattingContext().geometryForBox(inlineItem.layoutBox());
     // Negative margin start pulls the content to the logical left direction.
-    auto adjustedContentStart = contentLogicalWidth() + std::min(boxGeometry.marginStart(), 0_lu);
-    m_runs.append({ inlineItem, adjustedContentStart, logicalWidth });
+    auto adjustedRunStart = contentLogicalWidth() + std::min(boxGeometry.marginStart(), 0_lu);
+    m_runs.append({ inlineItem, adjustedRunStart, logicalWidth });
     m_contentLogicalWidth += logicalWidth;
     m_trimmableTrailingContent.reset();
     m_trailingSoftHyphenWidth = { };

Modified: trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp (268984 => 268985)


--- trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-10-26 17:49:27 UTC (rev 268984)
+++ trunk/Source/WebCore/layout/integration/LayoutIntegrationLineLayout.cpp	2020-10-26 17:52:23 UTC (rev 268985)
@@ -205,7 +205,8 @@
 
             if (layoutBox.isReplacedBox()) {
                 auto& renderer = downcast<RenderBox>(m_boxTree.rendererForLayoutBox(layoutBox));
-                auto borderBoxLocation = FloatPoint { runRect.x(), runRect.y() + m_layoutState.geometryForBox(layoutBox).marginBefore() };
+                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));
             }
         }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to