Title: [267587] trunk
Revision
267587
Author
[email protected]
Date
2020-09-25 12:03:37 -0700 (Fri, 25 Sep 2020)

Log Message

[LFC][MarginCollapsing] Only inflow boxes collapse their quirk margins with their parents
https://bugs.webkit.org/show_bug.cgi?id=216981

Reviewed by Antti Koivisto.

Source/WebCore:

Test: fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating.html

* layout/blockformatting/BlockFormattingContextQuirks.cpp:
(WebCore::Layout::BlockFormattingContext::Quirks::shouldCollapseMarginBeforeWithParentMarginBefore const):

LayoutTests:

* fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating-expected.html: Added.
* fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (267586 => 267587)


--- trunk/LayoutTests/ChangeLog	2020-09-25 19:03:26 UTC (rev 267586)
+++ trunk/LayoutTests/ChangeLog	2020-09-25 19:03:37 UTC (rev 267587)
@@ -1,3 +1,13 @@
+2020-09-25  Zalan Bujtas  <[email protected]>
+
+        [LFC][MarginCollapsing] Only inflow boxes collapse their quirk margins with their parents
+        https://bugs.webkit.org/show_bug.cgi?id=216981
+
+        Reviewed by Antti Koivisto.
+
+        * fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating-expected.html: Added.
+        * fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating.html: Added.
+
 2020-09-25  Frederic Wang  <[email protected]>
 
         Bug 216702 - Implement the CSS math-style property

Added: trunk/LayoutTests/fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating-expected.html (0 => 267587)


--- trunk/LayoutTests/fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating-expected.html	2020-09-25 19:03:37 UTC (rev 267587)
@@ -0,0 +1,11 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+div {
+  position: absolute;
+  top: 16px;
+  width: 100px; 
+  height: 100px;
+  background-color: green;
+}
+</style>
+<div></div>

Added: trunk/LayoutTests/fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating.html (0 => 267587)


--- trunk/LayoutTests/fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating.html	                        (rev 0)
+++ trunk/LayoutTests/fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating.html	2020-09-25 19:03:37 UTC (rev 267587)
@@ -0,0 +1,10 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ internal:LayoutFormattingContextEnabled=true internal:LayoutFormattingContextIntegrationEnabled=false ] -->
+<style>
+p {
+  float: left; 
+  width: 100px;
+  height: 100px;
+  background-color: green
+}
+</style>
+<p>

Modified: trunk/Source/WebCore/ChangeLog (267586 => 267587)


--- trunk/Source/WebCore/ChangeLog	2020-09-25 19:03:26 UTC (rev 267586)
+++ trunk/Source/WebCore/ChangeLog	2020-09-25 19:03:37 UTC (rev 267587)
@@ -1,3 +1,15 @@
+2020-09-25  Zalan Bujtas  <[email protected]>
+
+        [LFC][MarginCollapsing] Only inflow boxes collapse their quirk margins with their parents
+        https://bugs.webkit.org/show_bug.cgi?id=216981
+
+        Reviewed by Antti Koivisto.
+
+        Test: fast/layoutformattingcontext/quirk-margin-not-collapse-when-floating.html
+
+        * layout/blockformatting/BlockFormattingContextQuirks.cpp:
+        (WebCore::Layout::BlockFormattingContext::Quirks::shouldCollapseMarginBeforeWithParentMarginBefore const):
+
 2020-09-25  Frederic Wang  <[email protected]>
 
         Bug 216702 - Implement the CSS math-style property

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (267586 => 267587)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2020-09-25 19:03:26 UTC (rev 267586)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp	2020-09-25 19:03:37 UTC (rev 267587)
@@ -104,14 +104,23 @@
     return layoutState().inQuirksMode() && isQuirkContainer(layoutBox);
 }
 
+enum class VerticalMargin { Before, After };
+static inline bool hasQuirkMarginToCollapse(const Box& layoutBox, VerticalMargin verticalMargin)
+{
+    if (!layoutBox.isInFlow())
+        return false;
+    auto& style = layoutBox.style();
+    return (verticalMargin == VerticalMargin::Before && style.hasMarginBeforeQuirk()) || (verticalMargin == VerticalMargin::After && style.hasMarginAfterQuirk());
+}
+
 bool BlockFormattingContext::Quirks::shouldCollapseMarginBeforeWithParentMarginBefore(const Box& layoutBox) const
 {
-    return layoutState().inQuirksMode() && layoutBox.style().hasMarginBeforeQuirk() && isQuirkContainer(layoutBox.containingBlock());
+    return layoutState().inQuirksMode() && hasQuirkMarginToCollapse(layoutBox, VerticalMargin::Before) && isQuirkContainer(layoutBox.containingBlock());
 }
 
 bool BlockFormattingContext::Quirks::shouldCollapseMarginAfterWithParentMarginAfter(const Box& layoutBox) const
 {
-    return layoutState().inQuirksMode() && layoutBox.style().hasMarginAfterQuirk() && isQuirkContainer(layoutBox.containingBlock());
+    return layoutState().inQuirksMode() && hasQuirkMarginToCollapse(layoutBox, VerticalMargin::After) && isQuirkContainer(layoutBox.containingBlock());
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to