LibWeb: Clamp growth limit after adding planned increase in GFC

Fixes implementation of the following line from the spec:
"However, limit the growth of any fit-content() tracks by their
fit-content() argument."

Now we correctly apply a limit to increased growth limit rather than to
the planned increase.

Change in "Tests/LibWeb/Layout/input/grid/fit-content-2.html" is a
progression and "Item as wide as the content." is actually as wide as a
content.
This commit is contained in:
Aliaksandr Kalenik 2024-09-08 21:00:27 +02:00 committed by Alexander Kalenik
commit 07aa25ce50
Notes: github-actions[bot] 2024-09-09 09:42:02 +00:00
4 changed files with 80 additions and 20 deletions

View file

@ -867,10 +867,14 @@ void GridFormattingContext::increase_sizes_to_accommodate_spanning_items_crossin
});
for (auto& track : spanned_tracks) {
if (track.max_track_sizing_function.is_fit_content()) {
track.growth_limit = css_clamp(
track.planned_increase,
track.base_size,
track.max_track_sizing_function.css_size().to_px(grid_container(), available_size.to_px_or_zero()));
track.growth_limit.value() += track.planned_increase;
if (track.growth_limit.value() < track.base_size)
track.growth_limit = track.base_size;
if (available_size.is_definite()) {
auto fit_content_limit = track.max_track_sizing_function.css_size().to_px(grid_container(), available_size.to_px_or_zero());
if (track.growth_limit.value() > fit_content_limit)
track.growth_limit = fit_content_limit;
}
} else if (!track.growth_limit.has_value()) {
// If the affected size is an infinite growth limit, set it to the tracks base size plus the planned increase.
track.growth_limit = track.base_size + track.planned_increase;