Diff
Modified: trunk/Source/WebCore/layout/FormattingState.h (295207 => 295208)
--- trunk/Source/WebCore/layout/FormattingState.h 2022-06-03 14:41:53 UTC (rev 295207)
+++ trunk/Source/WebCore/layout/FormattingState.h 2022-06-03 15:03:54 UTC (rev 295208)
@@ -47,7 +47,7 @@
void markNeedsLayout(const Box&, StyleDiff);
bool needsLayout(const Box&);
- void setIntrinsicWidthConstraintsForBox(const Box&, IntrinsicWidthConstraints);
+ void setIntrinsicWidthConstraintsForBox(const Box&, IntrinsicWidthConstraints);
std::optional<IntrinsicWidthConstraints> intrinsicWidthConstraintsForBox(const Box&) const;
void clearIntrinsicWidthConstraints(const Box&);
Modified: trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp (295207 => 295208)
--- trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp 2022-06-03 14:41:53 UTC (rev 295207)
+++ trunk/Source/WebCore/layout/formattingContexts/flex/FlexFormattingContext.cpp 2022-06-03 15:03:54 UTC (rev 295208)
@@ -225,7 +225,12 @@
auto& style = layoutBox.style();
auto logicalWidthType = flexDirectionIsInlineAxis ? style.width().type() : style.height().type();
auto logicalHeightType = flexDirectionIsInlineAxis ? style.height().type() : style.width().type();
- logicalFlexItemList[index] = { flexItemList[index].marginRect, logicalWidthType, logicalHeightType, layoutBox };
+ logicalFlexItemList[index] = { flexItemList[index].marginRect
+ , logicalWidthType
+ , logicalHeightType
+ // FIXME: Convert to logical intrinsic width
+ , *formattingState.intrinsicWidthConstraintsForBox(layoutBox)
+ , layoutBox };
}
return logicalFlexItemList;
}
@@ -285,7 +290,7 @@
{
auto flexConstraints = downcast<ConstraintsForFlexContent>(constraints);
auto logicalFlexItems = convertFlexItemsToLogicalSpace(flexConstraints);
- auto flexLayout = FlexLayout { formattingState(), root().style() };
+ auto flexLayout = FlexLayout { root().style() };
flexLayout.layout(flexConstraints, logicalFlexItems);
setFlexItemsGeometry(logicalFlexItems, flexConstraints);
}
Modified: trunk/Source/WebCore/layout/formattingContexts/flex/FlexLayout.cpp (295207 => 295208)
--- trunk/Source/WebCore/layout/formattingContexts/flex/FlexLayout.cpp 2022-06-03 14:41:53 UTC (rev 295207)
+++ trunk/Source/WebCore/layout/formattingContexts/flex/FlexLayout.cpp 2022-06-03 15:03:54 UTC (rev 295208)
@@ -34,9 +34,8 @@
namespace WebCore {
namespace Layout {
-FlexLayout::FlexLayout(const FlexFormattingState& formattingState, const RenderStyle& flexBoxStyle)
- : m_formattingState(formattingState)
- , m_flexBoxStyle(flexBoxStyle)
+FlexLayout::FlexLayout(const RenderStyle& flexBoxStyle)
+ : m_flexBoxStyle(flexBoxStyle)
{
}
@@ -80,8 +79,6 @@
void FlexLayout::computeLogicalWidthForShrinkingFlexItems(LogicalFlexItems& flexItems, LayoutUnit availableSpace)
{
- auto& formattingState = this->formattingState();
-
auto totalShrink = 0.f;
auto totalFlexibleSpace = LayoutUnit { };
auto flexShrinkBase = 0.f;
@@ -103,7 +100,7 @@
auto baseSize = style.flexBasis().isFixed() ? LayoutUnit { style.flexBasis().value() } : flexItem.width();
if (auto shrinkValue = style.flexShrink()) {
auto flexShrink = shrinkValue * baseSize;
- shrinkingItems.append({ flexShrink, formattingState.intrinsicWidthConstraintsForBox(flexItem.layoutBox())->minimum, baseSize, flexItem, { } });
+ shrinkingItems.append({ flexShrink, flexItem.minimumContentWidth(), baseSize, flexItem, { } });
totalShrink += flexShrink;
totalFlexibleSpace += baseSize;
} else
@@ -148,8 +145,6 @@
void FlexLayout::computeLogicalWidthForStretchingFlexItems(LogicalFlexItems& flexItems, LayoutUnit availableSpace)
{
- auto& formattingState = this->formattingState();
-
auto totalFlexibleSpace = LayoutUnit { };
auto totalGrowth = 0.f;
auto flexGrowBase = 0.f;
@@ -170,7 +165,7 @@
auto baseSize = style.flexBasis().isFixed() ? LayoutUnit { style.flexBasis().value() } : flexItem.width();
if (auto growValue = style.flexGrow()) {
auto flexGrow = growValue * baseSize;
- stretchingItems.append({ flexGrow, formattingState.intrinsicWidthConstraintsForBox(flexItem.layoutBox())->minimum, baseSize, flexItem, { } });
+ stretchingItems.append({ flexGrow, flexItem.minimumContentWidth(), baseSize, flexItem, { } });
totalGrowth += flexGrow;
totalFlexibleSpace += baseSize;
} else
Modified: trunk/Source/WebCore/layout/formattingContexts/flex/FlexLayout.h (295207 => 295208)
--- trunk/Source/WebCore/layout/formattingContexts/flex/FlexLayout.h 2022-06-03 14:41:53 UTC (rev 295207)
+++ trunk/Source/WebCore/layout/formattingContexts/flex/FlexLayout.h 2022-06-03 15:03:54 UTC (rev 295208)
@@ -38,11 +38,11 @@
// https://www.w3.org/TR/css-flexbox-1/
class FlexLayout {
public:
- FlexLayout(const FlexFormattingState&, const RenderStyle& flexBoxStyle);
+ FlexLayout(const RenderStyle& flexBoxStyle);
struct LogicalFlexItem {
public:
- LogicalFlexItem(const FlexRect&, LengthType widthType, LengthType heightType, const ContainerBox&);
+ LogicalFlexItem(const FlexRect&, LengthType widthType, LengthType heightType, IntrinsicWidthConstraints, const ContainerBox&);
LogicalFlexItem() = default;
void setTop(LayoutUnit top) { m_marginRect.value.setTop(top); }
@@ -61,6 +61,8 @@
bool isHeightAuto() const { return m_marginRect.heightType == LengthType::Auto; }
+ LayoutUnit minimumContentWidth() const { return m_intrinsicWidthConstraints.minimum; }
+
const RenderStyle& style() const { return m_layoutBox->style(); }
const ContainerBox& layoutBox() const { return *m_layoutBox; }
@@ -71,6 +73,7 @@
LengthType heightType { LengthType::Auto };
};
MarginRect m_marginRect { };
+ IntrinsicWidthConstraints m_intrinsicWidthConstraints { };
CheckedPtr<const ContainerBox> m_layoutBox;
};
using LogicalFlexItems = Vector<LogicalFlexItem>;
@@ -86,15 +89,14 @@
LayoutUnit computeAvailableLogicalVerticalSpace(LogicalFlexItems&, const ConstraintsForFlexContent&) const;
LayoutUnit computeAvailableLogicalHorizontalSpace(LogicalFlexItems&, const ConstraintsForFlexContent&) const;
- const FlexFormattingState& formattingState() const { return m_formattingState; }
const RenderStyle& flexBoxStyle() const { return m_flexBoxStyle; }
- const FlexFormattingState& m_formattingState;
const RenderStyle& m_flexBoxStyle;
};
-inline FlexLayout::LogicalFlexItem::LogicalFlexItem(const FlexRect& marginRect, LengthType widthType, LengthType heightType, const ContainerBox& layoutBox)
+inline FlexLayout::LogicalFlexItem::LogicalFlexItem(const FlexRect& marginRect, LengthType widthType, LengthType heightType, IntrinsicWidthConstraints intrinsicWidthConstraints, const ContainerBox& layoutBox)
: m_marginRect({ marginRect, widthType, heightType })
+ , m_intrinsicWidthConstraints(intrinsicWidthConstraints)
, m_layoutBox(layoutBox)
{
}