mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
LibWeb: Generate a method to get camel-cased CSS property names
This commit is contained in:
parent
b5c682bc2e
commit
74840de7fc
Notes:
sideshowbarker
2024-07-17 06:24:08 +09:00
Author: https://github.com/mattco98 Commit: https://github.com/SerenityOS/serenity/commit/74840de7fc Pull-request: https://github.com/SerenityOS/serenity/pull/24530
1 changed files with 28 additions and 0 deletions
|
@ -174,6 +174,7 @@ bool is_animatable_property(PropertyID);
|
|||
Optional<PropertyID> property_id_from_camel_case_string(StringView);
|
||||
Optional<PropertyID> property_id_from_string(StringView);
|
||||
[[nodiscard]] FlyString const& string_from_property_id(PropertyID);
|
||||
[[nodiscard]] FlyString const& camel_case_string_from_property_id(PropertyID);
|
||||
bool is_inherited_property(PropertyID);
|
||||
NonnullRefPtr<StyleValue> property_initial_value(JS::Realm&, PropertyID);
|
||||
|
||||
|
@ -428,6 +429,33 @@ FlyString const& string_from_property_id(PropertyID property_id) {
|
|||
}
|
||||
}
|
||||
|
||||
FlyString const& camel_case_string_from_property_id(PropertyID property_id) {
|
||||
switch (property_id) {
|
||||
)~~~");
|
||||
|
||||
properties.for_each_member([&](auto& name, auto& value) {
|
||||
VERIFY(value.is_object());
|
||||
|
||||
auto member_generator = generator.fork();
|
||||
member_generator.set("name", name);
|
||||
member_generator.set("name:titlecase", title_casify(name));
|
||||
member_generator.set("name:camelcase", camel_casify(name));
|
||||
member_generator.append(R"~~~(
|
||||
case PropertyID::@name:titlecase@: {
|
||||
static FlyString name = "@name:camelcase@"_fly_string;
|
||||
return name;
|
||||
}
|
||||
)~~~");
|
||||
});
|
||||
|
||||
generator.append(R"~~~(
|
||||
default: {
|
||||
static FlyString invalid_property_id_string = "(invalid CSS::PropertyID)"_fly_string;
|
||||
return invalid_property_id_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AnimationType animation_type_from_longhand_property(PropertyID property_id)
|
||||
{
|
||||
switch (property_id) {
|
||||
|
|
Loading…
Add table
Reference in a new issue