From 2e02b621266035c0b00a92f8a2173a5a0442c291 Mon Sep 17 00:00:00 2001 From: stelar7 Date: Mon, 24 Mar 2025 20:56:36 +0100 Subject: [PATCH] LibWeb/IDB: Implement IDBObjectStore::autoIncrement --- Libraries/LibWeb/IndexedDB/IDBObjectStore.h | 4 ++++ Libraries/LibWeb/IndexedDB/IDBObjectStore.idl | 2 +- Libraries/LibWeb/IndexedDB/Internal/ObjectStore.h | 4 +--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Libraries/LibWeb/IndexedDB/IDBObjectStore.h b/Libraries/LibWeb/IndexedDB/IDBObjectStore.h index c4c8284921a..6acf517f005 100644 --- a/Libraries/LibWeb/IndexedDB/IDBObjectStore.h +++ b/Libraries/LibWeb/IndexedDB/IDBObjectStore.h @@ -26,6 +26,10 @@ public: JS::Value key_path() const; GC::Ref transaction() const { return m_transaction; } + // https://w3c.github.io/IndexedDB/#dom-idbobjectstore-autoincrement + // The autoIncrement getter steps are to return true if this’s object store has a key generator, and false otherwise. + bool auto_increment() const { return m_store->key_generator().has_value(); } + protected: explicit IDBObjectStore(JS::Realm&, GC::Ref, GC::Ref); virtual void initialize(JS::Realm&) override; diff --git a/Libraries/LibWeb/IndexedDB/IDBObjectStore.idl b/Libraries/LibWeb/IndexedDB/IDBObjectStore.idl index 92f3eefdae0..e1790faa374 100644 --- a/Libraries/LibWeb/IndexedDB/IDBObjectStore.idl +++ b/Libraries/LibWeb/IndexedDB/IDBObjectStore.idl @@ -8,7 +8,7 @@ interface IDBObjectStore { readonly attribute any keyPath; [FIXME] readonly attribute DOMStringList indexNames; [SameObject] readonly attribute IDBTransaction transaction; - [FIXME] readonly attribute boolean autoIncrement; + readonly attribute boolean autoIncrement; [FIXME, NewObject] IDBRequest put(any value, optional any key); [FIXME, NewObject] IDBRequest add(any value, optional any key); diff --git a/Libraries/LibWeb/IndexedDB/Internal/ObjectStore.h b/Libraries/LibWeb/IndexedDB/Internal/ObjectStore.h index 4a6e1dc98fd..cf2b55adaef 100644 --- a/Libraries/LibWeb/IndexedDB/Internal/ObjectStore.h +++ b/Libraries/LibWeb/IndexedDB/Internal/ObjectStore.h @@ -33,9 +33,7 @@ public: Optional key_path() const { return m_key_path; } bool uses_inline_keys() const { return m_key_path.has_value(); } bool uses_out_of_line_keys() const { return !m_key_path.has_value(); } - - // The autoIncrement getter steps are to return true if this’s object store has a key generator, and false otherwise. - bool auto_increment() const { return m_key_generator.has_value(); } + Optional key_generator() const { return m_key_generator; } private: ObjectStore(String name, bool auto_increment, Optional const& key_path)