mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb/IDB: Implement IDBDatabase::objectStoreNames
This commit is contained in:
committed by
Jelle Raaijmakers
parent
1ad9b3ee6e
commit
b11276e5c4
Notes:
github-actions[bot]
2025-03-27 15:48:55 +00:00
Author: https://github.com/stelar7 Commit: https://github.com/LadybirdBrowser/ladybird/commit/b11276e5c4e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4077 Reviewed-by: https://github.com/AtkinsSJ Reviewed-by: https://github.com/gmta ✅
@@ -18,10 +18,10 @@ GC_DEFINE_ALLOCATOR(IDBDatabase);
|
||||
IDBDatabase::IDBDatabase(JS::Realm& realm, Database& db)
|
||||
: EventTarget(realm)
|
||||
, m_name(db.name())
|
||||
, m_object_store_names(HTML::DOMStringList::create(realm, {}))
|
||||
, m_associated_database(db)
|
||||
{
|
||||
db.associate(*this);
|
||||
db.object_stores().copy_to(m_object_store_set);
|
||||
}
|
||||
|
||||
IDBDatabase::~IDBDatabase() = default;
|
||||
@@ -40,7 +40,7 @@ void IDBDatabase::initialize(JS::Realm& realm)
|
||||
void IDBDatabase::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_object_store_names);
|
||||
visitor.visit(m_object_store_set);
|
||||
visitor.visit(m_associated_database);
|
||||
}
|
||||
|
||||
@@ -138,4 +138,16 @@ WebIDL::ExceptionOr<GC::Ref<IDBObjectStore>> IDBDatabase::create_object_store(St
|
||||
return IDBObjectStore::create(realm, object_store, *transaction);
|
||||
}
|
||||
|
||||
// https://w3c.github.io/IndexedDB/#dom-idbdatabase-objectstorenames
|
||||
GC::Ref<HTML::DOMStringList> IDBDatabase::object_store_names()
|
||||
{
|
||||
// 1. Let names be a list of the names of the object stores in this's object store set.
|
||||
Vector<String> names;
|
||||
for (auto const& object_store : this->object_store_set())
|
||||
names.append(object_store->name());
|
||||
|
||||
// 2. Return the result (a DOMStringList) of creating a sorted name list with names.
|
||||
return create_a_sorted_name_list(realm(), names);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user