Title: [272462] trunk/Source/WebCore
Revision
272462
Author
[email protected]
Date
2021-02-06 08:01:56 -0800 (Sat, 06 Feb 2021)

Log Message

[LFC][IFC][Quirk] Keep the root inline box baseline anchored at 0
https://bugs.webkit.org/show_bug.cgi?id=221517

Reviewed by Antti Koivisto.

In quirks mode when the root inline box has no content, a negative baseline value should not push the root baseline upwards.
e.g.
<div><span style="vertical-align: -300px">this text should be ~300px while the root baseline is at 0px</span></div>
However an inline box with negative ascent (e.g. large enough negative margin-top value) can pull the root inline box up.

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

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (272461 => 272462)


--- trunk/Source/WebCore/ChangeLog	2021-02-06 15:22:57 UTC (rev 272461)
+++ trunk/Source/WebCore/ChangeLog	2021-02-06 16:01:56 UTC (rev 272462)
@@ -1,5 +1,20 @@
 2021-02-06  Zalan Bujtas  <[email protected]>
 
+        [LFC][IFC][Quirk] Keep the root inline box baseline anchored at 0
+        https://bugs.webkit.org/show_bug.cgi?id=221517
+
+        Reviewed by Antti Koivisto.
+
+        In quirks mode when the root inline box has no content, a negative baseline value should not push the root baseline upwards.
+        e.g.
+        <div><span style="vertical-align: -300px">this text should be ~300px while the root baseline is at 0px</span></div>
+        However an inline box with negative ascent (e.g. large enough negative margin-top value) can pull the root inline box up.
+
+        * layout/inlineformatting/InlineFormattingContextGeometry.cpp:
+        (WebCore::Layout::LineBoxBuilder::computeLineBoxHeightAndAlignInlineLevelBoxesVertically):
+
+2021-02-06  Zalan Bujtas  <[email protected]>
+
         ASSERT NOT REACHED in WebCore::Layout::LineBuilder::candidateContentForLine
         https://bugs.webkit.org/show_bug.cgi?id=221492
         <rdar://problem/74032439>

Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp (272461 => 272462)


--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2021-02-06 15:22:57 UTC (rev 272461)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContextGeometry.cpp	2021-02-06 16:01:56 UTC (rev 272462)
@@ -545,8 +545,18 @@
             }
             inlineLevelBoxAbsoluteBaselineOffsetMap.add(inlineLevelBox.get(), absoluteBaselineOffset);
             auto affectsRootInlineBoxVerticalPosition = quirks.inlineLevelBoxAffectsLineBox(*inlineLevelBox, lineBox);
-            if (affectsRootInlineBoxVerticalPosition)
-                maximumTopOffsetFromRootInlineBoxBaseline = std::max(maximumTopOffsetFromRootInlineBoxBaseline.valueOr(std::numeric_limits<InlineLayoutUnit>::lowest()), absoluteBaselineOffset + inlineLevelBox->layoutBounds().ascent);
+            if (affectsRootInlineBoxVerticalPosition) {
+                auto topOffsetFromRootInlineBoxBaseline = absoluteBaselineOffset + inlineLevelBox->layoutBounds().ascent;
+                if (maximumTopOffsetFromRootInlineBoxBaseline)
+                    maximumTopOffsetFromRootInlineBoxBaseline = std::max(*maximumTopOffsetFromRootInlineBoxBaseline, topOffsetFromRootInlineBoxBaseline);
+                else {
+                    // We are is quirk mode and the root inline box has no content. The root inline box's baseline is anchored at 0.
+                    // However negative ascent (e.g negative top margin) can "push" the root inline box upwards and have a negative value.
+                    maximumTopOffsetFromRootInlineBoxBaseline = inlineLevelBox->layoutBounds().ascent >= 0
+                        ? std::max(0.0f, topOffsetFromRootInlineBoxBaseline)
+                        : topOffsetFromRootInlineBoxBaseline;
+                }
+            }
         }
         auto rootInlineBoxLogicalTop = maximumTopOffsetFromRootInlineBoxBaseline.valueOr(0.f) - rootInlineBox.baseline();
         rootInlineBox.setLogicalTop(rootInlineBoxLogicalTop);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to