/* * Copyright (c) 2020, the SerenityOS developers. * Copyright (c) 2023, Tim Flynn * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include #include #include #include namespace Web::HTML { struct AssignedNodesOptions { bool flatten { false }; }; class HTMLSlotElement final : public HTMLElement , public DOM::Slot { WEB_PLATFORM_OBJECT(HTMLSlotElement, HTMLElement); GC_DECLARE_ALLOCATOR(HTMLSlotElement); public: virtual ~HTMLSlotElement() override; Vector> assigned_nodes(AssignedNodesOptions options = {}) const; Vector> assigned_elements(AssignedNodesOptions options = {}) const; using SlottableHandle = Variant, GC::Root>; void assign(Vector nodes); ReadonlySpan manually_assigned_nodes() const { return m_manually_assigned_nodes; } private: HTMLSlotElement(DOM::Document&, DOM::QualifiedName); virtual bool is_html_slot_element() const override { return true; } virtual void initialize(JS::Realm&) override; virtual void visit_edges(JS::Cell::Visitor&) override; virtual void attribute_changed(FlyString const& name, Optional const& old_value, Optional const& value, Optional const& namespace_) override; // https://html.spec.whatwg.org/multipage/scripting.html#manually-assigned-nodes Vector m_manually_assigned_nodes; }; } namespace Web::DOM { template<> inline bool Node::fast_is() const { return is_html_slot_element(); } }