LibWeb: Avoid computing automatic minimum size for some flex items

There's a specific (and thankfully very common!) scenario where we can
actually skip calculating the automatic minimum size for flex items.

In single-line (no wrapping) flex containers, if the sum of all item
flex base sizes is <= the flex container's main size, we know that
none of the items will be shrunk by the layout algorithm.

And so for any flex item with definite main size AND automatic minimum
main size, we can treat the automatic minimum size as 0.
This commit is contained in:
Andreas Kling 2025-04-21 18:27:47 +02:00 committed by Andreas Kling
commit 7b2a427430
Notes: github-actions[bot] 2025-04-22 13:47:03 +00:00
4 changed files with 366 additions and 10 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2021-2024, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2021-2025, Andreas Kling <andreas@ladybird.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
@ -173,7 +173,7 @@ private:
void determine_available_space_for_items(AvailableSpace const&);
void determine_flex_base_size_and_hypothetical_main_size(FlexItem&);
void determine_flex_base_size(FlexItem&);
void collect_flex_items_into_flex_lines();