1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 18:55:07 +00:00
serenity/Libraries/LibHTML/CSS/Selector.h
Andreas Kling 8946e50986 LibHTML: Implement some attribute selector support
This patch adds a[foo] and a[foo=bar] attribute selectors.

Note that an attribute selector is an optional part of a selector
component, and not a component on its own.
2019-11-21 20:07:43 +01:00

57 lines
1.2 KiB
C++

#pragma once
#include <AK/String.h>
#include <AK/Vector.h>
#include <LibHTML/CSS/Specificity.h>
class Selector {
public:
struct Component {
enum class Type {
Invalid,
Universal,
TagName,
Id,
Class,
};
Type type { Type::Invalid };
enum class PseudoClass {
None,
Link,
Hover,
};
PseudoClass pseudo_class { PseudoClass::None };
enum class Relation {
None,
ImmediateChild,
Descendant,
AdjacentSibling,
GeneralSibling,
};
Relation relation { Relation::None };
String value;
enum class AttributeMatchType {
None,
HasAttribute,
ExactValueMatch,
};
AttributeMatchType attribute_match_type { AttributeMatchType::None };
String attribute_name;
String attribute_value;
};
explicit Selector(Vector<Component>&&);
~Selector();
const Vector<Component>& components() const { return m_components; }
Specificity specificity() const;
private:
Vector<Component> m_components;
};