1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 03:57:43 +00:00

LibWeb: Parse CSS selectors according to the spec

The spec does not directly tell us how to parse selectors, so there are
likely some bugs here, but I've used the spec language where possible.
This is very much based on the previous selector parsing code.

Any parse error inside a selector makes the entire SelectorList
invalid, so nothing is returned.
This commit is contained in:
Sam Atkins 2021-07-23 16:13:07 +01:00 committed by Andreas Kling
parent 8d1762ac62
commit 8d0ff98eff
4 changed files with 475 additions and 374 deletions

View file

@ -34,8 +34,8 @@ public:
Type type { Type::Invalid };
struct NthChildPattern {
int step_size = 0;
int offset = 0;
int step_size { 0 };
int offset = { 0 };
static NthChildPattern parse(StringView const& args);
};
@ -70,7 +70,7 @@ public:
SelectorList not_selector {};
};
PseudoClass pseudo_class;
PseudoClass pseudo_class {};
enum class PseudoElement {
None,
@ -81,7 +81,7 @@ public:
};
PseudoElement pseudo_element { PseudoElement::None };
FlyString value;
FlyString value {};
struct Attribute {
enum class MatchType {
@ -95,10 +95,10 @@ public:
EndsWithString, // [att$=val]
};
MatchType match_type { MatchType::None };
FlyString name;
String value;
FlyString name {};
String value {};
};
Attribute attribute;
Attribute attribute {};
};
enum class Combinator {