ladybird/Libraries/LibHTML/CSS/Selector.h
Andreas Kling bedb00603c LibHTML: Add adjacent (+) and general (~) sibling combinators
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>.
2019-10-06 19:59:07 +02:00

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;
};