Diff
Modified: trunk/Source/WebCore/ChangeLog (260897 => 260898)
--- trunk/Source/WebCore/ChangeLog 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/ChangeLog 2020-04-29 16:06:32 UTC (rev 260898)
@@ -1,3 +1,32 @@
+2020-04-29 Zalan Bujtas <[email protected]>
+
+ [LFC] FormattingContext::constraintsForInFlow/OutOfFlowContent should take const ContainerBox&
+ https://bugs.webkit.org/show_bug.cgi?id=211161
+
+ Reviewed by Antti Koivisto.
+
+ Leaf boxes should not need to compute constraints (as by definition they don't have in/out-of-flow descendants).
+
+ * layout/FormattingContext.cpp:
+ (WebCore::Layout::FormattingContext::layoutOutOfFlowContent):
+ * layout/FormattingContext.h:
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::constraintsForOutOfFlowContent):
+ (WebCore::Layout::FormattingContext::Geometry::constraintsForInFlowContent):
+ * layout/FormattingContextQuirks.cpp:
+ (WebCore::Layout::FormattingContext::Quirks::heightValueOfNearestContainingBlockWithFixedHeight):
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
+ (WebCore::Layout::BlockFormattingContext::precomputeVerticalPositionForBoxAndAncestors):
+ * layout/blockformatting/BlockFormattingContextQuirks.cpp:
+ (WebCore::Layout::BlockFormattingContext::Quirks::stretchedInFlowHeight):
+ * layout/blockformatting/PrecomputedBlockMarginCollapse.cpp:
+ (WebCore::Layout::BlockFormattingContext::MarginCollapse::precomputedPositiveNegativeValues const):
+ * layout/inlineformatting/InlineFormattingContext.cpp:
+ (WebCore::Layout::InlineFormattingContext::layoutInFlowContent):
+ * layout/tableformatting/TableFormattingContext.cpp:
+ (WebCore::Layout::TableFormattingContext::layoutCell):
+
2020-04-29 Joonghun Park <[email protected]>
Unreviewed. Remove no longer used variable and the build warning below.
Modified: trunk/Source/WebCore/layout/FormattingContext.cpp (260897 => 260898)
--- trunk/Source/WebCore/layout/FormattingContext.cpp 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/FormattingContext.cpp 2020-04-29 16:06:32 UTC (rev 260898)
@@ -141,7 +141,7 @@
auto constraintsForLayoutBox = [&] (const auto& outOfFlowBox) {
auto& containingBlock = outOfFlowBox.containingBlock();
- return &containingBlock == &root() ? constraints : Geometry::constraintsForOutOfFlowContent(geometryForBox(containingBlock));
+ return &containingBlock == &root() ? constraints : geometry().constraintsForOutOfFlowContent(containingBlock);
};
for (auto& outOfFlowBox : formattingState().outOfFlowBoxes()) {
@@ -154,19 +154,14 @@
computeBorderAndPadding(*outOfFlowBox, horizontalConstraintsForBorderAndPadding);
computeOutOfFlowHorizontalGeometry(*outOfFlowBox, containingBlockConstraints);
- if (is<ContainerBox>(*outOfFlowBox)) {
+ auto outOfFlowBoxHasContent = is<ContainerBox>(*outOfFlowBox) && downcast<ContainerBox>(*outOfFlowBox).hasChild();
+ if (outOfFlowBoxHasContent) {
auto& containerBox = downcast<ContainerBox>(*outOfFlowBox);
- auto& containerDisplayBox = geometryForBox(containerBox);
-
- if (containerBox.hasInFlowOrFloatingChild()) {
- auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState());
- formattingContext->layoutInFlowContent(invalidationState, Geometry::constraintsForInFlowContent(containerDisplayBox));
- }
+ auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState());
+ if (containerBox.hasInFlowOrFloatingChild())
+ formattingContext->layoutInFlowContent(invalidationState, geometry().constraintsForInFlowContent(containerBox));
computeOutOfFlowVerticalGeometry(containerBox, containingBlockConstraints);
- if (containerBox.hasChild()) {
- auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState());
- formattingContext->layoutOutOfFlowContent(invalidationState, Geometry::constraintsForOutOfFlowContent(containerDisplayBox));
- }
+ formattingContext->layoutOutOfFlowContent(invalidationState, geometry().constraintsForOutOfFlowContent(containerBox));
} else
computeOutOfFlowVerticalGeometry(*outOfFlowBox, containingBlockConstraints);
}
Modified: trunk/Source/WebCore/layout/FormattingContext.h (260897 => 260898)
--- trunk/Source/WebCore/layout/FormattingContext.h 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/FormattingContext.h 2020-04-29 16:06:32 UTC (rev 260898)
@@ -157,8 +157,8 @@
LayoutUnit contentHeightForFormattingContextRoot(const Box&) const;
- static ConstraintsForOutOfFlowContent constraintsForOutOfFlowContent(const Display::Box& containingBlockGeometry);
- static ConstraintsForInFlowContent constraintsForInFlowContent(const Display::Box& containingBlockGeometry);
+ ConstraintsForOutOfFlowContent constraintsForOutOfFlowContent(const ContainerBox&);
+ ConstraintsForInFlowContent constraintsForInFlowContent(const ContainerBox&, Optional<EscapeReason> = WTF::nullopt);
protected:
friend class FormattingContext;
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (260897 => 260898)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2020-04-29 16:06:32 UTC (rev 260898)
@@ -1098,17 +1098,19 @@
return intrinsicWidth;
}
-FormattingContext::ConstraintsForOutOfFlowContent FormattingContext::Geometry::constraintsForOutOfFlowContent(const Display::Box& containingBlockGeometry)
+FormattingContext::ConstraintsForOutOfFlowContent FormattingContext::Geometry::constraintsForOutOfFlowContent(const ContainerBox& containerBox)
{
+ auto& boxGeometry = formattingContext().geometryForBox(containerBox);
return {
- { containingBlockGeometry.paddingBoxLeft(), containingBlockGeometry.paddingBoxWidth() },
- { containingBlockGeometry.paddingBoxTop(), containingBlockGeometry.paddingBoxHeight() },
- containingBlockGeometry.contentBoxWidth() };
+ { boxGeometry.paddingBoxLeft(), boxGeometry.paddingBoxWidth() },
+ { boxGeometry.paddingBoxTop(), boxGeometry.paddingBoxHeight() },
+ boxGeometry.contentBoxWidth() };
}
-FormattingContext::ConstraintsForInFlowContent FormattingContext::Geometry::constraintsForInFlowContent(const Display::Box& containingBlockGeometry)
+FormattingContext::ConstraintsForInFlowContent FormattingContext::Geometry::constraintsForInFlowContent(const ContainerBox& containerBox, Optional<EscapeReason> escapeReason)
{
- return { { containingBlockGeometry.contentBoxLeft(), containingBlockGeometry.contentBoxWidth() }, { containingBlockGeometry.contentBoxTop(), { } } };
+ auto& boxGeometry = formattingContext().geometryForBox(containerBox, escapeReason);
+ return { { boxGeometry.contentBoxLeft(), boxGeometry.contentBoxWidth() }, { boxGeometry.contentBoxTop(), { } } };
}
}
Modified: trunk/Source/WebCore/layout/FormattingContextQuirks.cpp (260897 => 260898)
--- trunk/Source/WebCore/layout/FormattingContextQuirks.cpp 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/FormattingContextQuirks.cpp 2020-04-29 16:06:32 UTC (rev 260898)
@@ -50,11 +50,12 @@
// If the only fixed value box we find is the ICB, then ignore the body and the document (vertical) margin, padding and border. So much quirkiness.
// -and it's totally insane because now we freely travel across formatting context boundaries and computed margins are nonexistent.
if (containingBlock->isBodyBox() || containingBlock->isDocumentBox()) {
+
+ auto geometry = formattingContext.geometry();
+ auto horizontalConstraints = geometry.constraintsForInFlowContent(containingBlock->containingBlock(), FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk).horizontal;
+ auto verticalMargin = geometry.computedVerticalMargin(*containingBlock, horizontalConstraints);
+
auto& boxGeometry = formattingContext.geometryForBox(*containingBlock, FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk);
-
- auto& containingBlockDisplayBox = formattingContext.geometryForBox(containingBlock->containingBlock(), FormattingContext::EscapeReason::FindFixedHeightAncestorQuirk);
- auto horizontalConstraints = Geometry::constraintsForInFlowContent(containingBlockDisplayBox).horizontal;
- auto verticalMargin = formattingContext.geometry().computedVerticalMargin(*containingBlock, horizontalConstraints);
auto verticalPadding = boxGeometry.paddingTop().valueOr(0) + boxGeometry.paddingBottom().valueOr(0);
auto verticalBorder = boxGeometry.borderTop() + boxGeometry.borderBottom();
bodyAndDocumentVerticalMarginPaddingAndBorder += verticalMargin.before.valueOr(0) + verticalMargin.after.valueOr(0) + verticalPadding + verticalBorder;
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (260897 => 260898)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-04-29 16:06:32 UTC (rev 260898)
@@ -93,9 +93,7 @@
auto constraintsForLayoutBox = [&] (const auto& layoutBox) {
auto& containingBlock = layoutBox.containingBlock();
- if (&containingBlock == &formattingRoot)
- return constraints;
- return Geometry::constraintsForInFlowContent(geometryForBox(containingBlock));
+ return &containingBlock == &formattingRoot ? constraints : geometry().constraintsForInFlowContent(containingBlock);
};
// This is a post-order tree traversal layout.
@@ -113,7 +111,6 @@
computeBorderAndPadding(layoutBox, containingBlockConstraints.horizontal);
computeStaticVerticalPosition(layoutBox, containingBlockConstraints.vertical);
-
computeWidthAndMargin(floatingContext, layoutBox, { constraints, containingBlockConstraints });
computeStaticHorizontalPosition(layoutBox, containingBlockConstraints.horizontal);
@@ -131,7 +128,7 @@
}
}
// Layout the inflow descendants of this formatting context root.
- LayoutContext::createFormattingContext(containerBox, layoutState())->layoutInFlowContent(invalidationState, Geometry::constraintsForInFlowContent(geometryForBox(containerBox)));
+ LayoutContext::createFormattingContext(containerBox, layoutState())->layoutInFlowContent(invalidationState, geometry().constraintsForInFlowContent(containerBox));
}
break;
}
@@ -152,7 +149,7 @@
// Now that we computed the root's height, we can layout the out-of-flow descendants.
if (is<ContainerBox>(layoutBox) && downcast<ContainerBox>(layoutBox).hasChild()) {
auto& containerBox = downcast<ContainerBox>(layoutBox);
- LayoutContext::createFormattingContext(containerBox, layoutState())->layoutOutOfFlowContent(invalidationState, Geometry::constraintsForOutOfFlowContent(geometryForBox(containerBox)));
+ LayoutContext::createFormattingContext(containerBox, layoutState())->layoutOutOfFlowContent(invalidationState, geometry().constraintsForOutOfFlowContent(containerBox));
}
}
// Resolve final positions.
@@ -257,7 +254,7 @@
for (auto* ancestor = &layoutBox; ancestor && ancestor != &root(); ancestor = &ancestor->containingBlock()) {
auto constraintsForAncestor = [&] {
auto& containingBlock = ancestor->containingBlock();
- return &containingBlock == &root() ? constraintsPair.formattingContextRoot : Geometry::constraintsForInFlowContent(geometryForBox(containingBlock));
+ return &containingBlock == &root() ? constraintsPair.formattingContextRoot : geometry().constraintsForInFlowContent(containingBlock);
}();
auto computedVerticalMargin = geometry().computedVerticalMargin(*ancestor, constraintsForAncestor.horizontal);
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp (260897 => 260898)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContextQuirks.cpp 2020-04-29 16:06:32 UTC (rev 260898)
@@ -73,7 +73,8 @@
// Here is the quirky part for body box when it stretches all the way to the ICB even when the document box does not (e.g. out-of-flow positioned).
ASSERT(layoutBox.isBodyBox());
- auto& initialContainingBlockGeometry = formattingContext.geometryForBox(layoutBox.initialContainingBlock(), EscapeReason::BodyStrechesToViewportQuirk);
+ auto& initialContainingBlock = layoutBox.initialContainingBlock();
+ auto& initialContainingBlockGeometry = formattingContext.geometryForBox(initialContainingBlock, EscapeReason::BodyStrechesToViewportQuirk);
// Start the content height with the ICB.
auto bodyBoxContentHeight = initialContainingBlockGeometry.contentBoxHeight();
// Body box's own border and padding shrink the content height.
@@ -91,7 +92,8 @@
bodyBoxContentHeight -= documentBoxGeometry.verticalBorder() + documentBoxGeometry.verticalPadding().valueOr(0);
// However the non-in-flow document box's vertical margins are ignored. They don't affect the body box's content height.
if (documentBox.isInFlow()) {
- auto precomputeDocumentBoxVerticalMargin = formattingContext.geometry().computedVerticalMargin(documentBox, Geometry::constraintsForInFlowContent(initialContainingBlockGeometry).horizontal);
+ auto geometry = formattingContext.geometry();
+ auto precomputeDocumentBoxVerticalMargin = geometry.computedVerticalMargin(documentBox, geometry.constraintsForInFlowContent(initialContainingBlock, EscapeReason::BodyStrechesToViewportQuirk).horizontal);
bodyBoxContentHeight -= precomputeDocumentBoxVerticalMargin.before.valueOr(0) + precomputeDocumentBoxVerticalMargin.after.valueOr(0);
}
return std::max(contentHeightAndMargin.contentHeight, bodyBoxContentHeight);
Modified: trunk/Source/WebCore/layout/blockformatting/PrecomputedBlockMarginCollapse.cpp (260897 => 260898)
--- trunk/Source/WebCore/layout/blockformatting/PrecomputedBlockMarginCollapse.cpp 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/blockformatting/PrecomputedBlockMarginCollapse.cpp 2020-04-29 16:06:32 UTC (rev 260898)
@@ -44,8 +44,9 @@
if (blockFormattingState.hasPositiveAndNegativeVerticalMargin(layoutBox))
return blockFormattingState.positiveAndNegativeVerticalMargin(layoutBox).before;
- auto horizontalConstraints = Geometry::constraintsForInFlowContent(formattingContext().geometryForBox(layoutBox.containingBlock())).horizontal;
- auto computedVerticalMargin = formattingContext().geometry().computedVerticalMargin(layoutBox, horizontalConstraints);
+ auto geometry = formattingContext().geometry();
+ auto horizontalConstraints = geometry.constraintsForInFlowContent(layoutBox.containingBlock()).horizontal;
+ auto computedVerticalMargin = geometry.computedVerticalMargin(layoutBox, horizontalConstraints);
auto nonCollapsedMargin = UsedVerticalMargin::NonCollapsedValues { computedVerticalMargin.before.valueOr(0), computedVerticalMargin.after.valueOr(0) };
return precomputedPositiveNegativeMarginBefore(layoutBox, nonCollapsedMargin);
}
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp (260897 => 260898)
--- trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineFormattingContext.cpp 2020-04-29 16:06:32 UTC (rev 260898)
@@ -92,20 +92,18 @@
// Inline-blocks, inline-tables and replaced elements (img, video) can be sized but not yet positioned.
if (is<ContainerBox>(layoutBox) && layoutBox->establishesFormattingContext()) {
ASSERT(layoutBox->isInlineBlockBox() || layoutBox->isInlineTableBox() || layoutBox->isFloatingPositioned());
- auto& containerBox = downcast<ContainerBox>(*layoutBox);
- computeBorderAndPadding(containerBox, constraints.horizontal);
- computeWidthAndMargin(containerBox, constraints.horizontal);
+ auto& formattingRoot = downcast<ContainerBox>(*layoutBox);
+ computeBorderAndPadding(formattingRoot, constraints.horizontal);
+ computeWidthAndMargin(formattingRoot, constraints.horizontal);
- auto& formattingRootDisplayBox = geometryForBox(containerBox);
- if (containerBox.hasInFlowOrFloatingChild()) {
- auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState());
- formattingContext->layoutInFlowContent(invalidationState, Geometry::constraintsForInFlowContent(formattingRootDisplayBox));
- }
- computeHeightAndMargin(containerBox, constraints.horizontal);
- if (containerBox.hasChild()) {
- auto formattingContext = LayoutContext::createFormattingContext(containerBox, layoutState());
- formattingContext->layoutOutOfFlowContent(invalidationState, Geometry::constraintsForOutOfFlowContent(formattingRootDisplayBox));
- }
+ if (formattingRoot.hasChild()) {
+ auto formattingContext = LayoutContext::createFormattingContext(formattingRoot, layoutState());
+ if (formattingRoot.hasInFlowOrFloatingChild())
+ formattingContext->layoutInFlowContent(invalidationState, geometry().constraintsForInFlowContent(formattingRoot));
+ computeHeightAndMargin(formattingRoot, constraints.horizontal);
+ formattingContext->layoutOutOfFlowContent(invalidationState, geometry().constraintsForOutOfFlowContent(formattingRoot));
+ } else
+ computeHeightAndMargin(formattingRoot, constraints.horizontal);
} else {
// Replaced and other type of leaf atomic inline boxes.
computeBorderAndPadding(*layoutBox, constraints.horizontal);
Modified: trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp (260897 => 260898)
--- trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2020-04-29 15:25:07 UTC (rev 260897)
+++ trunk/Source/WebCore/layout/tableformatting/TableFormattingContext.cpp 2020-04-29 16:06:32 UTC (rev 260898)
@@ -177,7 +177,7 @@
if (cellBox.hasInFlowOrFloatingChild()) {
auto invalidationState = InvalidationState { };
- auto constraintsForCellContent = Geometry::constraintsForInFlowContent(cellDisplayBox);
+ auto constraintsForCellContent = geometry().constraintsForInFlowContent(cellBox);
constraintsForCellContent.vertical.logicalHeight = usedCellHeight;
LayoutContext::createFormattingContext(cellBox, layoutState())->layoutInFlowContent(invalidationState, constraintsForCellContent);
}