LibWeb/IDB: Set the source of a IDBRequest

This commit is contained in:
stelar7 2025-03-21 11:27:13 +01:00 committed by Sam Atkins
parent 090ac66af1
commit 923927564d
Notes: github-actions[bot] 2025-03-25 10:51:18 +00:00
3 changed files with 15 additions and 5 deletions

View file

@ -1,6 +1,7 @@
/* /*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org> * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2025, stelar7 <dudedbz@gmail.com>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -16,8 +17,9 @@ GC_DEFINE_ALLOCATOR(IDBOpenDBRequest);
IDBOpenDBRequest::~IDBOpenDBRequest() = default; IDBOpenDBRequest::~IDBOpenDBRequest() = default;
// NOTE: The source of an open request is always null.
IDBOpenDBRequest::IDBOpenDBRequest(JS::Realm& realm) IDBOpenDBRequest::IDBOpenDBRequest(JS::Realm& realm)
: IDBRequest(realm) : IDBRequest(realm, {})
{ {
} }

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org> * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com> * Copyright (c) 2024-2025, stelar7 <dudedbz@gmail.com>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -16,8 +16,9 @@ GC_DEFINE_ALLOCATOR(IDBRequest);
IDBRequest::~IDBRequest() = default; IDBRequest::~IDBRequest() = default;
IDBRequest::IDBRequest(JS::Realm& realm) IDBRequest::IDBRequest(JS::Realm& realm, IDBRequestSource source)
: EventTarget(realm) : EventTarget(realm)
, m_source(source)
{ {
} }
@ -27,6 +28,11 @@ void IDBRequest::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBRequest); WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBRequest);
} }
GC::Ref<IDBRequest> IDBRequest::create(JS::Realm& realm, IDBRequestSource source)
{
return realm.create<IDBRequest>(realm, source);
}
void IDBRequest::visit_edges(Visitor& visitor) void IDBRequest::visit_edges(Visitor& visitor)
{ {
Base::visit_edges(visitor); Base::visit_edges(visitor);

View file

@ -1,7 +1,7 @@
/* /*
* Copyright (c) 2024, Shannon Booth <shannon@serenityos.org> * Copyright (c) 2024, Shannon Booth <shannon@serenityos.org>
* Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org> * Copyright (c) 2024, Jamie Mansfield <jmansfield@cadixdev.org>
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com> * Copyright (c) 2024-2025, stelar7 <dudedbz@gmail.com>
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
@ -24,6 +24,8 @@ class IDBRequest : public DOM::EventTarget {
public: public:
virtual ~IDBRequest() override; virtual ~IDBRequest() override;
[[nodiscard]] static GC::Ref<IDBRequest> create(JS::Realm&, IDBRequestSource);
[[nodiscard]] bool done() const { return m_done; } [[nodiscard]] bool done() const { return m_done; }
[[nodiscard]] bool processed() const { return m_processed; } [[nodiscard]] bool processed() const { return m_processed; }
[[nodiscard]] IDBRequestSource source() const { return m_source; } [[nodiscard]] IDBRequestSource source() const { return m_source; }
@ -46,7 +48,7 @@ public:
WebIDL::CallbackType* onerror(); WebIDL::CallbackType* onerror();
protected: protected:
explicit IDBRequest(JS::Realm&); explicit IDBRequest(JS::Realm&, IDBRequestSource);
virtual void initialize(JS::Realm&) override; virtual void initialize(JS::Realm&) override;
virtual void visit_edges(Visitor& visitor) override; virtual void visit_edges(Visitor& visitor) override;