mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:57:35 +00:00
LibWeb: Add DOM::Node::parent_or_shadow_host_element()
This will be used in style computation to inherit style across shadow tree boundaries.
This commit is contained in:
parent
9c46fb7337
commit
87b0ddb354
2 changed files with 16 additions and 0 deletions
|
@ -872,6 +872,19 @@ ParentNode* Node::parent_or_shadow_host()
|
||||||
return verify_cast<ParentNode>(parent());
|
return verify_cast<ParentNode>(parent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Element* Node::parent_or_shadow_host_element()
|
||||||
|
{
|
||||||
|
if (is<ShadowRoot>(*this))
|
||||||
|
return static_cast<ShadowRoot&>(*this).host();
|
||||||
|
if (!parent())
|
||||||
|
return nullptr;
|
||||||
|
if (is<Element>(*parent()))
|
||||||
|
return static_cast<Element*>(parent());
|
||||||
|
if (is<ShadowRoot>(*parent()))
|
||||||
|
return static_cast<ShadowRoot&>(*parent()).host();
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
JS::NonnullGCPtr<NodeList> Node::child_nodes()
|
JS::NonnullGCPtr<NodeList> Node::child_nodes()
|
||||||
{
|
{
|
||||||
if (!m_child_nodes) {
|
if (!m_child_nodes) {
|
||||||
|
|
|
@ -45,6 +45,9 @@ public:
|
||||||
ParentNode* parent_or_shadow_host();
|
ParentNode* parent_or_shadow_host();
|
||||||
ParentNode const* parent_or_shadow_host() const { return const_cast<Node*>(this)->parent_or_shadow_host(); }
|
ParentNode const* parent_or_shadow_host() const { return const_cast<Node*>(this)->parent_or_shadow_host(); }
|
||||||
|
|
||||||
|
Element* parent_or_shadow_host_element();
|
||||||
|
Element const* parent_or_shadow_host_element() const { return const_cast<Node*>(this)->parent_or_shadow_host_element(); }
|
||||||
|
|
||||||
virtual ~Node();
|
virtual ~Node();
|
||||||
|
|
||||||
// FIXME: Move cleanup to the regular destructor.
|
// FIXME: Move cleanup to the regular destructor.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue