mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 04:38:11 +00:00
LibHTML: Implement compound selectors
This patch moves the Selector object model closer to the specification objects in Selectors Level 4. A "Selector" in LibHTML is now a { Vector<ComplexSelector> }, which is a { Relation, CompoundSelector }. A CompoundSelector is really just a Vector<SimpleSelector>, and SimpleSelector is "Component" renamed. This makes a lot more selectors actually match on the Ubuntu Apache2 default homepage. :^)
This commit is contained in:
parent
449ebbddb6
commit
d19d4da14a
5 changed files with 194 additions and 148 deletions
|
@ -6,7 +6,7 @@
|
|||
|
||||
class Selector {
|
||||
public:
|
||||
struct Component {
|
||||
struct SimpleSelector {
|
||||
enum class Type {
|
||||
Invalid,
|
||||
Universal,
|
||||
|
@ -23,15 +23,6 @@ public:
|
|||
};
|
||||
PseudoClass pseudo_class { PseudoClass::None };
|
||||
|
||||
enum class Relation {
|
||||
None,
|
||||
ImmediateChild,
|
||||
Descendant,
|
||||
AdjacentSibling,
|
||||
GeneralSibling,
|
||||
};
|
||||
Relation relation { Relation::None };
|
||||
|
||||
String value;
|
||||
|
||||
enum class AttributeMatchType {
|
||||
|
@ -45,13 +36,27 @@ public:
|
|||
String attribute_value;
|
||||
};
|
||||
|
||||
explicit Selector(Vector<Component>&&);
|
||||
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>&&);
|
||||
~Selector();
|
||||
|
||||
const Vector<Component>& components() const { return m_components; }
|
||||
const Vector<ComplexSelector>& complex_selectors() const { return m_complex_selectors; }
|
||||
|
||||
Specificity specificity() const;
|
||||
|
||||
private:
|
||||
Vector<Component> m_components;
|
||||
Vector<ComplexSelector> m_complex_selectors;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue