From bfa330914d1d4c3ff68757883bbbf9fd640a02fb Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Sun, 19 May 2024 18:03:00 +1200 Subject: [PATCH] LibWeb: Add stub interface for IDBRequest --- Userland/Libraries/LibWeb/CMakeLists.txt | 1 + Userland/Libraries/LibWeb/Forward.h | 1 + .../Libraries/LibWeb/IndexedDB/IDBRequest.cpp | 28 +++++++++++++++++++ .../Libraries/LibWeb/IndexedDB/IDBRequest.h | 26 +++++++++++++++++ .../Libraries/LibWeb/IndexedDB/IDBRequest.idl | 20 +++++++++++++ Userland/Libraries/LibWeb/idl_files.cmake | 1 + 6 files changed, 77 insertions(+) create mode 100644 Userland/Libraries/LibWeb/IndexedDB/IDBRequest.cpp create mode 100644 Userland/Libraries/LibWeb/IndexedDB/IDBRequest.h create mode 100644 Userland/Libraries/LibWeb/IndexedDB/IDBRequest.idl diff --git a/Userland/Libraries/LibWeb/CMakeLists.txt b/Userland/Libraries/LibWeb/CMakeLists.txt index 786f5b75f6c..4e7bc50adec 100644 --- a/Userland/Libraries/LibWeb/CMakeLists.txt +++ b/Userland/Libraries/LibWeb/CMakeLists.txt @@ -448,6 +448,7 @@ set(SOURCES Infra/JSON.cpp Infra/Strings.cpp IndexedDB/IDBFactory.cpp + IndexedDB/IDBRequest.cpp Internals/Inspector.cpp Internals/InternalAnimationTimeline.cpp Internals/Internals.cpp diff --git a/Userland/Libraries/LibWeb/Forward.h b/Userland/Libraries/LibWeb/Forward.h index f07a2cd2858..54c1ddc832e 100644 --- a/Userland/Libraries/LibWeb/Forward.h +++ b/Userland/Libraries/LibWeb/Forward.h @@ -500,6 +500,7 @@ class Performance; namespace Web::IndexedDB { class IDBFactory; +class IDBRequest; } namespace Web::Internals { diff --git a/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.cpp b/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.cpp new file mode 100644 index 00000000000..1f8264eeb8b --- /dev/null +++ b/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.cpp @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024, Shannon Booth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include + +namespace Web::IndexedDB { + +JS_DEFINE_ALLOCATOR(IDBRequest); + +IDBRequest::~IDBRequest() = default; + +IDBRequest::IDBRequest(JS::Realm& realm) + : EventTarget(realm) +{ +} + +void IDBRequest::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBRequest); +} + +} diff --git a/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.h b/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.h new file mode 100644 index 00000000000..c938a653d79 --- /dev/null +++ b/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.h @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024, Shannon Booth + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include + +namespace Web::IndexedDB { + +class IDBRequest : public DOM::EventTarget { + WEB_PLATFORM_OBJECT(IDBRequest, EventTarget); + JS_DECLARE_ALLOCATOR(IDBRequest); + +public: + virtual ~IDBRequest() override; + +protected: + explicit IDBRequest(JS::Realm&); + + virtual void initialize(JS::Realm&) override; +}; + +} diff --git a/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.idl b/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.idl new file mode 100644 index 00000000000..4e0b1643c06 --- /dev/null +++ b/Userland/Libraries/LibWeb/IndexedDB/IDBRequest.idl @@ -0,0 +1,20 @@ +#import + +// https://w3c.github.io/IndexedDB/#idbrequest +[Exposed=(Window,Worker)] +interface IDBRequest : EventTarget { + // FIXME: readonly attribute any result; + // FIXME: readonly attribute DOMException? error; + // FIXME: readonly attribute (IDBObjectStore or IDBIndex or IDBCursor)? source; + // FIXME: readonly attribute IDBTransaction? transaction; + // FIXME: readonly attribute IDBRequestReadyState readyState; + + // Event handlers: + // FIXME: attribute EventHandler onsuccess; + // FIXME: attribute EventHandler onerror; +}; + +enum IDBRequestReadyState { + "pending", + "done" +}; diff --git a/Userland/Libraries/LibWeb/idl_files.cmake b/Userland/Libraries/LibWeb/idl_files.cmake index 920b815d0ac..1f3e37b217c 100644 --- a/Userland/Libraries/LibWeb/idl_files.cmake +++ b/Userland/Libraries/LibWeb/idl_files.cmake @@ -217,6 +217,7 @@ libweb_js_bindings(HTML/WorkerLocation) libweb_js_bindings(HTML/WorkerNavigator) libweb_js_bindings(HighResolutionTime/Performance) libweb_js_bindings(IndexedDB/IDBFactory) +libweb_js_bindings(IndexedDB/IDBRequest) libweb_js_bindings(Internals/Inspector) libweb_js_bindings(Internals/InternalAnimationTimeline) libweb_js_bindings(Internals/Internals)