1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 17:27:35 +00:00

LibWeb: Allow SVG painting to escape out of a shadow tree

The spec for the `<use>` element requires a shadow tree for the
rendered content, so we need to be able to escape shadow trees when
rendering svg content.
This commit is contained in:
PrestonLTaylor 2023-05-28 18:27:35 +01:00 committed by Andreas Kling
parent fd360ba171
commit 31d536912c
5 changed files with 24 additions and 5 deletions

View file

@ -636,6 +636,15 @@ public:
return nullptr;
}
template<typename U>
U const* shadow_including_first_ancestor_of_type() const
{
return const_cast<Node*>(this)->template shadow_including_first_ancestor_of_type<U>();
}
template<typename U>
U* shadow_including_first_ancestor_of_type();
bool is_parent_of(Node const& other) const
{
for (auto* child = first_child(); child; child = child->next_sibling()) {

View file

@ -55,6 +55,16 @@ private:
template<>
inline bool Node::fast_is<ParentNode>() const { return is_parent_node(); }
template<typename U>
inline U* Node::shadow_including_first_ancestor_of_type()
{
for (auto* ancestor = parent_or_shadow_host(); ancestor; ancestor = ancestor->parent_or_shadow_host()) {
if (is<U>(*ancestor))
return &verify_cast<U>(*ancestor);
}
return nullptr;
}
template<typename Callback>
inline void ParentNode::for_each_child(Callback callback) const
{