From b66ff21379efb990e2c34e3c1fd07021038a246e Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Thu, 28 Sep 2023 16:14:08 +0100 Subject: [PATCH] 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. --- .../Libraries/LibWeb/Layout/GridFormattingContext.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp index 4d3a0c5b742..2b23cdb7c9c 100644 --- a/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp +++ b/Userland/Libraries/LibWeb/Layout/GridFormattingContext.cpp @@ -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 track’s flex factor is greater than // the track’s 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; + } } } }