2022-07-11 12:37:51 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2022, Luke Wilde <lukew@serenityos.org>
|
2024-10-04 08:19:50 -03:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-07-11 12:37:51 -03:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
2022-09-25 19:15:49 -03:00
|
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
2024-04-26 21:09:58 -03:00
|
|
|
#include <LibWeb/Bindings/MutationRecordPrototype.h>
|
2022-07-11 12:37:51 -03:00
|
|
|
#include <LibWeb/DOM/MutationRecord.h>
|
|
|
|
|
#include <LibWeb/DOM/Node.h>
|
|
|
|
|
#include <LibWeb/DOM/NodeList.h>
|
|
|
|
|
|
|
|
|
|
namespace Web::DOM {
|
|
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC_DEFINE_ALLOCATOR(MutationRecord);
|
2023-11-19 15:47:52 -03:00
|
|
|
|
2024-11-14 12:01:23 -03:00
|
|
|
GC::Ref<MutationRecord> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional<String> const& attribute_name, Optional<String> const& attribute_namespace, Optional<String> const& old_value)
|
2022-09-01 12:13:18 -03:00
|
|
|
{
|
2024-11-13 13:50:17 -03:00
|
|
|
return realm.create<MutationRecord>(realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value);
|
2022-09-01 12:13:18 -03:00
|
|
|
}
|
2022-07-11 12:37:51 -03:00
|
|
|
|
2023-09-06 04:28:47 -03:00
|
|
|
MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, Optional<String> const& attribute_name, Optional<String> const& attribute_namespace, Optional<String> const& old_value)
|
2022-09-25 19:15:49 -03:00
|
|
|
: PlatformObject(realm)
|
2022-09-01 12:13:18 -03:00
|
|
|
, m_type(type)
|
2024-11-14 12:01:23 -03:00
|
|
|
, m_target(GC::make_root(target))
|
2022-09-01 12:13:18 -03:00
|
|
|
, m_added_nodes(added_nodes)
|
|
|
|
|
, m_removed_nodes(removed_nodes)
|
2024-11-14 12:01:23 -03:00
|
|
|
, m_previous_sibling(GC::make_root(previous_sibling))
|
|
|
|
|
, m_next_sibling(GC::make_root(next_sibling))
|
2022-09-01 12:13:18 -03:00
|
|
|
, m_attribute_name(attribute_name)
|
|
|
|
|
, m_attribute_namespace(attribute_namespace)
|
|
|
|
|
, m_old_value(old_value)
|
|
|
|
|
{
|
|
|
|
|
}
|
2022-07-11 12:37:51 -03:00
|
|
|
|
2022-09-01 12:13:18 -03:00
|
|
|
MutationRecord::~MutationRecord() = default;
|
2022-07-11 12:37:51 -03:00
|
|
|
|
2023-08-07 03:41:28 -03:00
|
|
|
void MutationRecord::initialize(JS::Realm& realm)
|
2023-01-10 08:28:20 -03:00
|
|
|
{
|
2024-03-16 09:13:08 -03:00
|
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(MutationRecord);
|
2025-04-20 11:22:57 -03:00
|
|
|
Base::initialize(realm);
|
2023-01-10 08:28:20 -03:00
|
|
|
}
|
|
|
|
|
|
2022-09-01 12:13:18 -03:00
|
|
|
void MutationRecord::visit_edges(Cell::Visitor& visitor)
|
2022-07-11 12:37:51 -03:00
|
|
|
{
|
2022-09-01 12:13:18 -03:00
|
|
|
Base::visit_edges(visitor);
|
2023-11-19 00:18:00 -03:00
|
|
|
visitor.visit(m_target);
|
|
|
|
|
visitor.visit(m_added_nodes);
|
|
|
|
|
visitor.visit(m_removed_nodes);
|
|
|
|
|
visitor.visit(m_previous_sibling);
|
|
|
|
|
visitor.visit(m_next_sibling);
|
2022-07-11 12:37:51 -03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|