mirror of
https://github.com/zebrajr/ladybird.git
synced 2026-01-15 12:15:15 +00:00
LibWeb: Treat near-zero aspect-ratios as degenerate
This commit is contained in:
committed by
Jelle Raaijmakers
parent
f9a996650b
commit
04b4cd9e00
@@ -91,7 +91,12 @@ Optional<CSSPixelFraction> Box::preferred_aspect_ratio() const
|
||||
if (ratio.is_degenerate())
|
||||
return {};
|
||||
|
||||
return CSSPixelFraction(ratio.numerator(), ratio.denominator());
|
||||
auto fraction = CSSPixelFraction(ratio.numerator(), ratio.denominator());
|
||||
// ratio.is_degenerate() operates on doubles while CSSPixelFraction uses CSSPixels, so we need to check again here.
|
||||
if (fraction == 0)
|
||||
return {};
|
||||
|
||||
return fraction;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<title>CSS aspect-ratio: Doesn't crash with small but nonzero width/height in ratio</title>
|
||||
<link rel="help" href="https://drafts.csswg.org/css-sizing-4/#aspect-ratio">
|
||||
<div style="aspect-ratio: 1/0.00000000000001"></div>
|
||||
<div style="aspect-ratio: 0.00000000000001/1"></div>
|
||||
Reference in New Issue
Block a user