LibWeb: Add IDBKeyRange

This commit is contained in:
stelar7 2024-11-07 19:04:11 +01:00 committed by Jelle Raaijmakers
commit 48fae7b64f
Notes: github-actions[bot] 2024-11-26 13:52:44 +00:00
8 changed files with 80 additions and 0 deletions

View file

@ -516,6 +516,7 @@ set(SOURCES
IndexedDB/IDBFactory.cpp
IndexedDB/IDBOpenDBRequest.cpp
IndexedDB/IDBIndex.cpp
IndexedDB/IDBKeyRange.cpp
IndexedDB/IDBObjectStore.cpp
IndexedDB/IDBRequest.cpp
IndexedDB/IDBTransaction.cpp

View file

@ -578,6 +578,7 @@ class IDBCursor;
class IDBDatabase;
class IDBFactory;
class IDBIndex;
class IDBKeyRange;
class IDBObjectStore;
class IDBOpenDBRequest;
class IDBRequest;

View file

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

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/#keyrange
class IDBKeyRange : public Bindings::PlatformObject {
WEB_PLATFORM_OBJECT(IDBKeyRange, Bindings::PlatformObject);
GC_DECLARE_ALLOCATOR(IDBKeyRange);
public:
virtual ~IDBKeyRange() override;
[[nodiscard]] static GC::Ref<IDBKeyRange> create(JS::Realm&);
protected:
explicit IDBKeyRange(JS::Realm&);
virtual void initialize(JS::Realm&) override;
};
}

View file

@ -0,0 +1,14 @@
[Exposed=(Window,Worker)]
interface IDBKeyRange {
[FIXME] readonly attribute any lower;
[FIXME] readonly attribute any upper;
[FIXME] readonly attribute boolean lowerOpen;
[FIXME] readonly attribute boolean upperOpen;
[FIXME, NewObject] static IDBKeyRange only(any value);
[FIXME, NewObject] static IDBKeyRange lowerBound(any lower, optional boolean open = false);
[FIXME, NewObject] static IDBKeyRange upperBound(any upper, optional boolean open = false);
[FIXME, NewObject] static IDBKeyRange bound(any lower, any upper, optional boolean lowerOpen = false, optional boolean upperOpen = false);
[FIXME] boolean includes(any key);
};

View file

@ -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/IDBKeyRange)
libweb_js_bindings(IndexedDB/IDBObjectStore)
libweb_js_bindings(IndexedDB/IDBOpenDBRequest)
libweb_js_bindings(IndexedDB/IDBRequest)

View file

@ -61,6 +61,7 @@ static bool is_platform_object(Type const& type)
"HTMLCollection"sv,
"IDBCursor"sv,
"IDBIndex"sv,
"IDBKeyRange"sv,
"IDBObjectStore"sv,
"IDBTransaction"sv,
"ImageBitmap"sv,

View file

@ -203,6 +203,7 @@ IDBCursor
IDBDatabase
IDBFactory
IDBIndex
IDBKeyRange
IDBObjectStore
IDBOpenDBRequest
IDBRequest