mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
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:
Notes:
github-actions[bot]
2025-07-15 13:27:30 +00:00
Author: https://github.com/Calme1709 Commit: https://github.com/LadybirdBrowser/ladybird/commit/9ed85ddd63a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5386 Reviewed-by: https://github.com/AtkinsSJ ✅
@@ -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"~~~(
|
||||
|
||||
Reference in New Issue
Block a user