LibWeb/CSS: Allow Selector::absolutized() to return null

It's possible for absolutizing a selector to return an invalid selector
(eg, it could cause `:has()` inside `:has()`) so we need to be able to
express that.
This commit is contained in:
Sam Atkins 2024-11-14 12:48:50 +00:00 committed by Andreas Kling
commit da31c10ce1
Notes: github-actions[bot] 2024-11-14 19:08:23 +00:00
3 changed files with 31 additions and 14 deletions

View file

@ -222,7 +222,7 @@ public:
String serialize() const;
SimpleSelector absolutized(SimpleSelector const& selector_for_nesting) const;
Optional<SimpleSelector> absolutized(SimpleSelector const& selector_for_nesting) const;
};
enum class Combinator {
@ -240,7 +240,7 @@ public:
Combinator combinator { Combinator::None };
Vector<SimpleSelector> simple_selectors;
CompoundSelector absolutized(SimpleSelector const& selector_for_nesting) const;
Optional<CompoundSelector> absolutized(SimpleSelector const& selector_for_nesting) const;
};
static NonnullRefPtr<Selector> create(Vector<CompoundSelector>&& compound_selectors)
@ -254,7 +254,7 @@ public:
Optional<PseudoElement> const& pseudo_element() const { return m_pseudo_element; }
NonnullRefPtr<Selector> relative_to(SimpleSelector const&) const;
bool contains_the_nesting_selector() const { return m_contains_the_nesting_selector; }
NonnullRefPtr<Selector> absolutized(SimpleSelector const& selector_for_nesting) const;
RefPtr<Selector> absolutized(SimpleSelector const& selector_for_nesting) const;
u32 specificity() const;
String serialize() const;