[LFC][IFC] Replaced inline boxes sit on the baseline with their margins
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Jun 2020 05:26:28 +0000 (05:26 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 28 Jun 2020 05:26:28 +0000 (05:26 +0000)
https://bugs.webkit.org/show_bug.cgi?id=213679

Reviewed by Antti Koivisto.

Source/WebCore:

Take the margin box into account when computing the top position of a baseline aligned replaced inline box.

Test: fast/layoutformattingcontext/replaced-box-with-margin-on-baseline.html

* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::alignContentVertically):

LayoutTests:

* fast/layoutformattingcontext/replaced-box-with-margin-on-baseline-expected.html: Added.
* fast/layoutformattingcontext/replaced-box-with-margin-on-baseline.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@263631 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/fast/layoutformattingcontext/replaced-box-with-margin-on-baseline-expected.html [new file with mode: 0644]
LayoutTests/fast/layoutformattingcontext/replaced-box-with-margin-on-baseline.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/layout/inlineformatting/InlineLineBuilder.cpp

index adf1f8e..ba96893 100644 (file)
@@ -1,3 +1,13 @@
+2020-06-27  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Replaced inline boxes sit on the baseline with their margins
+        https://bugs.webkit.org/show_bug.cgi?id=213679
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/replaced-box-with-margin-on-baseline-expected.html: Added.
+        * fast/layoutformattingcontext/replaced-box-with-margin-on-baseline.html: Added.
+
 2020-06-27  Mark Lam  <mark.lam@apple.com>
 
         Fix missing exception check in createIDBKeyFromValue().
diff --git a/LayoutTests/fast/layoutformattingcontext/replaced-box-with-margin-on-baseline-expected.html b/LayoutTests/fast/layoutformattingcontext/replaced-box-with-margin-on-baseline-expected.html
new file mode 100644 (file)
index 0000000..888281e
--- /dev/null
@@ -0,0 +1,19 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    width: 500px;
+    height: 365px; 
+    background-color: green;
+    font-size: 20px;
+}
+
+img {
+    width: 50px;
+    height: 50px;
+    position: relative;
+    top: -160px;
+    left: 5px;
+}
+</style>
+<div></div>
+<img src="../replaced/resources/square-blue-100x100.png">
diff --git a/LayoutTests/fast/layoutformattingcontext/replaced-box-with-margin-on-baseline.html b/LayoutTests/fast/layoutformattingcontext/replaced-box-with-margin-on-baseline.html
new file mode 100644 (file)
index 0000000..5611b37
--- /dev/null
@@ -0,0 +1,17 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+    width: 500px;
+    background-color: green;
+    font-size: 20px;
+}
+
+img {
+    margin-top: 200px;
+    margin-bottom: 100px;
+    border: 5px solid green;
+    width: 50px;
+    height: 50px;
+}
+</style>
+<div><img src="../replaced/resources/square-blue-100x100.png"></div>
index 3c9c634..bfb876a 100644 (file)
@@ -1,3 +1,17 @@
+2020-06-27  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][IFC] Replaced inline boxes sit on the baseline with their margins
+        https://bugs.webkit.org/show_bug.cgi?id=213679
+
+        Reviewed by Antti Koivisto.
+
+        Take the margin box into account when computing the top position of a baseline aligned replaced inline box.
+
+        Test: fast/layoutformattingcontext/replaced-box-with-margin-on-baseline.html
+
+        * layout/inlineformatting/InlineLineBuilder.cpp:
+        (WebCore::Layout::LineBuilder::alignContentVertically):
+
 2020-06-27  Mark Lam  <mark.lam@apple.com>
 
         Fix missing exception check in createIDBKeyFromValue().
index 7aec317..6ae3178 100644 (file)
@@ -173,8 +173,10 @@ void LineBuilder::alignContentVertically()
                 auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
                 auto baselineOffsetFromMarginBox = boxGeometry.marginBefore() + boxGeometry.borderTop() + boxGeometry.paddingTop().valueOr(0) + inlineBlockBaselineOffset;
                 logicalTop = baselineOffset() - baselineOffsetFromMarginBox;
-            } else
-                logicalTop = baselineOffset() - run.logicalRect().height();
+            } else {
+                auto& boxGeometry = formattingContext().geometryForBox(layoutBox);
+                logicalTop = baselineOffset() - (boxGeometry.verticalBorder() + boxGeometry.verticalPadding().valueOr(0_lu) + run.logicalRect().height() + boxGeometry.marginAfter());
+            }
             break;
         case VerticalAlign::Top:
             logicalTop = 0_lu;