mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 07:58:11 +00:00
LibWeb: Flexbox: Avoid division by zero
This is not a good thing, one should not divide by zero! :^)
This commit is contained in:
parent
85af2ac450
commit
fad825e94e
1 changed files with 3 additions and 1 deletions
|
@ -504,7 +504,9 @@ void FlexFormattingContext::run(Box& box, LayoutMode)
|
|||
});
|
||||
|
||||
for_each_unfrozen_item([&](FlexItem* flex_item) {
|
||||
float ratio = flex_item->scaled_flex_shrink_factor / sum_of_scaled_flex_shrink_factor_of_unfrozen_items;
|
||||
float ratio = 1.0f;
|
||||
if (sum_of_scaled_flex_shrink_factor_of_unfrozen_items != 0.0f)
|
||||
ratio = flex_item->scaled_flex_shrink_factor / sum_of_scaled_flex_shrink_factor_of_unfrozen_items;
|
||||
flex_item->target_main_size = flex_item->flex_base_size - (AK::abs(remaining_free_space) * ratio);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue