
"div p" now generates a Selector with two components where the second component is a type=TagName, value="p", relation=Descendant. We still don't handle matching of these, but at least we parse them.
37 lines
708 B
C++
37 lines
708 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,
|
|
};
|
|
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;
|
|
};
|