LibWeb: Add IDBObjectStore
This commit is contained in:
parent
297c775b34
commit
16ce2b975a
Notes:
github-actions[bot]
2024-11-26 13:52:57 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/16ce2b975a5 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2236 Reviewed-by: https://github.com/gmta ✅
8 changed files with 99 additions and 0 deletions
|
@ -516,6 +516,7 @@ set(SOURCES
|
|||
IndexedDB/IDBFactory.cpp
|
||||
IndexedDB/IDBOpenDBRequest.cpp
|
||||
IndexedDB/IDBIndex.cpp
|
||||
IndexedDB/IDBObjectStore.cpp
|
||||
IndexedDB/IDBRequest.cpp
|
||||
IndexedDB/IDBVersionChangeEvent.cpp
|
||||
Internals/Inspector.cpp
|
||||
|
|
|
@ -578,6 +578,7 @@ class IDBCursor;
|
|||
class IDBDatabase;
|
||||
class IDBFactory;
|
||||
class IDBIndex;
|
||||
class IDBObjectStore;
|
||||
class IDBOpenDBRequest;
|
||||
class IDBRequest;
|
||||
class IDBVersionChangeEvent;
|
||||
|
|
34
Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp
Normal file
34
Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/IDBObjectStorePrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/IndexedDB/IDBObjectStore.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(IDBObjectStore);
|
||||
|
||||
IDBObjectStore::~IDBObjectStore() = default;
|
||||
|
||||
IDBObjectStore::IDBObjectStore(JS::Realm& realm)
|
||||
: PlatformObject(realm)
|
||||
{
|
||||
}
|
||||
|
||||
GC::Ref<IDBObjectStore> IDBObjectStore::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.create<IDBObjectStore>(realm);
|
||||
}
|
||||
|
||||
void IDBObjectStore::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBObjectStore);
|
||||
}
|
||||
|
||||
}
|
28
Libraries/LibWeb/IndexedDB/IDBObjectStore.h
Normal file
28
Libraries/LibWeb/IndexedDB/IDBObjectStore.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*
|
||||
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <LibGC/Heap.h>
|
||||
#include <LibWeb/Bindings/PlatformObject.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#object-store-interface
|
||||
class IDBObjectStore : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(IDBObjectStore, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(IDBObjectStore);
|
||||
|
||||
public:
|
||||
virtual ~IDBObjectStore() override;
|
||||
[[nodiscard]] static GC::Ref<IDBObjectStore> create(JS::Realm&);
|
||||
|
||||
protected:
|
||||
explicit IDBObjectStore(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
|
||||
}
|
32
Libraries/LibWeb/IndexedDB/IDBObjectStore.idl
Normal file
32
Libraries/LibWeb/IndexedDB/IDBObjectStore.idl
Normal file
|
@ -0,0 +1,32 @@
|
|||
#import <IndexedDB/IDBRequest.idl>
|
||||
#import <IndexedDB/IDBIndex.idl>
|
||||
#import <IndexedDB/IDBCursor.idl>
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
interface IDBObjectStore {
|
||||
[FIXME] attribute DOMString name;
|
||||
[FIXME] readonly attribute any keyPath;
|
||||
[FIXME] readonly attribute DOMStringList indexNames;
|
||||
[FIXME, SameObject] readonly attribute IDBTransaction transaction;
|
||||
[FIXME] readonly attribute boolean autoIncrement;
|
||||
|
||||
[FIXME, NewObject] IDBRequest put(any value, optional any key);
|
||||
[FIXME, NewObject] IDBRequest add(any value, optional any key);
|
||||
[FIXME, NewObject] IDBRequest delete(any query);
|
||||
[FIXME, NewObject] IDBRequest clear();
|
||||
[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");
|
||||
[FIXME] IDBIndex index(DOMString name);
|
||||
[FIXME, NewObject] IDBIndex createIndex(DOMString name, (DOMString or sequence<DOMString>) keyPath, optional IDBIndexParameters options = {});
|
||||
[FIXME] undefined deleteIndex(DOMString name);
|
||||
};
|
||||
|
||||
dictionary IDBIndexParameters {
|
||||
boolean unique = false;
|
||||
boolean multiEntry = false;
|
||||
};
|
|
@ -249,6 +249,7 @@ libweb_js_bindings(IndexedDB/IDBCursor)
|
|||
libweb_js_bindings(IndexedDB/IDBDatabase)
|
||||
libweb_js_bindings(IndexedDB/IDBFactory)
|
||||
libweb_js_bindings(IndexedDB/IDBIndex)
|
||||
libweb_js_bindings(IndexedDB/IDBObjectStore)
|
||||
libweb_js_bindings(IndexedDB/IDBOpenDBRequest)
|
||||
libweb_js_bindings(IndexedDB/IDBRequest)
|
||||
libweb_js_bindings(IndexedDB/IDBVersionChangeEvent)
|
||||
|
|
|
@ -61,6 +61,7 @@ static bool is_platform_object(Type const& type)
|
|||
"HTMLCollection"sv,
|
||||
"IDBCursor"sv,
|
||||
"IDBIndex"sv,
|
||||
"IDBObjectStore"sv,
|
||||
"ImageBitmap"sv,
|
||||
"ImageData"sv,
|
||||
"Instance"sv,
|
||||
|
|
|
@ -203,6 +203,7 @@ IDBCursor
|
|||
IDBDatabase
|
||||
IDBFactory
|
||||
IDBIndex
|
||||
IDBObjectStore
|
||||
IDBOpenDBRequest
|
||||
IDBRequest
|
||||
IDBVersionChangeEvent
|
||||
|
|
Loading…
Add table
Reference in a new issue