diff options
author | Sam Atkins <atkinssj@gmail.com> | 2021-07-12 14:58:03 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-07-14 13:31:00 +0200 |
commit | 96b2356cbb187424ca3864fb1ca1095275d8ea61 (patch) | |
tree | eaae78d6f07b4d47033d6335bc408831c4a64a79 /Userland/Libraries/LibWeb/CSS/Selector.h | |
parent | dadcb4634430d6e963e53dc8465261fad87470ee (diff) | |
download | serenity-96b2356cbb187424ca3864fb1ca1095275d8ea61.zip |
LibWeb: Add 'Attribute' as a CSS SimpleSelector::Type
Previously, SimpleSelectors optionally had Attribute-selector data
as well as their main type. Now, they're either one or the other,
which better matches the spec, and makes parsing and matching more
straightforward.
Diffstat (limited to 'Userland/Libraries/LibWeb/CSS/Selector.h')
-rw-r--r-- | Userland/Libraries/LibWeb/CSS/Selector.h | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/Selector.h b/Userland/Libraries/LibWeb/CSS/Selector.h index 7bed123dd0..ab19ce156d 100644 --- a/Userland/Libraries/LibWeb/CSS/Selector.h +++ b/Userland/Libraries/LibWeb/CSS/Selector.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> + * Copyright (c) 2021, Sam Atkins <atkinssj@gmail.com> * * SPDX-License-Identifier: BSD-2-Clause */ @@ -21,6 +22,7 @@ public: TagName, Id, Class, + Attribute, }; Type type { Type::Invalid }; @@ -56,20 +58,22 @@ public: FlyString value; - enum class AttributeMatchType { - None, - HasAttribute, - ExactValueMatch, - ContainsWord, // [att~=val] - ContainsString, // [att*=val] - StartsWithSegment, // [att|=val] - StartsWithString, // [att^=val] - EndsWithString, // [att$=val] + struct Attribute { + enum class MatchType { + None, + HasAttribute, + ExactValueMatch, + ContainsWord, // [att~=val] + ContainsString, // [att*=val] + StartsWithSegment, // [att|=val] + StartsWithString, // [att^=val] + EndsWithString, // [att$=val] + }; + MatchType match_type { MatchType::None }; + FlyString name; + String value; }; - - AttributeMatchType attribute_match_type { AttributeMatchType::None }; - FlyString attribute_name; - String attribute_value; + Attribute attribute; struct NthChildPattern { int step_size = 0; |