mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 10:38:13 +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
|
@ -1301,7 +1301,7 @@ void FlexFormattingContext::distribute_any_remaining_free_space()
|
|||
CSSPixels initial_offset = 0;
|
||||
auto number_of_items = flex_line.items.size();
|
||||
|
||||
if (auto_margins == 0) {
|
||||
if (auto_margins == 0 && number_of_items > 0) {
|
||||
switch (flex_container().computed_values().justify_content()) {
|
||||
case CSS::JustifyContent::Start:
|
||||
case CSS::JustifyContent::FlexStart:
|
||||
|
|
|
@ -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