LibWeb/CSS: Mark list-valued properties

Typed-OM requires us to have a generic way of asking "does property X
accept a list or a single value?" so this exists mainly for that.
Coordinating lists are annotated too - I'm not clear on exactly what
will be needed for those, but giving them a unique value now at the
worst will make them easier to find later.
This commit is contained in:
Sam Atkins
2025-09-19 12:13:15 +01:00
committed by Andreas Kling
parent b3ad4be90c
commit 1e1752b33b
Notes: github-actions[bot] 2025-10-04 20:58:38 +00:00
3 changed files with 123 additions and 19 deletions

View File

@@ -254,6 +254,9 @@ WEB_API Optional<PropertyID> property_id_from_string(StringView);
WEB_API bool is_inherited_property(PropertyID);
NonnullRefPtr<StyleValue const> property_initial_value(PropertyID);
bool property_is_single_valued(PropertyID);
bool property_is_list_valued(PropertyID);
bool property_accepts_type(PropertyID, ValueType);
struct AcceptedTypeRange {
float min;
@@ -774,6 +777,38 @@ NonnullRefPtr<StyleValue const> property_initial_value(PropertyID property_id)
}
VERIFY_NOT_REACHED();
}
bool property_is_single_valued(PropertyID property_id)
{
return !property_is_list_valued(property_id);
}
bool property_is_list_valued(PropertyID property_id)
{
switch (property_id) {
)~~~");
properties.for_each_member([&](auto& name, JsonValue const& value) {
auto property = value.as_object();
if (auto multiplicity = property.get_string("multiplicity"sv);
multiplicity.has_value() && multiplicity != "single"sv) {
if (!first_is_one_of(multiplicity, "list"sv, "coordinating-list"sv)) {
dbgln("'{}' is not a valid value for 'multiplicity'. Accepted values are: 'single', 'list', 'coordinating-list'", multiplicity.value());
VERIFY_NOT_REACHED();
}
auto property_generator = generator.fork();
property_generator.set("name:titlecase", title_casify(name));
property_generator.appendln(" case PropertyID::@name:titlecase@:");
}
});
generator.append(R"~~~(
return true;
default:
return false;
}
}
bool property_has_quirk(PropertyID property_id, Quirk quirk)
{