mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 17:58:18 +03: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
Notes:
sideshowbarker
2024-07-17 17:31:07 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/ad8d65fd6e
@ -836,11 +836,16 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
|
||||
} else {
|
||||
// Item has indefinite main size, layout with "fit-content"
|
||||
|
||||
float fit_content_main_size;
|
||||
if (is_row_layout())
|
||||
fit_content_main_size = calculate_fit_content_width(item.box, m_available_space->main);
|
||||
else
|
||||
fit_content_main_size = calculate_fit_content_height(item.box, m_available_space->main);
|
||||
// If we're in a column layout and looking for the width, just use the fit-content width.
|
||||
if (!is_row_layout()) {
|
||||
item.hypothetical_cross_size = calculate_fit_content_width(item.box, m_available_space->cross);
|
||||
return;
|
||||
}
|
||||
|
||||
// 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);
|
||||
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!
|
||||
VERIFY(independent_formatting_context);
|
||||
|
||||
if (is_row_layout()) {
|
||||
box_state.content_width = fit_content_main_size;
|
||||
} else {
|
||||
box_state.content_height = fit_content_main_size;
|
||||
}
|
||||
box_state.content_width = fit_content_main_size;
|
||||
independent_formatting_context->run(item.box, LayoutMode::Default);
|
||||
|
||||
if (is_row_layout()) {
|
||||
item.hypothetical_cross_size = BlockFormattingContext::compute_theoretical_height(throwaway_state, item.box);
|
||||
} else {
|
||||
item.hypothetical_cross_size = box_state.content_width;
|
||||
}
|
||||
item.hypothetical_cross_size = BlockFormattingContext::compute_theoretical_height(throwaway_state, item.box);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user