LibWeb: Add missing check for flexible grid tracks

Previously this didn't cause issues because the default flex-factor is
0, but once we only store a flex-factor for FlexibleLength-type
GridSizes, this causes a crash.
This commit is contained in:
Sam Atkins 2023-09-28 16:14:08 +01:00 committed by Sam Atkins
parent 127bfd64a8
commit b66ff21379
Notes: sideshowbarker 2024-07-17 01:11:48 +09:00

View file

@ -1250,9 +1250,11 @@ void GridFormattingContext::expand_flexible_tracks(AvailableSpace const& availab
// For each flexible track, if the product of the used flex fraction and the tracks flex factor is greater than
// the tracks base size, set its base size to that product.
for (auto& track : tracks_and_gaps) {
auto scaled_fraction = CSSPixels::nearest_value_for(track.max_track_sizing_function.flex_factor()) * flex_fraction;
if (scaled_fraction > track.base_size) {
track.base_size = scaled_fraction;
if (track.max_track_sizing_function.is_flexible_length()) {
auto scaled_fraction = CSSPixels::nearest_value_for(track.max_track_sizing_function.flex_factor()) * flex_fraction;
if (scaled_fraction > track.base_size) {
track.base_size = scaled_fraction;
}
}
}
}