LibWeb: Add IDBIndex

This commit is contained in:
stelar7 2024-11-07 18:52:59 +01:00 committed by Jelle Raaijmakers
commit 297c775b34
Notes: github-actions[bot] 2024-11-26 13:53:02 +00:00
8 changed files with 85 additions and 1 deletions

View file

@ -0,0 +1,34 @@
/*
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibWeb/Bindings/IDBIndexPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/IndexedDB/IDBIndex.h>
namespace Web::IndexedDB {
GC_DEFINE_ALLOCATOR(IDBIndex);
IDBIndex::~IDBIndex() = default;
IDBIndex::IDBIndex(JS::Realm& realm)
: PlatformObject(realm)
{
}
GC::Ref<IDBIndex> IDBIndex::create(JS::Realm& realm)
{
return realm.create<IDBIndex>(realm);
}
void IDBIndex::initialize(JS::Realm& realm)
{
Base::initialize(realm);
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBIndex);
}
}

View 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/#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<IDBIndex> create(JS::Realm&);
protected:
explicit IDBIndex(JS::Realm&);
virtual void initialize(JS::Realm&) override;
};
}

View file

@ -0,0 +1,17 @@
#import <IndexedDB/IDBCursor.idl>
[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");
};