layout: Floor content-box size by zero when stretching flex item (#38521)

When stretching the cross size of a flex item to its flex line, we were
computing the stretch size by subtracting padding, border and margin
from the line size. However, this could result in a negative amount for
the content-box cross size. Therefore, this floors it by zero.

Testing: Adding new tests
Fixes: #38517

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
This commit is contained in:
Oriol Brufau 2025-08-07 11:19:22 -07:00 committed by GitHub
parent cf99d437fb
commit 87538282db
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 99 additions and 1 deletions

View file

@ -1552,7 +1552,7 @@ impl InitialFlexLineLayout<'_> {
cross_axis,
Size::Stretch,
Au::zero,
Some(final_line_cross_size - item.item.pbm_auto_is_zero.cross),
Some(Au::zero().max(final_line_cross_size - item.item.pbm_auto_is_zero.cross)),
|| content_size.into(),
// Tables have a special sizing in the block axis in that handles collapsed rows,
// but it would prevent stretching. So we only recognize tables in the inline axis.