Title: [267437] trunk/Source/WebCore
Revision
267437
Author
[email protected]
Date
2020-09-22 14:45:32 -0700 (Tue, 22 Sep 2020)

Log Message

[LFC][IFC] Atomic inline-level box with margin is mispositioned
https://bugs.webkit.org/show_bug.cgi?id=216842

Reviewed by Antti Koivisto.

The inline box that an atomic inline-level box generates has the height of the margin box. Therefore the inline box's logical top position
is the position of the top edge of the margin box.
When converting the inline box geometry back to the layout box, we need to offset the top position (border box top edge)
with the value of the used margin before.

* layout/inlineformatting/InlineFormattingContext.cpp:
(WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (267436 => 267437)


--- trunk/Source/WebCore/ChangeLog	2020-09-22 20:47:07 UTC (rev 267436)
+++ trunk/Source/WebCore/ChangeLog	2020-09-22 21:45:32 UTC (rev 267437)
@@ -1,3 +1,18 @@
+2020-09-22  Zalan Bujtas  <[email protected]>
+
+        [LFC][IFC] Atomic inline-level box with margin is mispositioned
+        https://bugs.webkit.org/show_bug.cgi?id=216842
+
+        Reviewed by Antti Koivisto.
+
+        The inline box that an atomic inline-level box generates has the height of the margin box. Therefore the inline box's logical top position
+        is the position of the top edge of the margin box.
+        When converting the inline box geometry back to the layout box, we need to offset the top position (border box top edge)
+        with the value of the used margin before.
+
+        * layout/inlineformatting/InlineFormattingContext.cpp:
+        (WebCore::Layout::InlineFormattingContext::computeGeometryForLineContent):
+
 2020-09-22  Chris Dumez  <[email protected]>
 
         AudioParam.setValueCurveAtTime() should have an implicit call to setValueAtTime() at the end

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (267436 => 267437)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-09-22 20:47:07 UTC (rev 267436)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp	2020-09-22 21:45:32 UTC (rev 267437)
@@ -444,15 +444,16 @@
                 continue;
             }
             auto& boxGeometry = formattingState.boxGeometry(layoutBox);
-            auto logicalTopLeft = inlineBox->logicalRect().topLeft();
+            auto marginBoxLogicalTopLeft = inlineBox->logicalRect().topLeft();
+            auto borderBoxLogicalTopLeft = marginBoxLogicalTopLeft + InlineLayoutSize({ }, boxGeometry.marginBefore());
 
-            logicalTopLeft.move({ }, lineBoxVerticalOffset);
+            borderBoxLogicalTopLeft.move({ }, lineBoxVerticalOffset);
             if (layoutBox.isInFlowPositioned())
-                logicalTopLeft += geometry.inFlowPositionedPositionOffset(layoutBox, horizontalConstraints);
+                borderBoxLogicalTopLeft += geometry.inFlowPositionedPositionOffset(layoutBox, horizontalConstraints);
 
             if (layoutBox.isAtomicInlineLevelBox()) {
                 // Atomic inline boxes are all set. Their margin/border/content box geometries are already computed. We just have to position them here.
-                boxGeometry.setLogicalTopLeft(toLayoutPoint(logicalTopLeft));
+                boxGeometry.setLogicalTopLeft(toLayoutPoint(borderBoxLogicalTopLeft));
                 continue;
             }
             auto marginBoxWidth = inlineBox->logicalWidth();
@@ -462,13 +463,13 @@
             auto isSpanningInlineBox = previousLineIndex > 0 && formattingState.lineBoxes()[previousLineIndex].containsInlineLevelBox(layoutBox);
             if (!isSpanningInlineBox) {
                 // This box showed up on this line the first time.
-                boxGeometry.setLogicalTopLeft(toLayoutPoint(logicalTopLeft));
+                boxGeometry.setLogicalTopLeft(toLayoutPoint(borderBoxLogicalTopLeft));
                 boxGeometry.setContentBoxWidth(toLayoutUnit(contentBoxWidth));
                 boxGeometry.setContentBoxHeight(toLayoutUnit(inlineBox->logicalHeight()));
                 continue;
             }
             // This is a just a simple box geometry for the line spanning inline box. getBoundingClientRect looks into each line boxes (will turn into fragmented boxes).
-            boxGeometry.setLogicalLeft(std::min(boxGeometry.logicalLeft(), toLayoutUnit(logicalTopLeft.x())));
+            boxGeometry.setLogicalLeft(std::min(boxGeometry.logicalLeft(), toLayoutUnit(borderBoxLogicalTopLeft.x())));
             boxGeometry.setContentBoxWidth(std::max(toLayoutUnit(contentBoxWidth), boxGeometry.contentBoxWidth()));
             boxGeometry.setContentBoxHeight(boxGeometry.contentBoxHeight() + toLayoutUnit(inlineBox->logicalHeight()));
         }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to