Modified: trunk/Source/WebCore/ChangeLog (252188 => 252189)
--- trunk/Source/WebCore/ChangeLog 2019-11-07 17:31:16 UTC (rev 252188)
+++ trunk/Source/WebCore/ChangeLog 2019-11-07 18:03:15 UTC (rev 252189)
@@ -1,3 +1,27 @@
+2019-11-07 Zalan Bujtas <[email protected]>
+
+ [LFC][MarginCollapsing] Drag anonymous block level boxes into margin collapsing
+ https://bugs.webkit.org/show_bug.cgi?id=203927
+ <rdar://problem/56963636>
+
+ Reviewed by Antti Koivisto.
+
+ We've been ignoring anonymous block level boxes in the context of margin collapsing. Now with IFC, we can't really do that anymore.
+ This patch removes the early bailout on anon boxes and addresses the fallout.
+
+ * layout/MarginTypes.h:
+ * layout/blockformatting/BlockMarginCollapse.cpp:
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithParentMarginBefore const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithPreviousSiblingMarginAfter const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithFirstInFlowChildMarginBefore const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginAfterCollapsesWithParentMarginAfter const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginAfterCollapsesWithLastInFlowChildMarginAfter const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::updateMarginAfterForPreviousSibling):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::estimatedMarginBefore):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginBeforeIgnoringCollapsingThrough):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedVerticalValues):
+
2019-11-07 Alex Christensen <[email protected]>
Re-enable NSURLSession isolation after r252116
Modified: trunk/Source/WebCore/layout/MarginTypes.h (252188 => 252189)
--- trunk/Source/WebCore/layout/MarginTypes.h 2019-11-07 17:31:16 UTC (rev 252188)
+++ trunk/Source/WebCore/layout/MarginTypes.h 2019-11-07 18:03:15 UTC (rev 252189)
@@ -82,6 +82,12 @@
bool isCollapsedThrough { false };
};
+// FIXME: This structure might need to change to indicate that the cached value is not necessarily the same as the box's computed margin value.
+// This only matters in case of collapse through margins when they collapse into another sibling box.
+// <div style="margin: 1px"></div><div style="margin: 10px"></div> <- the second div's before/after marings collapse through and the same time they collapse into
+// the first div. When the parent computes its before margin, it should see the second div's collapsed through margin as the value to collapse width (adjoining margin value).
+// So while the first div's before margin is not 10px, the cached value is 10px so that when we compute the parent's margin we just need to check the fist
+// inflow child's cached margin value.
struct PositiveAndNegativeVerticalMargin {
struct Values {
bool isNonZero() const { return positive.valueOr(0) || negative.valueOr(0); }
Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (252188 => 252189)
--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2019-11-07 17:31:16 UTC (rev 252188)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2019-11-07 18:03:15 UTC (rev 252189)
@@ -112,9 +112,6 @@
{
// The first inflow child could propagate its top margin to parent.
// https://www.w3.org/TR/CSS21/box.html#collapsing-margins
- if (layoutBox.isAnonymous())
- return false;
-
ASSERT(layoutBox.isBlockLevelBox());
// Margins between a floated box and any other box do not collapse.
@@ -155,16 +152,10 @@
{
ASSERT(layoutBox.isBlockLevelBox());
- if (layoutBox.isAnonymous())
- return false;
-
if (!layoutBox.previousInFlowSibling())
return false;
auto& previousInFlowSibling = *layoutBox.previousInFlowSibling();
- if (previousInFlowSibling.isAnonymous())
- return false;
-
// Margins between a floated box and any other box do not collapse.
if (layoutBox.isFloatingPositioned() || previousInFlowSibling.isFloatingPositioned())
return false;
@@ -188,9 +179,6 @@
bool BlockFormattingContext::MarginCollapse::marginBeforeCollapsesWithFirstInFlowChildMarginBefore(const Box& layoutBox) const
{
- if (layoutBox.isAnonymous())
- return false;
-
ASSERT(layoutBox.isBlockLevelBox());
// Margins of elements that establish new block formatting contexts do not collapse with their in-flow children.
if (establishesBlockFormattingContext(layoutBox))
@@ -259,9 +247,6 @@
bool BlockFormattingContext::MarginCollapse::marginAfterCollapsesWithParentMarginAfter(const Box& layoutBox) const
{
- if (layoutBox.isAnonymous())
- return false;
-
ASSERT(layoutBox.isBlockLevelBox());
// Margins between a floated box and any other box do not collapse.
@@ -350,6 +335,11 @@
if (lastInFlowChild.isInlineBlockBox())
return false;
+ // This is a quirk behavior: When the margin after of the last inflow child (or a previous sibling with collapsed through margins)
+ // collapses with a quirk parent's the margin before, then the same margin after does not collapses with the parent's margin after.
+ if (formattingContext().quirks().shouldIgnoreCollapsedQuirkMargin(layoutBox) && marginAfterCollapsesWithParentMarginBefore(lastInFlowChild))
+ return false;
+
return true;
}
@@ -475,7 +465,7 @@
// 1. Get the margin before value from the next in-flow sibling. This is the same as this box's margin after value now since they are collapsed.
// 2. Update the collapsed margin after value as well as the positive/negative cache.
// 3. Check if the box's margins collapse through.
- // 4. If so, update the collapsed margin before value as well as the positive/negative cache.
+ // 4. If so, update the positive/negative cache.
// 5. In case of collapsed through margins check if the before margin collapes with the previous inflow sibling's after margin.
// 6. If so, jump to #2.
// 7. No need to propagate to parent because its margin is not computed yet (estimated at most).
@@ -493,10 +483,6 @@
if (marginsCollapseThrough)
collapsedVerticalMarginBefore = collapsedVerticalMarginAfter;
- // Update collapsed vertical margin values.
- previousSiblingVerticalMargin.setCollapsedValues({ collapsedVerticalMarginBefore, collapsedVerticalMarginAfter });
- previousSiblingDisplayBox.setVerticalMargin(previousSiblingVerticalMargin);
-
// Update positive/negative cache.
auto previousSiblingPositiveNegativeMargin = blockFormattingState.positiveAndNegativeVerticalMargin(previousSibling);
auto positiveNegativeMarginBefore = blockFormattingState.positiveAndNegativeVerticalMargin(*currentBox).before;
@@ -572,7 +558,7 @@
};
// We don't know yet the margin before value of the next sibling. Let's just pretend it does not have one and
- // update it later when we compute the next sibling's margin before. See updateCollapsedMarginAfter.
+ // update it later when we compute the next sibling's margin before. See updateMarginAfterForPreviousSibling.
PositiveAndNegativeVerticalMargin::Values nonCollapsedAfter;
if (nonCollapsedValues.after > 0)
nonCollapsedAfter = { nonCollapsedValues.after, { }, layoutBox.style().hasMarginAfterQuirk() };
@@ -584,9 +570,6 @@
EstimatedMarginBefore BlockFormattingContext::MarginCollapse::estimatedMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues usedNonCollapsedMargin)
{
- if (layoutBox.isAnonymous())
- return { };
-
ASSERT(layoutBox.isBlockLevelBox());
// Don't estimate vertical margins for out of flow boxes.
ASSERT(layoutBox.isInFlow() || layoutBox.isFloatingPositioned());
@@ -603,7 +586,6 @@
LayoutUnit BlockFormattingContext::MarginCollapse::marginBeforeIgnoringCollapsingThrough(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
{
- ASSERT(!layoutBox.isAnonymous());
ASSERT(layoutBox.isBlockLevelBox());
return marginValue(positiveNegativeMarginBefore(layoutBox, nonCollapsedValues)).valueOr(nonCollapsedValues.before);
}
@@ -625,9 +607,6 @@
UsedVerticalMargin::CollapsedValues BlockFormattingContext::MarginCollapse::collapsedVerticalValues(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
{
- if (layoutBox.isAnonymous())
- return { };
-
ASSERT(layoutBox.isBlockLevelBox());
// 1. Get min/max margin top values from the first in-flow child if we are collapsing margin top with it.
// 2. Get min/max margin top values from the previous in-flow sibling, if we are collapsing margin top with it.