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:
parent
dadcb46344
commit
96b2356cbb
5 changed files with 136 additions and 139 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue