diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp index d82e9efdfc..5b9a817098 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_cpp.cpp @@ -127,6 +127,34 @@ bool is_inherited_property(PropertyID property_id) } } +bool property_affects_layout(PropertyID property_id) +{ + switch (property_id) { +)~~~"); + + properties.for_each_member([&](auto& name, auto& value) { + VERIFY(value.is_object()); + + bool affects_layout = true; + if (value.as_object().has("affects-layout")) + affects_layout = value.as_object().get("affects-layout").to_bool(); + + if (affects_layout) { + auto member_generator = generator.fork(); + member_generator.set("name:titlecase", title_casify(name)); + member_generator.append(R"~~~( + case PropertyID::@name:titlecase@: +)~~~"); + } + }); + + generator.append(R"~~~( + return true; + default: + return false; + } +} + NonnullRefPtr property_initial_value(PropertyID property_id) { static Array, to_underlying(last_property_id) + 1> initial_values; diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp index d6db7a7008..c3a86fc5d1 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/Generate_CSS_PropertyID_h.cpp @@ -89,6 +89,8 @@ NonnullRefPtr property_initial_value(PropertyID); bool property_accepts_value(PropertyID, StyleValue&); size_t property_maximum_value_count(PropertyID); +bool property_affects_layout(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@; diff --git a/Userland/Libraries/LibWeb/CSS/Properties.json b/Userland/Libraries/LibWeb/CSS/Properties.json index 7188ed48c3..cc67da4006 100644 --- a/Userland/Libraries/LibWeb/CSS/Properties.json +++ b/Userland/Libraries/LibWeb/CSS/Properties.json @@ -43,6 +43,7 @@ ] }, "background-color": { + "affects-layout": false, "inherited": false, "initial": "transparent", "valid-types": [ @@ -501,6 +502,7 @@ ] }, "color": { + "affects-layout": false, "inherited": true, "initial": "-libweb-palette-base-text", "valid-types": [ @@ -1049,6 +1051,7 @@ ] }, "outline-width": { + "affects-layout": false, "inherited": false, "initial": "medium", "valid-types": [ @@ -1243,6 +1246,7 @@ }, "text-decoration-line": { "__comment": "FIXME: This property is not supposed to be inherited, but we currently rely on inheritance to propagate decorations into line boxes.", + "affects-layout": false, "inherited": true, "initial": "none", "valid-identifiers": [