1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 23:17:45 +00:00

LibWeb+LibJS: Use JS::GCPtr for pointers to GC-allocated objects

Fixes warnings found by LibJSGCVerifier
This commit is contained in:
Aliaksandr Kalenik 2023-12-11 12:23:04 +01:00 committed by Alexander Kalenik
parent ed97946975
commit 6ac43274b2
14 changed files with 31 additions and 31 deletions

View file

@ -462,7 +462,7 @@ ErrorOr<void> initialize_main_thread_vm()
auto destination = Fetch::Infrastructure::Request::Destination::Script;
// 11. Let fetchClient be settingsObject.
Optional<HTML::EnvironmentSettingsObject&> fetch_client = *settings_object;
JS::NonnullGCPtr fetch_client { *settings_object };
// 12. If loadState is not undefined, then:
if (load_state) {

View file

@ -3587,7 +3587,7 @@ void Document::update_for_history_step_application(JS::NonnullGCPtr<HTML::Sessio
}
}
HashMap<AK::URL, HTML::SharedImageRequest*>& Document::shared_image_requests()
HashMap<AK::URL, JS::GCPtr<HTML::SharedImageRequest>>& Document::shared_image_requests()
{
return m_shared_image_requests;
}

View file

@ -535,7 +535,7 @@ public:
void update_for_history_step_application(JS::NonnullGCPtr<HTML::SessionHistoryEntry>, bool do_not_reactive, size_t script_history_length, size_t script_history_index);
HashMap<AK::URL, HTML::SharedImageRequest*>& shared_image_requests();
HashMap<AK::URL, JS::GCPtr<HTML::SharedImageRequest>>& shared_image_requests();
JS::NonnullGCPtr<Animations::DocumentTimeline> timeline();
@ -754,7 +754,7 @@ private:
// https://html.spec.whatwg.org/multipage/browsing-the-web.html#latest-entry
JS::GCPtr<HTML::SessionHistoryEntry> m_latest_entry;
HashMap<AK::URL, HTML::SharedImageRequest*> m_shared_image_requests;
HashMap<AK::URL, JS::GCPtr<HTML::SharedImageRequest>> m_shared_image_requests;
// https://www.w3.org/TR/web-animations-1/#timeline-associated-with-a-document
HashTable<JS::NonnullGCPtr<Animations::AnimationTimeline>> m_associated_animation_timelines;

View file

@ -58,10 +58,10 @@ class FetchContext : public JS::GraphLoadingState::HostDefined {
JS_CELL(FetchContext, JS::GraphLoadingState::HostDefined);
public:
JS::Value parse_error; // [[ParseError]]
Fetch::Infrastructure::Request::Destination destination; // [[Destination]]
JS::GCPtr<JS::Promise> perform_fetch; // [[PerformFetch]]
EnvironmentSettingsObject& fetch_client; // [[FetchClient]]
JS::Value parse_error; // [[ParseError]]
Fetch::Infrastructure::Request::Destination destination; // [[Destination]]
JS::GCPtr<JS::Promise> perform_fetch; // [[PerformFetch]]
JS::NonnullGCPtr<EnvironmentSettingsObject> fetch_client; // [[FetchClient]]
private:
FetchContext(JS::Value parse_error, Fetch::Infrastructure::Request::Destination destination, JS::GCPtr<JS::Promise> perform_fetch, EnvironmentSettingsObject& fetch_client)

View file

@ -43,7 +43,7 @@ public:
void start_timer() { m_load_timer.start(); }
Duration load_time() const { return m_load_timer.elapsed_time(); }
Optional<Page&>& page() { return m_page; }
JS::GCPtr<Page> page() { return m_page; }
void set_page(Page& page) { m_page = page; }
unsigned hash() const
@ -79,7 +79,7 @@ private:
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> m_headers;
ByteBuffer m_body;
Core::ElapsedTimer m_load_timer;
Optional<Page&> m_page;
JS::GCPtr<Page> m_page;
bool m_main_resource { false };
};

View file

@ -231,8 +231,8 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
}
if (url.scheme() == "file") {
if (request.page().has_value())
m_page = request.page().value();
if (request.page())
m_page = request.page();
if (!m_page.has_value()) {
log_failure(request, "INTERNAL ERROR: No Page for request");
@ -302,7 +302,7 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
success_callback(data, response_headers, {});
});
m_page->client().request_file(move(file_request));
(*m_page)->client().request_file(move(file_request));
++m_pending_loads;
if (on_load_counter_change)
@ -348,9 +348,9 @@ void ResourceLoader::load(LoadRequest& request, SuccessCallback success_callback
if (on_load_counter_change)
on_load_counter_change();
if (request.page().has_value()) {
if (request.page()) {
if (auto set_cookie = response_headers.get("Set-Cookie"); set_cookie.has_value())
store_response_cookies(request.page().value(), request.url(), *set_cookie);
store_response_cookies(*request.page(), request.url(), *set_cookie);
if (auto cache_control = response_headers.get("cache-control"); cache_control.has_value()) {
if (cache_control.value().contains("no-store"sv)) {
s_resource_cache.remove(request);

View file

@ -144,7 +144,7 @@ private:
NonnullRefPtr<ResourceLoaderConnector> m_connector;
String m_user_agent;
String m_platform;
Optional<Page&> m_page {};
Optional<JS::GCPtr<Page>> m_page {};
};
}

View file

@ -74,14 +74,14 @@ public:
virtual void on_chunk(JS::Value chunk) override
{
// 1. Resolve promise with «[ "value" → chunk, "done" → false ]».
WebIDL::resolve_promise(m_realm, m_promise, JS::create_iterator_result_object(m_realm.vm(), chunk, false));
WebIDL::resolve_promise(m_realm, m_promise, JS::create_iterator_result_object(m_realm->vm(), chunk, false));
}
// close steps, given chunk
virtual void on_close(JS::Value chunk) override
{
// 1. Resolve promise with «[ "value" → chunk, "done" → true ]».
WebIDL::resolve_promise(m_realm, m_promise, JS::create_iterator_result_object(m_realm.vm(), chunk, true));
WebIDL::resolve_promise(m_realm, m_promise, JS::create_iterator_result_object(m_realm->vm(), chunk, true));
}
// error steps, given e
@ -99,7 +99,7 @@ private:
visitor.visit(m_promise);
}
JS::Realm& m_realm;
JS::NonnullGCPtr<JS::Realm> m_realm;
WebIDL::Promise& m_promise;
};

View file

@ -126,12 +126,12 @@ public:
virtual void on_chunk(JS::Value chunk) override
{
WebIDL::resolve_promise(m_realm, m_promise, JS::create_iterator_result_object(m_realm.vm(), chunk, false));
WebIDL::resolve_promise(m_realm, m_promise, JS::create_iterator_result_object(m_realm->vm(), chunk, false));
}
virtual void on_close() override
{
WebIDL::resolve_promise(m_realm, m_promise, JS::create_iterator_result_object(m_realm.vm(), JS::js_undefined(), true));
WebIDL::resolve_promise(m_realm, m_promise, JS::create_iterator_result_object(m_realm->vm(), JS::js_undefined(), true));
}
virtual void on_error(JS::Value error) override
@ -147,7 +147,7 @@ private:
visitor.visit(m_promise);
}
JS::Realm& m_realm;
JS::NonnullGCPtr<JS::Realm> m_realm;
WebIDL::Promise& m_promise;
};

View file

@ -53,8 +53,8 @@ private:
virtual void visit_edges(Visitor&) override;
JS::VM& m_vm;
JS::Realm& m_realm;
ReadableStreamDefaultReader& m_reader;
JS::NonnullGCPtr<JS::Realm> m_realm;
JS::NonnullGCPtr<ReadableStreamDefaultReader> m_reader;
ByteBuffer m_bytes;
SuccessSteps m_success_steps;
FailureSteps m_failure_steps;

View file

@ -42,7 +42,7 @@ protected:
// A ReadableStream instance that owns this reader
JS::GCPtr<ReadableStream> m_stream;
JS::Realm& m_realm;
JS::NonnullGCPtr<JS::Realm> m_realm;
};
}