summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-12-14 18:37:37 +0000
committerTim Flynn <trflynn89@pm.me>2022-12-15 06:56:37 -0500
commit2a66fc6cae8ef09e780cd795bf0b1d7f8844f4ec (patch)
tree51cf288c14d5fd321c2eaa03f21bdac2f94ea756
parent029db614e3c04279b9ae6c7e21e07baeccad63fd (diff)
downloadserenity-2a66fc6cae8ef09e780cd795bf0b1d7f8844f4ec.zip
LibJS: Add make_handle({Nonnull,}GCPtr<T>) overloads
-rw-r--r--Userland/Libraries/LibJS/AST.cpp2
-rw-r--r--Userland/Libraries/LibJS/Heap/Handle.h14
-rw-r--r--Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp2
-rw-r--r--Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp2
5 files changed, 18 insertions, 4 deletions
diff --git a/Userland/Libraries/LibJS/AST.cpp b/Userland/Libraries/LibJS/AST.cpp
index c578678051..92fcda3fca 100644
--- a/Userland/Libraries/LibJS/AST.cpp
+++ b/Userland/Libraries/LibJS/AST.cpp
@@ -3778,7 +3778,7 @@ ThrowCompletionOr<Value> TaggedTemplateLiteral::get_template_object(Interpreter&
MUST(template_->set_integrity_level(Object::IntegrityLevel::Frozen));
// 15. Append the Record { [[Site]]: templateLiteral, [[Array]]: template } to templateRegistry.
- m_cached_values.set(&realm, make_handle(template_.ptr()));
+ m_cached_values.set(&realm, make_handle(template_));
// 16. Return template.
return template_;
diff --git a/Userland/Libraries/LibJS/Heap/Handle.h b/Userland/Libraries/LibJS/Heap/Handle.h
index 3daf556829..cfcf70e9bc 100644
--- a/Userland/Libraries/LibJS/Heap/Handle.h
+++ b/Userland/Libraries/LibJS/Heap/Handle.h
@@ -121,6 +121,20 @@ inline Handle<T> make_handle(T& cell)
return Handle<T>::create(&cell);
}
+template<class T>
+inline Handle<T> make_handle(GCPtr<T> cell)
+{
+ if (!cell)
+ return Handle<T> {};
+ return Handle<T>::create(cell.ptr());
+}
+
+template<class T>
+inline Handle<T> make_handle(NonnullGCPtr<T> cell)
+{
+ return Handle<T>::create(cell.ptr());
+}
+
template<>
class Handle<Value> {
public:
diff --git a/Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp b/Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp
index 70646402d8..bd910b3965 100644
--- a/Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp
+++ b/Userland/Libraries/LibWeb/Fetch/FetchMethod.cpp
@@ -107,7 +107,7 @@ JS::NonnullGCPtr<JS::Promise> fetch_impl(JS::VM& vm, RequestInfo const& input, R
// 4. Set responseObject to the result of creating a Response object, given response, "immutable", and
// relevantRealm.
auto response_object = Response::create(relevant_realm, response, Headers::Guard::Immutable);
- response_object_handle = JS::make_handle(response_object.ptr());
+ response_object_handle = JS::make_handle(response_object);
// 5. Resolve p with responseObject.
WebIDL::resolve_promise(vm, promise_capability, response_object);
diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
index ebb01a6018..94120c1150 100644
--- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
+++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
@@ -323,7 +323,7 @@ Vector<JS::Handle<DOM::Document>> EventLoop::documents_in_this_event_loop() cons
Vector<JS::Handle<DOM::Document>> documents;
for (auto& document : m_documents) {
VERIFY(document);
- documents.append(JS::make_handle(*document.ptr()));
+ documents.append(JS::make_handle(*document));
}
return documents;
}
diff --git a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
index fb12da26a6..4a001fc4f6 100644
--- a/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Parser/HTMLParser.cpp
@@ -1174,7 +1174,7 @@ Create:
auto new_element = insert_html_element(HTMLToken::make_start_tag(entry->element->local_name()));
// 9. Replace the entry for entry in the list with an entry for new element.
- m_list_of_active_formatting_elements.entries().at(index).element = JS::make_handle(new_element.ptr());
+ m_list_of_active_formatting_elements.entries().at(index).element = JS::make_handle(new_element);
// 10. If the entry for new element in the list of active formatting elements is not the last entry in the list, return to the step labeled advance.
if (index != m_list_of_active_formatting_elements.entries().size() - 1)