mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 11:37:44 +00:00
LibWeb: Fix divisions by zero in FFC and GFC
This is the preparation to use fixed-point to represent CSSPixels. Previously, it was acceptable to divide CSSPixels by zero, resulting in inf, but after migrating to fixed-point stored as an integer, it would lead to undefined behavior.
This commit is contained in:
parent
d216621d2a
commit
5cdd03fc53
2 changed files with 7 additions and 1 deletions
|
@ -785,6 +785,9 @@ void GridFormattingContext::distribute_extra_space_across_spanned_tracks_base_si
|
|||
affected_tracks.append(track);
|
||||
}
|
||||
|
||||
if (affected_tracks.size() == 0)
|
||||
return;
|
||||
|
||||
for (auto& track : affected_tracks)
|
||||
track.item_incurred_increase = 0;
|
||||
|
||||
|
@ -870,6 +873,9 @@ void GridFormattingContext::distribute_extra_space_across_spanned_tracks_growth_
|
|||
for (auto& track : affected_tracks)
|
||||
track.item_incurred_increase = 0;
|
||||
|
||||
if (affected_tracks.size() == 0)
|
||||
return;
|
||||
|
||||
// 1. Find the space to distribute:
|
||||
CSSPixels spanned_tracks_sizes_sum = 0;
|
||||
for (auto& track : spanned_tracks) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue