[LFC][BFC][MarginCollapse] Replaced boxes don't collapse through their margins
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2019 16:44:41 +0000 (16:44 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 14 Feb 2019 16:44:41 +0000 (16:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=194622

Reviewed by Antti Koivisto.

Source/WebCore:

Ensure that block replaced boxes don't collapse through their vertical margins.

Test: fast/block/block-only/block-replaced-with-vertical-margins.html

* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::BlockFormattingContext::MarginCollapse::marginsCollapseThrough):
* page/FrameViewLayoutContext.cpp:
(WebCore::layoutUsingFormattingContext):

Tools:

* LayoutReloaded/misc/LFC-passing-tests.txt:

LayoutTests:

* fast/block/block-only/block-replaced-with-vertical-margins-expected.html: Added.
* fast/block/block-only/block-replaced-with-vertical-margins.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/block-only/block-replaced-with-vertical-margins-expected.html [new file with mode: 0644]
LayoutTests/fast/block/block-only/block-replaced-with-vertical-margins.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp
Tools/ChangeLog
Tools/LayoutReloaded/misc/LFC-passing-tests.txt

index cf31286..32bd451 100644 (file)
@@ -1,3 +1,13 @@
+2019-02-14  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][BFC][MarginCollapse] Replaced boxes don't collapse through their margins
+        https://bugs.webkit.org/show_bug.cgi?id=194622
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/block-only/block-replaced-with-vertical-margins-expected.html: Added.
+        * fast/block/block-only/block-replaced-with-vertical-margins.html: Added.
+
 2019-02-13  Ryosuke Niwa  <rniwa@webkit.org>
 
         Crash in DOMTimer::fired
diff --git a/LayoutTests/fast/block/block-only/block-replaced-with-vertical-margins-expected.html b/LayoutTests/fast/block/block-only/block-replaced-with-vertical-margins-expected.html
new file mode 100644 (file)
index 0000000..779a44e
--- /dev/null
@@ -0,0 +1,16 @@
+<style>
+.first {
+    width: 100px;
+    margin-top: 100px;
+    outline: 5px solid blue;
+}
+
+.second {
+    width: 100px;
+    height: 100px;
+    outline: 5px solid blue;
+    position: relative;
+    top: 20px
+}
+</style>
+<div class=first></div><div class=second></div>
\ No newline at end of file
diff --git a/LayoutTests/fast/block/block-only/block-replaced-with-vertical-margins.html b/LayoutTests/fast/block/block-only/block-replaced-with-vertical-margins.html
new file mode 100644 (file)
index 0000000..d3e021d
--- /dev/null
@@ -0,0 +1,19 @@
+<style>
+img {
+    display: block;
+    height: 0px;
+    min-height: 0px;
+    width: 100px;
+    margin-top: 100px;
+    margin-bottom: 10px;
+    outline: 5px solid blue;
+}
+
+div {
+    width: 100px;
+    height: 100px;
+    margin-top: 20px;
+    outline: 5px solid blue;
+}
+</style>
+<img src="foobar.jpg"><div></div>
\ No newline at end of file
index afec57a..5282495 100644 (file)
@@ -1,5 +1,21 @@
 2019-02-14  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][BFC][MarginCollapse] Replaced boxes don't collapse through their margins
+        https://bugs.webkit.org/show_bug.cgi?id=194622
+
+        Reviewed by Antti Koivisto.
+
+        Ensure that block replaced boxes don't collapse through their vertical margins. 
+
+        Test: fast/block/block-only/block-replaced-with-vertical-margins.html
+
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginsCollapseThrough):
+        * page/FrameViewLayoutContext.cpp:
+        (WebCore::layoutUsingFormattingContext):
+
+2019-02-14  Zalan Bujtas  <zalan@apple.com>
+
         [LFC] Shrink-to-fit-width should be constrained by min/max width
         https://bugs.webkit.org/show_bug.cgi?id=194653
 
index fc9ef81..00e0a0f 100644 (file)
@@ -392,6 +392,10 @@ bool BlockFormattingContext::MarginCollapse::marginsCollapseThrough(const Layout
     if (!layoutBox.style().minHeight().isAuto())
         return false;
 
+    // FIXME: Block replaced boxes clearly don't collapse through their margins, but I couldn't find it in the spec yet (and no, it's not a quirk).
+    if (layoutBox.isReplaced())
+        return false;
+
     if (!is<Container>(layoutBox))
         return true;
 
index bf1fc0c..9cd8fc0 100644 (file)
@@ -1,5 +1,14 @@
 2019-02-14  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][BFC][MarginCollapse] Replaced boxes don't collapse through their margins
+        https://bugs.webkit.org/show_bug.cgi?id=194622
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
+2019-02-14  Zalan Bujtas  <zalan@apple.com>
+
         [LFC] Shrink-to-fit-width should be constrained by min/max width
         https://bugs.webkit.org/show_bug.cgi?id=194653
 
index a5d5924..996dd33 100644 (file)
@@ -43,6 +43,7 @@ fast/block/block-only/absolute-width-shrink-to-fit.html
 fast/block/block-only/absolute-width-stretch.html
 fast/block/block-only/absolute-with-static-block-position-nested.html
 fast/block/block-only/almost-intruding-left-float-simple.html
+fast/block/block-only/block-replaced-with-vertical-margins.html
 fast/block/block-only/body-height-with-auto-html-height-quirk2.html
 fast/block/block-only/body-height-with-auto-html-height-quirk.html
 fast/block/block-only/body-height-with-non-auto-html-height-quirk2.html