1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-18 17:35:06 +00:00

LibWeb: Replace is_inherited_property() with generated code

We already include the inheritance for each property in Properties.json,
so made sense to use that instead of a list in StyleResolver.

Added `inherited: true` to a couple of properties to match the previous
code's behavior. One of those had a FIXME which I've moved to the JSON
file, which is hacky, but it works.
This commit is contained in:
Sam Atkins 2021-08-16 16:07:13 +01:00 committed by Andreas Kling
parent ea2b02186c
commit 0fba71a655
5 changed files with 36 additions and 36 deletions

View file

@ -82,7 +82,7 @@ const char* string_from_property_id(PropertyID property_id) {
member_generator.append(R"~~~(
case PropertyID::@name:titlecase@:
return "@name@";
)~~~");
)~~~");
});
generator.append(R"~~~(
@ -91,6 +91,37 @@ const char* string_from_property_id(PropertyID property_id) {
}
}
bool is_inherited_property(PropertyID property_id)
{
switch (property_id) {
)~~~");
json.value().as_object().for_each_member([&](auto& name, auto& value) {
VERIFY(value.is_object());
bool inherited = false;
if (value.as_object().has("inherited")) {
auto& inherited_value = value.as_object().get("inherited");
VERIFY(inherited_value.is_bool());
inherited = inherited_value.as_bool();
}
if (inherited) {
auto member_generator = generator.fork();
member_generator.set("name:titlecase", title_casify(name));
member_generator.append(R"~~~(
case PropertyID::@name:titlecase@:
return true;
)~~~");
}
});
generator.append(R"~~~(
default:
return false;
}
}
bool is_pseudo_property(PropertyID property_id)
{
switch (property_id) {