LibWeb: Don't treat non-replaced sizes as 0 for min-content contrib

This behavior is part of the cyclic percentage contribution logic from
CSS-SIZING-3 which explicitly only applies to non-replaced boxes.

This fixes an issue on Discord where buttons in the settings UI were
cropped to a narrower width than intended.

Fixes #3572
This commit is contained in:
Andreas Kling 2025-07-23 18:08:31 +02:00 committed by Andreas Kling
commit 8d02f28cc2
Notes: github-actions[bot] 2025-07-23 17:54:06 +00:00
8 changed files with 117 additions and 2 deletions

View file

@ -632,8 +632,10 @@ void FlexFormattingContext::determine_flex_base_size(FlexItem& item)
}
// 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()
// non-replaced flex items resolve percentages in the main axis to 0.
// https://drafts.csswg.org/css-sizing-3/#cyclic-percentage-contribution
if (item.box->is_replaced_box()
&& m_available_space_for_items->main.is_min_content()
&& computed_main_size(item.box).contains_percentage()) {
return CSSPixels(0);
}