LibWeb: Mark relevant properties as "positional-value-list-shorthands"

Some shorthand properties work differently to normal in that mapping of
provided values to longhands isn't necessarily 1-to-1 and depends on the
number of values provided, for example `margin`, `border-width`, `gap`,
etc.

These properties have distinct behaviors in how they are parsed and
serialized, having them marked allows us to implement theses behaviors
in a generic way.

No functionality changes.
This commit is contained in:
Callum Law 2025-07-10 20:21:45 +12:00 committed by Sam Atkins
commit 9ed85ddd63
Notes: github-actions[bot] 2025-07-15 13:27:30 +00:00
3 changed files with 72 additions and 16 deletions

View file

@ -323,6 +323,7 @@ Vector<PropertyID> const& longhands_for_shorthand(PropertyID);
Vector<PropertyID> const& expanded_longhands_for_shorthand(PropertyID);
bool property_maps_to_shorthand(PropertyID);
Vector<PropertyID> const& shorthands_for_longhand(PropertyID);
bool property_is_positional_value_list_shorthand(PropertyID);
size_t property_maximum_value_count(PropertyID);
@ -1335,6 +1336,33 @@ Vector<PropertyID> const& shorthands_for_longhand(PropertyID property_id)
}
}
}
)~~~");
generator.append(R"~~~(
bool property_is_positional_value_list_shorthand(PropertyID property_id)
{
switch (property_id)
{
)~~~");
properties.for_each_member([&](auto& name, auto& value) {
if (is_legacy_alias(value.as_object()))
return;
if (value.as_object().has("positional-value-list-shorthand"sv)) {
auto property_generator = generator.fork();
property_generator.set("name:titlecase", title_casify(name));
property_generator.append(R"~~~(
case PropertyID::@name:titlecase@:
)~~~");
}
});
generator.append(R"~~~(
return true;
default:
return false;
}
}
)~~~");
generator.append(R"~~~(