Modified: trunk/Source/WebCore/ChangeLog (254921 => 254922)
--- trunk/Source/WebCore/ChangeLog 2020-01-22 15:19:12 UTC (rev 254921)
+++ trunk/Source/WebCore/ChangeLog 2020-01-22 15:40:47 UTC (rev 254922)
@@ -1,5 +1,20 @@
2020-01-22 Zalan Bujtas <[email protected]>
+ [LFC][BFC] No need to special case formatting context root layout
+ https://bugs.webkit.org/show_bug.cgi?id=206569
+ <rdar://problem/58784767>
+
+ Reviewed by Antti Koivisto.
+
+ Let's move out all the formatting context layout logic from layoutFormattingContextRoot.
+
+ * layout/blockformatting/BlockFormattingContext.cpp:
+ (WebCore::Layout::BlockFormattingContext::layoutInFlowContent):
+ (WebCore::Layout::BlockFormattingContext::layoutFormattingContextRoot): Deleted.
+ * layout/blockformatting/BlockFormattingContext.h:
+
+2020-01-22 Zalan Bujtas <[email protected]>
+
[LFC][BFC] Move float avoider special available width handling to BlockFormattingContext::computeWidthAndMargin
https://bugs.webkit.org/show_bug.cgi?id=206567
<rdar://problem/58783979>
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp (254921 => 254922)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-01-22 15:19:12 UTC (rev 254921)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.cpp 2020-01-22 15:40:47 UTC (rev 254922)
@@ -124,12 +124,14 @@
computeStaticHorizontalPosition(layoutBox, horizontalConstraints);
if (layoutBox.establishesFormattingContext()) {
- // layoutFormattingContextRoot() takes care of the layoutBox itself and its descendants.
- layoutFormattingContextRoot(layoutBox, floatingContext, invalidationState, horizontalConstraints, verticalConstraints);
- layoutQueue.removeLast();
- if (!appendNextToLayoutQueue(layoutBox, LayoutDirection::Sibling))
- break;
- continue;
+ if (is<Container>(layoutBox) && downcast<Container>(layoutBox).hasInFlowOrFloatingChild()) {
+ // Layout the inflow descendants of this formatting context root.
+ auto& rootDisplayBox = geometryForBox(layoutBox);
+ auto horizontalConstraintsForFormattingContext = Geometry::horizontalConstraintsForInFlow(rootDisplayBox);
+ auto verticalConstraintsForFormattingContext = Geometry::verticalConstraintsForInFlow(rootDisplayBox);
+ LayoutContext::createFormattingContext(downcast<Container>(layoutBox), layoutState())->layoutInFlowContent(invalidationState, horizontalConstraintsForFormattingContext, verticalConstraintsForFormattingContext);
+ }
+ break;
}
if (!appendNextToLayoutQueue(layoutBox, LayoutDirection::Child))
break;
@@ -137,15 +139,30 @@
// Climb back on the ancestors and compute height/final position.
while (!layoutQueue.isEmpty()) {
- // All inflow descendants (if there are any) are laid out by now. Let's compute the box's height.
auto& layoutBox = *layoutQueue.takeLast();
auto horizontalConstraints = horizontalConstraintsForLayoutBox(layoutBox);
auto verticalConstraints = verticalConstraintsForLayoutBox(layoutBox);
- // Formatting root boxes are special-cased and they don't come here.
- ASSERT(!layoutBox.establishesFormattingContext());
+
+ // All inflow descendants (if there are any) are laid out by now. Let's compute the box's height.
computeHeightAndMargin(layoutBox, horizontalConstraints, verticalConstraints);
- // Move in-flow positioned children to their final position.
+
+ if (layoutBox.establishesFormattingContext()) {
+ // Now that we computed the root's height, we can layout the out-of-flow descendants.
+ if (is<Container>(layoutBox)) {
+ auto& rootDisplayBox = geometryForBox(layoutBox);
+ auto horizontalConstraintsForOutOfFlow = Geometry::horizontalConstraintsForOutOfFlow(rootDisplayBox);
+ auto verticalConstraintsForOutOfFlow = Geometry::verticalConstraintsForOutOfFlow(rootDisplayBox);
+ LayoutContext::createFormattingContext(downcast<Container>(layoutBox), layoutState())->layoutOutOfFlowContent(invalidationState, horizontalConstraintsForOutOfFlow, verticalConstraintsForOutOfFlow);
+ }
+ }
+ // Resolve final positions.
placeInFlowPositionedChildren(layoutBox, horizontalConstraints);
+ if (layoutBox.isFloatingPositioned()) {
+ computeFloatingPosition(floatingContext, layoutBox);
+ floatingContext.append(layoutBox);
+ } else if (layoutBox.isFloatAvoider())
+ computePositionToAvoidFloats(floatingContext, layoutBox);
+
if (appendNextToLayoutQueue(layoutBox, LayoutDirection::Sibling))
break;
}
@@ -189,35 +206,6 @@
return availableWidth;
}
-void BlockFormattingContext::layoutFormattingContextRoot(const Box& formattingContextRoot, FloatingContext& floatingContext, InvalidationState& invalidationState, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints, const ConstraintsPair<VerticalConstraints>& verticalConstraints)
-{
- ASSERT(formattingContextRoot.establishesFormattingContext());
- // Start laying out this formatting root in the formatting contenxt it lives in.
- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Compute] -> [Position][Border][Padding][Width][Margin] -> for layoutBox(" << &formattingContextRoot << ")");
-
- if (is<Container>(formattingContextRoot)) {
- // Swich over to the new formatting context (the one that the root creates).
- auto& rootContainer = downcast<Container>(formattingContextRoot);
- auto& rootContainerDisplayBox = geometryForBox(rootContainer);
- auto formattingContext = LayoutContext::createFormattingContext(rootContainer, layoutState());
- formattingContext->layoutInFlowContent(invalidationState, Geometry::horizontalConstraintsForInFlow(rootContainerDisplayBox), Geometry::verticalConstraintsForInFlow(rootContainerDisplayBox));
- // Come back and finalize the root's geometry.
- computeHeightAndMargin(rootContainer, horizontalConstraints, verticalConstraints);
- // Now that we computed the root's height, we can go back and layout the out-of-flow content.
- auto horizontalConstraintsForOutOfFlow = Geometry::horizontalConstraintsForOutOfFlow(rootContainerDisplayBox);
- auto verticalConstraintsForOutOfFlow = Geometry::verticalConstraintsForOutOfFlow(rootContainerDisplayBox);
- formattingContext->layoutOutOfFlowContent(invalidationState, horizontalConstraintsForOutOfFlow, verticalConstraintsForOutOfFlow);
- } else
- computeHeightAndMargin(formattingContextRoot, horizontalConstraints, verticalConstraints);
- // Float related final positioning.
- if (formattingContextRoot.isFloatingPositioned()) {
- computeFloatingPosition(floatingContext, formattingContextRoot);
- floatingContext.append(formattingContextRoot);
- }
- if (formattingContextRoot.isFloatAvoider())
- computePositionToAvoidFloats(floatingContext, formattingContextRoot);
-}
-
void BlockFormattingContext::placeInFlowPositionedChildren(const Box& layoutBox, const ConstraintsPair<HorizontalConstraints>& horizontalConstraints)
{
if (!is<Container>(layoutBox))
Modified: trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h (254921 => 254922)
--- trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-01-22 15:19:12 UTC (rev 254921)
+++ trunk/Source/WebCore/layout/blockformatting/BlockFormattingContext.h 2020-01-22 15:40:47 UTC (rev 254922)
@@ -57,7 +57,6 @@
const T root;
const T containingBlock;
};
- void layoutFormattingContextRoot(const Box&, FloatingContext&, InvalidationState&, const ConstraintsPair<HorizontalConstraints>&, const ConstraintsPair<VerticalConstraints>&);
void placeInFlowPositionedChildren(const Box&, const ConstraintsPair<HorizontalConstraints>&);
void computeWidthAndMargin(const FloatingContext&, const Box&, const ConstraintsPair<HorizontalConstraints>&);