mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
LibWeb: Introduce Mutation{Record,Observer} and observer microtasks
This commit is contained in:
parent
116a7b74fe
commit
c9ba5531e0
15 changed files with 531 additions and 0 deletions
38
Userland/Libraries/LibWeb/DOM/MutationRecord.h
Normal file
38
Userland/Libraries/LibWeb/DOM/MutationRecord.h
Normal file
|
@ -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;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue