LibWeb: Resolve flex item % main size to 0 during min-content sizing

When the flex container is sized under a min-content constraint in the
main axis, any flex items with a percentage main size should collapse
to zero width, not take up their own intrinsic min-content size.

This is not in the spec, but matches how other browsers behave.

Fixes an issue where the cartoons on https://basecamp.com/ were way
too large. :^)
This commit is contained in:
Andreas Kling 2024-10-06 15:22:20 +02:00 committed by Andreas Kling
commit 59ed823724
Notes: github-actions[bot] 2024-10-06 14:04:52 +00:00
3 changed files with 37 additions and 0 deletions

View file

@ -587,6 +587,13 @@ void FlexFormattingContext::determine_flex_base_size_and_hypothetical_main_size(
return get_pixel_height(child_box, size);
}
// AD-HOC: If we're sizing the flex container under a min-content constraint in the main axis,
// flex items resolve percentages in the main axis to 0.
if (m_available_space_for_items->main.is_min_content()
&& computed_main_size(item.box).contains_percentage()) {
return CSSPixels(0);
}
// B. If the flex item has ...
// - an intrinsic aspect ratio,
// - a used flex basis of content, and