mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-18 08:20:44 +00:00
LibWeb/IDB: Add internal Index object
This commit is contained in:
parent
8beade51e0
commit
9321ad04c0
Notes:
github-actions[bot]
2025-04-09 17:50:57 +00:00
Author: https://github.com/stelar7
Commit: 9321ad04c0
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4178
Reviewed-by: https://github.com/ADKaster ✅
Reviewed-by: https://github.com/AtkinsSJ
6 changed files with 119 additions and 0 deletions
42
Libraries/LibWeb/IndexedDB/Internal/Index.cpp
Normal file
42
Libraries/LibWeb/IndexedDB/Internal/Index.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2025, stelar7 <dudedbz@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/IndexedDB/Internal/Index.h>
|
||||
#include <LibWeb/IndexedDB/Internal/ObjectStore.h>
|
||||
|
||||
namespace Web::IndexedDB {
|
||||
|
||||
GC_DEFINE_ALLOCATOR(Index);
|
||||
|
||||
Index::~Index() = default;
|
||||
|
||||
GC::Ref<Index> Index::create(JS::Realm& realm, GC::Ref<ObjectStore> store, String name, KeyPath const& key_path, bool unique, bool multi_entry)
|
||||
{
|
||||
return realm.create<Index>(store, name, key_path, unique, multi_entry);
|
||||
}
|
||||
|
||||
Index::Index(GC::Ref<ObjectStore> store, String name, KeyPath const& key_path, bool unique, bool multi_entry)
|
||||
: m_object_store(store)
|
||||
, m_name(move(name))
|
||||
, m_unique(unique)
|
||||
, m_multi_entry(multi_entry)
|
||||
, m_key_path(key_path)
|
||||
{
|
||||
store->add_index(*this);
|
||||
}
|
||||
|
||||
void Index::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_object_store);
|
||||
|
||||
for (auto& record : m_records) {
|
||||
visitor.visit(record.key);
|
||||
visitor.visit(record.value);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue