LibWeb: Don't crash when converting small CSS::Ratio to CSSPixelFraction

Previously, a crash would occur in the if `CSSPixelFraction` was given a
denominator value less than the resolution of `CSSPixels` (1/64).

We now divide both parts of the ratio by the denominator in this case.
This commit is contained in:
Tim Ledbetter 2024-08-22 10:36:03 +01:00 committed by Andreas Kling
commit 2c5d626b21
Notes: github-actions[bot] 2024-08-22 11:50:33 +00:00
4 changed files with 27 additions and 1 deletions

View file

@ -93,7 +93,7 @@ Optional<CSSPixelFraction> Box::preferred_aspect_ratio() const
if (ratio.is_degenerate())
return {};
return CSSPixelFraction(CSSPixels(ratio.numerator()), CSSPixels(ratio.denominator()));
return CSSPixelFraction(ratio.numerator(), ratio.denominator());
}
}