2019-06-20 23:25:25 +02:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-06 15:34:26 +02:00
|
|
|
#include <AK/String.h>
|
2019-06-20 23:25:25 +02:00
|
|
|
#include <AK/Vector.h>
|
2019-06-29 17:32:32 +02:00
|
|
|
#include <LibHTML/CSS/Specificity.h>
|
2019-06-20 23:25:25 +02:00
|
|
|
|
|
|
|
class Selector {
|
|
|
|
public:
|
|
|
|
struct Component {
|
2019-06-29 17:32:32 +02:00
|
|
|
enum class Type {
|
|
|
|
Invalid,
|
2019-11-19 18:22:12 +01:00
|
|
|
Universal,
|
2019-06-29 17:32:32 +02:00
|
|
|
TagName,
|
|
|
|
Id,
|
2019-10-06 09:28:10 +02:00
|
|
|
Class,
|
2019-06-29 17:32:32 +02:00
|
|
|
};
|
2019-06-20 23:25:25 +02:00
|
|
|
Type type { Type::Invalid };
|
2019-10-06 09:28:10 +02:00
|
|
|
|
2019-10-13 21:54:26 +02:00
|
|
|
enum class PseudoClass {
|
|
|
|
None,
|
|
|
|
Link,
|
|
|
|
Hover,
|
|
|
|
};
|
|
|
|
PseudoClass pseudo_class { PseudoClass::None };
|
|
|
|
|
2019-10-06 09:28:10 +02:00
|
|
|
enum class Relation {
|
|
|
|
None,
|
|
|
|
ImmediateChild,
|
2019-10-06 11:05:57 +02:00
|
|
|
Descendant,
|
2019-10-06 19:59:07 +02:00
|
|
|
AdjacentSibling,
|
|
|
|
GeneralSibling,
|
2019-10-06 09:28:10 +02:00
|
|
|
};
|
|
|
|
Relation relation { Relation::None };
|
|
|
|
|
2019-06-20 23:25:25 +02:00
|
|
|
String value;
|
2019-11-21 20:07:43 +01:00
|
|
|
|
|
|
|
enum class AttributeMatchType {
|
|
|
|
None,
|
|
|
|
HasAttribute,
|
|
|
|
ExactValueMatch,
|
|
|
|
};
|
|
|
|
|
|
|
|
AttributeMatchType attribute_match_type { AttributeMatchType::None };
|
|
|
|
String attribute_name;
|
|
|
|
String attribute_value;
|
2019-06-20 23:25:25 +02:00
|
|
|
};
|
|
|
|
|
2019-06-22 09:27:39 +02:00
|
|
|
explicit Selector(Vector<Component>&&);
|
|
|
|
~Selector();
|
|
|
|
|
2019-06-20 23:25:25 +02:00
|
|
|
const Vector<Component>& components() const { return m_components; }
|
|
|
|
|
2019-06-29 17:32:32 +02:00
|
|
|
Specificity specificity() const;
|
|
|
|
|
2019-06-20 23:25:25 +02:00
|
|
|
private:
|
|
|
|
Vector<Component> m_components;
|
|
|
|
};
|