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

LibWeb: Introduce CustomElementRegistry and creating custom elements

The main missing feature here is form associated custom elements.
This commit is contained in:
Luke Wilde 2023-03-29 23:46:18 +01:00 committed by Andreas Kling
parent 083b547e97
commit 034aaf3f51
38 changed files with 1747 additions and 143 deletions

View file

@ -47,18 +47,34 @@ template<>
inline bool Node::fast_is<ShadowRoot>() const { return is_shadow_root(); }
template<typename Callback>
inline IterationDecision Node::for_each_shadow_including_descendant(Callback callback)
inline IterationDecision Node::for_each_shadow_including_inclusive_descendant(Callback callback)
{
if (callback(*this) == IterationDecision::Break)
return IterationDecision::Break;
for (auto* child = first_child(); child; child = child->next_sibling()) {
if (child->is_element()) {
if (JS::GCPtr<ShadowRoot> shadow_root = static_cast<Element*>(child)->shadow_root_internal()) {
if (shadow_root->for_each_shadow_including_descendant(callback) == IterationDecision::Break)
if (shadow_root->for_each_shadow_including_inclusive_descendant(callback) == IterationDecision::Break)
return IterationDecision::Break;
}
}
if (child->for_each_shadow_including_descendant(callback) == IterationDecision::Break)
if (child->for_each_shadow_including_inclusive_descendant(callback) == IterationDecision::Break)
return IterationDecision::Break;
}
return IterationDecision::Continue;
}
template<typename Callback>
inline IterationDecision Node::for_each_shadow_including_descendant(Callback callback)
{
for (auto* child = first_child(); child; child = child->next_sibling()) {
if (child->is_element()) {
if (JS::GCPtr<ShadowRoot> shadow_root = static_cast<Element*>(child)->shadow_root()) {
if (shadow_root->for_each_shadow_including_inclusive_descendant(callback) == IterationDecision::Break)
return IterationDecision::Break;
}
}
if (child->for_each_shadow_including_inclusive_descendant(callback) == IterationDecision::Break)
return IterationDecision::Break;
}
return IterationDecision::Continue;