mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:37:35 +00:00
LibWeb: Fix division by zero in solve_replaced_size_constraint()
Fixes crashes that occur in Discord after clicking on a direct messages conversation.
This commit is contained in:
parent
3ac4b02604
commit
c4f49e343a
3 changed files with 31 additions and 8 deletions
|
@ -283,14 +283,16 @@ CSSPixelSize FormattingContext::solve_replaced_size_constraint(CSSPixels input_w
|
|||
if (input_width > max_width && input_height < min_height)
|
||||
return { max_width, min_height };
|
||||
|
||||
if (input_width > max_width && input_height > max_height && max_width / input_width <= max_height / input_height)
|
||||
return { max_width, max(min_height, max_width / aspect_ratio) };
|
||||
if (input_width > max_width && input_height > max_height && max_width / input_width > max_height / input_height)
|
||||
return { max(min_width, max_height * aspect_ratio), max_height };
|
||||
if (input_width < min_width && input_height < min_height && min_width / input_width <= min_height / input_height)
|
||||
return { min(max_width, min_height * aspect_ratio), min_height };
|
||||
if (input_width < min_width && input_height < min_height && min_width / input_width > min_height / input_height)
|
||||
return { min_width, min(max_height, min_width / aspect_ratio) };
|
||||
if (input_width > 0) {
|
||||
if (input_width > max_width && input_height > max_height && max_width / input_width <= max_height / input_height)
|
||||
return { max_width, max(min_height, max_width / aspect_ratio) };
|
||||
if (input_width > max_width && input_height > max_height && max_width / input_width > max_height / input_height)
|
||||
return { max(min_width, max_height * aspect_ratio), max_height };
|
||||
if (input_width < min_width && input_height < min_height && min_width / input_width <= min_height / input_height)
|
||||
return { min(max_width, min_height * aspect_ratio), min_height };
|
||||
if (input_width < min_width && input_height < min_height && min_width / input_width > min_height / input_height)
|
||||
return { min_width, min(max_height, min_width / aspect_ratio) };
|
||||
}
|
||||
|
||||
if (input_width > max_width)
|
||||
return { max_width, max(max_width / aspect_ratio, min_height) };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue