|
@@ -0,0 +1,50 @@
|
|
|
+/*
|
|
|
+ * Copyright (c) 2023, Tim Flynn <trflynn89@serenityos.org>
|
|
|
+ *
|
|
|
+ * SPDX-License-Identifier: BSD-2-Clause
|
|
|
+ */
|
|
|
+
|
|
|
+#pragma once
|
|
|
+
|
|
|
+#include <AK/String.h>
|
|
|
+#include <AK/Variant.h>
|
|
|
+#include <LibJS/Heap/Cell.h>
|
|
|
+#include <LibJS/Heap/GCPtr.h>
|
|
|
+#include <LibWeb/Forward.h>
|
|
|
+
|
|
|
+namespace Web::DOM {
|
|
|
+
|
|
|
+// https://dom.spec.whatwg.org/#concept-slotable
|
|
|
+using Slottable = Variant<JS::NonnullGCPtr<Element>, JS::NonnullGCPtr<Text>>;
|
|
|
+
|
|
|
+// https://dom.spec.whatwg.org/#mixin-slotable
|
|
|
+class SlottableMixin {
|
|
|
+public:
|
|
|
+ virtual ~SlottableMixin();
|
|
|
+
|
|
|
+ String const& slottable_name() const { return m_name; } // Not called `name` to distinguish from `Element::name`.
|
|
|
+ void set_slottable_name(String name) { m_name = move(name); }
|
|
|
+
|
|
|
+ JS::GCPtr<HTML::HTMLSlotElement> assigned_slot();
|
|
|
+
|
|
|
+ JS::GCPtr<HTML::HTMLSlotElement> assigned_slot_internal() const { return m_assigned_slot; }
|
|
|
+ void set_assigned_slot(JS::GCPtr<HTML::HTMLSlotElement> assigned_slot) { m_assigned_slot = assigned_slot; }
|
|
|
+
|
|
|
+ JS::GCPtr<HTML::HTMLSlotElement> manual_slot_assignment() { return m_manual_slot_assignment; }
|
|
|
+ void set_manual_slot_assignment(JS::GCPtr<HTML::HTMLSlotElement> manual_slot_assignment) { m_manual_slot_assignment = manual_slot_assignment; }
|
|
|
+
|
|
|
+protected:
|
|
|
+ void visit_edges(JS::Cell::Visitor&);
|
|
|
+
|
|
|
+private:
|
|
|
+ // https://dom.spec.whatwg.org/#slotable-name
|
|
|
+ String m_name;
|
|
|
+
|
|
|
+ // https://dom.spec.whatwg.org/#slotable-assigned-slot
|
|
|
+ JS::GCPtr<HTML::HTMLSlotElement> m_assigned_slot;
|
|
|
+
|
|
|
+ // https://dom.spec.whatwg.org/#slottable-manual-slot-assignment
|
|
|
+ JS::GCPtr<HTML::HTMLSlotElement> m_manual_slot_assignment;
|
|
|
+};
|
|
|
+
|
|
|
+}
|