
This patch implements two more selector features: - "div + p" matches the <p> sibling immediately after a <div>. - "div ~ p" matches all <p> siblings after a <div>.
39 lines
765 B
C++
39 lines
765 B
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,
|
|
TagName,
|
|
Id,
|
|
Class,
|
|
};
|
|
Type type { Type::Invalid };
|
|
|
|
enum class Relation {
|
|
None,
|
|
ImmediateChild,
|
|
Descendant,
|
|
AdjacentSibling,
|
|
GeneralSibling,
|
|
};
|
|
Relation relation { Relation::None };
|
|
|
|
String value;
|
|
};
|
|
|
|
explicit Selector(Vector<Component>&&);
|
|
~Selector();
|
|
|
|
const Vector<Component>& components() const { return m_components; }
|
|
|
|
Specificity specificity() const;
|
|
|
|
private:
|
|
Vector<Component> m_components;
|
|
};
|