mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:37:43 +00:00
LibWeb: Port MutationRecord from DeprecatedString to String
This commit is contained in:
parent
75133cf733
commit
da1f137967
4 changed files with 24 additions and 12 deletions
|
@ -12,12 +12,12 @@
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
|
||||||
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)
|
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, Optional<String> const& attribute_name, Optional<String> const& attribute_namespace, Optional<String> const& old_value)
|
||||||
{
|
{
|
||||||
return realm.heap().allocate<MutationRecord>(realm, realm, type, target, added_nodes, removed_nodes, previous_sibling, next_sibling, attribute_name, attribute_namespace, old_value);
|
return 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, 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)
|
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)
|
||||||
: PlatformObject(realm)
|
: PlatformObject(realm)
|
||||||
, m_type(type)
|
, m_type(type)
|
||||||
, m_target(JS::make_handle(target))
|
, m_target(JS::make_handle(target))
|
||||||
|
|
|
@ -16,7 +16,7 @@ class MutationRecord : public Bindings::PlatformObject {
|
||||||
WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject);
|
WEB_PLATFORM_OBJECT(MutationRecord, Bindings::PlatformObject);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
[[nodiscard]] static 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);
|
[[nodiscard]] static JS::NonnullGCPtr<MutationRecord> create(JS::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);
|
||||||
|
|
||||||
virtual ~MutationRecord() override;
|
virtual ~MutationRecord() override;
|
||||||
|
|
||||||
|
@ -26,12 +26,12 @@ public:
|
||||||
NodeList const* removed_nodes() const { return m_removed_nodes; }
|
NodeList const* removed_nodes() const { return m_removed_nodes; }
|
||||||
Node const* previous_sibling() const { return m_previous_sibling; }
|
Node const* previous_sibling() const { return m_previous_sibling; }
|
||||||
Node const* next_sibling() const { return m_next_sibling; }
|
Node const* next_sibling() const { return m_next_sibling; }
|
||||||
DeprecatedString const& attribute_name() const { return m_attribute_name; }
|
Optional<String> const& attribute_name() const { return m_attribute_name; }
|
||||||
DeprecatedString const& attribute_namespace() const { return m_attribute_namespace; }
|
Optional<String> const& attribute_namespace() const { return m_attribute_namespace; }
|
||||||
DeprecatedString const& old_value() const { return m_old_value; }
|
Optional<String> const& old_value() const { return m_old_value; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
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);
|
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);
|
||||||
|
|
||||||
virtual void initialize(JS::Realm&) override;
|
virtual void initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
@ -42,9 +42,9 @@ private:
|
||||||
JS::GCPtr<NodeList> m_removed_nodes;
|
JS::GCPtr<NodeList> m_removed_nodes;
|
||||||
JS::GCPtr<Node> m_previous_sibling;
|
JS::GCPtr<Node> m_previous_sibling;
|
||||||
JS::GCPtr<Node> m_next_sibling;
|
JS::GCPtr<Node> m_next_sibling;
|
||||||
DeprecatedString m_attribute_name;
|
Optional<String> m_attribute_name;
|
||||||
DeprecatedString m_attribute_namespace;
|
Optional<String> m_attribute_namespace;
|
||||||
DeprecatedString m_old_value;
|
Optional<String> m_old_value;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#import <DOM/Node.idl>
|
#import <DOM/Node.idl>
|
||||||
#import <DOM/NodeList.idl>
|
#import <DOM/NodeList.idl>
|
||||||
|
|
||||||
[Exposed=Window, UseDeprecatedAKString]
|
[Exposed=Window]
|
||||||
interface MutationRecord {
|
interface MutationRecord {
|
||||||
|
|
||||||
readonly attribute DOMString type;
|
readonly attribute DOMString type;
|
||||||
|
|
|
@ -1530,7 +1530,19 @@ void Node::queue_mutation_record(FlyString const& type, DeprecatedString attribu
|
||||||
for (auto& interested_observer : interested_observers) {
|
for (auto& interested_observer : interested_observers) {
|
||||||
// 1. Let record be a new MutationRecord object with its type set to type, target set to target, attributeName set to name, attributeNamespace set to namespace, oldValue set to mappedOldValue,
|
// 1. Let record be a new MutationRecord object with its type set to type, target set to target, attributeName set to name, attributeNamespace set to namespace, oldValue set to mappedOldValue,
|
||||||
// addedNodes set to addedNodes, removedNodes set to removedNodes, previousSibling set to previousSibling, and nextSibling set to nextSibling.
|
// addedNodes set to addedNodes, removedNodes set to removedNodes, previousSibling set to previousSibling, and nextSibling set to nextSibling.
|
||||||
auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, attribute_name, attribute_namespace, /* mappedOldValue */ interested_observer.value);
|
Optional<String> maybe_attribute_name;
|
||||||
|
if (!attribute_name.is_null())
|
||||||
|
maybe_attribute_name = MUST(String::from_deprecated_string(attribute_name));
|
||||||
|
|
||||||
|
Optional<String> maybe_attribute_namespace;
|
||||||
|
if (!attribute_namespace.is_null())
|
||||||
|
maybe_attribute_namespace = MUST(String::from_deprecated_string(attribute_namespace));
|
||||||
|
|
||||||
|
Optional<String> maybe_interested_observer;
|
||||||
|
if (!interested_observer.value.is_null())
|
||||||
|
maybe_interested_observer = MUST(String::from_deprecated_string(interested_observer.value));
|
||||||
|
|
||||||
|
auto record = MutationRecord::create(realm(), type, *this, added_nodes_list, removed_nodes_list, previous_sibling, next_sibling, maybe_attribute_name, maybe_attribute_namespace, /* mappedOldValue */ maybe_interested_observer);
|
||||||
|
|
||||||
// 2. Enqueue record to observer’s record queue.
|
// 2. Enqueue record to observer’s record queue.
|
||||||
interested_observer.key->enqueue_record({}, move(record));
|
interested_observer.key->enqueue_record({}, move(record));
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue