mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:27:44 +00:00
LibHTML: Implement the universal selector ("*")
This commit is contained in:
parent
516708aab2
commit
56dad2272c
4 changed files with 12 additions and 0 deletions
|
@ -9,6 +9,7 @@ public:
|
||||||
struct Component {
|
struct Component {
|
||||||
enum class Type {
|
enum class Type {
|
||||||
Invalid,
|
Invalid,
|
||||||
|
Universal,
|
||||||
TagName,
|
TagName,
|
||||||
Id,
|
Id,
|
||||||
Class,
|
Class,
|
||||||
|
|
|
@ -30,6 +30,8 @@ bool matches(const Selector::Component& component, const Element& element)
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (component.type) {
|
switch (component.type) {
|
||||||
|
case Selector::Component::Type::Universal:
|
||||||
|
return true;
|
||||||
case Selector::Component::Type::Id:
|
case Selector::Component::Type::Id:
|
||||||
return component.value == element.attribute("id");
|
return component.value == element.attribute("id");
|
||||||
case Selector::Component::Type::Class:
|
case Selector::Component::Type::Class:
|
||||||
|
|
|
@ -150,6 +150,9 @@ void dump_rule(const StyleRule& rule)
|
||||||
case Selector::Component::Type::Invalid:
|
case Selector::Component::Type::Invalid:
|
||||||
type_description = "Invalid";
|
type_description = "Invalid";
|
||||||
break;
|
break;
|
||||||
|
case Selector::Component::Type::Universal:
|
||||||
|
type_description = "Universal";
|
||||||
|
break;
|
||||||
case Selector::Component::Type::Id:
|
case Selector::Component::Type::Id:
|
||||||
type_description = "Id";
|
type_description = "Id";
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -224,6 +224,12 @@ public:
|
||||||
consume_whitespace_or_comments();
|
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() == '.') {
|
if (peek() == '.') {
|
||||||
type = Selector::Component::Type::Class;
|
type = Selector::Component::Type::Class;
|
||||||
consume_one();
|
consume_one();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue