Diff
Modified: trunk/Source/WebCore/ChangeLog (256099 => 256100)
--- trunk/Source/WebCore/ChangeLog 2020-02-09 03:45:11 UTC (rev 256099)
+++ trunk/Source/WebCore/ChangeLog 2020-02-09 04:12:31 UTC (rev 256100)
@@ -1,5 +1,48 @@
2020-02-08 Zalan Bujtas <[email protected]>
+ [LFC][BFC] Replace "estimated" term with "precomputed"
+ https://bugs.webkit.org/show_bug.cgi?id=207433
+ <rdar://problem/59288794>
+
+ Reviewed by Antti Koivisto.
+
+ The term "pre-computed" describes better what this value is.
+
+ * layout/MarginTypes.h:
+ (WebCore::Layout::EstimatedMarginBefore::usedValue const): Deleted.
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::usedAvailableWidthForFloatAvoider const):
+ (WebCore::Layout::BlockFormattingContext::precomputeVerticalPosition):
+ (WebCore::Layout::BlockFormattingContext::precomputeVerticalPositionForAncestors):
+ (WebCore::Layout::BlockFormattingContext::precomputeVerticalPositionForFormattingRoot):
+ (WebCore::Layout::BlockFormattingContext::computePositionToAvoidFloats):
+ (WebCore::Layout::BlockFormattingContext::computeHeightAndMargin):
+ (WebCore::Layout::BlockFormattingContext::setPrecomputedMarginBefore):
+ (WebCore::Layout::BlockFormattingContext::hasPrecomputedMarginBefore const):
+ (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition): Deleted.
+ (WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPositionForAncestors): Deleted.
+ (WebCore::Layout::BlockFormattingContext::setEstimatedMarginBefore): Deleted.
+ (WebCore::Layout::BlockFormattingContext::hasEstimatedMarginBefore const): Deleted.
+ * layout/blockformatting/BlockFormattingContext.h:
+ * layout/blockformatting/BlockMarginCollapse.cpp:
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::hasClearance const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::updateMarginAfterForPreviousSibling):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::positiveNegativeValues const):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedMarginBefore):
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::estimatedMarginBefore): Deleted.
+ * layout/displaytree/DisplayBox.cpp:
+ (WebCore::Display::Box::Box):
+ * layout/displaytree/DisplayBox.h:
+ (WebCore::Display::Box::setHasPrecomputedMarginBefore):
+ (WebCore::Display::Box::invalidatePrecomputedMarginBefore):
+ (WebCore::Display::Box::top const):
+ (WebCore::Display::Box::topLeft const):
+ (WebCore::Display::Box::setVerticalMargin):
+ (WebCore::Display::Box::setHasEstimatedMarginBefore): Deleted.
+ (WebCore::Display::Box::invalidateEstimatedMarginBefore): Deleted.
+
+2020-02-08 Zalan Bujtas <[email protected]>
+
[LFC][BFC] Pre-compute vertical position only when we really need it.
https://bugs.webkit.org/show_bug.cgi?id=207432
<rdar://problem/59288539>
Modified: trunk/Source/WebCore/layout/MarginTypes.h (256099 => 256100)
--- trunk/Source/WebCore/layout/MarginTypes.h 2020-02-09 03:45:11 UTC (rev 256099)
+++ trunk/Source/WebCore/layout/MarginTypes.h 2020-02-09 04:12:31 UTC (rev 256100)
@@ -75,7 +75,7 @@
LayoutUnit end;
};
-struct EstimatedMarginBefore {
+struct PrecomputedMarginBefore {
LayoutUnit usedValue() const { return collapsedValue.valueOr(nonCollapsedValue); }
LayoutUnit nonCollapsedValue;
Optional<LayoutUnit> collapsedValue;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (256099 => 256100)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-02-09 03:45:11 UTC (rev 256099)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-02-09 04:12:31 UTC (rev 256100)
@@ -181,7 +181,7 @@
ASSERT(layoutBox.isFloatAvoider());
if (floatingContext.isEmpty())
return { };
- // Vertical static position is not computed yet, so let's just estimate it for now.
+ // Vertical static position is not computed yet, so let's just pre-compute it for now.
auto verticalPosition = mapTopToFormattingContextRoot(layoutBox);
auto constraints = floatingContext.constraints({ verticalPosition });
if (!constraints.left && !constraints.right)
@@ -233,27 +233,27 @@
formattingState().displayBox(layoutBox).setLeft(geometry().staticHorizontalPosition(layoutBox, horizontalConstraints.containingBlock));
}
-void BlockFormattingContext::computeEstimatedVerticalPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints)
+void BlockFormattingContext::precomputeVerticalPosition(const Box& layoutBox, const HorizontalConstraints& horizontalConstraints, const VerticalConstraints& verticalConstraints)
{
auto computedVerticalMargin = geometry().computedVerticalMargin(layoutBox, horizontalConstraints);
auto usedNonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
- auto estimatedMarginBefore = marginCollapse().estimatedMarginBefore(layoutBox, usedNonCollapsedMargin);
- setEstimatedMarginBefore(layoutBox, estimatedMarginBefore);
+ auto precomputedMarginBefore = marginCollapse().precomputedMarginBefore(layoutBox, usedNonCollapsedMargin);
+ setPrecomputedMarginBefore(layoutBox, precomputedMarginBefore);
auto& displayBox = formattingState().displayBox(layoutBox);
- auto nonCollapsedValues = UsedVerticalMargin::NonCollapsedValues { estimatedMarginBefore.nonCollapsedValue, { } };
- auto collapsedValues = UsedVerticalMargin::CollapsedValues { estimatedMarginBefore.collapsedValue, { }, estimatedMarginBefore.isCollapsedThrough };
+ auto nonCollapsedValues = UsedVerticalMargin::NonCollapsedValues { precomputedMarginBefore.nonCollapsedValue, { } };
+ auto collapsedValues = UsedVerticalMargin::CollapsedValues { precomputedMarginBefore.collapsedValue, { }, precomputedMarginBefore.isCollapsedThrough };
auto verticalMargin = UsedVerticalMargin { nonCollapsedValues, collapsedValues };
displayBox.setVerticalMargin(verticalMargin);
displayBox.setTop(verticalPositionWithMargin(layoutBox, verticalMargin, verticalConstraints));
#if ASSERT_ENABLED
- displayBox.setHasEstimatedMarginBefore();
+ displayBox.setHasPrecomputedMarginBefore();
#endif
}
-void BlockFormattingContext::computeEstimatedVerticalPositionForAncestors(const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints, const ConstraintsPair<VerticalConstraints>& verticalConstraints)
+void BlockFormattingContext::precomputeVerticalPositionForAncestors(const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints, const ConstraintsPair<VerticalConstraints>& verticalConstraints)
{
- // We only need to estimate margin top for float related layout (formatting context roots avoid floats).
+ // We only need to pre-compute the margin top for float related layout (formatting context roots avoid floats).
ASSERT(layoutBox.isFloatAvoider() || layoutBox.establishesInlineFormattingContext());
// In order to figure out whether a box should avoid a float, we need to know the final positions of both (ignore relative positioning for now).
@@ -267,8 +267,8 @@
// The idea here is that as long as we don't cross the block formatting context boundary, we should be able to pre-compute the final top position.
// FIXME: we currently don't account for the "clear" property when computing the final position for an ancestor.
for (auto* ancestor = layoutBox.containingBlock(); ancestor && !ancestor->establishesBlockFormattingContext(); ancestor = ancestor->containingBlock()) {
- // FIXME: with incremental layout, we might actually have a valid (non-estimated) margin top as well.
- if (hasEstimatedMarginBefore(*ancestor))
+ // FIXME: with incremental layout, we might actually have a valid (non-precomputed) margin top as well.
+ if (hasPrecomputedMarginBefore(*ancestor))
return;
auto horizontalConstraintsForAncestor = [&] {
auto* containingBlock = layoutBox.containingBlock();
@@ -278,7 +278,7 @@
auto* containingBlock = layoutBox.containingBlock();
return containingBlock == &root() ? verticalConstraints.root : Geometry::verticalConstraintsForInFlow(geometryForBox(*containingBlock));
};
- computeEstimatedVerticalPosition(*ancestor, horizontalConstraintsForAncestor(), verticalConstraintsForAncestor());
+ precomputeVerticalPosition(*ancestor, horizontalConstraintsForAncestor(), verticalConstraintsForAncestor());
}
}
@@ -288,8 +288,8 @@
if (layoutBox.isFloatAvoider() && !layoutBox.hasFloatClear())
return;
// We need the final vertical position when the formatting context inherits floats from the parent FC.
- computeEstimatedVerticalPositionForAncestors(layoutBox, horizontalConstraints, verticalConstraints);
- computeEstimatedVerticalPosition(layoutBox, horizontalConstraints.containingBlock, verticalConstraints.containingBlock);
+ precomputeVerticalPositionForAncestors(layoutBox, horizontalConstraints, verticalConstraints);
+ precomputeVerticalPosition(layoutBox, horizontalConstraints.containingBlock, verticalConstraints.containingBlock);
if (layoutBox.hasFloatClear()) {
// if we just let the box sit at the static vertical position, we might find unrelated float boxes there (boxes that we need to clear).
computeVerticalPositionForFloatClear(floatingContext, layoutBox);
@@ -304,7 +304,7 @@
// to a different set of containing blocks (but they all descendants of the BFC root).
// However according to the BFC rules, at this point of the layout flow we don't yet have computed vertical positions for the ancestors.
if (layoutBox.isFloatingPositioned()) {
- computeEstimatedVerticalPositionForAncestors(layoutBox, horizontalConstraints, verticalConstraints);
+ precomputeVerticalPositionForAncestors(layoutBox, horizontalConstraints, verticalConstraints);
formattingState().displayBox(layoutBox).setTopLeft(floatingContext.positionForFloat(layoutBox));
return;
}
@@ -311,7 +311,7 @@
// Non-float positioned float avoiders (formatting context roots and clear boxes) should be fine unless there are floats in this context.
if (floatingContext.isEmpty())
return;
- computeEstimatedVerticalPositionForAncestors(layoutBox, horizontalConstraints, verticalConstraints);
+ precomputeVerticalPositionForAncestors(layoutBox, horizontalConstraints, verticalConstraints);
if (layoutBox.hasFloatClear())
return computeVerticalPositionForFloatClear(floatingContext, layoutBox);
@@ -417,14 +417,14 @@
// Out of flow boxes don't need vertical adjustment after margin collapsing.
if (layoutBox.isOutOfFlowPositioned()) {
- ASSERT(!hasEstimatedMarginBefore(layoutBox));
+ ASSERT(!hasPrecomputedMarginBefore(layoutBox));
displayBox.setContentBoxHeight(contentHeightAndMargin.contentHeight);
displayBox.setVerticalMargin(verticalMargin);
return;
}
- ASSERT(!hasEstimatedMarginBefore(layoutBox) || estimatedMarginBefore(layoutBox).usedValue() == verticalMargin.before());
- removeEstimatedMarginBefore(layoutBox);
+ ASSERT(!hasPrecomputedMarginBefore(layoutBox) || precomputedMarginBefore(layoutBox).usedValue() == verticalMargin.before());
+ removePrecomputedMarginBefore(layoutBox);
displayBox.setTop(verticalPositionWithMargin(layoutBox, verticalMargin, verticalConstraints.containingBlock));
displayBox.setContentBoxHeight(contentHeightAndMargin.contentHeight);
displayBox.setVerticalMargin(verticalMargin);
@@ -540,18 +540,18 @@
return containingBlockContentBoxTop + verticalMargin.before();
}
-void BlockFormattingContext::setEstimatedMarginBefore(const Box& layoutBox, const EstimatedMarginBefore& estimatedMarginBefore)
+void BlockFormattingContext::setPrecomputedMarginBefore(const Box& layoutBox, const PrecomputedMarginBefore& precomputedMarginBefore)
{
// Can't cross formatting context boundary.
ASSERT(&layoutState().formattingStateForBox(layoutBox) == &formattingState());
- m_estimatedMarginBeforeList.set(&layoutBox, estimatedMarginBefore);
+ m_precomputedMarginBeforeList.set(&layoutBox, precomputedMarginBefore);
}
-bool BlockFormattingContext::hasEstimatedMarginBefore(const Box& layoutBox) const
+bool BlockFormattingContext::hasPrecomputedMarginBefore(const Box& layoutBox) const
{
// Can't cross formatting context boundary.
ASSERT(&layoutState().formattingStateForBox(layoutBox) == &formattingState());
- return m_estimatedMarginBeforeList.contains(&layoutBox);
+ return m_precomputedMarginBeforeList.contains(&layoutBox);
}
}
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (256099 => 256100)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-02-09 03:45:11 UTC (rev 256099)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-02-09 04:12:31 UTC (rev 256100)
@@ -67,8 +67,8 @@
void computePositionToAvoidFloats(const FloatingContext&, const Box&, const ConstraintsPair<HorizontalConstraints>&, const ConstraintsPair<VerticalConstraints>&);
void computeVerticalPositionForFloatClear(const FloatingContext&, const Box&);
- void computeEstimatedVerticalPosition(const Box&, const HorizontalConstraints&, const VerticalConstraints&);
- void computeEstimatedVerticalPositionForAncestors(const Box&, const ConstraintsPair<HorizontalConstraints>&, const ConstraintsPair<VerticalConstraints>&);
+ void precomputeVerticalPosition(const Box&, const HorizontalConstraints&, const VerticalConstraints&);
+ void precomputeVerticalPositionForAncestors(const Box&, const ConstraintsPair<HorizontalConstraints>&, const ConstraintsPair<VerticalConstraints>&);
void precomputeVerticalPositionForFormattingRoot(const FloatingContext&, const Box&, const ConstraintsPair<HorizontalConstraints>&, const ConstraintsPair<VerticalConstraints>&);
IntrinsicWidthConstraints computedIntrinsicWidthConstraints() override;
@@ -104,7 +104,7 @@
public:
UsedVerticalMargin::CollapsedValues collapsedVerticalValues(const Box&, UsedVerticalMargin::NonCollapsedValues);
- EstimatedMarginBefore estimatedMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues);
+ PrecomputedMarginBefore precomputedMarginBefore(const Box&, UsedVerticalMargin::NonCollapsedValues);
LayoutUnit marginBeforeIgnoringCollapsingThrough(const Box&, UsedVerticalMargin::NonCollapsedValues);
static void updateMarginAfterForPreviousSibling(BlockFormattingContext&, const MarginCollapse&, const Box&);
static void updatePositiveNegativeMarginValues(BlockFormattingContext&, const MarginCollapse&, const Box&);
@@ -158,13 +158,12 @@
};
BlockFormattingContext::Quirks quirks() const { return Quirks(*this); }
- void setEstimatedMarginBefore(const Box&, const EstimatedMarginBefore&);
- void removeEstimatedMarginBefore(const Box& layoutBox) { m_estimatedMarginBeforeList.remove(&layoutBox); }
- bool hasEstimatedMarginBefore(const Box&) const;
+ void setPrecomputedMarginBefore(const Box&, const PrecomputedMarginBefore&);
+ void removePrecomputedMarginBefore(const Box& layoutBox) { m_precomputedMarginBeforeList.remove(&layoutBox); }
+ bool hasPrecomputedMarginBefore(const Box&) const;
Optional<LayoutUnit> usedAvailableWidthForFloatAvoider(const FloatingContext&, const Box&) const;
#if ASSERT_ENABLED
- EstimatedMarginBefore estimatedMarginBefore(const Box& layoutBox) const { return m_estimatedMarginBeforeList.get(&layoutBox); }
- bool hasPrecomputedMarginBefore(const Box&) const;
+ PrecomputedMarginBefore precomputedMarginBefore(const Box& layoutBox) const { return m_precomputedMarginBeforeList.get(&layoutBox); }
#endif
const BlockFormattingState& formattingState() const { return downcast<BlockFormattingState>(FormattingContext::formattingState()); }
@@ -171,7 +170,7 @@
BlockFormattingState& formattingState() { return downcast<BlockFormattingState>(FormattingContext::formattingState()); }
private:
- HashMap<const Box*, EstimatedMarginBefore> m_estimatedMarginBeforeList;
+ HashMap<const Box*, PrecomputedMarginBefore> m_precomputedMarginBeforeList;
};
inline BlockFormattingContext::Geometry::Geometry(const BlockFormattingContext& blockFormattingContext)
Modified: trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp (256099 => 256100)
--- trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2020-02-09 03:45:11 UTC (rev 256099)
+++ trunk/Source/WebCore/layout/blockformatting/BlockMarginCollapse.cpp 2020-02-09 04:12:31 UTC (rev 256100)
@@ -85,7 +85,7 @@
{
if (!layoutBox.hasFloatClear())
return false;
- // FIXME: computeEstimatedVerticalPositionForFormattingRoot logic ends up calling into this function when the layoutBox (first inflow child) has
+ // FIXME: precomputedVerticalPositionForFormattingRoot logic ends up calling into this function when the layoutBox (first inflow child) has
// not been laid out.
if (!layoutState().hasDisplayBox(layoutBox))
return false;
@@ -472,7 +472,7 @@
// 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).
+ // 7. No need to propagate to parent because its margin is not computed yet (pre-computed at most).
auto* currentBox = &layoutBox;
auto& blockFormattingState = blockFormattingContext.formattingState();
while (marginCollapse.marginBeforeCollapsesWithPreviousSiblingMarginAfter(*currentBox)) {
@@ -513,7 +513,7 @@
auto positiveAndNegativeVerticalMargin = blockFormattingState.positiveAndNegativeVerticalMargin(layoutBox);
return marginType == MarginType::Before ? positiveAndNegativeVerticalMargin.before : positiveAndNegativeVerticalMargin.after;
}
- // This is the estimate path. We don't yet have positive/negative margin computed.
+ // This is the pre-computed path. We don't yet have positive/negative margin computed.
auto computedVerticalMargin = formattingContext().geometry().computedVerticalMargin(layoutBox, Geometry::horizontalConstraintsForInFlow(formattingContext().geometryForBox(*layoutBox.containingBlock())));
auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
@@ -571,10 +571,10 @@
return computedPositiveAndNegativeMargin(lastChildCollapsedMarginAfter(), nonCollapsedAfter);
}
-EstimatedMarginBefore BlockFormattingContext::MarginCollapse::estimatedMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues usedNonCollapsedMargin)
+PrecomputedMarginBefore BlockFormattingContext::MarginCollapse::precomputedMarginBefore(const Box& layoutBox, UsedVerticalMargin::NonCollapsedValues usedNonCollapsedMargin)
{
ASSERT(layoutBox.isBlockLevelBox());
- // Don't estimate vertical margins for out of flow boxes.
+ // Don't pre-compute vertical margins for out of flow boxes.
ASSERT(layoutBox.isInFlow() || layoutBox.isFloatingPositioned());
ASSERT(!layoutBox.replaced());
Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp (256099 => 256100)
--- trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp 2020-02-09 03:45:11 UTC (rev 256099)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.cpp 2020-02-09 04:12:31 UTC (rev 256100)
@@ -56,7 +56,7 @@
, m_hasValidPadding(other.m_hasValidPadding)
, m_hasValidContentHeight(other.m_hasValidContentHeight)
, m_hasValidContentWidth(other.m_hasValidContentWidth)
- , m_hasEstimatedMarginBefore(other.m_hasEstimatedMarginBefore)
+ , m_hasPrecomputedMarginBefore(other.m_hasPrecomputedMarginBefore)
#endif
{
}
Modified: trunk/Source/WebCore/layout/displaytree/DisplayBox.h (256099 => 256100)
--- trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2020-02-09 03:45:11 UTC (rev 256099)
+++ trunk/Source/WebCore/layout/displaytree/DisplayBox.h 2020-02-09 04:12:31 UTC (rev 256100)
@@ -113,7 +113,7 @@
Rect contentBox() const;
#if ASSERT_ENABLED
- void setHasEstimatedMarginBefore() { m_hasEstimatedMarginBefore = true; }
+ void setHasPrecomputedMarginBefore() { m_hasPrecomputedMarginBefore = true; }
#endif
void setTopLeft(const LayoutPoint&);
@@ -140,7 +140,7 @@
void invalidateMargin();
void invalidateBorder() { m_hasValidBorder = false; }
void invalidatePadding() { m_hasValidPadding = false; }
- void invalidateEstimatedMarginBefore() { m_hasEstimatedMarginBefore = false; }
+ void invalidatePrecomputedMarginBefore() { m_hasPrecomputedMarginBefore = false; }
void setHasValidTop() { m_hasValidTop = true; }
void setHasValidLeft() { m_hasValidLeft = true; }
@@ -179,7 +179,7 @@
bool m_hasValidPadding { false };
bool m_hasValidContentHeight { false };
bool m_hasValidContentWidth { false };
- bool m_hasEstimatedMarginBefore { false };
+ bool m_hasPrecomputedMarginBefore { false };
#endif // ASSERT_ENABLED
};
@@ -193,7 +193,7 @@
inline LayoutUnit Box::top() const
{
- ASSERT(m_hasValidTop && (m_hasEstimatedMarginBefore || m_hasValidVerticalMargin));
+ ASSERT(m_hasValidTop && (m_hasPrecomputedMarginBefore || m_hasValidVerticalMargin));
return m_topLeft.y();
}
@@ -205,7 +205,7 @@
inline LayoutPoint Box::topLeft() const
{
- ASSERT(m_hasValidTop && (m_hasEstimatedMarginBefore || m_hasValidVerticalMargin));
+ ASSERT(m_hasValidTop && (m_hasPrecomputedMarginBefore || m_hasValidVerticalMargin));
ASSERT(m_hasValidLeft && m_hasValidHorizontalMargin);
return m_topLeft;
}
@@ -276,7 +276,7 @@
#if ASSERT_ENABLED
setHasValidVerticalMargin();
setHasValidVerticalNonCollapsedMargin();
- invalidateEstimatedMarginBefore();
+ invalidatePrecomputedMarginBefore();
#endif
m_verticalMargin = margin;
}