diff --git a/Libraries/LibWeb/IndexedDB/IDBCursor.cpp b/Libraries/LibWeb/IndexedDB/IDBCursor.cpp index 6d90608c32c..76aa530eabf 100644 --- a/Libraries/LibWeb/IndexedDB/IDBCursor.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBCursor.cpp @@ -16,20 +16,20 @@ GC_DEFINE_ALLOCATOR(IDBCursor); IDBCursor::~IDBCursor() = default; -IDBCursor::IDBCursor(JS::Realm& realm, CursorSourceHandle source_handle, GC::Ptr position, Bindings::IDBCursorDirection direction, bool got_value, GC::Ptr key, JS::Value value, GC::Ref range, bool key_only) +IDBCursor::IDBCursor(JS::Realm& realm, CursorSourceHandle source_handle, GC::Ptr position, Bindings::IDBCursorDirection direction, GotValue got_value, GC::Ptr key, JS::Value value, GC::Ref range, KeyOnly key_only) : PlatformObject(realm) , m_position(position) , m_direction(direction) - , m_got_value(got_value) + , m_got_value(got_value == GotValue::Yes) , m_key(key) , m_value(value) , m_source_handle(source_handle) , m_range(range) - , m_key_only(key_only) + , m_key_only(key_only == KeyOnly::Yes) { } -GC::Ref IDBCursor::create(JS::Realm& realm, CursorSourceHandle source_handle, GC::Ptr position, Bindings::IDBCursorDirection direction, bool got_value, GC::Ptr key, JS::Value value, GC::Ref range, bool key_only) +GC::Ref IDBCursor::create(JS::Realm& realm, CursorSourceHandle source_handle, GC::Ptr position, Bindings::IDBCursorDirection direction, GotValue got_value, GC::Ptr key, JS::Value value, GC::Ref range, KeyOnly key_only) { return realm.create(realm, source_handle, position, direction, got_value, key, value, range, key_only); } diff --git a/Libraries/LibWeb/IndexedDB/IDBCursor.h b/Libraries/LibWeb/IndexedDB/IDBCursor.h index 70785b0b3c3..a18da8f3b89 100644 --- a/Libraries/LibWeb/IndexedDB/IDBCursor.h +++ b/Libraries/LibWeb/IndexedDB/IDBCursor.h @@ -25,9 +25,19 @@ class IDBCursor : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(IDBCursor, Bindings::PlatformObject); GC_DECLARE_ALLOCATOR(IDBCursor); + enum class GotValue { + No, + Yes, + }; + + enum class KeyOnly { + No, + Yes, + }; + public: virtual ~IDBCursor() override; - [[nodiscard]] static GC::Ref create(JS::Realm&, CursorSourceHandle, GC::Ptr, Bindings::IDBCursorDirection, bool, GC::Ptr, JS::Value, GC::Ref, bool); + [[nodiscard]] static GC::Ref create(JS::Realm&, CursorSourceHandle, GC::Ptr, Bindings::IDBCursorDirection, GotValue, GC::Ptr, JS::Value, GC::Ref, KeyOnly); [[nodiscard]] CursorSourceHandle source_handle() { return m_source_handle; } [[nodiscard]] Bindings::IDBCursorDirection direction() { return m_direction; } @@ -55,7 +65,7 @@ public: WebIDL::ExceptionOr continue_(JS::Value); protected: - explicit IDBCursor(JS::Realm&, CursorSourceHandle, GC::Ptr, Bindings::IDBCursorDirection, bool, GC::Ptr, JS::Value, GC::Ref, bool); + explicit IDBCursor(JS::Realm&, CursorSourceHandle, GC::Ptr, Bindings::IDBCursorDirection, GotValue, GC::Ptr, JS::Value, GC::Ref, KeyOnly); virtual void initialize(JS::Realm&) override; virtual void visit_edges(Visitor& visitor) override; diff --git a/Libraries/LibWeb/IndexedDB/IDBIndex.cpp b/Libraries/LibWeb/IndexedDB/IDBIndex.cpp index cc8e40e2c26..d63ec66a34c 100644 --- a/Libraries/LibWeb/IndexedDB/IDBIndex.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBIndex.cpp @@ -123,7 +123,7 @@ WebIDL::ExceptionOr> IDBIndex::open_cursor(JS::Value query, auto range = TRY(convert_a_value_to_a_key_range(realm, query)); // 6. Let cursor be a new cursor with its source handle set to this, undefined position, direction set to direction, got value flag set to false, undefined key and value, range set to range, and key only flag set to false. - auto cursor = IDBCursor::create(realm, GC::Ref(*this), {}, direction, false, {}, {}, range, false); + auto cursor = IDBCursor::create(realm, GC::Ref(*this), {}, direction, IDBCursor::GotValue::No, {}, {}, range, IDBCursor::KeyOnly::No); // 7. Let operation be an algorithm to run iterate a cursor with the current Realm record and cursor. auto operation = GC::Function()>::create(realm.heap(), [&realm, cursor] -> WebIDL::ExceptionOr { diff --git a/Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp b/Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp index 63d5ece9902..3a1528e5339 100644 --- a/Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp +++ b/Libraries/LibWeb/IndexedDB/IDBObjectStore.cpp @@ -442,7 +442,7 @@ WebIDL::ExceptionOr> IDBObjectStore::open_cursor(JS::Value q // 6. Let cursor be a new cursor with its source handle set to this, undefined position, direction set to direction, // got value flag set to false, undefined key and value, range set to range, and key only flag set to false. - auto cursor = IDBCursor::create(realm, GC::Ref(*this), {}, direction, false, {}, {}, range, false); + auto cursor = IDBCursor::create(realm, GC::Ref(*this), {}, direction, IDBCursor::GotValue::No, {}, {}, range, IDBCursor::KeyOnly::No); // 7. Let operation be an algorithm to run iterate a cursor with the current Realm record and cursor. auto operation = GC::Function()>::create(realm.heap(), [&realm, cursor] -> WebIDL::ExceptionOr { @@ -610,7 +610,7 @@ WebIDL::ExceptionOr> IDBObjectStore::open_key_cursor(JS::Val auto range = TRY(convert_a_value_to_a_key_range(realm, query)); // 6. Let cursor be a new cursor with its source handle set to this, undefined position, direction set to direction, got value flag set to false, undefined key and value, range set to range, and key only flag set to true. - auto cursor = IDBCursor::create(realm, GC::Ref(*this), {}, direction, false, {}, {}, range, true); + auto cursor = IDBCursor::create(realm, GC::Ref(*this), {}, direction, IDBCursor::GotValue::No, {}, {}, range, IDBCursor::KeyOnly::Yes); // 7. Let operation be an algorithm to run iterate a cursor with the current Realm record and cursor. auto operation = GC::Function()>::create(realm.heap(), [&realm, cursor] -> WebIDL::ExceptionOr {