Title: [239332] trunk/Source/WebCore
- Revision
- 239332
- Author
- [email protected]
- Date
- 2018-12-18 07:25:32 -0800 (Tue, 18 Dec 2018)
Log Message
[LFC][BFC][MarginCollapsing] Expand marginsCollapseThrough collapsing logic
https://bugs.webkit.org/show_bug.cgi?id=192794
Reviewed by Antti Koivisto.
* layout/blockformatting/BlockFormattingContext.h:
* layout/blockformatting/BlockMarginCollapse.cpp:
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginsCollapseThrough):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBefore):
(WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfter):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (239331 => 239332)
--- trunk/Source/WebCore/ChangeLog 2018-12-18 15:23:47 UTC (rev 239331)
+++ trunk/Source/WebCore/ChangeLog 2018-12-18 15:25:32 UTC (rev 239332)
@@ -1,5 +1,18 @@
2018-12-18 Zalan Bujtas <[email protected]>
+ [LFC][BFC][MarginCollapsing] Expand marginsCollapseThrough collapsing logic
+ https://bugs.webkit.org/show_bug.cgi?id=192794
+
+ Reviewed by Antti Koivisto.
+
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockMarginCollapse.cpp:
+ (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginsCollapseThrough):
+ (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginBefore):
+ (WebCore::Layout::BlockFormattingContext::Geometry::MarginCollapse::marginAfter):
+
+2018-12-18 Zalan Bujtas <[email protected]>
+
[LFC][BFC][MarginCollapsing] Expand marginAfterCollapsesWithNextSibling and marginBeforeCollapsesWithPreviousSibling collapsing logic
https://bugs.webkit.org/show_bug.cgi?id=192791
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (239331 => 239332)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2018-12-18 15:23:47 UTC (rev 239331)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2018-12-18 15:25:32 UTC (rev 239332)
@@ -107,7 +107,7 @@
static bool marginAfterCollapsesWithNextSibling(const Box&);
static bool marginAfterCollapsesWithSiblingMarginBeforeWithClearance(const Box&);
static bool marginAfterCollapsesWithParentMarginBefore(const Box&);
- static bool marginsCollapseThrough(const Box&);
+ static bool marginsCollapseThrough(const LayoutState&, const Box&);
};
static HeightAndMargin inFlowNonReplacedHeightAndMargin(const LayoutState&, const Box&, std::optional<LayoutUnit> usedHeight = { });
Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (239331 => 239332)
--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2018-12-18 15:23:47 UTC (rev 239331)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2018-12-18 15:25:32 UTC (rev 239332)
@@ -28,6 +28,7 @@
#if ENABLE(LAYOUT_FORMATTING_CONTEXT)
+#include "InlineFormattingState.h"
#include "LayoutBox.h"
#include "LayoutContainer.h"
#include "LayoutUnit.h"
@@ -326,11 +327,12 @@
return marginBeforeCollapsesWithPreviousSibling(*layoutBox.nextInFlowSibling());
}
-bool BlockFormattingContext::Geometry::MarginCollapse::marginsCollapseThrough(const Box& layoutBox)
+bool BlockFormattingContext::Geometry::MarginCollapse::marginsCollapseThrough(const LayoutState& layoutState, const Box& layoutBox)
{
ASSERT(layoutBox.isBlockLevelBox());
- // If the top and bottom margins of a box are adjoining, then it is possible for margins to collapse through it.
+ // A box's own margins collapse if the 'min-height' property is zero, and it has neither top or bottom borders nor top or bottom padding,
+ // and it has a 'height' of either 0 or 'auto', and it does not contain a line box, and all of its in-flow children's margins (if any) collapse.
if (hasBorderBefore(layoutBox) || hasBorderAfter(layoutBox))
return false;
@@ -337,15 +339,26 @@
if (hasPaddingBefore(layoutBox) || hasPaddingAfter(layoutBox))
return false;
- if (!layoutBox.style().height().isAuto() || !layoutBox.style().minHeight().isAuto())
+ // FIXME: Check for computed 0 height.
+ if (!layoutBox.style().height().isAuto())
return false;
+ // FIXME: Check for computed 0 height.
+ if (!layoutBox.style().minHeight().isAuto())
+ return false;
+
if (!is<Container>(layoutBox))
return true;
- auto& container = downcast<Container>(layoutBox);
- if (container.hasInFlowOrFloatingChild())
- return false;
+ if (layoutBox.establishesInlineFormattingContext()) {
+ if (downcast<InlineFormattingState>(layoutState.establishedFormattingState(layoutBox)).inlineRuns().isEmpty())
+ return false;
+ } else {
+ for (auto* inflowChild = downcast<Container>(layoutBox).firstInFlowChild(); inflowChild; inflowChild = inflowChild->nextInFlowSibling()) {
+ if (!marginsCollapseThrough(layoutState, *inflowChild))
+ return true;
+ }
+ }
return true;
}
@@ -366,7 +379,7 @@
return 0;
if (!marginBeforeCollapsesWithPreviousSibling(layoutBox)) {
- if (!marginsCollapseThrough(layoutBox))
+ if (!marginsCollapseThrough(layoutState, layoutBox))
return nonCollapsedMarginBefore(layoutState, layoutBox);
// Compute the collapsed through value.
auto marginBefore = nonCollapsedMarginBefore(layoutState, layoutBox);
@@ -396,7 +409,7 @@
if (marginAfterCollapsesWithParentMarginAfter(layoutBox))
return 0;
- if (marginsCollapseThrough(layoutBox))
+ if (marginsCollapseThrough(layoutState, layoutBox))
return 0;
// Floats and out of flow positioned boxes do not collapse their margins.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes