1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 00:17:46 +00:00

LibWeb: Add SimpleSelector::QualifiedName, with parsing

This is basically a name with a namespace prefix. It will be used for
adding namespaces to Universal, TagName, and Attribute selectors.

For convenience, this can also optionally parse/store the `*` wildcard
character as the name.
This commit is contained in:
Sam Atkins 2023-08-07 16:48:44 +01:00 committed by Sam Atkins
parent 4b7b726888
commit 5042c903be
3 changed files with 104 additions and 12 deletions

View file

@ -136,6 +136,31 @@ public:
Vector<FlyString> languages {};
};
struct Name {
Name(FlyString n)
: name(move(n))
, lowercase_name(name.to_string().to_lowercase().release_value_but_fixme_should_propagate_errors())
{
}
FlyString name;
FlyString lowercase_name;
};
// Equivalent to `<wq-name>`
// https://www.w3.org/TR/selectors-4/#typedef-wq-name
struct QualifiedName {
enum class NamespaceType {
Default, // `E`
None, // `|E`
Any, // `*|E`
Named, // `ns|E`
};
NamespaceType namespace_type { NamespaceType::Default };
FlyString namespace_ {};
Name name;
};
struct Attribute {
enum class MatchType {
HasAttribute,
@ -157,17 +182,6 @@ public:
CaseType case_type;
};
struct Name {
Name(FlyString n)
: name(move(n))
, lowercase_name(name.to_string().to_lowercase().release_value_but_fixme_should_propagate_errors())
{
}
FlyString name;
FlyString lowercase_name;
};
Type type;
Variant<Empty, Attribute, PseudoClass, PseudoElement, Name> value {};