diff --git a/Libraries/LibHTML/CSS/Selector.h b/Libraries/LibHTML/CSS/Selector.h index c30bad10d67..56e96a2569f 100644 --- a/Libraries/LibHTML/CSS/Selector.h +++ b/Libraries/LibHTML/CSS/Selector.h @@ -9,6 +9,7 @@ public: struct Component { enum class Type { Invalid, + Universal, TagName, Id, Class, diff --git a/Libraries/LibHTML/CSS/SelectorEngine.cpp b/Libraries/LibHTML/CSS/SelectorEngine.cpp index 56ad75c0506..58ef15bd014 100644 --- a/Libraries/LibHTML/CSS/SelectorEngine.cpp +++ b/Libraries/LibHTML/CSS/SelectorEngine.cpp @@ -30,6 +30,8 @@ bool matches(const Selector::Component& component, const Element& element) } switch (component.type) { + case Selector::Component::Type::Universal: + return true; case Selector::Component::Type::Id: return component.value == element.attribute("id"); case Selector::Component::Type::Class: diff --git a/Libraries/LibHTML/Dump.cpp b/Libraries/LibHTML/Dump.cpp index 424faffd84b..ab17073da0c 100644 --- a/Libraries/LibHTML/Dump.cpp +++ b/Libraries/LibHTML/Dump.cpp @@ -150,6 +150,9 @@ void dump_rule(const StyleRule& rule) case Selector::Component::Type::Invalid: type_description = "Invalid"; break; + case Selector::Component::Type::Universal: + type_description = "Universal"; + break; case Selector::Component::Type::Id: type_description = "Id"; break; diff --git a/Libraries/LibHTML/Parser/CSSParser.cpp b/Libraries/LibHTML/Parser/CSSParser.cpp index f21314e7ddf..36669b2c14b 100644 --- a/Libraries/LibHTML/Parser/CSSParser.cpp +++ b/Libraries/LibHTML/Parser/CSSParser.cpp @@ -224,6 +224,12 @@ public: consume_whitespace_or_comments(); } + if (peek() == '*') { + type = Selector::Component::Type::Universal; + consume_one(); + return Selector::Component { type, Selector::Component::PseudoClass::None, relation, String() }; + } + if (peek() == '.') { type = Selector::Component::Type::Class; consume_one();