summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-01-07 17:43:34 +0100
committerAndreas Kling <kling@serenityos.org>2023-01-07 19:41:21 +0100
commit244d4e19fa65434d3ffb334beb35a349d99b8ad7 (patch)
tree66f19a4b429d006a613a18e5764effd8d407c808 /Userland
parentc1d3c1e0cb75b0dd413418e8f2df63bc9b56c169 (diff)
downloadserenity-244d4e19fa65434d3ffb334beb35a349d99b8ad7.zip
LibWeb: Run more of flex layout algorithm for intrinsic sizing
We were trying to take a shortcut by avoiding much of the flex layout algorithm during intrinsic sizing. Unfortunately, this isn't good enough since we may end up needing some of the flex item metrics for intrinsic contribution calculations. This means we do a bit more work for flexboxes, but intrinsic sizes are correct in more cases.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
index bf4294ab1c..9456a444dc 100644
--- a/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
+++ b/Userland/Libraries/LibWeb/Layout/FlexFormattingContext.cpp
@@ -142,18 +142,13 @@ void FlexFormattingContext::run(Box const& run_box, LayoutMode, AvailableSpace c
}
if (available_width.is_intrinsic_sizing_constraint() || available_height.is_intrinsic_sizing_constraint()) {
- // We're computing intrinsic size for the flex container.
- determine_intrinsic_size_of_flex_container();
+ // We're computing intrinsic size for the flex container. This happens at the end of run().
+ } else {
- // Our caller is only interested in the content-width and content-height results,
- // which have now been set on m_flex_container_state, so there's no need to continue
- // the main layout algorithm after this point.
- return;
+ // 4. Determine the main size of the flex container
+ determine_main_size_of_flex_container();
}
- // 4. Determine the main size of the flex container
- determine_main_size_of_flex_container();
-
// 5. Collect flex items into flex lines:
// After this step no additional items are to be added to flex_lines or any of its items!
collect_flex_items_into_flex_lines();
@@ -231,6 +226,15 @@ void FlexFormattingContext::run(Box const& run_box, LayoutMode, AvailableSpace c
// part of the spec, and simply covering up the fact that our inside layout currently
// mutates the height of BFC roots.
copy_dimensions_from_flex_items_to_boxes();
+
+ if (available_width.is_intrinsic_sizing_constraint() || available_height.is_intrinsic_sizing_constraint()) {
+ // We're computing intrinsic size for the flex container.
+ determine_intrinsic_size_of_flex_container();
+
+ // Our caller is only interested in the content-width and content-height results,
+ // which have now been set on m_flex_container_state, so there's no need to continue
+ // the main layout algorithm after this point.
+ }
}
void FlexFormattingContext::parent_context_did_dimension_child_root_box()