[LFC] Float prev/next sibling should prevent top/bottom margin collapsing with parent.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Aug 2018 15:46:44 +0000 (15:46 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sun, 12 Aug 2018 15:46:44 +0000 (15:46 +0000)
https://bugs.webkit.org/show_bug.cgi?id=188487

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/block/block-only/floating-and-next-previous-inflow-with-margin.html

* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::isMarginTopCollapsedWithParent):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent):

Tools:

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

LayoutTests:

* fast/block/block-only/floating-and-next-previous-inflow-with-margin-expected.txt: Added.
* fast/block/block-only/floating-and-next-previous-inflow-with-margin.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin.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 d4e6fed..932161c 100644 (file)
@@ -1,3 +1,13 @@
+2018-08-12  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Float prev/next sibling should prevent top/bottom margin collapsing with parent.
+        https://bugs.webkit.org/show_bug.cgi?id=188487
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/block-only/floating-and-next-previous-inflow-with-margin-expected.txt: Added.
+        * fast/block/block-only/floating-and-next-previous-inflow-with-margin.html: Added.
+
 2018-08-10  Joseph Pecoraro  <pecoraro@apple.com>
 
         Web Inspector: console.log fires getters for deep properties
diff --git a/LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-expected.txt b/LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin-expected.txt
new file mode 100644 (file)
index 0000000..cc64dba
--- /dev/null
@@ -0,0 +1,10 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x118
+  RenderBlock {HTML} at (0,0) size 800x118
+    RenderBody {BODY} at (8,8) size 784x102
+      RenderBlock {DIV} at (0,0) size 102x102 [border: (1px solid #000000)]
+        RenderBlock (floating) {DIV} at (1,1) size 12x12 [border: (1px solid #000000)]
+        RenderBlock {DIV} at (1,21) size 12x12 [border: (1px solid #000000)]
+        RenderBlock {DIV} at (1,33) size 12x12 [border: (1px solid #000000)]
+        RenderBlock (floating) {DIV} at (1,65) size 12x12 [border: (1px solid #000000)]
diff --git a/LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin.html b/LayoutTests/fast/block/block-only/floating-and-next-previous-inflow-with-margin.html
new file mode 100644 (file)
index 0000000..db7b075
--- /dev/null
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+div {
+       border: 1px solid black;
+       width: 10px;
+       height: 10px;
+}
+</style>
+</head>
+<body>
+<div style="width: 100px; height: 100px;">
+    <div style="float: left;"></div>
+    <div style="margin-top: 20px;"></div>
+    <div style="margin-bottom: 20px;"></div>
+    <div style="float: left;"></div>
+</div>
+</body>
+</html>
index c84face..3aee6be 100644 (file)
@@ -1,3 +1,16 @@
+2018-08-12  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Float prev/next sibling should prevent top/bottom margin collapsing with parent.
+        https://bugs.webkit.org/show_bug.cgi?id=188487
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/block/block-only/floating-and-next-previous-inflow-with-margin.html
+
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::isMarginTopCollapsedWithParent):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent):
+
 2018-08-10  Antti Koivisto  <antti@apple.com>
 
         Use OptionSet for various RenderLayer flags
index d7c0a83..8610f1b 100644 (file)
@@ -97,8 +97,8 @@ static bool isMarginTopCollapsedWithParent(const LayoutContext& layoutContext, c
     // We never margin collapse the initial containing block.
     ASSERT(layoutBox.parent());
     auto& parent = *layoutBox.parent();
-    // Is this box the first inlflow child?
-    if (parent.firstInFlowChild() != &layoutBox)
+    // Only the first inlflow child collapses with parent (floating sibling also prevents collapsing). 
+    if (layoutBox.previousInFlowOrFloatingSibling())
         return false;
 
     if (parent.establishesBlockFormattingContext())
@@ -274,8 +274,8 @@ bool BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(c
     // We never margin collapse the initial containing block.
     ASSERT(layoutBox.parent());
     auto& parent = *layoutBox.parent();
-    // Is this the last inlflow child?
-    if (parent.lastInFlowChild() != &layoutBox)
+    // Only the last inlflow child collapses with parent (floating sibling also prevents collapsing). 
+    if (layoutBox.nextInFlowOrFloatingSibling())
         return false;
 
     if (parent.establishesBlockFormattingContext())
index bd75e20..76e7a2c 100644 (file)
@@ -1,3 +1,12 @@
+2018-08-12  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC] Float prev/next sibling should prevent top/bottom margin collapsing with parent.
+        https://bugs.webkit.org/show_bug.cgi?id=188487
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2018-08-11  Aakash Jain  <aakash_jain@apple.com>
 
         [ews-build] Separate queues for Builders and Testers - iOS
index 72d352a..45b2f64 100644 (file)
@@ -46,3 +46,4 @@ fast/block/block-only/floating-lefts-and-rights-simple.html
 fast/block/block-only/floating-multiple-lefts-in-body.html
 fast/block/block-only/floating-multiple-lefts-multiple-lines.html
 fast/block/block-only/floating-multiple-lefts.html
+fast/block/block-only/floating-and-next-previous-inflow-with-margin.html