Title: [239334] trunk/Source/WebCore
- Revision
- 239334
- Author
- [email protected]
- Date
- 2018-12-18 07:27:09 -0800 (Tue, 18 Dec 2018)
Log Message
[LFC][BFC][MarginCollapsing] Implement marginAfterCollapsesWithParentMarginBefore
https://bugs.webkit.org/show_bug.cgi?id=192798
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::collapsedMarginAfterFromLastChild):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfter):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (239333 => 239334)
--- trunk/Source/WebCore/ChangeLog 2018-12-18 15:26:50 UTC (rev 239333)
+++ trunk/Source/WebCore/ChangeLog 2018-12-18 15:27:09 UTC (rev 239334)
@@ -1,5 +1,21 @@
2018-12-18 Zalan Bujtas <[email protected]>
+ [LFC][BFC][MarginCollapsing] Implement marginAfterCollapsesWithParentMarginBefore
+ https://bugs.webkit.org/show_bug.cgi?id=192798
+
+ 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::collapsedMarginAfterFromLastChild):
+ (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore):
+ (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter):
+ (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfter):
+
+2018-12-18 Zalan Bujtas <[email protected]>
+
[LFC][BFC][MarginCollapsing] Expand marginsCollapseThrough collapsing logic
https://bugs.webkit.org/show_bug.cgi?id=192794
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (239333 => 239334)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2018-12-18 15:26:50 UTC (rev 239333)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2018-12-18 15:27:09 UTC (rev 239334)
@@ -90,7 +90,7 @@
static LayoutUnit marginAfter(const LayoutState&, const Box&);
static bool marginBeforeCollapsesWithParentMarginAfter(const Box&);
- static bool marginAfterCollapsesWithParentMarginAfter(const Box&);
+ static bool marginAfterCollapsesWithParentMarginAfter(const LayoutState&, const Box&);
private:
static LayoutUnit collapsedMarginAfterFromLastChild(const LayoutState&, const Box&);
@@ -106,7 +106,7 @@
static bool marginBeforeCollapsesWithPreviousSibling(const Box&);
static bool marginAfterCollapsesWithNextSibling(const Box&);
static bool marginAfterCollapsesWithSiblingMarginBeforeWithClearance(const Box&);
- static bool marginAfterCollapsesWithParentMarginBefore(const Box&);
+ static bool marginAfterCollapsesWithParentMarginBefore(const LayoutState&, const Box&);
static bool marginsCollapseThrough(const LayoutState&, const Box&);
};
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp (239333 => 239334)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2018-12-18 15:26:50 UTC (rev 239333)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextGeometry.cpp 2018-12-18 15:27:09 UTC (rev 239334)
@@ -84,7 +84,7 @@
// 2. the bottom edge of the bottom (possibly collapsed) margin of its last in-flow child, if the child's bottom margin...
auto* lastInFlowChild = downcast<Container>(layoutBox).lastInFlowChild();
ASSERT(lastInFlowChild);
- if (!MarginCollapse::marginAfterCollapsesWithParentMarginAfter(*lastInFlowChild)) {
+ if (!MarginCollapse::marginAfterCollapsesWithParentMarginAfter(layoutState, *lastInFlowChild)) {
auto& lastInFlowDisplayBox = layoutState.displayBoxForLayoutBox(*lastInFlowChild);
return { lastInFlowDisplayBox.bottom() + lastInFlowDisplayBox.marginAfter() - borderAndPaddingTop, { nonCollapsedMargin, collapsedMargin } };
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (239333 => 239334)
--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2018-12-18 15:26:50 UTC (rev 239333)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2018-12-18 15:27:09 UTC (rev 239334)
@@ -167,7 +167,7 @@
// FIXME: Check for collapsed through margin.
auto& lastInFlowChild = *downcast<Container>(layoutBox).lastInFlowChild();
- if (!marginAfterCollapsesWithParentMarginAfter(lastInFlowChild))
+ if (!marginAfterCollapsesWithParentMarginAfter(layoutState, lastInFlowChild))
return 0;
// Collect collapsed margin bottom recursively.
@@ -230,12 +230,25 @@
return false;
}
-bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore(const Box&)
+bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginBefore(const LayoutState& layoutState, const Box& layoutBox)
{
+ // 1. This is the first in-flow child and its margins collapse through and the margin before collapses with parent's margin before or
+ // 2. This box's margin before collapses with the previous sibling's margin after and that sibling collapses through and
+ // we can get to the first in-flow child like that.
+ auto* firstInFlowChild = layoutBox.parent()->firstInFlowChild();
+ for (auto* currentBox = &layoutBox; currentBox; currentBox = currentBox->previousInFlowSibling()) {
+ if (!marginsCollapseThrough(layoutState, *currentBox))
+ return false;
+ if (currentBox == firstInFlowChild)
+ return marginBeforeCollapsesWithParentMarginBefore(layoutState, *currentBox);
+ if (!marginBeforeCollapsesWithPreviousSibling(*currentBox))
+ return false;
+ }
+ ASSERT_NOT_REACHED();
return false;
}
-bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter(const Box& layoutBox)
+bool BlockFormattingContext::Geometry::MarginCollapse::marginAfterCollapsesWithParentMarginAfter(const LayoutState& layoutState, const Box& layoutBox)
{
if (layoutBox.isAnonymous())
return false;
@@ -281,7 +294,7 @@
// nor (if the box's min-height is non-zero) with the box's top margin.
auto computedMinHeight = parent.style().logicalMinHeight();
- if (!computedMinHeight.isAuto() && computedMinHeight.value() && marginAfterCollapsesWithParentMarginBefore(layoutBox))
+ if (!computedMinHeight.isAuto() && computedMinHeight.value() && marginAfterCollapsesWithParentMarginBefore(layoutState, layoutBox))
return false;
return true;
@@ -406,7 +419,7 @@
ASSERT(layoutBox.isBlockLevelBox());
// TODO: take _hasAdjoiningMarginBeforeAndBottom() into account.
- if (marginAfterCollapsesWithParentMarginAfter(layoutBox))
+ if (marginAfterCollapsesWithParentMarginAfter(layoutState, layoutBox))
return 0;
if (marginsCollapseThrough(layoutState, layoutBox))
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes