diff --git a/Libraries/LibWeb/CMakeLists.txt b/Libraries/LibWeb/CMakeLists.txt index fc7c4b4d690..5428df526fe 100644 --- a/Libraries/LibWeb/CMakeLists.txt +++ b/Libraries/LibWeb/CMakeLists.txt @@ -515,6 +515,7 @@ set(SOURCES IndexedDB/IDBCursor.cpp IndexedDB/IDBFactory.cpp IndexedDB/IDBOpenDBRequest.cpp + IndexedDB/IDBIndex.cpp IndexedDB/IDBRequest.cpp IndexedDB/IDBVersionChangeEvent.cpp Internals/Inspector.cpp diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index ecfbd198ec0..440690bc68f 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -575,8 +575,9 @@ class Performance; namespace Web::IndexedDB { class Database; class IDBCursor; -class IDBFactory; class IDBDatabase; +class IDBFactory; +class IDBIndex; class IDBOpenDBRequest; class IDBRequest; class IDBVersionChangeEvent; diff --git a/Libraries/LibWeb/IndexedDB/IDBIndex.cpp b/Libraries/LibWeb/IndexedDB/IDBIndex.cpp new file mode 100644 index 00000000000..9d11c0ec8dd --- /dev/null +++ b/Libraries/LibWeb/IndexedDB/IDBIndex.cpp @@ -0,0 +1,34 @@ +/* + * Copyright (c) 2024, stelar7 + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include +#include +#include +#include + +namespace Web::IndexedDB { + +GC_DEFINE_ALLOCATOR(IDBIndex); + +IDBIndex::~IDBIndex() = default; + +IDBIndex::IDBIndex(JS::Realm& realm) + : PlatformObject(realm) +{ +} + +GC::Ref IDBIndex::create(JS::Realm& realm) +{ + return realm.create(realm); +} + +void IDBIndex::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBIndex); +} + +} diff --git a/Libraries/LibWeb/IndexedDB/IDBIndex.h b/Libraries/LibWeb/IndexedDB/IDBIndex.h new file mode 100644 index 00000000000..3e1b080a6db --- /dev/null +++ b/Libraries/LibWeb/IndexedDB/IDBIndex.h @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2024, stelar7 + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +#include +#include + +namespace Web::IndexedDB { + +// https://w3c.github.io/IndexedDB/#index-interface +class IDBIndex : public Bindings::PlatformObject { + WEB_PLATFORM_OBJECT(IDBIndex, Bindings::PlatformObject); + GC_DECLARE_ALLOCATOR(IDBIndex); + +public: + virtual ~IDBIndex() override; + [[nodiscard]] static GC::Ref create(JS::Realm&); + +protected: + explicit IDBIndex(JS::Realm&); + virtual void initialize(JS::Realm&) override; +}; + +} diff --git a/Libraries/LibWeb/IndexedDB/IDBIndex.idl b/Libraries/LibWeb/IndexedDB/IDBIndex.idl new file mode 100644 index 00000000000..a096122f40d --- /dev/null +++ b/Libraries/LibWeb/IndexedDB/IDBIndex.idl @@ -0,0 +1,17 @@ +#import + +[Exposed=(Window,Worker)] +interface IDBIndex { + [FIXME] attribute DOMString name; + [FIXME, SameObject] readonly attribute IDBObjectStore objectStore; + [FIXME] readonly attribute any keyPath; + [FIXME] readonly attribute boolean multiEntry; + [FIXME] readonly attribute boolean unique; + [FIXME, NewObject] IDBRequest get(any query); + [FIXME, NewObject] IDBRequest getKey(any query); + [FIXME, NewObject] IDBRequest getAll(optional any query, optional [EnforceRange] unsigned long count); + [FIXME, NewObject] IDBRequest getAllKeys(optional any query, optional [EnforceRange] unsigned long count); + [FIXME, NewObject] IDBRequest count(optional any query); + [FIXME, NewObject] IDBRequest openCursor(optional any query, optional IDBCursorDirection direction = "next"); + [FIXME, NewObject] IDBRequest openKeyCursor(optional any query, optional IDBCursorDirection direction = "next"); +}; diff --git a/Libraries/LibWeb/idl_files.cmake b/Libraries/LibWeb/idl_files.cmake index 84e511ba437..e7f44fecffc 100644 --- a/Libraries/LibWeb/idl_files.cmake +++ b/Libraries/LibWeb/idl_files.cmake @@ -248,6 +248,7 @@ libweb_js_bindings(HighResolutionTime/Performance) libweb_js_bindings(IndexedDB/IDBCursor) libweb_js_bindings(IndexedDB/IDBDatabase) libweb_js_bindings(IndexedDB/IDBFactory) +libweb_js_bindings(IndexedDB/IDBIndex) libweb_js_bindings(IndexedDB/IDBOpenDBRequest) libweb_js_bindings(IndexedDB/IDBRequest) libweb_js_bindings(IndexedDB/IDBVersionChangeEvent) diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp index 1da14fe972e..803e7cd8ac7 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/BindingsGenerator/IDLGenerators.cpp @@ -60,6 +60,7 @@ static bool is_platform_object(Type const& type) "FormData"sv, "HTMLCollection"sv, "IDBCursor"sv, + "IDBIndex"sv, "ImageBitmap"sv, "ImageData"sv, "Instance"sv, diff --git a/Tests/LibWeb/Text/expected/all-window-properties.txt b/Tests/LibWeb/Text/expected/all-window-properties.txt index a647b5a83e2..26ff077bf42 100644 --- a/Tests/LibWeb/Text/expected/all-window-properties.txt +++ b/Tests/LibWeb/Text/expected/all-window-properties.txt @@ -202,6 +202,7 @@ History IDBCursor IDBDatabase IDBFactory +IDBIndex IDBOpenDBRequest IDBRequest IDBVersionChangeEvent