diff options
author | Matthew Olsson <matthewcolsson@gmail.com> | 2023-02-26 16:09:02 -0700 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2023-03-15 08:48:49 +0100 |
commit | 7c0c1c8f4969abeec1436346f29081b3afbcdeab (patch) | |
tree | 985c294882161720a82dc54c70d0680e29700ec9 /Userland/Libraries/LibWeb/DOM | |
parent | 1df3652e272e1aa69b3a1f8d1730ec464242ada9 (diff) | |
download | serenity-7c0c1c8f4969abeec1436346f29081b3afbcdeab.zip |
LibJS+LibWeb: Wrap raw JS::Cell*/& fields in GCPtr/NonnullGCPtr
Diffstat (limited to 'Userland/Libraries/LibWeb/DOM')
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h | 4 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/DOMImplementation.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Document.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/EventTarget.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/MutationObserver.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Node.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/Node.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/NodeFilter.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/NodeFilter.h | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp | 2 | ||||
-rw-r--r-- | Userland/Libraries/LibWeb/DOM/StaticNodeList.h | 2 |
13 files changed, 22 insertions, 22 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp index 9cce5645f1..64edce7881 100644 --- a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp +++ b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.cpp @@ -59,7 +59,7 @@ void AccessibilityTreeNode::serialize_tree_as_json(JsonObjectSerializer<StringBu if (value()->has_child_nodes()) { auto node_children = MUST(object.add_array("children"sv)); - for (auto* child : children()) { + for (auto& child : children()) { if (child->value()->is_uninteresting_whitespace_node()) continue; JsonObjectSerializer<StringBuilder> child_object = MUST(node_children.add_object()); diff --git a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h index 84f47be048..d2f1ee24e7 100644 --- a/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h +++ b/Userland/Libraries/LibWeb/DOM/AccessibilityTreeNode.h @@ -22,7 +22,7 @@ public: JS::GCPtr<DOM::Node const> value() const { return m_value; } void set_value(JS::GCPtr<DOM::Node const> value) { m_value = value; } - Vector<AccessibilityTreeNode*> children() const { return m_children; } + Vector<JS::GCPtr<AccessibilityTreeNode>> children() const { return m_children; } void append_child(AccessibilityTreeNode* child) { m_children.append(child); } void serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object, Document const&) const; @@ -34,7 +34,7 @@ private: explicit AccessibilityTreeNode(JS::GCPtr<DOM::Node const>); JS::GCPtr<DOM::Node const> m_value; - Vector<AccessibilityTreeNode*> m_children; + Vector<JS::GCPtr<AccessibilityTreeNode>> m_children; }; } diff --git a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h index a74808f37b..db41ac8ea7 100644 --- a/Userland/Libraries/LibWeb/DOM/DOMImplementation.h +++ b/Userland/Libraries/LibWeb/DOM/DOMImplementation.h @@ -36,7 +36,7 @@ private: Document& document() { return m_document; } Document const& document() const { return m_document; } - Document& m_document; + JS::NonnullGCPtr<Document> m_document; }; } diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h index 17dc38ddb8..1346c8549c 100644 --- a/Userland/Libraries/LibWeb/DOM/Document.h +++ b/Userland/Libraries/LibWeb/DOM/Document.h @@ -567,7 +567,7 @@ private: bool m_needs_full_style_update { false }; - HashTable<NodeIterator*> m_node_iterators; + HashTable<JS::GCPtr<NodeIterator>> m_node_iterators; // https://html.spec.whatwg.org/multipage/dom.html#is-initial-about:blank bool m_is_initial_about_blank { false }; diff --git a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp index 6158de86b9..f4ad3377b1 100644 --- a/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp @@ -83,7 +83,7 @@ bool EventDispatcher::inner_invoke(Event& event, Vector<JS::Handle<DOM::DOMEvent // 6. Let global be listener callbackās associated Realmās global object. auto& callback = listener->callback->callback(); - auto& realm = callback.callback.shape().realm(); + auto& realm = callback.callback->shape().realm(); auto& global = realm.global_object(); // 7. Let currentEvent be undefined. diff --git a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp index a581a4cc9c..62e1196b1f 100644 --- a/Userland/Libraries/LibWeb/DOM/EventTarget.cpp +++ b/Userland/Libraries/LibWeb/DOM/EventTarget.cpp @@ -464,12 +464,12 @@ WebIDL::CallbackType* EventTarget::get_current_value_of_event_handler(Deprecated function->set_script_or_module({}); // 12. Set eventHandler's value to the result of creating a Web IDL EventHandler callback function object whose object reference is function and whose callback context is settings object. - event_handler->value = realm.heap().allocate_without_realm<WebIDL::CallbackType>(*function, settings_object).ptr(); + event_handler->value = JS::GCPtr(realm.heap().allocate_without_realm<WebIDL::CallbackType>(*function, settings_object)); } // 4. Return eventHandler's value. - VERIFY(event_handler->value.has<WebIDL::CallbackType*>()); - return *event_handler->value.get_pointer<WebIDL::CallbackType*>(); + VERIFY(event_handler->value.has<JS::GCPtr<WebIDL::CallbackType>>()); + return *event_handler->value.get_pointer<JS::GCPtr<WebIDL::CallbackType>>(); } // https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-attributes:event-handler-idl-attributes-3 @@ -512,7 +512,7 @@ void EventTarget::set_event_handler_attribute(DeprecatedFlyString const& name, W auto& event_handler = event_handler_iterator->value; - event_handler->value = value; + event_handler->value = JS::GCPtr(value); // 4. Activate an event handler given eventTarget and name. // NOTE: See the optimization comment above. diff --git a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp index 5d587e246f..9ea46c18be 100644 --- a/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp +++ b/Userland/Libraries/LibWeb/DOM/MutationObserver.cpp @@ -80,7 +80,7 @@ WebIDL::ExceptionOr<void> MutationObserver::observe(Node& target, MutationObserv // 7. For each registered of targetās registered observer list, if registeredās observer is this: bool updated_existing_observer = false; for (auto& registered_observer : target.registered_observers_list()) { - if (registered_observer.observer().ptr() != this) + if (registered_observer->observer().ptr() != this) continue; updated_existing_observer = true; @@ -92,12 +92,12 @@ WebIDL::ExceptionOr<void> MutationObserver::observe(Node& target, MutationObserv continue; node->registered_observers_list().remove_all_matching([®istered_observer](RegisteredObserver& observer) { - return is<TransientRegisteredObserver>(observer) && verify_cast<TransientRegisteredObserver>(observer).source().ptr() == ®istered_observer; + return is<TransientRegisteredObserver>(observer) && verify_cast<TransientRegisteredObserver>(observer).source().ptr() == registered_observer; }); } // 2. Set registeredās options to options. - registered_observer.set_options(options); + registered_observer->set_options(options); break; } diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp index df322dcd44..7d104ad9e7 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.cpp +++ b/Userland/Libraries/LibWeb/DOM/Node.cpp @@ -602,8 +602,8 @@ void Node::remove(bool suppress_observers) // whose observer is registeredās observer, options is registeredās options, and source is registered to nodeās registered observer list. for (auto* inclusive_ancestor = parent; inclusive_ancestor; inclusive_ancestor = inclusive_ancestor->parent()) { for (auto& registered : inclusive_ancestor->m_registered_observer_list) { - if (registered.options().subtree) { - auto transient_observer = TransientRegisteredObserver::create(registered.observer(), registered.options(), registered); + if (registered->options().subtree) { + auto transient_observer = TransientRegisteredObserver::create(registered->observer(), registered->options(), registered); m_registered_observer_list.append(move(transient_observer)); } } @@ -1411,7 +1411,7 @@ void Node::queue_mutation_record(DeprecatedFlyString const& type, DeprecatedStri for (auto& node : nodes) { for (auto& registered_observer : node->m_registered_observer_list) { // 1. Let options be registeredās options. - auto& options = registered_observer.options(); + auto& options = registered_observer->options(); // 2. If none of the following are true // - node is not target and options["subtree"] is false @@ -1426,7 +1426,7 @@ void Node::queue_mutation_record(DeprecatedFlyString const& type, DeprecatedStri && !(type == MutationType::characterData && (!options.character_data.has_value() || !options.character_data.value())) && !(type == MutationType::childList && !options.child_list)) { // 1. Let mo be registeredās observer. - auto mutation_observer = registered_observer.observer(); + auto mutation_observer = registered_observer->observer(); // 2. If interestedObservers[mo] does not exist, then set interestedObservers[mo] to null. if (!interested_observers.contains(mutation_observer)) diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h index 89cf7014df..2387894852 100644 --- a/Userland/Libraries/LibWeb/DOM/Node.h +++ b/Userland/Libraries/LibWeb/DOM/Node.h @@ -645,7 +645,7 @@ protected: // https://dom.spec.whatwg.org/#registered-observer-list // "Nodes have a strong reference to registered observers in their registered observer list." https://dom.spec.whatwg.org/#garbage-collection - Vector<RegisteredObserver&> m_registered_observer_list; + Vector<JS::NonnullGCPtr<RegisteredObserver>> m_registered_observer_list; void build_accessibility_tree(AccessibilityTreeNode& parent); diff --git a/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp b/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp index a81a25e7a0..a667615ba6 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp +++ b/Userland/Libraries/LibWeb/DOM/NodeFilter.cpp @@ -24,7 +24,7 @@ NodeFilter::NodeFilter(JS::Realm& realm, WebIDL::CallbackType& callback) void NodeFilter::visit_edges(Cell::Visitor& visitor) { Base::visit_edges(visitor); - visitor.visit(&m_callback); + visitor.visit(m_callback); } } diff --git a/Userland/Libraries/LibWeb/DOM/NodeFilter.h b/Userland/Libraries/LibWeb/DOM/NodeFilter.h index 894919d4ca..aa6cb55156 100644 --- a/Userland/Libraries/LibWeb/DOM/NodeFilter.h +++ b/Userland/Libraries/LibWeb/DOM/NodeFilter.h @@ -46,7 +46,7 @@ private: virtual void visit_edges(Cell::Visitor&) override; - WebIDL::CallbackType& m_callback; + JS::NonnullGCPtr<WebIDL::CallbackType> m_callback; }; AK_ENUM_BITWISE_OPERATORS(NodeFilter::WhatToShow); diff --git a/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp b/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp index 5a863cc175..bf5804d902 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp +++ b/Userland/Libraries/LibWeb/DOM/StaticNodeList.cpp @@ -42,7 +42,7 @@ Node const* StaticNodeList::item(u32 index) const // The item(index) method must return the indexth node in the collection. If there is no indexth node in the collection, then the method must return null. if (index >= m_static_nodes.size()) return nullptr; - return &m_static_nodes[index]; + return m_static_nodes[index]; } // https://dom.spec.whatwg.org/#ref-for-dfn-supported-property-indices diff --git a/Userland/Libraries/LibWeb/DOM/StaticNodeList.h b/Userland/Libraries/LibWeb/DOM/StaticNodeList.h index 78f4564700..46997e9f98 100644 --- a/Userland/Libraries/LibWeb/DOM/StaticNodeList.h +++ b/Userland/Libraries/LibWeb/DOM/StaticNodeList.h @@ -29,7 +29,7 @@ private: virtual void visit_edges(Cell::Visitor&) override; - Vector<Node&> m_static_nodes; + Vector<JS::NonnullGCPtr<Node>> m_static_nodes; }; } |