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

LibJS: Handle both const and non-const Ts in Handle<T>::create()

Again, the const-ness only really involves Heap-internal metadata, so
the callers shouldn't care about mutations here.
This commit is contained in:
Matthew Olsson 2023-02-25 10:44:31 -07:00 committed by Linus Groh
parent 74e93a46ea
commit 70a2ca7fc0
6 changed files with 10 additions and 10 deletions

View file

@ -838,7 +838,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> http_fetch(JS::Realm& rea
// NOTE: Step 2 is performed in pending_preflight_response's load callback below.
}
auto fetch_main_content = [request = JS::make_handle(request), realm = JS::make_handle(realm), fetch_params = JS::make_handle(const_cast<Infrastructure::FetchParams&>(fetch_params))]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> {
auto fetch_main_content = [request = JS::make_handle(request), realm = JS::make_handle(realm), fetch_params = JS::make_handle(fetch_params)]() -> WebIDL::ExceptionOr<JS::NonnullGCPtr<PendingResponse>> {
// 2. If requests redirect mode is "follow", then set requests service-workers mode to "none".
// NOTE: Redirects coming from the network (as opposed to from a service worker) are not to be exposed to a
// service worker.

View file

@ -52,11 +52,11 @@ void PendingResponse::resolve(JS::NonnullGCPtr<Infrastructure::Response> respons
run_callback();
}
void PendingResponse::run_callback() const
void PendingResponse::run_callback()
{
VERIFY(m_callback);
VERIFY(m_response);
Platform::EventLoopPlugin::the().deferred_invoke([strong_this = JS::make_handle(const_cast<PendingResponse&>(*this))] {
Platform::EventLoopPlugin::the().deferred_invoke([strong_this = JS::make_handle(*this)] {
strong_this->m_callback(*strong_this->m_response);
strong_this->m_request->remove_pending_response({}, *strong_this.ptr());
});

View file

@ -35,7 +35,7 @@ private:
virtual void visit_edges(JS::Cell::Visitor&) override;
void run_callback() const;
void run_callback();
Callback m_callback;
JS::NonnullGCPtr<Infrastructure::Request> m_request;