mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 09:52:31 +00:00
LibWeb/DOM: Implement "is closed-shadow-hidden" algorithm
This commit is contained in:
parent
1435480d76
commit
3fbd3146a1
Notes:
github-actions[bot]
2025-06-17 11:40:03 +00:00
Author: https://github.com/AtkinsSJ
Commit: 3fbd3146a1
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/5113
2 changed files with 25 additions and 0 deletions
|
@ -588,6 +588,29 @@ Node& Node::shadow_including_root()
|
||||||
return node_root;
|
return node_root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://dom.spec.whatwg.org/#concept-closed-shadow-hidden
|
||||||
|
bool Node::is_closed_shadow_hidden_from(Node const& b) const
|
||||||
|
{
|
||||||
|
// A node A is closed-shadow-hidden from a node B if all of the following conditions are true:
|
||||||
|
auto const& a_root = root();
|
||||||
|
|
||||||
|
// - A’s root is a shadow root.
|
||||||
|
if (!a_root.is_shadow_root())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// - A’s root is not a shadow-including inclusive ancestor of B.
|
||||||
|
if (a_root.is_shadow_including_inclusive_ancestor_of(b))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// - A’s root is a shadow root whose mode is "closed" or A’s root’s host is closed-shadow-hidden from B.
|
||||||
|
if (a_root.is_shadow_root() && static_cast<ShadowRoot const&>(a_root).mode() == Bindings::ShadowRootMode::Closed)
|
||||||
|
return true;
|
||||||
|
if (a_root.is_document_fragment() && static_cast<DocumentFragment const&>(a_root).host()->is_closed_shadow_hidden_from(b))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#connected
|
// https://dom.spec.whatwg.org/#connected
|
||||||
bool Node::is_connected() const
|
bool Node::is_connected() const
|
||||||
{
|
{
|
||||||
|
|
|
@ -294,6 +294,8 @@ public:
|
||||||
return const_cast<Node*>(this)->shadow_including_root();
|
return const_cast<Node*>(this)->shadow_including_root();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool is_closed_shadow_hidden_from(Node const&) const;
|
||||||
|
|
||||||
bool is_connected() const;
|
bool is_connected() const;
|
||||||
|
|
||||||
[[nodiscard]] bool is_browsing_context_connected() const;
|
[[nodiscard]] bool is_browsing_context_connected() const;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue