1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 07:17:35 +00:00

LibWeb: Fix division by zero in auto-fit/fill track calculation in GFC

Fixes https://github.com/SerenityOS/serenity/issues/22319
This commit is contained in:
Aliaksandr Kalenik 2023-12-16 18:23:14 +01:00 committed by Andreas Kling
parent 4a2a37275e
commit 4c81414b14
3 changed files with 18 additions and 0 deletions

View file

@ -0,0 +1,9 @@
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
BlockContainer <html> at (0,0) content-size 800x16 [BFC] children: not-inline
Box <body> at (8,8) content-size 784x0 [GFC] children: not-inline
BlockContainer <(anonymous)> (not painted) [BFC] children: inline
TextNode <#text>
ViewportPaintable (Viewport<#document>) [0,0 800x600]
PaintableWithLines (BlockContainer<HTML>) [0,0 800x16]
PaintableBox (Box<BODY>) [8,8 784x0]

View file

@ -0,0 +1,6 @@
<!DOCTYPE html><style>
body {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(0%, 1fr));
}
</style><body>

View file

@ -121,6 +121,9 @@ int GridFormattingContext::count_of_repeated_auto_fill_or_fit_tracks(Vector<CSS:
sum_of_grid_track_sizes += min(resolve_definite_track_size(track_sizing_function.grid_size(), available_space), resolve_definite_track_size(track_sizing_function.grid_size(), available_space)); sum_of_grid_track_sizes += min(resolve_definite_track_size(track_sizing_function.grid_size(), available_space), resolve_definite_track_size(track_sizing_function.grid_size(), available_space));
} }
} }
if (sum_of_grid_track_sizes == 0)
return 0;
return max(1, (get_free_space(available_space, GridDimension::Column).to_px_or_zero() / sum_of_grid_track_sizes).to_int()); return max(1, (get_free_space(available_space, GridDimension::Column).to_px_or_zero() / sum_of_grid_track_sizes).to_int());
// For the purpose of finding the number of auto-repeated tracks in a standalone axis, the UA must // For the purpose of finding the number of auto-repeated tracks in a standalone axis, the UA must