Diff
Modified: trunk/Source/WebCore/ChangeLog (263945 => 263946)
--- trunk/Source/WebCore/ChangeLog 2020-07-04 21:09:46 UTC (rev 263945)
+++ trunk/Source/WebCore/ChangeLog 2020-07-04 21:17:03 UTC (rev 263946)
@@ -1,5 +1,40 @@
2020-07-04 Zalan Bujtas <[email protected]>
+ [LFC][BFC] Move PositiveAndNegativeVerticalMargin to UsedVerticalMargin
+ https://bugs.webkit.org/show_bug.cgi?id=213963
+
+ Reviewed by Antti Koivisto.
+
+ Now that UsedVerticalMargin is not used in Display::Box, we can merged these 2 layout structures.
+
+ * layout/MarginTypes.h:
+ (WebCore::Layout::UsedVerticalMargin::PositiveAndNegativePair::Values::isNonZero const):
+ (WebCore::Layout::PositiveAndNegativeVerticalMargin::Values::isNonZero const): Deleted.
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::precomputeVerticalPositionForBoxAndAncestors):
+ (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin):
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockFormattingState.h:
+ (WebCore::Layout::BlockFormattingState::hasUsedVerticalMargin const):
+ (WebCore::Layout::BlockFormattingState::setPositiveAndNegativeVerticalMargin): Deleted.
+ (WebCore::Layout::BlockFormattingState::hasPositiveAndNegativeVerticalMargin const): Deleted.
+ (WebCore::Layout::BlockFormattingState::positiveAndNegativeVerticalMargin const): Deleted.
+ * layout/blockformatting/BlockMarginCollapse.cpp:
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::computedPositiveAndNegativeMargin const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::marginValue const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::updateMarginAfterForPreviousSibling):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeValues const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginBefore const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::collapsedVerticalValues):
+ * layout/blockformatting/PrecomputedBlockMarginCollapse.cpp:
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeValues const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeMarginBefore const):
+ * layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp:
+ (WebCore::Layout::TableWrapperBlockFormattingContext::computeHeightAndMarginForTableBox):
+
+2020-07-04 Zalan Bujtas <[email protected]>
+
[LFC][BFC] Remove redundant out-of-flow height-and-margin handling
https://bugs.webkit.org/show_bug.cgi?id=213959
Modified: trunk/Source/WebCore/layout/MarginTypes.h (263945 => 263946)
--- trunk/Source/WebCore/layout/MarginTypes.h 2020-07-04 21:09:46 UTC (rev 263945)
+++ trunk/Source/WebCore/layout/MarginTypes.h 2020-07-04 21:17:03 UTC (rev 263946)
@@ -50,6 +50,25 @@
bool isCollapsedThrough { false };
};
CollapsedValues collapsedValues;
+
+ // 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 first
+ // inflow child's cached margin values.
+ struct PositiveAndNegativePair {
+ struct Values {
+ bool isNonZero() const { return positive.valueOr(0) || negative.valueOr(0); }
+
+ Optional<LayoutUnit> positive;
+ Optional<LayoutUnit> negative;
+ bool isQuirk { false };
+ };
+ Values before;
+ Values after;
+ };
+ PositiveAndNegativePair positiveAndNegativeValues;
};
static inline LayoutUnit marginBefore(const UsedVerticalMargin& usedVerticalMargin)
@@ -74,29 +93,11 @@
LayoutUnit end;
};
-// 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 first
-// inflow child's cached margin values.
-struct PositiveAndNegativeVerticalMargin {
- struct Values {
- bool isNonZero() const { return positive.valueOr(0) || negative.valueOr(0); }
-
- Optional<LayoutUnit> positive;
- Optional<LayoutUnit> negative;
- bool isQuirk { false };
- };
- Values before;
- Values after;
-};
-
struct PrecomputedMarginBefore {
LayoutUnit usedValue() const { return collapsedValue.valueOr(nonCollapsedValue); }
LayoutUnit nonCollapsedValue;
Optional<LayoutUnit> collapsedValue;
- PositiveAndNegativeVerticalMargin::Values positiveAndNegativeMarginBefore;
+ UsedVerticalMargin::PositiveAndNegativePair::Values positiveAndNegativeMarginBefore;
};
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (263945 => 263946)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-07-04 21:09:46 UTC (rev 263945)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-07-04 21:17:03 UTC (rev 263946)
@@ -258,12 +258,11 @@
auto computedVerticalMargin = geometry().computedVerticalMargin(*ancestor, constraintsForAncestor.horizontal);
auto usedNonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
auto precomputedMarginBefore = marginCollapse().precomputedMarginBefore(*ancestor, usedNonCollapsedMargin);
- formattingState().setPositiveAndNegativeVerticalMargin(*ancestor, { precomputedMarginBefore.positiveAndNegativeMarginBefore, { } });
auto& displayBox = formattingState().displayBox(*ancestor);
auto nonCollapsedValues = UsedVerticalMargin::NonCollapsedValues { precomputedMarginBefore.nonCollapsedValue, { } };
auto collapsedValues = UsedVerticalMargin::CollapsedValues { precomputedMarginBefore.collapsedValue, { }, false };
- auto verticalMargin = UsedVerticalMargin { nonCollapsedValues, collapsedValues };
+ auto verticalMargin = UsedVerticalMargin { nonCollapsedValues, collapsedValues, { precomputedMarginBefore.positiveAndNegativeMarginBefore, { } } };
formattingState().setUsedVerticalMargin(*ancestor, verticalMargin);
displayBox.setVerticalMargin({ marginBefore(verticalMargin), marginAfter(verticalMargin) });
@@ -367,10 +366,8 @@
// 2. Adjust vertical position using the collapsed values.
// 3. Adjust previous in-flow sibling margin after using this margin.
auto marginCollapse = this->marginCollapse();
- auto collapsedAndPositiveNegativeValues = marginCollapse.collapsedVerticalValues(layoutBox, contentHeightAndMargin.nonCollapsedMargin);
+ auto verticalMargin = marginCollapse.collapsedVerticalValues(layoutBox, contentHeightAndMargin.nonCollapsedMargin);
// Cache the computed positive and negative margin value pair.
- formattingState().setPositiveAndNegativeVerticalMargin(layoutBox, collapsedAndPositiveNegativeValues.positiveAndNegativeVerticalValues);
- auto verticalMargin = UsedVerticalMargin { contentHeightAndMargin.nonCollapsedMargin, collapsedAndPositiveNegativeValues.collapsedValues };
formattingState().setUsedVerticalMargin(layoutBox, verticalMargin);
#if ASSERT_ENABLED
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (263945 => 263946)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-07-04 21:09:46 UTC (rev 263945)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-07-04 21:17:03 UTC (rev 263946)
@@ -99,11 +99,7 @@
// This class implements margin collapsing for block formatting context.
class MarginCollapse {
public:
- struct CollapsedAndPositiveNegativeValues {
- UsedVerticalMargin::CollapsedValues collapsedValues;
- PositiveAndNegativeVerticalMargin positiveAndNegativeVerticalValues;
- };
- CollapsedAndPositiveNegativeValues collapsedVerticalValues(const Box&, UsedVerticalMargin::NonCollapsedValues);
+ UsedVerticalMargin collapsedVerticalValues(const Box&, UsedVerticalMargin::NonCollapsedValues);
PrecomputedMarginBefore precomputedMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues);
LayoutUnit marginBeforeIgnoringCollapsingThrough(const Box&, UsedVerticalMargin::NonCollapsedValues);
@@ -127,15 +123,15 @@
MarginCollapse(const BlockFormattingContext&);
enum class MarginType { Before, After };
- PositiveAndNegativeVerticalMargin::Values positiveNegativeValues(const Box&, MarginType) const;
- PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
- PositiveAndNegativeVerticalMargin::Values positiveNegativeMarginAfter(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
+ UsedVerticalMargin::PositiveAndNegativePair::Values positiveNegativeValues(const Box&, MarginType) const;
+ UsedVerticalMargin::PositiveAndNegativePair::Values positiveNegativeMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
+ UsedVerticalMargin::PositiveAndNegativePair::Values positiveNegativeMarginAfter(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
- PositiveAndNegativeVerticalMargin::Values precomputedPositiveNegativeMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
- PositiveAndNegativeVerticalMargin::Values precomputedPositiveNegativeValues(const Box&) const;
+ UsedVerticalMargin::PositiveAndNegativePair::Values precomputedPositiveNegativeMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues) const;
+ UsedVerticalMargin::PositiveAndNegativePair::Values precomputedPositiveNegativeValues(const Box&) const;
- PositiveAndNegativeVerticalMargin::Values computedPositiveAndNegativeMargin(PositiveAndNegativeVerticalMargin::Values, PositiveAndNegativeVerticalMargin::Values) const;
- Optional<LayoutUnit> marginValue(PositiveAndNegativeVerticalMargin::Values) const;
+ UsedVerticalMargin::PositiveAndNegativePair::Values computedPositiveAndNegativeMargin(UsedVerticalMargin::PositiveAndNegativePair::Values, UsedVerticalMargin::PositiveAndNegativePair::Values) const;
+ Optional<LayoutUnit> marginValue(UsedVerticalMargin::PositiveAndNegativePair::Values) const;
bool hasClearance(const Box&) const;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h (263945 => 263946)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h 2020-07-04 21:09:46 UTC (rev 263945)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingState.h 2020-07-04 21:17:03 UTC (rev 263946)
@@ -40,15 +40,11 @@
BlockFormattingState(Ref<FloatingState>&&, LayoutState&);
~BlockFormattingState();
- void setPositiveAndNegativeVerticalMargin(const Box& layoutBox, PositiveAndNegativeVerticalMargin verticalMargin) { m_positiveAndNegativeVerticalMargin.set(&layoutBox, verticalMargin); }
- bool hasPositiveAndNegativeVerticalMargin(const Box& layoutBox) const { return m_positiveAndNegativeVerticalMargin.contains(&layoutBox); }
- PositiveAndNegativeVerticalMargin positiveAndNegativeVerticalMargin(const Box& layoutBox) const { return m_positiveAndNegativeVerticalMargin.get(&layoutBox); }
-
void setUsedVerticalMargin(const Box& layoutBox, const UsedVerticalMargin& usedVerticalMargin) { m_usedVerticalMargins.set(&layoutBox, usedVerticalMargin); }
UsedVerticalMargin usedVerticalMargin(const Box& layoutBox) const { return m_usedVerticalMargins.get(&layoutBox); }
+ bool hasUsedVerticalMargin(const Box& layoutBox) const { return m_usedVerticalMargins.contains(&layoutBox); }
private:
- HashMap<const Box*, PositiveAndNegativeVerticalMargin> m_positiveAndNegativeVerticalMargin;
HashMap<const Box*, UsedVerticalMargin> m_usedVerticalMargins;
};
Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (263945 => 263946)
--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2020-07-04 21:09:46 UTC (rev 263945)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2020-07-04 21:17:03 UTC (rev 263946)
@@ -433,9 +433,9 @@
return true;
}
-PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::computedPositiveAndNegativeMargin(PositiveAndNegativeVerticalMargin::Values a, PositiveAndNegativeVerticalMargin::Values b) const
+UsedVerticalMargin::PositiveAndNegativePair::Values BlockFormattingContext::MarginCollapse::computedPositiveAndNegativeMargin(UsedVerticalMargin::PositiveAndNegativePair::Values a, UsedVerticalMargin::PositiveAndNegativePair::Values b) const
{
- PositiveAndNegativeVerticalMargin::Values computedValues;
+ UsedVerticalMargin::PositiveAndNegativePair::Values computedValues;
if (a.positive && b.positive)
computedValues.positive = std::max(*a.positive, *b.positive);
else
@@ -456,7 +456,7 @@
return computedValues;
}
-Optional<LayoutUnit> BlockFormattingContext::MarginCollapse::marginValue(PositiveAndNegativeVerticalMargin::Values marginValues) const
+Optional<LayoutUnit> BlockFormattingContext::MarginCollapse::marginValue(UsedVerticalMargin::PositiveAndNegativePair::Values marginValues) const
{
// When two or more margins collapse, the resulting margin width is the maximum of the collapsing margins' widths.
// In the case of negative margins, the maximum of the absolute values of the negative adjoining margins is deducted from the maximum
@@ -493,15 +493,16 @@
collapsedVerticalMarginBefore = collapsedVerticalMarginAfter;
// Update positive/negative cache.
- auto previousSiblingPositiveNegativeMargin = blockFormattingState.positiveAndNegativeVerticalMargin(previousSibling);
- auto positiveNegativeMarginBefore = blockFormattingState.positiveAndNegativeVerticalMargin(*currentBox).before;
+ auto previousSiblingPositiveNegativeMargin = blockFormattingState.usedVerticalMargin(previousSibling).positiveAndNegativeValues;
+ auto positiveNegativeMarginBefore = blockFormattingState.usedVerticalMargin(*currentBox).positiveAndNegativeValues.before;
- previousSiblingPositiveNegativeMargin.after = marginCollapse.computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, previousSiblingPositiveNegativeMargin.after);
+ auto adjustedPreviousSiblingVerticalMargin = previousSiblingVerticalMargin;
+ adjustedPreviousSiblingVerticalMargin.positiveAndNegativeValues.after = marginCollapse.computedPositiveAndNegativeMargin(positiveNegativeMarginBefore, previousSiblingPositiveNegativeMargin.after);
if (marginsCollapseThrough) {
- previousSiblingPositiveNegativeMargin.before = marginCollapse.computedPositiveAndNegativeMargin(previousSiblingPositiveNegativeMargin.before, previousSiblingPositiveNegativeMargin.after);
- previousSiblingPositiveNegativeMargin.after = previousSiblingPositiveNegativeMargin.before;
+ adjustedPreviousSiblingVerticalMargin.positiveAndNegativeValues.before = marginCollapse.computedPositiveAndNegativeMargin(previousSiblingPositiveNegativeMargin.before, adjustedPreviousSiblingVerticalMargin.positiveAndNegativeValues.after);
+ adjustedPreviousSiblingVerticalMargin.positiveAndNegativeValues.after = adjustedPreviousSiblingVerticalMargin.positiveAndNegativeValues.before;
}
- blockFormattingState.setPositiveAndNegativeVerticalMargin(previousSibling, previousSiblingPositiveNegativeMargin);
+ blockFormattingState.setUsedVerticalMargin(previousSibling, adjustedPreviousSiblingVerticalMargin);
if (!marginsCollapseThrough)
break;
@@ -510,25 +511,25 @@
}
}
-PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::positiveNegativeValues(const Box& layoutBox, MarginType marginType) const
+UsedVerticalMargin::PositiveAndNegativePair::Values BlockFormattingContext::MarginCollapse::positiveNegativeValues(const Box& layoutBox, MarginType marginType) const
{
auto& blockFormattingState = downcast<BlockFormattingState>(layoutState().formattingStateForBox(layoutBox));
// By the time we get here in BFC layout to gather positive and negative margin values for either a previous sibling or a child box,
// we mush have computed and cached those values.
- ASSERT(blockFormattingState.hasPositiveAndNegativeVerticalMargin(layoutBox));
- auto positiveAndNegativeVerticalMargin = blockFormattingState.positiveAndNegativeVerticalMargin(layoutBox);
+ ASSERT(blockFormattingState.hasUsedVerticalMargin(layoutBox));
+ auto positiveAndNegativeVerticalMargin = blockFormattingState.usedVerticalMargin(layoutBox).positiveAndNegativeValues;
return marginType == MarginType::Before ? positiveAndNegativeVerticalMargin.before : positiveAndNegativeVerticalMargin.after;
}
-PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::positiveNegativeMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues) const
+UsedVerticalMargin::PositiveAndNegativePair::Values BlockFormattingContext::MarginCollapse::positiveNegativeMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues) const
{
- auto firstChildCollapsedMarginBefore = [&]() -> PositiveAndNegativeVerticalMargin::Values {
+ auto firstChildCollapsedMarginBefore = [&]() -> UsedVerticalMargin::PositiveAndNegativePair::Values {
if (!marginBeforeCollapsesWithFirstInFlowChildMarginBefore(layoutBox))
return { };
return positiveNegativeValues(*downcast<ContainerBox>(layoutBox).firstInFlowChild(), MarginType::Before);
};
- auto previouSiblingCollapsedMarginAfter = [&]() -> PositiveAndNegativeVerticalMargin::Values {
+ auto previouSiblingCollapsedMarginAfter = [&]() -> UsedVerticalMargin::PositiveAndNegativePair::Values {
if (!marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutBox))
return { };
return positiveNegativeValues(*layoutBox.previousInFlowSibling(), MarginType::After);
@@ -541,7 +542,7 @@
if (collapsedMarginBefore.isQuirk && formattingContext().quirks().shouldIgnoreCollapsedQuirkMargin(layoutBox))
collapsedMarginBefore = { };
- PositiveAndNegativeVerticalMargin::Values nonCollapsedBefore;
+ UsedVerticalMargin::PositiveAndNegativePair::Values nonCollapsedBefore;
if (nonCollapsedValues.before > 0)
nonCollapsedBefore = { nonCollapsedValues.before, { }, layoutBox.style().hasMarginBeforeQuirk() };
else if (nonCollapsedValues.before < 0)
@@ -550,9 +551,9 @@
return computedPositiveAndNegativeMargin(collapsedMarginBefore, nonCollapsedBefore);
}
-PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues) const
+UsedVerticalMargin::PositiveAndNegativePair::Values BlockFormattingContext::MarginCollapse::positiveNegativeMarginAfter(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues) const
{
- auto lastChildCollapsedMarginAfter = [&]() -> PositiveAndNegativeVerticalMargin::Values {
+ auto lastChildCollapsedMarginAfter = [&]() -> UsedVerticalMargin::PositiveAndNegativePair::Values {
if (!marginAfterCollapsesWithLastInFlowChildMarginAfter(layoutBox))
return { };
return positiveNegativeValues(*downcast<ContainerBox>(layoutBox).lastInFlowChild(), MarginType::After);
@@ -560,7 +561,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 updateMarginAfterForPreviousSibling.
- PositiveAndNegativeVerticalMargin::Values nonCollapsedAfter;
+ UsedVerticalMargin::PositiveAndNegativePair::Values nonCollapsedAfter;
if (nonCollapsedValues.after > 0)
nonCollapsedAfter = { nonCollapsedValues.after, { }, layoutBox.style().hasMarginAfterQuirk() };
else if (nonCollapsedValues.after < 0)
@@ -575,7 +576,7 @@
return marginValue(positiveNegativeMarginBefore(layoutBox, nonCollapsedValues)).valueOr(nonCollapsedValues.before);
}
-BlockFormattingContext::MarginCollapse::CollapsedAndPositiveNegativeValues BlockFormattingContext::MarginCollapse::collapsedVerticalValues(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
+UsedVerticalMargin BlockFormattingContext::MarginCollapse::collapsedVerticalValues(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues)
{
ASSERT(layoutBox.isBlockLevelBox());
// 1. Get min/max margin top values from the first in-flow child if we are collapsing margin top with it.
@@ -582,7 +583,7 @@
// 2. Get min/max margin top values from the previous in-flow sibling, if we are collapsing margin top with it.
// 3. Get this layout box's computed margin top value.
// 4. Update the min/max value and compute the final margin.
- auto positiveAndNegativeVerticalMargin = PositiveAndNegativeVerticalMargin { this->positiveNegativeMarginBefore(layoutBox, nonCollapsedValues), this->positiveNegativeMarginAfter(layoutBox, nonCollapsedValues) };
+ auto positiveAndNegativeVerticalMargin = UsedVerticalMargin::PositiveAndNegativePair { this->positiveNegativeMarginBefore(layoutBox, nonCollapsedValues), this->positiveNegativeMarginAfter(layoutBox, nonCollapsedValues) };
auto marginsCollapseThrough = this->marginsCollapseThrough(layoutBox);
if (marginsCollapseThrough) {
@@ -592,14 +593,15 @@
auto hasCollapsedMarginBefore = marginBeforeCollapsesWithFirstInFlowChildMarginBefore(layoutBox) || marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutBox);
auto hasCollapsedMarginAfter = marginAfterCollapsesWithLastInFlowChildMarginAfter(layoutBox);
+ auto usedVerticalMargin = UsedVerticalMargin { nonCollapsedValues, { }, positiveAndNegativeVerticalMargin };
if ((hasCollapsedMarginBefore && hasCollapsedMarginAfter) || marginsCollapseThrough)
- return { { marginValue(positiveAndNegativeVerticalMargin.before), marginValue(positiveAndNegativeVerticalMargin.after), marginsCollapseThrough }, positiveAndNegativeVerticalMargin };
- if (hasCollapsedMarginBefore)
- return { { marginValue(positiveAndNegativeVerticalMargin.before), { }, false }, positiveAndNegativeVerticalMargin };
- if (hasCollapsedMarginAfter)
- return { { { }, marginValue(positiveAndNegativeVerticalMargin.after), false }, positiveAndNegativeVerticalMargin };
- return { { { }, { }, false }, positiveAndNegativeVerticalMargin };
+ usedVerticalMargin.collapsedValues = { marginValue(positiveAndNegativeVerticalMargin.before), marginValue(positiveAndNegativeVerticalMargin.after), marginsCollapseThrough };
+ else if (hasCollapsedMarginBefore)
+ usedVerticalMargin.collapsedValues = { marginValue(positiveAndNegativeVerticalMargin.before), { }, false };
+ else if (hasCollapsedMarginAfter)
+ usedVerticalMargin.collapsedValues = { { }, marginValue(positiveAndNegativeVerticalMargin.after), false };
+ return usedVerticalMargin;
}
}
Modified: trunk/Source/WebCore/layout/blockformatting/PrecomputedBlockMarginCollapse.cpp (263945 => 263946)
--- trunk/Source/WebCore/layout/blockformatting/PrecomputedBlockMarginCollapse.cpp 2020-07-04 21:09:46 UTC (rev 263945)
+++ trunk/Source/WebCore/layout/blockformatting/PrecomputedBlockMarginCollapse.cpp 2020-07-04 21:17:03 UTC (rev 263946)
@@ -38,11 +38,11 @@
namespace WebCore {
namespace Layout {
-PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeValues(const Box& layoutBox) const
+UsedVerticalMargin::PositiveAndNegativePair::Values BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeValues(const Box& layoutBox) const
{
auto& blockFormattingState = downcast<BlockFormattingState>(layoutState().formattingStateForBox(layoutBox));
- if (blockFormattingState.hasPositiveAndNegativeVerticalMargin(layoutBox))
- return blockFormattingState.positiveAndNegativeVerticalMargin(layoutBox).before;
+ if (blockFormattingState.hasUsedVerticalMargin(layoutBox))
+ return blockFormattingState.usedVerticalMargin(layoutBox).positiveAndNegativeValues.before;
auto geometry = formattingContext().geometry();
auto horizontalConstraints = geometry.constraintsForInFlowContent(layoutBox.containingBlock()).horizontal;
@@ -51,20 +51,20 @@
return precomputedPositiveNegativeMarginBefore(layoutBox, nonCollapsedMargin);
}
-PositiveAndNegativeVerticalMargin::Values BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues) const
+UsedVerticalMargin::PositiveAndNegativePair::Values BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues nonCollapsedValues) const
{
- auto firstChildCollapsedMarginBefore = [&]() -> PositiveAndNegativeVerticalMargin::Values {
+ auto firstChildCollapsedMarginBefore = [&]() -> UsedVerticalMargin::PositiveAndNegativePair::Values {
if (!marginBeforeCollapsesWithFirstInFlowChildMarginBefore(layoutBox))
return { };
return precomputedPositiveNegativeValues(*downcast<ContainerBox>(layoutBox).firstInFlowChild());
};
- auto previouSiblingCollapsedMarginAfter = [&]() -> PositiveAndNegativeVerticalMargin::Values {
+ auto previouSiblingCollapsedMarginAfter = [&]() -> UsedVerticalMargin::PositiveAndNegativePair::Values {
if (!marginBeforeCollapsesWithPreviousSiblingMarginAfter(layoutBox))
return { };
auto& previousInFlowSibling = *layoutBox.previousInFlowSibling();
auto& blockFormattingState = downcast<BlockFormattingState>(layoutState().formattingStateForBox(previousInFlowSibling));
- return blockFormattingState.positiveAndNegativeVerticalMargin(previousInFlowSibling).after;
+ return blockFormattingState.usedVerticalMargin(previousInFlowSibling).positiveAndNegativeValues.after;
};
// 1. Gather positive and negative margin values from first child if margins are adjoining.
@@ -74,7 +74,7 @@
if (collapsedMarginBefore.isQuirk && formattingContext().quirks().shouldIgnoreCollapsedQuirkMargin(layoutBox))
collapsedMarginBefore = { };
- auto nonCollapsedBefore = PositiveAndNegativeVerticalMargin::Values { };
+ auto nonCollapsedBefore = UsedVerticalMargin::PositiveAndNegativePair::Values { };
if (nonCollapsedValues.before > 0)
nonCollapsedBefore = { nonCollapsedValues.before, { }, layoutBox.style().hasMarginBeforeQuirk() };
else if (nonCollapsedValues.before < 0)
Modified: trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp (263945 => 263946)
--- trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp 2020-07-04 21:09:46 UTC (rev 263945)
+++ trunk/Source/WebCore/layout/blockformatting/tablewrapper/TableWrapperBlockFormattingContext.cpp 2020-07-04 21:17:03 UTC (rev 263946)
@@ -220,10 +220,8 @@
auto heightAndMargin = geometry().inFlowHeightAndMargin(tableBox, constraints.horizontal, { quirks().overrideTableHeight(tableBox) });
auto marginCollapse = this->marginCollapse();
- auto collapsedAndPositiveNegativeValues = marginCollapse.collapsedVerticalValues(tableBox, heightAndMargin.nonCollapsedMargin);
+ auto verticalMargin = marginCollapse.collapsedVerticalValues(tableBox, heightAndMargin.nonCollapsedMargin);
// Cache the computed positive and negative margin value pair.
- formattingState().setPositiveAndNegativeVerticalMargin(tableBox, collapsedAndPositiveNegativeValues.positiveAndNegativeVerticalValues);
- auto verticalMargin = UsedVerticalMargin { heightAndMargin.nonCollapsedMargin, collapsedAndPositiveNegativeValues.collapsedValues };
formattingState().setUsedVerticalMargin(tableBox, verticalMargin);
auto& displayBox = formattingState().displayBox(tableBox);