LibWeb: Clamp negative font-size when loading font

`font-size` can end up with a negative value - either due to `calc`
being resolved using the old method which doesn't clamp the value, or
interpolation - in this case we should clamp negative values to zero.

Gains us 36 new WPT passes and fixes crashes in the three imported
tests.
This commit is contained in:
Callum Law 2025-08-22 03:50:16 +12:00 committed by Sam Atkins
commit 56c4e8199b
Notes: github-actions[bot] 2025-09-01 11:30:15 +00:00
9 changed files with 456 additions and 40 deletions

View file

@ -1989,6 +1989,10 @@ RefPtr<Gfx::FontCascadeList const> StyleComputer::compute_font_for_style_values(
}
}
// FIXME: Font size can end up being negative due to interpolation - we can remove this once we correctly handle interpolation clamping.
if (font_size_in_px < 0)
font_size_in_px = 0;
auto slope = font_style.to_font_slope();
// FIXME: Implement the full font-matching algorithm: https://www.w3.org/TR/css-fonts-4/#font-matching-algorithm