2020-08-01 03:07:00 +01:00
|
|
|
/*
|
2021-04-28 22:46:44 +02:00
|
|
|
* Copyright (c) 2020, the SerenityOS developers.
|
2023-09-05 14:49:30 -04:00
|
|
|
* Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
2020-08-01 03:07:00 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-08-01 03:07:00 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-09-05 15:05:46 -04:00
|
|
|
#include <AK/Variant.h>
|
|
|
|
#include <AK/Vector.h>
|
|
|
|
#include <LibJS/Heap/Handle.h>
|
2023-09-05 14:49:30 -04:00
|
|
|
#include <LibWeb/DOM/Slot.h>
|
2023-09-05 15:05:46 -04:00
|
|
|
#include <LibWeb/DOM/Slottable.h>
|
2020-08-01 03:07:00 +01:00
|
|
|
#include <LibWeb/HTML/HTMLElement.h>
|
|
|
|
|
|
|
|
namespace Web::HTML {
|
|
|
|
|
2023-09-05 15:05:46 -04:00
|
|
|
struct AssignedNodesOptions {
|
|
|
|
bool flatten { false };
|
|
|
|
};
|
|
|
|
|
2023-09-05 14:49:30 -04:00
|
|
|
class HTMLSlotElement final
|
|
|
|
: public HTMLElement
|
|
|
|
, public DOM::Slot {
|
2022-08-28 13:42:07 +02:00
|
|
|
WEB_PLATFORM_OBJECT(HTMLSlotElement, HTMLElement);
|
|
|
|
|
2020-08-01 03:07:00 +01:00
|
|
|
public:
|
2022-08-28 13:42:07 +02:00
|
|
|
virtual ~HTMLSlotElement() override;
|
2020-08-01 03:07:00 +01:00
|
|
|
|
2023-09-05 15:05:46 -04:00
|
|
|
Vector<JS::Handle<DOM::Node>> assigned_nodes(AssignedNodesOptions options = {});
|
|
|
|
Vector<JS::Handle<DOM::Element>> assigned_elements(AssignedNodesOptions options = {});
|
|
|
|
|
|
|
|
using SlottableHandle = Variant<JS::Handle<DOM::Element>, JS::Handle<DOM::Text>>;
|
|
|
|
void assign(Vector<SlottableHandle> nodes);
|
|
|
|
|
|
|
|
ReadonlySpan<DOM::Slottable> manually_assigned_nodes() const { return m_manually_assigned_nodes; }
|
|
|
|
|
2022-08-28 13:42:07 +02:00
|
|
|
private:
|
2022-02-18 21:00:52 +01:00
|
|
|
HTMLSlotElement(DOM::Document&, DOM::QualifiedName);
|
2023-01-10 06:28:20 -05:00
|
|
|
|
2023-08-07 08:41:28 +02:00
|
|
|
virtual void initialize(JS::Realm&) override;
|
2023-09-05 14:49:30 -04:00
|
|
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
2023-09-05 15:05:46 -04:00
|
|
|
|
|
|
|
// https://html.spec.whatwg.org/multipage/scripting.html#manually-assigned-nodes
|
|
|
|
Vector<DOM::Slottable> m_manually_assigned_nodes;
|
2020-08-01 03:07:00 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|