mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 17:55:07 +02:00
LibWeb/IDB: Implement IDBObjectStore::name
This commit is contained in:
committed by
Jelle Raaijmakers
parent
2e02b62126
commit
3879391fa6
Notes:
github-actions[bot]
2025-03-27 15:49:10 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/3879391fa6a Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4077 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/gmta ✅
@@ -14,6 +14,7 @@
|
||||
#include <LibJS/Heap/Cell.h>
|
||||
#include <LibJS/Runtime/Realm.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Algorithms.h>
|
||||
#include <LibWeb/IndexedDB/Internal/Database.h>
|
||||
#include <LibWeb/IndexedDB/Internal/KeyGenerator.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
@@ -26,23 +27,26 @@ class ObjectStore : public JS::Cell {
|
||||
GC_DECLARE_ALLOCATOR(ObjectStore);
|
||||
|
||||
public:
|
||||
[[nodiscard]] static GC::Ref<ObjectStore> create(JS::Realm&, String, bool, Optional<KeyPath> const&);
|
||||
[[nodiscard]] static GC::Ref<ObjectStore> create(JS::Realm&, GC::Ref<Database>, String, bool, Optional<KeyPath> const&);
|
||||
virtual ~ObjectStore();
|
||||
|
||||
String name() const { return m_name; }
|
||||
void set_name(String name) { m_name = move(name); }
|
||||
Optional<KeyPath> 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(); }
|
||||
Optional<KeyGenerator> key_generator() const { return m_key_generator; }
|
||||
|
||||
GC::Ref<Database> database() const { return m_database; }
|
||||
|
||||
protected:
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
private:
|
||||
ObjectStore(String name, bool auto_increment, Optional<KeyPath> const& key_path)
|
||||
: m_name(move(name))
|
||||
, m_key_path(key_path)
|
||||
{
|
||||
if (auto_increment)
|
||||
m_key_generator = KeyGenerator {};
|
||||
}
|
||||
ObjectStore(GC::Ref<Database> database, String name, bool auto_increment, Optional<KeyPath> const& key_path);
|
||||
|
||||
// AD-HOC: An ObjectStore needs to know what Database it belongs to...
|
||||
GC::Ref<Database> m_database;
|
||||
|
||||
// An object store has a name, which is a name. At any one time, the name is unique within the database to which it belongs.
|
||||
String m_name;
|
||||
|
||||
Reference in New Issue
Block a user