mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibWeb: Port MutationRecord types to FlyString
Co-authored-by: Luke Wilde <lukew@serenityos.org>
This commit is contained in:
parent
db2ba5f1d9
commit
8a8340b3cd
6 changed files with 14 additions and 12 deletions
|
@ -12,12 +12,12 @@
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> MutationRecord::create(JS::Realm& realm, DeprecatedFlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> MutationRecord::create(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
|
||||||
{
|
{
|
||||||
return MUST_OR_THROW_OOM(realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value));
|
return MUST_OR_THROW_OOM(realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value));
|
||||||
}
|
}
|
||||||
|
|
||||||
MutationRecord::MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
|
MutationRecord::MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value)
|
||||||
: PlatformObject(realm)
|
: PlatformObject(realm)
|
||||||
, m_type(type)
|
, m_type(type)
|
||||||
, m_target(JS::make_handle(target))
|
, m_target(JS::make_handle(target))
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/Bindings/PlatformObject.h>
|
#include <LibWeb/Bindings/PlatformObject.h>
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
@ -15,11 +16,11 @@ class MutationRecord : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject);
|
WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> create(JS::Realm&, DeprecatedFlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<MutationRecord>> create(JS::Realm&, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value);
|
||||||
|
|
||||||
virtual ~MutationRecord() override;
|
virtual ~MutationRecord() override;
|
||||||
|
|
||||||
DeprecatedFlyString const& type() const { return m_type; }
|
FlyString const& type() const { return m_type; }
|
||||||
Node const* target() const { return m_target; }
|
Node const* target() const { return m_target; }
|
||||||
NodeList const* added_nodes() const { return m_added_nodes; }
|
NodeList const* added_nodes() const { return m_added_nodes; }
|
||||||
NodeList const* removed_nodes() const { return m_removed_nodes; }
|
NodeList const* removed_nodes() const { return m_removed_nodes; }
|
||||||
|
@ -30,12 +31,12 @@ public:
|
||||||
DeprecatedString const& old_value() const { return m_old_value; }
|
DeprecatedString const& old_value() const { return m_old_value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MutationRecord(JS::Realm& realm, DeprecatedFlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value);
|
MutationRecord(JS::Realm& realm, FlyString const& type, Node const& target, NodeList& added_nodes, NodeList& removed_nodes, Node* previous_sibling, Node* next_sibling, DeprecatedString const& attribute_name, DeprecatedString const& attribute_namespace, DeprecatedString const& old_value);
|
||||||
|
|
||||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
DeprecatedFlyString m_type;
|
FlyString m_type;
|
||||||
JS::GCPtr<Node const> m_target;
|
JS::GCPtr<Node const> m_target;
|
||||||
JS::GCPtr<NodeList> m_added_nodes;
|
JS::GCPtr<NodeList> m_added_nodes;
|
||||||
JS::GCPtr<NodeList> m_removed_nodes;
|
JS::GCPtr<NodeList> m_removed_nodes;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
namespace Web::DOM::MutationType {
|
namespace Web::DOM::MutationType {
|
||||||
|
|
||||||
#define __ENUMERATE_MUTATION_TYPE(name) DeprecatedFlyString name;
|
#define __ENUMERATE_MUTATION_TYPE(name) FlyString name;
|
||||||
ENUMERATE_MUTATION_TYPES
|
ENUMERATE_MUTATION_TYPES
|
||||||
#undef __ENUMERATE_MUTATION_TYPE
|
#undef __ENUMERATE_MUTATION_TYPE
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ ErrorOr<void> initialize_strings()
|
||||||
static bool s_initialized = false;
|
static bool s_initialized = false;
|
||||||
VERIFY(!s_initialized);
|
VERIFY(!s_initialized);
|
||||||
|
|
||||||
#define __ENUMERATE_MUTATION_TYPE(name) name = #name;
|
#define __ENUMERATE_MUTATION_TYPE(name) name = TRY(#name##_fly_string);
|
||||||
ENUMERATE_MUTATION_TYPES
|
ENUMERATE_MUTATION_TYPES
|
||||||
#undef __ENUMERATE_MUTATION_TYPE
|
#undef __ENUMERATE_MUTATION_TYPE
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/DeprecatedFlyString.h>
|
|
||||||
#include <AK/Error.h>
|
#include <AK/Error.h>
|
||||||
|
#include <AK/FlyString.h>
|
||||||
|
|
||||||
namespace Web::DOM::MutationType {
|
namespace Web::DOM::MutationType {
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace Web::DOM::MutationType {
|
||||||
__ENUMERATE_MUTATION_TYPE(characterData) \
|
__ENUMERATE_MUTATION_TYPE(characterData) \
|
||||||
__ENUMERATE_MUTATION_TYPE(childList)
|
__ENUMERATE_MUTATION_TYPE(childList)
|
||||||
|
|
||||||
#define __ENUMERATE_MUTATION_TYPE(name) extern DeprecatedFlyString name;
|
#define __ENUMERATE_MUTATION_TYPE(name) extern FlyString name;
|
||||||
ENUMERATE_MUTATION_TYPES
|
ENUMERATE_MUTATION_TYPES
|
||||||
#undef __ENUMERATE_MUTATION_TYPE
|
#undef __ENUMERATE_MUTATION_TYPE
|
||||||
|
|
||||||
|
|
|
@ -1390,7 +1390,7 @@ Painting::PaintableBox const* Node::paint_box() const
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#queue-a-mutation-record
|
// https://dom.spec.whatwg.org/#queue-a-mutation-record
|
||||||
void Node::queue_mutation_record(DeprecatedFlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling) const
|
void Node::queue_mutation_record(FlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling) const
|
||||||
{
|
{
|
||||||
// NOTE: We defer garbage collection until the end of the scope, since we can't safely use MutationObserver* as a hashmap key otherwise.
|
// NOTE: We defer garbage collection until the end of the scope, since we can't safely use MutationObserver* as a hashmap key otherwise.
|
||||||
// FIXME: This is a total hack.
|
// FIXME: This is a total hack.
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
#include <AK/Badge.h>
|
#include <AK/Badge.h>
|
||||||
#include <AK/DeprecatedString.h>
|
#include <AK/DeprecatedString.h>
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <AK/JsonObjectSerializer.h>
|
#include <AK/JsonObjectSerializer.h>
|
||||||
#include <AK/RefPtr.h>
|
#include <AK/RefPtr.h>
|
||||||
#include <AK/TypeCasts.h>
|
#include <AK/TypeCasts.h>
|
||||||
|
@ -227,7 +228,7 @@ public:
|
||||||
|
|
||||||
void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); }
|
void add_registered_observer(RegisteredObserver& registered_observer) { m_registered_observer_list.append(registered_observer); }
|
||||||
|
|
||||||
void queue_mutation_record(DeprecatedFlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling) const;
|
void queue_mutation_record(FlyString const& type, DeprecatedString attribute_name, DeprecatedString attribute_namespace, DeprecatedString old_value, JS::NonnullGCPtr<NodeList> added_nodes, JS::NonnullGCPtr<NodeList> removed_nodes, Node* previous_sibling, Node* next_sibling) const;
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#concept-shadow-including-descendant
|
// https://dom.spec.whatwg.org/#concept-shadow-including-descendant
|
||||||
template<typename Callback>
|
template<typename Callback>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue