LibWeb: Store font-weight in ComputedProperties in computed form

We now also more closely follow the spec when computing values for
font-weight and we now:
 - Support relative lengths in `calc()`s
 - Properly clamp `calc()`s
 - Support relative keywords (e.g. lighter, bolder)
 - Respect that font-weight can be a non-integer number.

This does expose a few false positives in the font-weight-computed.html
WPT test. This is because we don't recompute non-inherited font-weight
within `recompute_inherited_style` which means that relative keyword
values can fall out of sync with their parent's value. These previously
passed as we treated `bolder` and `lighter` as aliases for `bold` and
`normal` respectively.
This commit is contained in:
Callum Law 2025-09-02 01:14:06 +12:00 committed by Sam Atkins
commit 39484e2027
Notes: github-actions[bot] 2025-09-19 09:08:40 +00:00
15 changed files with 214 additions and 117 deletions

View file

@ -2104,4 +2104,9 @@ CSSPixels ComputedProperties::font_size() const
return property(PropertyID::FontSize).as_length().length().absolute_length_to_px();
}
double ComputedProperties::font_weight() const
{
return property(PropertyID::FontWeight).as_number().number();
}
}