mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:57:35 +00:00
LibWeb: Clamp flex items to min/max main size during intrinsic sizing
We were neglecting to clamp flex items when calculating the intrinsic main size of the flex container. This was covered by a FIXME, which we can now remove. :^)
This commit is contained in:
parent
dc66a3cad9
commit
4c89252f6a
1 changed files with 5 additions and 1 deletions
|
@ -1484,7 +1484,10 @@ float FlexFormattingContext::calculate_intrinsic_main_size_of_flex_container(Lay
|
|||
else if (flex_item->desired_flex_fraction < 0)
|
||||
product = chosen_flex_fraction * flex_item->scaled_flex_shrink_factor;
|
||||
auto result = flex_item->flex_base_size + product;
|
||||
// FIXME: Clamp result to min/max main size
|
||||
|
||||
auto clamp_min = has_main_min_size(flex_item->box) ? specified_main_min_size(flex_item->box) : automatic_minimum_size(*flex_item);
|
||||
auto clamp_max = has_main_max_size(flex_item->box) ? specified_main_max_size(flex_item->box) : NumericLimits<float>::max();
|
||||
result = css_clamp(result, clamp_min, clamp_max);
|
||||
|
||||
// NOTE: The spec doesn't mention anything about the *outer* size here, but if we don't add the margin box,
|
||||
// flex items with non-zero padding/border/margin in the main axis end up overflowing the container.
|
||||
|
@ -1493,6 +1496,7 @@ float FlexFormattingContext::calculate_intrinsic_main_size_of_flex_container(Lay
|
|||
sum += result;
|
||||
}
|
||||
|
||||
// 5. The flex container’s max-content size is the largest sum (among all the lines) of the afore-calculated sizes of all items within a single line.
|
||||
largest_sum = max(largest_sum, sum);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue