summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/DOM/MutationRecord.h
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2022-07-11 16:37:51 +0100
committerAndreas Kling <kling@serenityos.org>2022-07-11 22:35:08 +0200
commitc9ba5531e0e0985408dbc0905263ce3a38e1ad20 (patch)
tree5ac20a3c3f96392b402a6f95024ad12ddb0fbf8b /Userland/Libraries/LibWeb/DOM/MutationRecord.h
parent116a7b74feef6e261b0c8c1dedffacb5a0d7e047 (diff)
downloadserenity-c9ba5531e0e0985408dbc0905263ce3a38e1ad20.zip
LibWeb: Introduce Mutation{Record,Observer} and observer microtasks
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM/MutationRecord.h')
-rw-r--r--Userland/Libraries/LibWeb/DOM/MutationRecord.h38
1 files changed, 38 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/MutationRecord.h b/Userland/Libraries/LibWeb/DOM/MutationRecord.h
new file mode 100644
index 0000000000..0c1b279400
--- /dev/null
+++ b/Userland/Libraries/LibWeb/DOM/MutationRecord.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/RefCounted.h>
+#include <LibWeb/Bindings/Wrappable.h>
+
+namespace Web::DOM {
+
+// https://dom.spec.whatwg.org/#mutationrecord
+// NOTE: This is implemented as a pure virtual interface with the actual implementation in the CPP file to prevent this circular dependency: Node.h -> MutationRecord.h -> MutationObserver.h -> Node.h
+// This is also why this uses raw pointers and references, since using (NN)RP requires us to include the templated type, even in a header specifying a function return type.
+class MutationRecord
+ : public RefCounted<MutationRecord>
+ , public Bindings::Wrappable {
+public:
+ using WrapperType = Bindings::MutationRecordWrapper;
+
+ static NonnullRefPtr<MutationRecord> create(FlyString const& type, Node& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, String const& attribute_name, String const& attribute_namespace, String const& old_value);
+
+ virtual ~MutationRecord() override = default;
+
+ virtual FlyString const& type() const = 0;
+ virtual Node const* target() const = 0;
+ virtual NodeList const* added_nodes() const = 0;
+ virtual NodeList const* removed_nodes() const = 0;
+ virtual Node const* previous_sibling() const = 0;
+ virtual Node const* next_sibling() const = 0;
+ virtual String const& attribute_name() const = 0;
+ virtual String const& attribute_namespace() const = 0;
+ virtual String const& old_value() const = 0;
+};
+
+}