summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2022-10-04 11:56:59 +0200
committerAndreas Kling <kling@serenityos.org>2022-10-04 11:56:59 +0200
commitc48931d15cbb7e2efc599ec675f115aaea223864 (patch)
tree2bc9e87a3107588500421d48736b9c82bdf5b22d /Userland
parent4d84e349ae84e1dfae4baab399dbb2e3fe6aa720 (diff)
downloadserenity-c48931d15cbb7e2efc599ec675f115aaea223864.zip
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.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index bc64cf6bf1..cd34662c42 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -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);
}
}