mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 20:15:17 +00:00
LibHTML: Parse descendant relations in CSS selectors
"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.
This commit is contained in:
parent
847072c2b1
commit
2a266db05b
Notes:
sideshowbarker
2024-07-19 11:48:09 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/2a266db05bf
3 changed files with 9 additions and 1 deletions
|
@ -18,6 +18,7 @@ public:
|
|||
enum class Relation {
|
||||
None,
|
||||
ImmediateChild,
|
||||
Descendant,
|
||||
};
|
||||
Relation relation { Relation::None };
|
||||
|
||||
|
|
|
@ -155,6 +155,9 @@ void dump_rule(const StyleRule& rule)
|
|||
case Selector::Component::Relation::ImmediateChild:
|
||||
relation_description = "{ImmediateChild}";
|
||||
break;
|
||||
case Selector::Component::Relation::Descendant:
|
||||
relation_description = "{Descendant}";
|
||||
break;
|
||||
}
|
||||
dbgprintf(" %s:%s %s\n", type_description, component.value.characters(), relation_description);
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@ public:
|
|||
{
|
||||
consume_whitespace();
|
||||
Selector::Component::Type type;
|
||||
Selector::Component::Relation relation = Selector::Component::Relation::None;
|
||||
Selector::Component::Relation relation = Selector::Component::Relation::Descendant;
|
||||
|
||||
if (peek() == '{')
|
||||
return {};
|
||||
|
@ -149,6 +149,10 @@ public:
|
|||
break;
|
||||
}
|
||||
|
||||
if (components.is_empty())
|
||||
return;
|
||||
components.first().relation = Selector::Component::Relation::None;
|
||||
|
||||
current_rule.selectors.append(Selector(move(components)));
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue