Title: [232661] trunk/Source/WebCore
Revision
232661
Author
[email protected]
Date
2018-06-09 12:35:33 -0700 (Sat, 09 Jun 2018)

Log Message

[LFC] MarginCollapse functions should be able to resolve non-fixed margin values
https://bugs.webkit.org/show_bug.cgi?id=186461

Reviewed by Antti Koivisto.

We need the containing block's computed width to resolve vertical and horizontal margins.

* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild):
(WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom):
(WebCore::Layout::collapsedMarginTopFromFirstChild): Deleted.
(WebCore::Layout::nonCollapsedMarginTop): Deleted.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (232660 => 232661)


--- trunk/Source/WebCore/ChangeLog	2018-06-09 16:27:16 UTC (rev 232660)
+++ trunk/Source/WebCore/ChangeLog	2018-06-09 19:35:33 UTC (rev 232661)
@@ -1,3 +1,25 @@
+2018-06-09  Zalan Bujtas  <[email protected]>
+
+        [LFC] MarginCollapse functions should be able to resolve non-fixed margin values
+        https://bugs.webkit.org/show_bug.cgi?id=186461
+
+        Reviewed by Antti Koivisto.
+
+        We need the containing block's computed width to resolve vertical and horizontal margins.
+
+        * layout/blockformatting/BlockFormattingContext.h:
+        * layout/blockformatting/BlockMarginCollapse.cpp:
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginTop):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBottom):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild):
+        (WebCore::Layout::BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom):
+        (WebCore::Layout::collapsedMarginTopFromFirstChild): Deleted.
+        (WebCore::Layout::nonCollapsedMarginTop): Deleted.
+
 2018-06-08  Darin Adler  <[email protected]>
 
         [Cocoa] Remove all uses of NSAutoreleasePool as part of preparation for ARC

Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (232660 => 232661)


--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-06-09 16:27:16 UTC (rev 232660)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h	2018-06-09 19:35:33 UTC (rev 232661)
@@ -77,15 +77,21 @@
     // This class implements margin collapsing for block formatting context.
     class MarginCollapse {
     public:
-        static LayoutUnit marginTop(const Box&);
-        static LayoutUnit marginBottom(const Box&);
+        static LayoutUnit marginTop(const LayoutContext&, const Box&);
+        static LayoutUnit marginBottom(const LayoutContext&, const Box&);
 
         static bool isMarginBottomCollapsedWithParent(const Box&);
         static bool isMarginTopCollapsedWithParentMarginBottom(const Box&);
     
     private:
-        static LayoutUnit collapsedMarginBottomFromLastChild(const Box&);
-        static LayoutUnit nonCollapsedMarginBottom(const Box&);
+        static LayoutUnit collapsedMarginBottomFromLastChild(const LayoutContext&, const Box&);
+        static LayoutUnit nonCollapsedMarginBottom(const LayoutContext&, const Box&);
+
+        static LayoutUnit computedNonCollapsedMarginTop(const LayoutContext&, const Box&);
+        static LayoutUnit computedNonCollapsedMarginBottom(const LayoutContext&, const Box&);
+
+        static LayoutUnit collapsedMarginTopFromFirstChild(const LayoutContext&, const Box&);
+        static LayoutUnit nonCollapsedMarginTop(const LayoutContext&, const Box&);
     };
 };
 

Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (232660 => 232661)


--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-06-09 16:27:16 UTC (rev 232660)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp	2018-06-09 19:35:33 UTC (rev 232661)
@@ -111,7 +111,7 @@
     return true;
 }
 
-static LayoutUnit collapsedMarginTopFromFirstChild(const Box& layoutBox)
+LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginTopFromFirstChild(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     // Check if the first child collapses its margin top.
     if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild())
@@ -122,13 +122,13 @@
         return 0;
 
     // Collect collapsed margin top recursively.
-    return marginValue(firstInFlowChild.style().marginTop().value(), collapsedMarginTopFromFirstChild(firstInFlowChild));
+    return marginValue(computedNonCollapsedMarginTop(layoutContext, firstInFlowChild), collapsedMarginTopFromFirstChild(layoutContext, firstInFlowChild));
 }
 
-static LayoutUnit nonCollapsedMarginTop(const Box& layoutBox)
+LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     // Non collapsed margin top includes collapsed margin from inflow first child.
-    return marginValue(layoutBox.style().marginTop().value(), collapsedMarginTopFromFirstChild(layoutBox));
+    return marginValue(computedNonCollapsedMarginTop(layoutContext, layoutBox), collapsedMarginTopFromFirstChild(layoutContext, layoutBox));
 }
 
 /*static bool hasAdjoiningMarginTopAndBottom(const Box&)
@@ -145,9 +145,18 @@
     // A collapsed margin is considered adjoining to another margin if any of its component margins is adjoining to that margin.
     return false;
 }*/
+LayoutUnit BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginTop(const LayoutContext& layoutContext, const Box& layoutBox)
+{
+    return FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).top;
+}
 
-LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const Box& layoutBox)
+LayoutUnit BlockFormattingContext::MarginCollapse::computedNonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
 {
+    return FormattingContext::Geometry::computedNonCollapsedVerticalMarginValue(layoutContext, layoutBox).bottom;
+}
+
+LayoutUnit BlockFormattingContext::MarginCollapse::marginTop(const LayoutContext& layoutContext, const Box& layoutBox)
+{
     if (layoutBox.isAnonymous())
         return 0;
 
@@ -157,20 +166,20 @@
 
     // Floats and out of flow positioned boxes do not collapse their margins.
     if (!isMarginTopCollapsedWithSibling(layoutBox))
-        return nonCollapsedMarginTop(layoutBox);
+        return nonCollapsedMarginTop(layoutContext, layoutBox);
 
     // The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling,
     // unless that sibling has clearance.
     auto* previousInFlowSibling = layoutBox.previousInFlowSibling();
     if (!previousInFlowSibling)
-        return nonCollapsedMarginTop(layoutBox);
+        return nonCollapsedMarginTop(layoutContext, layoutBox);
 
-    auto previousSiblingMarginBottom = nonCollapsedMarginBottom(*previousInFlowSibling);
-    auto marginTop = nonCollapsedMarginTop(layoutBox);
+    auto previousSiblingMarginBottom = nonCollapsedMarginBottom(layoutContext, *previousInFlowSibling);
+    auto marginTop = nonCollapsedMarginTop(layoutContext, layoutBox);
     return marginValue(marginTop, previousSiblingMarginBottom);
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const Box& layoutBox)
+LayoutUnit BlockFormattingContext::MarginCollapse::marginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     if (layoutBox.isAnonymous())
         return 0;
@@ -181,13 +190,13 @@
 
     // Floats and out of flow positioned boxes do not collapse their margins.
     if (!isMarginBottomCollapsedWithSibling(layoutBox))
-        return nonCollapsedMarginBottom(layoutBox);
+        return nonCollapsedMarginBottom(layoutContext, layoutBox);
 
     // The bottom margin of an in-flow block-level element always collapses with the top margin of its next in-flow block-level sibling,
     // unless that sibling has clearance.
     if (layoutBox.nextInFlowSibling())
         return 0;
-    return nonCollapsedMarginBottom(layoutBox);
+    return nonCollapsedMarginBottom(layoutContext, layoutBox);
 }
 
 bool BlockFormattingContext::MarginCollapse::isMarginBottomCollapsedWithParent(const Box& layoutBox)
@@ -231,7 +240,7 @@
     return false;
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild(const Box& layoutBox)
+LayoutUnit BlockFormattingContext::MarginCollapse::collapsedMarginBottomFromLastChild(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     // Check if the last child propagates its margin bottom.
     if (!is<Container>(layoutBox) || !downcast<Container>(layoutBox).hasInFlowChild())
@@ -242,13 +251,13 @@
         return 0;
 
     // Collect collapsed margin bottom recursively.
-    return marginValue(lastInFlowChild.style().marginBottom().value(), collapsedMarginBottomFromLastChild(lastInFlowChild));
+    return marginValue(computedNonCollapsedMarginBottom(layoutContext, lastInFlowChild), collapsedMarginBottomFromLastChild(layoutContext, lastInFlowChild));
 }
 
-LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom(const Box& layoutBox)
+LayoutUnit BlockFormattingContext::MarginCollapse::nonCollapsedMarginBottom(const LayoutContext& layoutContext, const Box& layoutBox)
 {
     // Non collapsed margin bottom includes collapsed margin from inflow last child.
-    return marginValue(layoutBox.style().marginBottom().value(), collapsedMarginBottomFromLastChild(layoutBox));
+    return marginValue(computedNonCollapsedMarginBottom(layoutContext, layoutBox), collapsedMarginBottomFromLastChild(layoutContext, layoutBox));
 }
 
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to