LibWeb: Add OpacityValueStyleValue

This allows us to avoid the ugly hack in
`property_accepted_type_ranges()`.

This also updates the `ValueType` to be `opacity-value` rather than
`opacity` to match the spec.
This commit is contained in:
Callum Law
2026-04-14 01:35:53 +12:00
committed by Sam Atkins
parent d6dbabdf0e
commit 8a7332b7b9
Notes: github-actions[bot] 2026-04-22 13:26:11 +00:00
18 changed files with 127 additions and 71 deletions

View File

@@ -235,7 +235,7 @@ enum class PropertyID : @property_id_underlying_type@ {
generator.set("first_inherited_property_id", title_casify(inherited_longhand_property_ids.first()));
generator.set("last_inherited_property_id", title_casify(inherited_longhand_property_ids.last()));
// FIXME: property_accepts_{number,percentage}() has a different range from accepted_type_ranges() despite the names sounding similar.
// FIXME: property_accepts_{number,percentage}() and property_accepted_type_ranges provide the same data, we should consolidate them.
generator.append(R"~~~(
};
@@ -999,13 +999,6 @@ AcceptedTypeRangeMap property_accepted_type_ranges(PropertyID property_id)
for (auto& type : valid_types.values()) {
VERIFY(type.is_string());
// Opacity values should have their calculated and interpolated values clamped to [0,1] which is
// different from the range of allowed values [-∞,∞].
if (type.as_string() == "opacity"sv) {
ranges_builder.append("{ ValueType::Number, { 0, 1 } }, { ValueType::Percentage, { 0, 100 } }"sv);
continue;
}
Vector<String> type_parts = MUST(type.as_string().split(' '));
if (type_parts.size() < 2)