Title: [294638] trunk/Source/WebCore/layout
- Revision
- 294638
- Author
- za...@apple.com
- Date
- 2022-05-23 06:49:05 -0700 (Mon, 23 May 2022)
Log Message
Add support for block direction grow
https://bugs.webkit.org/show_bug.cgi?id=240776
Reviewed by Antti Koivisto.
This is a basic block direction grow support (e.g. default block direction (top->bottom) with flex direction of column) when
flex box's height is fixed.
* Source/WebCore/layout/formattingContexts/FormattingConstraints.h:
* Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp:
(WebCore::Layout::FlexFormattingContext::layoutInFlowContentForIntegration):
* Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp:
(WebCore::LayoutIntegration::FlexLayout::updateRenderers const):
Canonical link: https://commits.webkit.org/250862@main
Modified Paths
Diff
Modified: trunk/Source/WebCore/layout/formattingContexts/FormattingConstraints.h (294637 => 294638)
--- trunk/Source/WebCore/layout/formattingContexts/FormattingConstraints.h 2022-05-23 13:38:06 UTC (rev 294637)
+++ trunk/Source/WebCore/layout/formattingContexts/FormattingConstraints.h 2022-05-23 13:49:05 UTC (rev 294638)
@@ -66,7 +66,7 @@
private:
OptionSet<BaseTypeFlag> baseTypeFlags() const { return OptionSet<BaseTypeFlag>::fromRaw(m_baseTypeFlags); }
- unsigned m_baseTypeFlags : 2; // OptionSet<BaseTypeFlag>
+ unsigned m_baseTypeFlags : 3; // OptionSet<BaseTypeFlag>
HorizontalConstraints m_horizontal;
LayoutUnit m_logicalTop;
};
Modified: trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp (294637 => 294638)
--- trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp 2022-05-23 13:38:06 UTC (rev 294637)
+++ trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp 2022-05-23 13:49:05 UTC (rev 294638)
@@ -209,24 +209,27 @@
auto logicalFlexItemList = convertFlexItemsToLogicalSpace();
auto totalGrowth = 0.f;
- auto totalFixedWidth = LayoutUnit { };
+ auto totalFixedSpace = LayoutUnit { };
for (auto& logicalFlexItem : logicalFlexItemList) {
totalGrowth += logicalFlexItem.layoutBox->style().flexGrow();
// FIXME: Use min/max here.
- totalFixedWidth += logicalFlexItem.rect.width();
+ totalFixedSpace += logicalFlexItem.rect.width();
}
+ auto flexConstraints = downcast<ConstraintsForFlexContent>(constraints);
auto logicalLeft = LayoutUnit { };
auto logicalTop = LayoutUnit { };
- auto availableWidth = constraints.horizontal().logicalWidth;
- auto flexibleWidth = availableWidth - totalFixedWidth;
+ auto flexDirection = root().style().flexDirection();
+ auto flexDirectionIsInlineAxis = flexDirection == FlexDirection::Row || flexDirection == FlexDirection::RowReverse;
+ auto availableSpace = std::optional<LayoutUnit> { flexDirectionIsInlineAxis ? std::make_optional(flexConstraints.horizontal().logicalWidth) : flexConstraints.availableVerticalSpace() };
+ auto flexibleSpace = availableSpace.value_or(0_lu) - totalFixedSpace;
for (auto& logicalFlexItem : logicalFlexItemList) {
logicalFlexItem.rect.setTopLeft({ logicalLeft, logicalTop });
logicalLeft = logicalFlexItem.rect.right();
auto growFlexItemIfApplicable = [&] {
- if (flexibleWidth <= 0)
+ if (flexibleSpace <= 0)
return;
auto grow = logicalFlexItem.layoutBox->style().flexGrow();
if (!grow)
@@ -233,12 +236,13 @@
return;
// This value specifies the flex grow factor, which determines how much the flex item will grow relative to the
// rest of the flex items in the flex container when positive free space is distributed.
- logicalFlexItem.rect.setWidth(LayoutUnit { availableWidth * grow / totalGrowth });
+ ASSERT(availableSpace.has_value());
+ logicalFlexItem.rect.setWidth(LayoutUnit { *availableSpace * grow / totalGrowth });
// FIXME: constrain logical width on min width.
};
growFlexItemIfApplicable();
}
- setFlexItemsGeometry(logicalFlexItemList, downcast<ConstraintsForFlexContent>(constraints));
+ setFlexItemsGeometry(logicalFlexItemList, flexConstraints);
}
IntrinsicWidthConstraints FlexFormattingContext::computedIntrinsicWidthConstraintsForIntegration()
Modified: trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp (294637 => 294638)
--- trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp 2022-05-23 13:38:06 UTC (rev 294637)
+++ trunk/Source/WebCore/layout/integration/flex/LayoutIntegrationFlexLayout.cpp 2022-05-23 13:49:05 UTC (rev 294638)
@@ -139,6 +139,7 @@
auto borderBox = Layout::BoxGeometry::borderBoxRect(flexItemGeometry);
renderer.setLocation(borderBox.topLeft());
renderer.setWidth(borderBox.width());
+ renderer.setHeight(borderBox.height());
}
}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes