mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-25 19:56:30 +00:00
LibWeb: Add IDBCursor
This commit is contained in:
parent
614b93beca
commit
71772d97dc
Notes:
github-actions[bot]
2024-11-26 13:53:08 +00:00
Author: https://github.com/stelar7
Commit: 71772d97dc
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2236
Reviewed-by: https://github.com/gmta ✅
8 changed files with 88 additions and 0 deletions
34
Libraries/LibWeb/IndexedDB/IDBCursor.cpp
Normal file
34
Libraries/LibWeb/IndexedDB/IDBCursor.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2024, stelar7 <dudedbz@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/IDBCursorPrototype.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/HTML/EventNames.h>
|
||||
#include <LibWeb/IndexedDB/IDBCursor.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(IDBCursor);
|
||||
|
||||
IDBCursor::~IDBCursor() = default;
|
||||
|
||||
IDBCursor::IDBCursor(JS::Realm& realm)
|
||||
: PlatformObject(realm)
|
||||
{
|
||||
}
|
||||
|
||||
GC::Ref<IDBCursor> IDBCursor::create(JS::Realm& realm)
|
||||
{
|
||||
return realm.create<IDBCursor>(realm);
|
||||
}
|
||||
|
||||
void IDBCursor::initialize(JS::Realm& realm)
|
||||
{
|
||||
Base::initialize(realm);
|
||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(IDBCursor);
|
||||
}
|
||||
|
||||
}
|
27
Libraries/LibWeb/IndexedDB/IDBCursor.h
Normal file
27
Libraries/LibWeb/IndexedDB/IDBCursor.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* 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/#cursor-interface
|
||||
class IDBCursor : public Bindings::PlatformObject {
|
||||
WEB_PLATFORM_OBJECT(IDBCursor, Bindings::PlatformObject);
|
||||
GC_DECLARE_ALLOCATOR(IDBCursor);
|
||||
|
||||
public:
|
||||
virtual ~IDBCursor() override;
|
||||
[[nodiscard]] static GC::Ref<IDBCursor> create(JS::Realm&);
|
||||
|
||||
protected:
|
||||
explicit IDBCursor(JS::Realm&);
|
||||
virtual void initialize(JS::Realm&) override;
|
||||
};
|
||||
}
|
22
Libraries/LibWeb/IndexedDB/IDBCursor.idl
Normal file
22
Libraries/LibWeb/IndexedDB/IDBCursor.idl
Normal file
|
@ -0,0 +1,22 @@
|
|||
#import <IndexedDB/IDBRequest.idl>
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
interface IDBCursor {
|
||||
[FIXME] readonly attribute (IDBObjectStore or IDBIndex) source;
|
||||
[FIXME] readonly attribute IDBCursorDirection direction;
|
||||
[FIXME] readonly attribute any key;
|
||||
[FIXME] readonly attribute any primaryKey;
|
||||
[FIXME, SameObject] readonly attribute IDBRequest request;
|
||||
[FIXME] undefined advance([EnforceRange] unsigned long count);
|
||||
[FIXME] undefined continue(optional any key);
|
||||
[FIXME] undefined continuePrimaryKey(any key, any primaryKey);
|
||||
[FIXME, NewObject] IDBRequest update(any value);
|
||||
[FIXME, NewObject] IDBRequest delete();
|
||||
};
|
||||
|
||||
enum IDBCursorDirection {
|
||||
"next",
|
||||
"nextunique",
|
||||
"prev",
|
||||
"prevunique"
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue