Skip to content

Commit

Permalink
[FFC] Compute flex item's cross size by running layout
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=258779

Reviewed by Antti Koivisto.

Call IFC directly to compute the cross size of each flex item.
(This will eventually run through integration codepath)

* Source/WebCore/layout/formattingContexts/flex/FlexLayout.cpp:
(WebCore::Layout::FlexLayout::hypotheticalCrossSizeForFlexItems const):

Canonical link: https://commits.webkit.org/265698@main
  • Loading branch information
alanbaradlay committed Jul 2, 2023
1 parent 0bf69cd commit d4622b8
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions Source/WebCore/layout/formattingContexts/flex/FlexLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -424,10 +424,30 @@ FlexLayout::SizeList FlexLayout::hypotheticalCrossSizeForFlexItems(const Logical
UNUSED_PARAM(flexItemsMainSizeList);
// FIXME: This is where layout is called on flex items.
SizeList hypotheticalCrossSizeList(flexItems.size());
for (size_t index = 0; index < flexItems.size(); ++index) {
// FIXME: replace this with the actual layout result. See above.
ASSERT(flexItems[index].crossAxis().definiteSize);
hypotheticalCrossSizeList[index] = *flexItems[index].crossAxis().definiteSize;
for (size_t flexItemIndex = 0; flexItemIndex < flexItems.size(); ++flexItemIndex) {
auto& flexItem = flexItems[flexItemIndex];

if (auto definiteSize = flexItems[flexItemIndex].crossAxis().definiteSize) {
hypotheticalCrossSizeList[flexItemIndex] = *definiteSize;
continue;
}
auto& flexItemBox = flexItem.layoutBox();
auto crossSizeAfterPerformingLayout = [&]() -> LayoutUnit {
if (!flexItemBox.establishesInlineFormattingContext()) {
ASSERT_NOT_IMPLEMENTED_YET();
return { };
}
// FIXME: Let it run through integration codepath.
auto floatingState = FloatingState { flexItemBox };
auto parentBlockLayoutState = BlockLayoutState { floatingState };
auto inlineLayoutState = InlineLayoutState { parentBlockLayoutState, { } };
auto& inlineFormattingState = flexFormattingContext().layoutState().ensureInlineFormattingState(flexItemBox);
auto inlineFormattingContext = InlineFormattingContext { flexItemBox, inlineFormattingState, { } };
auto constraintsForInFlowContent = ConstraintsForInFlowContent { HorizontalConstraints { { }, flexItemsMainSizeList[flexItemIndex] }, { } };
auto layoutResult = inlineFormattingContext.layoutInFlowAndFloatContent({ constraintsForInFlowContent, { } }, inlineLayoutState);
return LayoutUnit { layoutResult.displayContent.lines.last().lineBoxLogicalRect().maxY() };
};
hypotheticalCrossSizeList[flexItemIndex] = crossSizeAfterPerformingLayout();
}
return hypotheticalCrossSizeList;
}
Expand Down

0 comments on commit d4622b8

Please sign in to comment.