mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-29 12:19:54 +00:00
LibWeb/IDB: Implement IDBCursor::effective_key
This commit is contained in:
parent
f996fb9d80
commit
141093e032
Notes:
github-actions[bot]
2025-05-08 13:14:58 +00:00
Author: https://github.com/stelar7
Commit: 141093e032
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4650
Reviewed-by: https://github.com/AtkinsSJ ✅
2 changed files with 15 additions and 0 deletions
|
@ -148,4 +148,18 @@ WebIDL::ExceptionOr<void> IDBCursor::continue_(JS::Value key)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// https://w3c.github.io/IndexedDB/#cursor-effective-key
|
||||||
|
[[nodiscard]] GC::Ref<Key> IDBCursor::effective_key() const
|
||||||
|
{
|
||||||
|
return m_source_handle.visit(
|
||||||
|
[&](GC::Ref<IDBObjectStore>) -> GC::Ref<Key> {
|
||||||
|
// If the source of a cursor is an object store, the effective key of the cursor is the cursor’s position
|
||||||
|
return *m_position;
|
||||||
|
},
|
||||||
|
[&](GC::Ref<IDBIndex>) -> GC::Ref<Key> {
|
||||||
|
// If the source of a cursor is an index, the effective key is the cursor’s object store position.
|
||||||
|
return *m_object_store_position;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,7 @@ public:
|
||||||
|
|
||||||
[[nodiscard]] GC::Ref<IDBTransaction> transaction();
|
[[nodiscard]] GC::Ref<IDBTransaction> transaction();
|
||||||
[[nodiscard]] CursorSource internal_source();
|
[[nodiscard]] CursorSource internal_source();
|
||||||
|
[[nodiscard]] GC::Ref<Key> effective_key() const;
|
||||||
|
|
||||||
void set_request(GC::Ptr<IDBRequest> request) { m_request = request; }
|
void set_request(GC::Ptr<IDBRequest> request) { m_request = request; }
|
||||||
void set_position(GC::Ptr<Key> position) { m_position = position; }
|
void set_position(GC::Ptr<Key> position) { m_position = position; }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue