mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 12:05:15 +00:00
LibWeb: Generate property_maximum_value_count()
This will allow the CSS Parser to check if a property has been give too many arguments, and if so, reject it as invalid.
This commit is contained in:
parent
e40ea819d9
commit
a1bc89b814
Notes:
sideshowbarker
2024-07-18 03:32:59 +09:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/SerenityOS/serenity/commit/a1bc89b814d Pull-request: https://github.com/SerenityOS/serenity/pull/10188
2 changed files with 28 additions and 0 deletions
|
@ -252,6 +252,32 @@ bool property_has_quirk(PropertyID property_id, Quirk quirk)
|
|||
}
|
||||
}
|
||||
|
||||
size_t property_maximum_value_count(PropertyID property_id)
|
||||
{
|
||||
switch (property_id) {
|
||||
)~~~");
|
||||
|
||||
properties.for_each_member([&](auto& name, auto& value) {
|
||||
VERIFY(value.is_object());
|
||||
if (value.as_object().has("max-values")) {
|
||||
auto max_values = value.as_object().get("max-values");
|
||||
VERIFY(max_values.is_number() && !max_values.is_double());
|
||||
auto property_generator = generator.fork();
|
||||
property_generator.set("name:titlecase", title_casify(name));
|
||||
property_generator.set("max_values", max_values.to_string());
|
||||
property_generator.append(R"~~~(
|
||||
case PropertyID::@name:titlecase@:
|
||||
return @max_values@;
|
||||
)~~~");
|
||||
}
|
||||
});
|
||||
|
||||
generator.append(R"~~~(
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Web::CSS
|
||||
|
||||
)~~~");
|
||||
|
|
|
@ -106,6 +106,8 @@ bool is_inherited_property(PropertyID);
|
|||
bool is_pseudo_property(PropertyID);
|
||||
RefPtr<StyleValue> property_initial_value(PropertyID);
|
||||
|
||||
size_t property_maximum_value_count(PropertyID);
|
||||
|
||||
constexpr PropertyID first_property_id = PropertyID::@first_property_id@;
|
||||
constexpr PropertyID last_property_id = PropertyID::@last_property_id@;
|
||||
constexpr PropertyID first_shorthand_property_id = PropertyID::@first_shorthand_property_id@;
|
||||
|
|
Loading…
Add table
Reference in a new issue