mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 15:40:19 +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
Notes:
sideshowbarker
2024-07-17 10:08:28 +09:00
Author: https://github.com/kalenikaliaksandr Commit: https://github.com/SerenityOS/serenity/commit/c4f49e343a Pull-request: https://github.com/SerenityOS/serenity/pull/23273
3 changed files with 31 additions and 8 deletions
|
@ -0,0 +1,13 @@
|
|||
Viewport <#document> at (0,0) content-size 800x600 children: not-inline
|
||||
BlockContainer <html> at (0,0) content-size 800x16 [BFC] children: not-inline
|
||||
BlockContainer <body> at (8,8) content-size 784x0 children: not-inline
|
||||
BlockContainer <div> at (8,8) content-size 0x0 children: inline
|
||||
frag 0 from SVGSVGBox start: 0, length: 0, rect: [8,8 100x100] baseline: 100
|
||||
SVGSVGBox <svg> at (8,8) content-size 100x100 [SVG] children: not-inline
|
||||
TextNode <#text>
|
||||
|
||||
ViewportPaintable (Viewport<#document>) [0,0 800x600]
|
||||
PaintableWithLines (BlockContainer<HTML>) [0,0 800x16] overflow: [0,0 800x108]
|
||||
PaintableWithLines (BlockContainer<BODY>) [8,8 784x0] overflow: [8,8 100x100]
|
||||
PaintableWithLines (BlockContainer<DIV>) [8,8 0x0] overflow: [8,8 100x100]
|
||||
SVGSVGPaintable (SVGSVGBox<svg>) [8,8 100x100]
|
|
@ -0,0 +1,8 @@
|
|||
<!DOCTYPE html>
|
||||
<style>
|
||||
svg {
|
||||
aspect-ratio: 1 / 1;
|
||||
min-width: 100px;
|
||||
min-height: 100px;
|
||||
}
|
||||
</style><div style="width: 0px; height: 0px"><svg xmlns="http://www.w3.org/2000/svg"></svg>
|
|
@ -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…
Reference in a new issue