Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 3adac8a5320e8d4ebf7b0ca230da312fa1b08236
      
https://github.com/WebKit/WebKit/commit/3adac8a5320e8d4ebf7b0ca230da312fa1b08236
  Author: Rupin Mittal <[email protected]>
  Date:   2026-04-09 (Thu, 09 Apr 2026)

  Changed paths:
    M Source/WebCore/Modules/indexeddb/IDBGetAllOptions.cpp
    M Source/WebCore/Modules/indexeddb/IDBGetAllOptions.h
    M Source/WebCore/Modules/indexeddb/IDBIndex.cpp
    M Source/WebCore/Modules/indexeddb/IDBIndex.h
    M Source/WebCore/Modules/indexeddb/IDBIndex.idl
    M Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp
    M Source/WebCore/Modules/indexeddb/IDBKeyRange.h
    M Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
    M Source/WebCore/Modules/indexeddb/IDBObjectStore.h
    M Source/WebCore/Modules/indexeddb/IDBObjectStore.idl

  Log Message:
  -----------
  [IndexedDB API] Consolidate the parsing logic in getAll* functions
https://bugs.webkit.org/show_bug.cgi?id=311455
rdar://174054869

Reviewed by Sihui Liu.

The functions getAll() / getAllKeys() / getAllRecords() all follow these steps:
https://w3c.github.io/IndexedDB/#create-a-request-to-retrieve-multiple-items.

The inputs to getAll() and getAllKeys() are JSValues that can be many different
things: undefined, IDBKey, IDBKeyRange, or IDBGetAllOptions. To parse their
input, they use steps 8 and 9 of the above algorithm.

The input to getAllRecords() may only be IDBGetAllOptions. So this uses only
step 9 of the algorithm.

The current implementation scatters and duplicates the implementations of these
two steps:

1. Both steps run 
https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key-range.
   But there is no central implementation that they both call.

   getAll() / getAllKeys implement this by having two different overloads so the
   bindings code can do part of the algorithm. But they must still do the rest.
   getAllRecords() implements the whole algorithm.

2. The implementations of all three functions in their scattered forms are all
   duplicated in IDBIndex and IDBObjectStore.

To fix this, we:

1. Introduce a single implementation of
   https://w3c.github.io/IndexedDB/#convert-a-value-to-a-key-range.

   Implemented in IDBKeyRange::fromValue().

2. Formalize the concept of an unbounded key range. Up to now, we have been 
relying
   on the fact that a IDBKeyRangeData created from a nullptr IDBKeyRange is 
basically
   an unbounded key range. This is error prone.

   Implemented in IDBKeyRange::unbounded().

3. Use IDBKeyRange::fromValue() in Step 9 of the algorithm (parsing 
IDBGetAllOptions)

   Implemented in parseGetAllOptions().

4. Encapsulate Steps 8 and 9 -- parsing a queryOrOptions (which can be any of 
the
   mulitple input types noted above) into one function by using the above 
functions.

   Implemented in parseQueryOrOptions().

5. Consolidate getAll() and getAllKeys() to each use a single function instead 
of two
   overloads by calling parseQueryOrOptions(). This is done in both IDBIndex and
   IDBObjectStore.

6. Simplify getAllRecords() to just calling parseGetAllOptions(). This is done 
in both
   IDBIndex and IDBObjectStore.

There is no behavior change. This is covered by existing tests.

* Source/WebCore/Modules/indexeddb/IDBGetAllOptions.cpp:
(WebCore::parseQueryOrOptions):
(WebCore::parseGetAllOptions):
* Source/WebCore/Modules/indexeddb/IDBGetAllOptions.h:
* Source/WebCore/Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::doGetAllShared):
(WebCore::IDBIndex::getAll):
(WebCore::IDBIndex::getAllKeys):
(WebCore::IDBIndex::getAllRecords):
* Source/WebCore/Modules/indexeddb/IDBIndex.h:
* Source/WebCore/Modules/indexeddb/IDBIndex.idl:
* Source/WebCore/Modules/indexeddb/IDBKeyRange.cpp:
(WebCore::IDBKeyRange::fromValue):
(WebCore::IDBKeyRange::unbounded):
* Source/WebCore/Modules/indexeddb/IDBKeyRange.h:
* Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::doGetAllShared):
(WebCore::IDBObjectStore::getAll):
(WebCore::IDBObjectStore::getAllKeys):
(WebCore::IDBObjectStore::getAllRecords):
* Source/WebCore/Modules/indexeddb/IDBObjectStore.h:
* Source/WebCore/Modules/indexeddb/IDBObjectStore.idl:

Canonical link: https://commits.webkit.org/310848@main



To unsubscribe from these emails, change your notification settings at 
https://github.com/WebKit/WebKit/settings/notifications

Reply via email to