mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +00:00
LibWeb: Only calculate intrinsic size in the desired flex axis
Previously, FlexFormattingContext would calculate intrinsic sizes in both axes simultaneously, despite only one being needed. This patch reduces the amount of unnecessary work by only calculating the requested intrinsic size.
This commit is contained in:
parent
4d84e349ae
commit
c48931d15c
Notes:
sideshowbarker
2024-07-17 10:08:28 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c48931d15c
1 changed files with 7 additions and 9 deletions
|
@ -1396,15 +1396,13 @@ void FlexFormattingContext::copy_dimensions_from_flex_items_to_boxes()
|
|||
// https://drafts.csswg.org/css-flexbox-1/#intrinsic-sizes
|
||||
void FlexFormattingContext::determine_intrinsic_size_of_flex_container()
|
||||
{
|
||||
float main_size = calculate_intrinsic_main_size_of_flex_container();
|
||||
float cross_size = calculate_intrinsic_cross_size_of_flex_container();
|
||||
|
||||
if (is_row_layout()) {
|
||||
m_flex_container_state.set_content_width(main_size);
|
||||
m_flex_container_state.set_content_height(cross_size);
|
||||
} else {
|
||||
m_flex_container_state.set_content_height(main_size);
|
||||
m_flex_container_state.set_content_width(cross_size);
|
||||
if (m_available_space_for_flex_container->main.is_intrinsic_sizing_constraint()) {
|
||||
float main_size = calculate_intrinsic_main_size_of_flex_container();
|
||||
set_main_size(flex_container(), main_size);
|
||||
}
|
||||
if (m_available_space_for_items->cross.is_intrinsic_sizing_constraint()) {
|
||||
float cross_size = calculate_intrinsic_cross_size_of_flex_container();
|
||||
set_cross_size(flex_container(), cross_size);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue