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
parent 3a43fa9e35
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

@ -187,8 +187,10 @@ SelectorList const& CSSStyleRule::absolutized_selectors() const
},
};
SelectorList absolutized_selectors;
for (auto const& selector : selectors())
absolutized_selectors.append(selector->absolutized(parent_selector));
for (auto const& selector : selectors()) {
if (auto absolutized = selector->absolutized(parent_selector))
absolutized_selectors.append(absolutized.release_nonnull());
}
m_cached_absolutized_selectors = move(absolutized_selectors);
} else {
// NOTE: We can't actually replace & with :scope, because & has to have 0 specificity.