LibWeb: Introduce the slottable concept for DOM elements and text nodes

A slottable is either a DOM element or a DOM text node. They may be
assigned to slots (HTMLSlotElement) either automatically or manually.
Automatic assignment occurs by matching a slot's `name` attribute to
a slottable's `slot` attribute. Manual assignment occurs by using the
slot's (not yet implemented) `assign` API.

This commit does not perform the above assignments. It just sets up the
slottable concept via IDL and hooks the slottable mixin into the element
and text nodes.
This commit is contained in:
Timothy Flynn 2023-09-05 13:07:35 -04:00 committed by Andreas Kling
commit 45b36bd08a
Notes: sideshowbarker 2024-07-17 00:25:35 +09:00
12 changed files with 116 additions and 1 deletions

View file

@ -930,6 +930,15 @@ Element* Node::parent_or_shadow_host_element()
return nullptr;
}
Slottable Node::as_slottable()
{
VERIFY(is_slottable());
if (is_element())
return JS::NonnullGCPtr { static_cast<Element&>(*this) };
return JS::NonnullGCPtr { static_cast<Text&>(*this) };
}
JS::NonnullGCPtr<NodeList> Node::child_nodes()
{
if (!m_child_nodes) {