mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb: Don't use get_free_space()
to count auto-fill/fit tracks [GFC]
Spec says that definite grid container size should be used as free space so there's no need to use `get_free_space()` that does iteration over tracks and subtracts definite sizes from available space.
This commit is contained in:
parent
ea29877385
commit
b315e80142
Notes:
github-actions[bot]
2025-06-23 00:31:31 +00:00
Author: https://github.com/kalenikaliaksandr
Commit: b315e80142
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5171
1 changed files with 3 additions and 6 deletions
|
@ -262,19 +262,16 @@ int GridFormattingContext::count_of_repeated_auto_fill_or_fit_tracks(GridDimensi
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
auto const& available_size = dimension == GridDimension::Column ? m_available_space->width : m_available_space->height;
|
auto const& available_size = dimension == GridDimension::Column ? m_available_space->width : m_available_space->height;
|
||||||
auto free_space = get_free_space(*m_available_space, dimension).to_px_or_zero();
|
|
||||||
auto const& gap = dimension == GridDimension::Column ? grid_computed_values.column_gap() : grid_computed_values.row_gap();
|
auto const& gap = dimension == GridDimension::Column ? grid_computed_values.column_gap() : grid_computed_values.row_gap();
|
||||||
auto gap_px = gap_to_px(gap, grid_container(), available_size.to_px_or_zero());
|
auto gap_px = gap_to_px(gap, grid_container(), available_size.to_px_or_zero());
|
||||||
auto size_of_repeated_tracks_with_gap = size_of_repeated_tracks + repeat_track_list.size() * gap_px;
|
auto size_of_repeated_tracks_with_gap = size_of_repeated_tracks + repeat_track_list.size() * gap_px;
|
||||||
// If any number of repetitions would overflow, then 1 repetition.
|
|
||||||
if (free_space <= size_of_repeated_tracks_with_gap) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
// Otherwise, if the grid container has a definite min size in the relevant axis, the number of repetitions is the
|
// Otherwise, if the grid container has a definite min size in the relevant axis, the number of repetitions is the
|
||||||
// smallest possible positive integer that fulfills that minimum requirement
|
// smallest possible positive integer that fulfills that minimum requirement
|
||||||
else if (available_size.is_definite()) {
|
if (available_size.is_definite()) {
|
||||||
// NOTE: Gap size is added to free space to compensate for the fact that the last track does not have a gap
|
// NOTE: Gap size is added to free space to compensate for the fact that the last track does not have a gap
|
||||||
|
auto free_space = available_size.to_px_or_zero();
|
||||||
auto number_of_repetitions = ((free_space + gap_px) / size_of_repeated_tracks_with_gap).to_int();
|
auto number_of_repetitions = ((free_space + gap_px) / size_of_repeated_tracks_with_gap).to_int();
|
||||||
|
// If any number of repetitions would overflow, then 1 repetition.
|
||||||
return max(1, number_of_repetitions);
|
return max(1, number_of_repetitions);
|
||||||
}
|
}
|
||||||
// Otherwise, the specified track list repeats only once.
|
// Otherwise, the specified track list repeats only once.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue