mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 06:07:34 +00:00
LibWeb: Fix calculation of hypothetical cross size in column flex layout
Simplify automatic cross sizing of items in flex-direction:column by using the fit-content width directly. There's obviously a lot more nuance to this, but for now this makes flex items with both width:auto and height:auto actually get some height in column flex layouts.
This commit is contained in:
parent
2f3d7a7c36
commit
ad8d65fd6e
1 changed files with 12 additions and 15 deletions
|
@ -836,11 +836,16 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
|
||||||
} else {
|
} else {
|
||||||
// Item has indefinite main size, layout with "fit-content"
|
// Item has indefinite main size, layout with "fit-content"
|
||||||
|
|
||||||
float fit_content_main_size;
|
// If we're in a column layout and looking for the width, just use the fit-content width.
|
||||||
if (is_row_layout())
|
if (!is_row_layout()) {
|
||||||
fit_content_main_size = calculate_fit_content_width(item.box, m_available_space->main);
|
item.hypothetical_cross_size = calculate_fit_content_width(item.box, m_available_space->cross);
|
||||||
else
|
return;
|
||||||
fit_content_main_size = calculate_fit_content_height(item.box, m_available_space->main);
|
}
|
||||||
|
|
||||||
|
// We're in a row layout, looking for the height. Figure out the fit-content width,
|
||||||
|
// then layout with that and see what height comes out of it.
|
||||||
|
|
||||||
|
float fit_content_main_size = calculate_fit_content_width(item.box, m_available_space->main);
|
||||||
|
|
||||||
FormattingState throwaway_state(&m_state);
|
FormattingState throwaway_state(&m_state);
|
||||||
auto& box_state = throwaway_state.get_mutable(item.box);
|
auto& box_state = throwaway_state.get_mutable(item.box);
|
||||||
|
@ -850,18 +855,10 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
|
||||||
// NOTE: Flex items should always create an independent formatting context!
|
// NOTE: Flex items should always create an independent formatting context!
|
||||||
VERIFY(independent_formatting_context);
|
VERIFY(independent_formatting_context);
|
||||||
|
|
||||||
if (is_row_layout()) {
|
box_state.content_width = fit_content_main_size;
|
||||||
box_state.content_width = fit_content_main_size;
|
|
||||||
} else {
|
|
||||||
box_state.content_height = fit_content_main_size;
|
|
||||||
}
|
|
||||||
independent_formatting_context->run(item.box, LayoutMode::Default);
|
independent_formatting_context->run(item.box, LayoutMode::Default);
|
||||||
|
|
||||||
if (is_row_layout()) {
|
item.hypothetical_cross_size = BlockFormattingContext::compute_theoretical_height(throwaway_state, item.box);
|
||||||
item.hypothetical_cross_size = BlockFormattingContext::compute_theoretical_height(throwaway_state, item.box);
|
|
||||||
} else {
|
|
||||||
item.hypothetical_cross_size = box_state.content_width;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue