Title: [240546] trunk
Revision
240546
Author
[email protected]
Date
2019-01-26 07:01:34 -0800 (Sat, 26 Jan 2019)

Log Message

[LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
https://bugs.webkit.org/show_bug.cgi?id=193865

Reviewed by Antti Koivisto.

Source/WebCore:

Height computation ->
// 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
// ...the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom
// margin does not collapse with the element's bottom margin

<div style="border: 1px solid green">
  <div style="margin-top: 100px;"></div>
</div>

When the child vertical margins collapse through (margin-top = margin-bottom = 100px), the bottom edge of the bottom margin is
the same as the bottom edge of the top margin which is alredy taken into use while positioning so technically the bottom margin value should be ignored.

Test: fast/block/margin-collapse/collapsed-through-child-simple.html

* layout/MarginTypes.h:
(WebCore::Layout::UsedVerticalMargin::isCollapsedThrough const):
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::hasCollapsedThroughMargin const):

Tools:

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

LayoutTests:

* fast/block/margin-collapse/collapsed-through-child-simple-expected.html: Added.
* fast/block/margin-collapse/collapsed-through-child-simple.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (240545 => 240546)


--- trunk/LayoutTests/ChangeLog	2019-01-26 13:13:00 UTC (rev 240545)
+++ trunk/LayoutTests/ChangeLog	2019-01-26 15:01:34 UTC (rev 240546)
@@ -1,3 +1,13 @@
+2019-01-26  Zalan Bujtas  <[email protected]>
+
+        [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
+        https://bugs.webkit.org/show_bug.cgi?id=193865
+
+        Reviewed by Antti Koivisto.
+
+        * fast/block/margin-collapse/collapsed-through-child-simple-expected.html: Added.
+        * fast/block/margin-collapse/collapsed-through-child-simple.html: Added.
+
 2019-01-25  Devin Rousso  <[email protected]>
 
         Web Inspector: provide a way to edit page settings on a remote target

Added: trunk/LayoutTests/fast/block/margin-collapse/collapsed-through-child-simple-expected.html (0 => 240546)


--- trunk/LayoutTests/fast/block/margin-collapse/collapsed-through-child-simple-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/margin-collapse/collapsed-through-child-simple-expected.html	2019-01-26 15:01:34 UTC (rev 240546)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+<head>
+<style>
+.line { width: 50px; height: 0px; border-top: 1px solid blue; margin-bottom: 100px; }
+.container { width: 50px; height: 100px; border-top: 1px solid blue; border-bottom: 1px solid blue; background: green; }
+</style>
+</head>
+<body>
+<div class=line></div>
+<div class=container></div>
+</body>
+</html>

Added: trunk/LayoutTests/fast/block/margin-collapse/collapsed-through-child-simple.html (0 => 240546)


--- trunk/LayoutTests/fast/block/margin-collapse/collapsed-through-child-simple.html	                        (rev 0)
+++ trunk/LayoutTests/fast/block/margin-collapse/collapsed-through-child-simple.html	2019-01-26 15:01:34 UTC (rev 240546)
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+<html lang="en">
+<head>
+<style>
+.container { width: 50px; border: 0px solid blue; background: green; }
+.collapsedThrough { width: 200px; border: 0px solid blue; margin-top: 100px; }
+</style>
+</head>
+<body>
+<div class=container style="border-top-width: 1px">
+  <div class=collapsedThrough></div>
+</div>
+<div class=container style="border-top-width: 1px; border-bottom-width: 1px">
+  <div class=collapsedThrough></div>
+</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (240545 => 240546)


--- trunk/Source/WebCore/ChangeLog	2019-01-26 13:13:00 UTC (rev 240545)
+++ trunk/Source/WebCore/ChangeLog	2019-01-26 15:01:34 UTC (rev 240546)
@@ -1,5 +1,33 @@
 2019-01-26  Zalan Bujtas  <[email protected]>
 
+        [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
+        https://bugs.webkit.org/show_bug.cgi?id=193865
+
+        Reviewed by Antti Koivisto.
+
+        Height computation ->
+        // 10.6.3 Block-level non-replaced elements in normal flow when 'overflow' computes to 'visible'
+        // ...the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom
+        // margin does not collapse with the element's bottom margin
+
+        <div style="border: 1px solid green">
+          <div style="margin-top: 100px;"></div>
+        </div>
+
+        When the child vertical margins collapse through (margin-top = margin-bottom = 100px), the bottom edge of the bottom margin is
+        the same as the bottom edge of the top margin which is alredy taken into use while positioning so technically the bottom margin value should be ignored. 
+
+        Test: fast/block/margin-collapse/collapsed-through-child-simple.html
+
+        * layout/MarginTypes.h:
+        (WebCore::Layout::UsedVerticalMargin::isCollapsedThrough const):
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        * layout/displaytree/DisplayBox.h:
+        (WebCore::Display::Box::hasCollapsedThroughMargin const):
+
+2019-01-26  Zalan Bujtas  <[email protected]>
+
         [LFC][BFC][MarginCollapsing] marginAfterCollapsesWithParentMarginAfter/marginAfterCollapsesWithLastInFlowChildMarginAfter should check for border/padding after values.
         https://bugs.webkit.org/show_bug.cgi?id=193864
 

Modified: trunk/Source/WebCore/layout/MarginTypes.h (240545 => 240546)


--- trunk/Source/WebCore/layout/MarginTypes.h	2019-01-26 13:13:00 UTC (rev 240545)
+++ trunk/Source/WebCore/layout/MarginTypes.h	2019-01-26 15:01:34 UTC (rev 240546)
@@ -40,6 +40,7 @@
 struct UsedVerticalMargin {
     LayoutUnit before() const { return m_collapsedValues.before.valueOr(m_nonCollapsedValues.before); }
     LayoutUnit after() const { return m_collapsedValues.after.valueOr(m_nonCollapsedValues.after); }
+    bool isCollapsedThrough() const { return m_collapsedValues.isCollapsedThrough; }
 
     struct NonCollapsedValues {
         LayoutUnit before;

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (240545 => 240546)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-01-26 13:13:00 UTC (rev 240545)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2019-01-26 15:01:34 UTC (rev 240546)
@@ -85,7 +85,8 @@
         ASSERT(lastInFlowChild);
         if (!MarginCollapse::marginAfterCollapsesWithParentMarginAfter(layoutState, *lastInFlowChild)) {
             auto& lastInFlowDisplayBox = layoutState.displayBoxForLayoutBox(*lastInFlowChild);
-            return { lastInFlowDisplayBox.bottom() + lastInFlowDisplayBox.marginAfter() - borderAndPaddingTop, nonCollapsedMargin };
+            auto bottomEdgeOfBottomMargin = lastInFlowDisplayBox.bottom() + (lastInFlowDisplayBox.hasCollapsedThroughMargin() ? LayoutUnit() : lastInFlowDisplayBox.marginAfter()); 
+            return { bottomEdgeOfBottomMargin - borderAndPaddingTop, nonCollapsedMargin };
         }
 
         // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin

Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (240545 => 240546)


--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2019-01-26 13:13:00 UTC (rev 240545)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h	2019-01-26 15:01:34 UTC (rev 240546)
@@ -143,6 +143,7 @@
     LayoutUnit marginStart() const;
     LayoutUnit marginAfter() const;
     LayoutUnit marginEnd() const;
+    bool hasCollapsedThroughMargin() const { return m_verticalMargin.isCollapsedThrough(); }
     bool hasClearance() const { return m_hasClearance; }
 
     LayoutUnit nonCollapsedMarginBefore() const;

Modified: trunk/Tools/ChangeLog (240545 => 240546)


--- trunk/Tools/ChangeLog	2019-01-26 13:13:00 UTC (rev 240545)
+++ trunk/Tools/ChangeLog	2019-01-26 15:01:34 UTC (rev 240546)
@@ -1,3 +1,12 @@
+2019-01-26  Zalan Bujtas  <[email protected]>
+
+        [LFC][BFC] Ignore last inflow child's collapsed through margin after when computing containing block's height.
+        https://bugs.webkit.org/show_bug.cgi?id=193865
+
+        Reviewed by Antti Koivisto.
+
+        * LayoutReloaded/misc/LFC-passing-tests.txt:
+
 2019-01-25  Ryosuke Niwa  <[email protected]>
 
         Need a mechanism to override navigator.userAgent

Modified: trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt (240545 => 240546)


--- trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2019-01-26 13:13:00 UTC (rev 240545)
+++ trunk/Tools/LayoutReloaded/misc/LFC-passing-tests.txt	2019-01-26 15:01:34 UTC (rev 240546)
@@ -134,6 +134,7 @@
 fast/block/margin-collapse/039.html
 fast/block/margin-collapse/040.html
 fast/block/margin-collapse/044.html
+fast/block/margin-collapse/collapsed-through-child-simple.html
 fast/block/positioning/003.html
 fast/block/positioning/004.html
 fast/block/positioning/005.html
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to