mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:57:44 +00:00
LibWeb: Make FormattingContext::run() take available space as input
Instead of formatting contexts flailing around to figure out from the "inside" how much space is available on the "outside", we should provide the amount of available space in both axes as an input to run(). This basically means that when something creates a nested formatting context, the parent context is responsible for telling the nested context how much space is available for layout. This information is provided immediately when invoking run(). Note that this commit doesn't pass accurate values in all cases yet. This first step just makes it build, and passes available values in some cases where getting them was trivial.
This commit is contained in:
parent
6b2ce2ccc3
commit
f161e20e57
17 changed files with 163 additions and 41 deletions
|
@ -67,7 +67,7 @@ float FlexFormattingContext::automatic_content_height() const
|
|||
return m_state.get(flex_container()).content_height();
|
||||
}
|
||||
|
||||
void FlexFormattingContext::run(Box const& run_box, LayoutMode layout_mode)
|
||||
void FlexFormattingContext::run(Box const& run_box, LayoutMode layout_mode, [[maybe_unused]] AvailableSpace const& available_width, [[maybe_unused]] AvailableSpace const& available_height)
|
||||
{
|
||||
VERIFY(&run_box == &flex_container());
|
||||
|
||||
|
@ -598,7 +598,7 @@ void FlexFormattingContext::determine_available_main_and_cross_space(bool& main_
|
|||
cross_available_space = cross_max_size;
|
||||
}
|
||||
|
||||
m_available_space = AvailableSpace { .main = main_available_space, .cross = cross_available_space };
|
||||
m_available_space = AvailableSpaceForItems { .main = main_available_space, .cross = cross_available_space };
|
||||
}
|
||||
|
||||
float FlexFormattingContext::calculate_indefinite_main_size(FlexItem const& item)
|
||||
|
@ -635,7 +635,7 @@ float FlexFormattingContext::calculate_indefinite_main_size(FlexItem const& item
|
|||
VERIFY(independent_formatting_context);
|
||||
|
||||
box_state.set_content_width(fit_content_cross_size);
|
||||
independent_formatting_context->run(item.box, LayoutMode::Normal);
|
||||
independent_formatting_context->run(item.box, LayoutMode::Normal, AvailableSpace::make_indefinite(), AvailableSpace::make_indefinite());
|
||||
|
||||
return independent_formatting_context->automatic_content_height();
|
||||
}
|
||||
|
@ -1100,7 +1100,7 @@ void FlexFormattingContext::determine_hypothetical_cross_size_of_item(FlexItem&
|
|||
// NOTE: Flex items should always create an independent formatting context!
|
||||
VERIFY(independent_formatting_context);
|
||||
|
||||
independent_formatting_context->run(item.box, LayoutMode::Normal);
|
||||
independent_formatting_context->run(item.box, LayoutMode::Normal, AvailableSpace::make_indefinite(), AvailableSpace::make_indefinite());
|
||||
|
||||
auto automatic_cross_size = is_row_layout() ? independent_formatting_context->automatic_content_height()
|
||||
: box_state.content_width();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue