LibWeb: Simplify handling of font-variation-settings

Since we resolve any relative lengths at compute time there's no need
for the value to be passed around as a `NumberOrCalculated` and we can
just resolve it within `ComputedProperties::font_variation_settings`.

The only place this is used it is used with value_or so there's no need
to return it is an `Optional`.

This is only used for loading fonts (which occurs during style
computation) so there's no need to store it in `ComputedValues`
This commit is contained in:
Callum Law 2025-11-06 15:55:21 +13:00 committed by Sam Atkins
parent 4fb28539a9
commit dfa47d9ed6
Notes: github-actions[bot] 2025-12-05 10:04:40 +00:00
7 changed files with 14 additions and 23 deletions

View file

@ -1945,7 +1945,7 @@ HashMap<StringView, u8> ComputedProperties::font_feature_settings() const
return {};
}
Optional<HashMap<FlyString, NumberOrCalculated>> ComputedProperties::font_variation_settings() const
HashMap<FlyString, double> ComputedProperties::font_variation_settings() const
{
auto const& value = property(PropertyID::FontVariationSettings);
@ -1954,7 +1954,7 @@ Optional<HashMap<FlyString, NumberOrCalculated>> ComputedProperties::font_variat
if (value.is_value_list()) {
auto const& axis_tags = value.as_value_list().values();
HashMap<FlyString, NumberOrCalculated> result;
HashMap<FlyString, double> result;
result.ensure_capacity(axis_tags.size());
for (auto const& tag_value : axis_tags) {
auto const& axis_tag = tag_value->as_open_type_tagged();
@ -1963,7 +1963,7 @@ Optional<HashMap<FlyString, NumberOrCalculated>> ComputedProperties::font_variat
result.set(axis_tag.tag(), axis_tag.value()->as_number().number());
} else {
VERIFY(axis_tag.value()->is_calculated());
result.set(axis_tag.tag(), NumberOrCalculated { axis_tag.value()->as_calculated() });
result.set(axis_tag.tag(), axis_tag.value()->as_calculated().resolve_number({}).value());
}
}
return result;