1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-09-18 09:56:17 +00:00

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.
This commit is contained in:
Sam Atkins 2021-07-12 14:58:03 +01:00 committed by Andreas Kling
parent dadcb46344
commit 96b2356cbb
5 changed files with 136 additions and 139 deletions

View file

@ -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;