diff --git a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp index d8f4dd942d..d409100492 100644 --- a/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp +++ b/Userland/Libraries/LibWeb/CSS/StyleResolver.cpp @@ -229,10 +229,15 @@ static inline void set_property_border_style(StyleProperties& style, const Style style.set_property(CSS::PropertyID::BorderLeftStyle, value); } -static void set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, const StyleValue& value, DOM::Document& document) +static void set_property_expanding_shorthands(StyleProperties& style, CSS::PropertyID property_id, const StyleValue& value, DOM::Document& document, bool is_internally_generated_pseudo_property = false) { CSS::ParsingContext context(document); + if (is_pseudo_property(property_id) && !is_internally_generated_pseudo_property) { + dbgln("Ignoring non-internally-generated pseudo property: {}", string_from_property_id(property_id)); + return; + } + if (property_id == CSS::PropertyID::TextDecoration) { switch (value.to_identifier()) { case CSS::ValueID::None: diff --git a/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp b/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp index 1fde66eee3..1fe95967fe 100644 --- a/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp +++ b/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_cpp.cpp @@ -112,7 +112,35 @@ const char* string_from_property_id(PropertyID property_id) { } } +bool is_pseudo_property(PropertyID property_id) +{ + switch (property_id) { +)~~~"); + + json.value().as_object().for_each_member([&](auto& name, auto& value) { + VERIFY(value.is_object()); + + auto pseudo = value.as_object().get_or("pseudo", false); + VERIFY(pseudo.is_bool()); + + if (pseudo.as_bool()) { + 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; + } +} + } // namespace Web::CSS + )~~~"); outln("{}", generator.as_string_view()); diff --git a/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp b/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp index 6391df70f4..bad3913379 100644 --- a/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp +++ b/Userland/Libraries/LibWeb/CodeGenerators/Generate_CSS_PropertyID_h.cpp @@ -91,6 +91,7 @@ enum class PropertyID { PropertyID property_id_from_string(const StringView&); const char* string_from_property_id(PropertyID); +bool is_pseudo_property(PropertyID); } // namespace Web::CSS