mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:28:12 +00:00
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.
This commit is contained in:
parent
c1d3c1e0cb
commit
244d4e19fa
1 changed files with 13 additions and 9 deletions
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue