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

@ -814,6 +814,9 @@ CSS::RequiredInvalidationAfterStyleChange Element::recompute_inherited_style()
computed_properties->set_property(property_id, *preabsolutized_value, is_inherited ? CSS::ComputedProperties::Inherited::Yes : CSS::ComputedProperties::Inherited::No);
old_values_with_relative_units.set(i, old_value);
}
// FIXME: We should also consider properties which depend on their inherited values for computation (e.g.
// relative font-sizes or font-weights)
if (!computed_properties->is_property_inherited(property_id))
continue;