Improve performance of column flexboxes (#34346)

If a flex item in a single-line column flex container stretches, then
we can know its final size. So instead of first laying it out using its
intrinsic inline size, and then stretching it later, we can use the
correct size from the very beginning.

Signed-off-by: Oriol Brufau <obrufau@igalia.com>
Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
Oriol Brufau 2024-11-22 23:52:47 +01:00 committed by GitHub
parent 524c54640d
commit f943ba023a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1901,8 +1901,16 @@ impl FlexItem<'_> {
self.content_max_size.cross,
)
});
content_contributions
.shrink_to_fit(containing_block.inline_size - self.pbm_auto_is_zero.cross)
let stretch_size = containing_block.inline_size - self.pbm_auto_is_zero.cross;
let style = self.box_.style();
if flex_context
.config
.item_with_auto_cross_size_stretches_to_container_size(style, &self.margin)
{
stretch_size
} else {
content_contributions.shrink_to_fit(stretch_size)
}
}),
// The main size of a flex item is considered to be definite if its flex basis is definite
// or the flex container has a definite main size.