[LFC][BFC][MarginCollapsing] Collapsing through should not ignore floats.
authorzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2019 14:42:46 +0000 (14:42 +0000)
committerzalan@apple.com <zalan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 18 Jan 2019 14:42:46 +0000 (14:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193564

Reviewed by Antti Koivisto.

Source/WebCore:

Float boxes prevent collapsing through.

Test: fast/block/float/float-in-descendant-formatting-context.html

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

Tools:

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

LayoutTests:

* fast/block/float/float-in-descendant-formatting-context-expected.txt: Added.
* fast/block/float/float-in-descendant-formatting-context.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/block/float/float-in-descendant-formatting-context-expected.txt [new file with mode: 0644]
LayoutTests/fast/block/float/float-in-descendant-formatting-context.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 3c8324a..cbcbd31 100644 (file)
@@ -1,3 +1,13 @@
+2019-01-18  Zalan Bujtas  <zalan@apple.com>
+
+        [LFC][BFC][MarginCollapsing] Collapsing through should not ignore floats.
+        https://bugs.webkit.org/show_bug.cgi?id=193564
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/float/float-in-descendant-formatting-context-expected.txt: Added.
+        * fast/block/float/float-in-descendant-formatting-context.html: Added.
+
 2019-01-17  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS] Content offset jumps erratically when autoscrolling near scroll view content inset areas
diff --git a/LayoutTests/fast/block/float/float-in-descendant-formatting-context-expected.txt b/LayoutTests/fast/block/float/float-in-descendant-formatting-context-expected.txt
new file mode 100644 (file)
index 0000000..bc9c3ae
--- /dev/null
@@ -0,0 +1,9 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x26
+  RenderBlock {HTML} at (0,0) size 800x26
+    RenderBody {BODY} at (8,8) size 784x10
+layer at (8,8) size 784x10
+  RenderBlock {DIV} at (0,0) size 784x10
+    RenderInline {SPAN} at (0,0) size 0x0
+    RenderBlock (floating) {DIV} at (0,0) size 10x10
diff --git a/LayoutTests/fast/block/float/float-in-descendant-formatting-context.html b/LayoutTests/fast/block/float/float-in-descendant-formatting-context.html
new file mode 100644 (file)
index 0000000..51eff50
--- /dev/null
@@ -0,0 +1,6 @@
+<!DOCTYPE html>
+<html>
+<body>
+<div style="overflow: hidden"><span></span><div style="float: left; width: 10px; height: 10px;"></div></div>
+</body>
+</html>
\ No newline at end of file
index c6ae827..c9b21f2 100644 (file)
@@ -1,5 +1,19 @@
 2019-01-18  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][BFC][MarginCollapsing] Collapsing through should not ignore floats.
+        https://bugs.webkit.org/show_bug.cgi?id=193564
+
+        Reviewed by Antti Koivisto.
+
+        Float boxes prevent collapsing through.
+
+        Test: fast/block/float/float-in-descendant-formatting-context.html
+
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginsCollapseThrough):
+
+2019-01-18  Zalan Bujtas  <zalan@apple.com>
+
         [LFC] Do not skip float boxes that are not part of the current formatting context when computing bottom.
         https://bugs.webkit.org/show_bug.cgi?id=193562
 
index 08de2a0..2ef34df 100644 (file)
@@ -409,14 +409,23 @@ bool BlockFormattingContext::MarginCollapse::marginsCollapseThrough(const Layout
             // we haven't started laying it out yet.
             if (!layoutState.hasFormattingState(layoutBox))
                 return false;
-            return downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutBox)).inlineRuns().isEmpty();
+            auto& formattingState = downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutBox));
+            if (!formattingState.inlineRuns().isEmpty())
+                return false;
+            // Any float box in this formatting context prevents collapsing through.
+            auto& floats = formattingState.floatingState().floats();
+            for (auto& floatItem : floats) {
+                if (floatItem.isDescendantOfFormattingRoot(downcast<Container>(layoutBox)))
+                    return false;
+            }
+            return true;
         }
 
         if (establishesBlockFormattingContext(layoutBox))
             return false;
     }
 
-    for (auto* inflowChild = downcast<Container>(layoutBox).firstInFlowChild(); inflowChild; inflowChild = inflowChild->nextInFlowSibling()) {
+    for (auto* inflowChild = downcast<Container>(layoutBox).firstInFlowOrFloatingChild(); inflowChild; inflowChild = inflowChild->nextInFlowOrFloatingSibling()) {
         if (establishesBlockFormattingContext(*inflowChild))
             return false;
         if (!marginsCollapseThrough(layoutState, *inflowChild))
index 83e5a4b..51421ce 100644 (file)
@@ -1,5 +1,14 @@
 2019-01-18  Zalan Bujtas  <zalan@apple.com>
 
+        [LFC][BFC][MarginCollapsing] Collapsing through should not ignore floats.
+        https://bugs.webkit.org/show_bug.cgi?id=193564
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
+2019-01-18  Zalan Bujtas  <zalan@apple.com>
+
         [LFC] Do not skip float boxes that are not part of the current formatting context when computing bottom.
         https://bugs.webkit.org/show_bug.cgi?id=193562
 
index aaf2655..5cfe2d1 100644 (file)
@@ -120,6 +120,7 @@ fast/block/float/float-overhangs-root.html
 fast/block/float/float-with-anonymous-previous-sibling.html
 fast/block/float/floats-not-cleared-crash.html
 fast/block/float/crash-when-intruding-float-has-anonymous-parent-and-detach.html
+fast/block/float/float-in-descendant-formatting-context.html
 fast/block/margin-collapse/002.html
 fast/block/margin-collapse/003.html
 fast/block/margin-collapse/026.html