1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-09 09:34:57 +09:00

LibWeb/IDB: Resolve FIXME regarding removing from indecies

This commit is contained in:
stelar7 2025-05-13 23:09:28 +02:00 committed by Jelle Raaijmakers
parent 46ecf239c4
commit 13674c1b32
Notes: github-actions[bot] 2025-05-14 15:18:50 +00:00
3 changed files with 12 additions and 1 deletions

View file

@ -1318,7 +1318,10 @@ JS::Value delete_records_from_an_object_store(GC::Ref<ObjectStore> store, GC::Re
// 1. Remove all records, if any, from stores list of records with key in range.
store->remove_records_in_range(range);
// FIXME: 2. For each index which references store, remove every record from indexs list of records whose value is in range, if any such records exist.
// 2. For each index which references store, remove every record from indexs list of records whose value is in range, if any such records exist.
for (auto const& [name, index] : store->index_set()) {
index->remove_records_with_value_in_range(range);
}
// 3. Return undefined.
return JS::js_undefined();

View file

@ -122,4 +122,11 @@ void Index::store_a_record(IndexRecord const& record)
});
}
void Index::remove_records_with_value_in_range(GC::Ref<IDBKeyRange> range)
{
m_records.remove_all_matching([&](auto const& record) {
return range->is_in_range(record.value);
});
}
}

View file

@ -45,6 +45,7 @@ public:
GC::ConservativeVector<IndexRecord> first_n_in_range(GC::Ref<IDBKeyRange> range, Optional<WebIDL::UnsignedLong> count);
u64 count_records_in_range(GC::Ref<IDBKeyRange> range);
void store_a_record(IndexRecord const& record);
void remove_records_with_value_in_range(GC::Ref<IDBKeyRange> range);
HTML::SerializationRecord referenced_value(IndexRecord const& index_record) const;