1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:07:45 +00:00

LibWeb: Subtract border & padding when using flex line size as item size

The flex line cross size includes the margin boxes of items, so when
we're taking the flex line's cross size to use as an item cross size,
we have to subtract the margin, border padding from both sides.

Previous we only subtracted the cross margins, which led to oversized
items in some cases.
This commit is contained in:
Andreas Kling 2022-09-18 17:40:13 +02:00
parent 7bf3b40867
commit 97b5230413

View file

@ -1135,7 +1135,10 @@ void FlexFormattingContext::determine_used_cross_size_of_each_flex_item()
&& !flex_item->margins.cross_before_is_auto
&& !flex_item->margins.cross_after_is_auto) {
// FIXME: Clamp to the item's used min and max cross sizes.
flex_item->cross_size = flex_line.cross_size - flex_item->margins.cross_before - flex_item->margins.cross_after;
flex_item->cross_size = flex_line.cross_size
- flex_item->margins.cross_before - flex_item->margins.cross_after
- flex_item->padding.cross_before - flex_item->padding.cross_after
- flex_item->borders.cross_before - flex_item->borders.cross_after;
} else {
// Otherwise, the used cross size is the items hypothetical cross size.
flex_item->cross_size = flex_item->hypothetical_cross_size;