2019-06-20 18:25:25 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
2019-09-06 10:34:26 -03:00
|
|
|
#include <AK/String.h>
|
2019-06-20 18:25:25 -03:00
|
|
|
#include <AK/Vector.h>
|
2019-06-29 12:32:32 -03:00
|
|
|
#include <LibHTML/CSS/Specificity.h>
|
2019-06-20 18:25:25 -03:00
|
|
|
|
|
|
|
|
class Selector {
|
|
|
|
|
public:
|
2019-11-27 16:37:36 -03:00
|
|
|
struct SimpleSelector {
|
2019-06-29 12:32:32 -03:00
|
|
|
enum class Type {
|
|
|
|
|
Invalid,
|
2019-11-19 14:22:12 -03:00
|
|
|
Universal,
|
2019-06-29 12:32:32 -03:00
|
|
|
TagName,
|
|
|
|
|
Id,
|
2019-10-06 04:28:10 -03:00
|
|
|
Class,
|
2019-06-29 12:32:32 -03:00
|
|
|
};
|
2019-06-20 18:25:25 -03:00
|
|
|
Type type { Type::Invalid };
|
2019-10-06 04:28:10 -03:00
|
|
|
|
2019-10-13 16:54:26 -03:00
|
|
|
enum class PseudoClass {
|
|
|
|
|
None,
|
|
|
|
|
Link,
|
|
|
|
|
Hover,
|
|
|
|
|
};
|
|
|
|
|
PseudoClass pseudo_class { PseudoClass::None };
|
|
|
|
|
|
2019-06-20 18:25:25 -03:00
|
|
|
String value;
|
2019-11-21 16:07:43 -03:00
|
|
|
|
|
|
|
|
enum class AttributeMatchType {
|
|
|
|
|
None,
|
|
|
|
|
HasAttribute,
|
|
|
|
|
ExactValueMatch,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
AttributeMatchType attribute_match_type { AttributeMatchType::None };
|
|
|
|
|
String attribute_name;
|
|
|
|
|
String attribute_value;
|
2019-06-20 18:25:25 -03:00
|
|
|
};
|
|
|
|
|
|
2019-11-27 16:37:36 -03:00
|
|
|
struct ComplexSelector {
|
|
|
|
|
enum class Relation {
|
|
|
|
|
None,
|
|
|
|
|
ImmediateChild,
|
|
|
|
|
Descendant,
|
|
|
|
|
AdjacentSibling,
|
|
|
|
|
GeneralSibling,
|
|
|
|
|
};
|
|
|
|
|
Relation relation { Relation::None };
|
|
|
|
|
|
|
|
|
|
using CompoundSelector = Vector<SimpleSelector>;
|
|
|
|
|
CompoundSelector compound_selector;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
explicit Selector(Vector<ComplexSelector>&&);
|
2019-06-22 04:27:39 -03:00
|
|
|
~Selector();
|
|
|
|
|
|
2019-11-27 16:37:36 -03:00
|
|
|
const Vector<ComplexSelector>& complex_selectors() const { return m_complex_selectors; }
|
2019-06-20 18:25:25 -03:00
|
|
|
|
2019-06-29 12:32:32 -03:00
|
|
|
Specificity specificity() const;
|
|
|
|
|
|
2019-06-20 18:25:25 -03:00
|
|
|
private:
|
2019-11-27 16:37:36 -03:00
|
|
|
Vector<ComplexSelector> m_complex_selectors;
|
2019-06-20 18:25:25 -03:00
|
|
|
};
|