mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-20 17:29:21 +00:00
LibWeb: Implement :host and :host(<compound-selector>) selector matching
The :host family of pseudo class selectors select the shadow host element when matching against a rule from within the element's shadow tree. This is a bit convoluted due to the fact that the document-level StyleComputer keeps track of *all* style rules, and not just the document-level ones. In the future, we should refactor style storage so that shadow roots have their own style scope, and we can simplify a lot of this.
This commit is contained in:
parent
274c46a3c9
commit
4c326fc5f6
Notes:
github-actions[bot]
2024-07-23 16:04:40 +00:00
Author: https://github.com/awesomekling
Commit: 4c326fc5f6
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/790
Reviewed-by: https://github.com/AtkinsSJ
7 changed files with 127 additions and 44 deletions
|
@ -720,7 +720,7 @@ WebIDL::ExceptionOr<bool> Element::matches(StringView selectors) const
|
|||
// 3. If the result of match a selector against an element, using s, this, and scoping root this, returns success, then return true; otherwise, return false.
|
||||
auto sel = maybe_selectors.value();
|
||||
for (auto& s : sel) {
|
||||
if (SelectorEngine::matches(s, {}, *this, {}, static_cast<ParentNode const*>(this)))
|
||||
if (SelectorEngine::matches(s, {}, *this, nullptr, {}, static_cast<ParentNode const*>(this)))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -739,7 +739,7 @@ WebIDL::ExceptionOr<DOM::Element const*> Element::closest(StringView selectors)
|
|||
auto matches_selectors = [this](CSS::SelectorList const& selector_list, Element const* element) {
|
||||
// 4. For each element in elements, if match a selector against an element, using s, element, and scoping root this, returns success, return element.
|
||||
for (auto const& selector : selector_list) {
|
||||
if (SelectorEngine::matches(selector, {}, *element, {}, this))
|
||||
if (SelectorEngine::matches(selector, {}, *element, nullptr, {}, this))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue