Title: [239336] trunk/Source/WebCore
Revision
239336
Author
[email protected]
Date
2018-12-18 07:30:25 -0800 (Tue, 18 Dec 2018)

Log Message

[LFC][BFC][MarginCollapsing] Implement marginBeforeCollapsesWithParentMarginAfter
https://bugs.webkit.org/show_bug.cgi?id=192801

Reviewed by Antti Koivisto.

* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockFormattingContextGeometry.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithParentMarginAfter):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (239335 => 239336)


--- trunk/Source/WebCore/ChangeLog	2018-12-18 15:28:47 UTC (rev 239335)
+++ trunk/Source/WebCore/ChangeLog	2018-12-18 15:30:25 UTC (rev 239336)
@@ -1,5 +1,18 @@
 2018-12-18  Zalan Bujtas  <[email protected]>
 
+        [LFC][BFC][MarginCollapsing] Implement marginBeforeCollapsesWithParentMarginAfter
+        https://bugs.webkit.org/show_bug.cgi?id=192801
+
+        Reviewed by Antti Koivisto.
+
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockFormattingContextGeometry.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::inFlowNonReplacedHeightAndMargin):
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithParentMarginAfter):
+
+2018-12-18  Zalan Bujtas  <[email protected]>
+
         [LFC][BFC][MarginCollapsing] Implement marginAfterCollapsesWithSiblingMarginBeforeWithClearance
         https://bugs.webkit.org/show_bug.cgi?id=192799
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (239335 => 239336)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-12-18 15:28:47 UTC (rev 239335)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-12-18 15:30:25 UTC (rev 239336)
@@ -89,7 +89,7 @@
             static LayoutUnit marginBefore(const LayoutState&, const Box&);
             static LayoutUnit marginAfter(const LayoutState&, const Box&);
 
-            static bool marginBeforeCollapsesWithParentMarginAfter(const Box&);
+            static bool marginBeforeCollapsesWithParentMarginAfter(const LayoutState&, const Box&);
             static bool marginAfterCollapsesWithParentMarginAfter(const LayoutState&, const Box&);
 
         private:

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (239335 => 239336)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-12-18 15:28:47 UTC (rev 239335)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp	2018-12-18 15:30:25 UTC (rev 239336)
@@ -91,7 +91,7 @@
 
         // 3. the bottom border edge of the last in-flow child whose top margin doesn't collapse with the element's bottom margin
         auto* inFlowChild = lastInFlowChild;
-        while (inFlowChild && MarginCollapse::marginBeforeCollapsesWithParentMarginAfter(*inFlowChild))
+        while (inFlowChild && MarginCollapse::marginBeforeCollapsesWithParentMarginAfter(layoutState, *inFlowChild))
             inFlowChild = inFlowChild->previousInFlowSibling();
         if (inFlowChild) {
             auto& inFlowDisplayBox = layoutState.displayBoxForLayoutBox(*inFlowChild);

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (239335 => 239336)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-12-18 15:28:47 UTC (rev 239335)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-12-18 15:30:25 UTC (rev 239336)
@@ -174,8 +174,21 @@
     return marginValue(computedNonCollapsedMarginAfter(layoutState, lastInFlowChild), collapsedMarginAfterFromLastChild(layoutState, lastInFlowChild));
 }
 
-bool BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithParentMarginAfter(const Box&)
+bool BlockFormattingContext::Geometry::MarginCollapse::marginBeforeCollapsesWithParentMarginAfter(const LayoutState& layoutState, const Box& layoutBox)
 {
+    // 1. This is the last in-flow child and its margins collapse through and the margin after collapses with parent's margin after or
+    // 2. This box's margin after collapses with the next sibling's margin before and that sibling collapses through and
+    // we can get to the last in-flow child like that.
+    auto* lastInFlowChild = layoutBox.parent()->lastInFlowChild();
+    for (auto* currentBox = &layoutBox; currentBox; currentBox = currentBox->nextInFlowSibling()) {
+        if (!marginsCollapseThrough(layoutState, *currentBox))
+            return false;
+        if (currentBox == lastInFlowChild)
+            return marginAfterCollapsesWithParentMarginAfter(layoutState, *currentBox); 
+        if (!marginAfterCollapsesWithNextSibling(*currentBox))
+            return false;
+    }
+    ASSERT_NOT_REACHED();
     return false;
 }
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to