[WebIDL] Remove (most) custom bindings for the IndexedDB code
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Dec 2016 01:33:33 +0000 (01:33 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Dec 2016 01:33:33 +0000 (01:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=166451

Reviewed by Darin Adler.

Source/WebCore:

Removes the custom bindings for all but one attribute (IDBRequest.result) in
the IndexedDB code.
- Adds a new WebIDL extension type, IDBKey, to represent the complex key conversion
  rules IndexedDB specifies.
- Replaces custom bindings for IDBCursor.source with use of a union.
- Replaces custom enum type checking for IDBCursor.direction with a WebIDL enum.
- Replaces custom code generation for IDBKeyPaths with a union.

* CMakeLists.txt:
* DerivedSources.make:
* WebCore.xcodeproj/project.pbxproj:
Add new files.

* Modules/indexeddb/IDBCursor.cpp:
(WebCore::IDBCursor::source):
(WebCore::IDBCursor::direction):
(WebCore::IDBCursor::directionNext): Deleted.
(WebCore::IDBCursor::directionNextUnique): Deleted.
(WebCore::IDBCursor::directionPrev): Deleted.
(WebCore::IDBCursor::directionPrevUnique): Deleted.
(WebCore::IDBCursor::stringToDirection): Deleted.
(WebCore::IDBCursor::directionToString): Deleted.
* Modules/indexeddb/IDBCursor.h:
(WebCore::IDBCursor::objectStore): Deleted.
(WebCore::IDBCursor::index): Deleted.
Replace custom enum checking with direct use of the enum, letting the generator
handle the checks. Also adds source function which returns a Variant.

* Modules/indexeddb/IDBCursor.idl:
Remove custom annotation and use correct types.

* Modules/indexeddb/IDBCursorDirection.h: Added.
* Modules/indexeddb/IDBCursorDirection.idl: Added.

* Modules/indexeddb/IDBIndex.cpp:
(WebCore::IDBIndex::openCursor):
(WebCore::IDBIndex::openKeyCursor):
* Modules/indexeddb/IDBIndex.h:
* Modules/indexeddb/IDBIndex.idl:
* Modules/indexeddb/IDBObjectStore.cpp:
(WebCore::IDBObjectStore::openCursor):
(WebCore::IDBObjectStore::openKeyCursor):
* Modules/indexeddb/IDBObjectStore.h:
* Modules/indexeddb/IDBObjectStore.idl:
Replace Strings with IDBCursorDirection enums.

* Modules/indexeddb/IDBKeyRange.idl:
Remove annotation and use new IDBKey extension type.

* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::onSuccess):
(WebCore::IDBOpenDBRequest::onUpgradeNeeded):
(WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
Use ReadyState enum in place of the old m_isDone boolean.

* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::IDBRequest):
(WebCore::IDBRequest::error):
(WebCore::IDBRequest::source):
(WebCore::IDBRequest::dispatchEvent):
(WebCore::IDBRequest::willIterateCursor):
(WebCore::IDBRequest::completeRequestAndDispatchEvent):
(WebCore::IDBRequest::readyState): Deleted.
* Modules/indexeddb/IDBRequest.h:
(WebCore::IDBRequest::readyState):
(WebCore::IDBRequest::isDone):
(WebCore::IDBRequest::objectStoreSource): Deleted.
(WebCore::IDBRequest::indexSource): Deleted.
(WebCore::IDBRequest::cursorSource): Deleted.
* Modules/indexeddb/IDBRequest.idl:
Replace the readyState String with a enum, and the custom source binding with a
source function that returns a Variant.

* Modules/indexeddb/IndexedDB.h:
Add the missing values to CursorDirection to make it comply with the IDL definition.

* bindings/generic/IDLTypes.h:
* bindings/js/JSDOMConvert.h:
(WebCore::JSConverter<IDLIDBKey<T>>::convert):
Add new extension type IDLIDBKey.

* bindings/js/JSIDBCursorCustom.cpp:
(WebCore::JSIDBCursor::source): Deleted.
* bindings/js/JSIDBRequestCustom.cpp:
(WebCore::JSIDBRequest::source): Deleted.
Remove custom bindings.

* bindings/scripts/CodeGenerator.pm:
(IsBuiltinType):
* bindings/scripts/CodeGeneratorJS.pm:
(GetBaseIDLType):
(NativeToJSValueDOMConvertNeedsState):
(NativeToJSValueDOMConvertNeedsGlobalObject):
(NativeToJSValue):
Add support for IDBKey, and remove custom code for IndexedDB in core conversion logic.

* bindings/scripts/IDLAttributes.txt:
Remove now unused ImplementationReturnType attribute.

* inspector/InspectorIndexedDBAgent.cpp:
Update to work with new functions taking enums rather than strings.

LayoutTests:

* storage/indexeddb/exceptions-expected.txt:
* storage/indexeddb/exceptions-private-expected.txt:
* storage/indexeddb/index-basics-expected.txt:
* storage/indexeddb/index-basics-private-expected.txt:
* storage/indexeddb/index-basics-workers-expected.txt:
* storage/indexeddb/objectstore-cursor-expected.txt:
* storage/indexeddb/objectstore-cursor-private-expected.txt:
Update results for improved exception messages.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@210148 268f45cc-cd09-0410-ab3c-d52691b4dbfc

40 files changed:
LayoutTests/ChangeLog
LayoutTests/storage/indexeddb/exceptions-expected.txt
LayoutTests/storage/indexeddb/exceptions-private-expected.txt
LayoutTests/storage/indexeddb/index-basics-expected.txt
LayoutTests/storage/indexeddb/index-basics-private-expected.txt
LayoutTests/storage/indexeddb/index-basics-workers-expected.txt
LayoutTests/storage/indexeddb/objectstore-cursor-expected.txt
LayoutTests/storage/indexeddb/objectstore-cursor-private-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/DerivedSources.make
Source/WebCore/Modules/indexeddb/IDBCursor.cpp
Source/WebCore/Modules/indexeddb/IDBCursor.h
Source/WebCore/Modules/indexeddb/IDBCursor.idl
Source/WebCore/Modules/indexeddb/IDBCursorDirection.h [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/IDBCursorDirection.idl [new file with mode: 0644]
Source/WebCore/Modules/indexeddb/IDBIndex.cpp
Source/WebCore/Modules/indexeddb/IDBIndex.h
Source/WebCore/Modules/indexeddb/IDBIndex.idl
Source/WebCore/Modules/indexeddb/IDBKeyRange.idl
Source/WebCore/Modules/indexeddb/IDBObjectStore.cpp
Source/WebCore/Modules/indexeddb/IDBObjectStore.h
Source/WebCore/Modules/indexeddb/IDBObjectStore.idl
Source/WebCore/Modules/indexeddb/IDBOpenDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.cpp
Source/WebCore/Modules/indexeddb/IDBRequest.h
Source/WebCore/Modules/indexeddb/IDBRequest.idl
Source/WebCore/Modules/indexeddb/IndexedDB.h
Source/WebCore/Modules/indexeddb/server/MemoryIndexCursor.cpp
Source/WebCore/Modules/indexeddb/server/SQLiteIDBCursor.cpp
Source/WebCore/Modules/indexeddb/shared/IDBCursorInfo.cpp
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/generic/IDLTypes.h
Source/WebCore/bindings/js/JSDOMConvert.h
Source/WebCore/bindings/js/JSIDBCursorCustom.cpp
Source/WebCore/bindings/js/JSIDBRequestCustom.cpp
Source/WebCore/bindings/scripts/CodeGenerator.pm
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.txt
Source/WebCore/inspector/InspectorIndexedDBAgent.cpp

index e7e3d18..789635b 100644 (file)
@@ -1,3 +1,19 @@
+2016-12-25  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove (most) custom bindings for the IndexedDB code
+        https://bugs.webkit.org/show_bug.cgi?id=166451
+
+        Reviewed by Darin Adler.
+
+        * storage/indexeddb/exceptions-expected.txt:
+        * storage/indexeddb/exceptions-private-expected.txt:
+        * storage/indexeddb/index-basics-expected.txt:
+        * storage/indexeddb/index-basics-private-expected.txt:
+        * storage/indexeddb/index-basics-workers-expected.txt:
+        * storage/indexeddb/objectstore-cursor-expected.txt:
+        * storage/indexeddb/objectstore-cursor-private-expected.txt:
+        Update results for improved exception messages.
+
 2016-12-23  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r209299): Selection is broken when you zoom in webpage using trackpad
index 7f94dff..c4116a9 100644 (file)
@@ -253,7 +253,7 @@ Exception message: Failed to execute 'openCursor' on 'IDBObjectStore': The trans
 The value for the direction parameter is invalid.
 Expecting TypeError exception from store.openCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS store.openCursor(0, 'invalid-direction') threw TypeError: Type error
+PASS store.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBObjectStore.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 IDBObjectStore.put()
 This method throws a DOMException of type ReadOnlyError if the transaction which this IDBObjectStore belongs to is has its mode set to "readonly".
@@ -390,7 +390,7 @@ Exception message: Failed to execute 'openCursor' on 'IDBIndex': The transaction
 The value for the direction parameter is invalid.
 Expecting TypeError exception from index.openCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS index.openCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS index.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 IDBIndex.openKeyCursor()
 If the range parameter is specified but is not a valid key or a key range, this method throws a DOMException of type DataError.
@@ -408,7 +408,7 @@ Exception message: Failed to execute 'openKeyCursor' on 'IDBIndex': The transact
 The value for the direction parameter is invalid.
 Expecting TypeError exception from index.openKeyCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS index.openKeyCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openKeyCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS index.openKeyCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openKeyCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 3.2.7 Cursor
 transaction = db.transaction(['store', 'inlineKeyStore'], 'readwrite')
index 7f94dff..c4116a9 100644 (file)
@@ -253,7 +253,7 @@ Exception message: Failed to execute 'openCursor' on 'IDBObjectStore': The trans
 The value for the direction parameter is invalid.
 Expecting TypeError exception from store.openCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS store.openCursor(0, 'invalid-direction') threw TypeError: Type error
+PASS store.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBObjectStore.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 IDBObjectStore.put()
 This method throws a DOMException of type ReadOnlyError if the transaction which this IDBObjectStore belongs to is has its mode set to "readonly".
@@ -390,7 +390,7 @@ Exception message: Failed to execute 'openCursor' on 'IDBIndex': The transaction
 The value for the direction parameter is invalid.
 Expecting TypeError exception from index.openCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS index.openCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS index.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 IDBIndex.openKeyCursor()
 If the range parameter is specified but is not a valid key or a key range, this method throws a DOMException of type DataError.
@@ -408,7 +408,7 @@ Exception message: Failed to execute 'openKeyCursor' on 'IDBIndex': The transact
 The value for the direction parameter is invalid.
 Expecting TypeError exception from index.openKeyCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS index.openKeyCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openKeyCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS index.openKeyCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openKeyCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 3.2.7 Cursor
 transaction = db.transaction(['store', 'inlineKeyStore'], 'readwrite')
index 8022699..2015343 100644 (file)
@@ -69,7 +69,7 @@ PASS event.target.result is "key2"
 Verify that specifying an invalid direction raises an exception:
 Expecting TypeError exception from indexObject.openKeyCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS indexObject.openKeyCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openKeyCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS indexObject.openKeyCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openKeyCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 indexObject.openKeyCursor()
 PASS event.target.source is indexObject
@@ -94,7 +94,7 @@ PASS event.target.result is null
 Verify that specifying an invalid direction raises an exception:
 Expecting TypeError exception from indexObject.openCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS indexObject.openCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS indexObject.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 indexObject.openCursor()
 PASS event.target.source is indexObject
index 8022699..2015343 100644 (file)
@@ -69,7 +69,7 @@ PASS event.target.result is "key2"
 Verify that specifying an invalid direction raises an exception:
 Expecting TypeError exception from indexObject.openKeyCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS indexObject.openKeyCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openKeyCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS indexObject.openKeyCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openKeyCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 indexObject.openKeyCursor()
 PASS event.target.source is indexObject
@@ -94,7 +94,7 @@ PASS event.target.result is null
 Verify that specifying an invalid direction raises an exception:
 Expecting TypeError exception from indexObject.openCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS indexObject.openCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS indexObject.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 indexObject.openCursor()
 PASS event.target.source is indexObject
index ab9b565..a320648 100644 (file)
@@ -70,7 +70,7 @@ PASS [Worker] event.target.result is "key2"
 [Worker] Verify that specifying an invalid direction raises an exception:
 [Worker] Expecting TypeError exception from indexObject.openKeyCursor(0, 'invalid-direction')
 PASS [Worker] Exception was thrown.
-PASS [Worker] indexObject.openKeyCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openKeyCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS [Worker] indexObject.openKeyCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openKeyCursor must be one of: "next", "nextunique", "prev", "prevunique"
 [Worker] 
 [Worker] indexObject.openKeyCursor()
 PASS [Worker] event.target.source is indexObject
@@ -95,7 +95,7 @@ PASS [Worker] event.target.result is null
 [Worker] Verify that specifying an invalid direction raises an exception:
 [Worker] Expecting TypeError exception from indexObject.openCursor(0, 'invalid-direction')
 PASS [Worker] Exception was thrown.
-PASS [Worker] indexObject.openCursor(0, 'invalid-direction') threw TypeError: Failed to execute 'openCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.
+PASS [Worker] indexObject.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBIndex.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 [Worker] 
 [Worker] indexObject.openCursor()
 PASS [Worker] event.target.source is indexObject
index 508eb7a..6eff3da 100644 (file)
@@ -12,7 +12,7 @@ objectStore = db.createObjectStore('someObjectStore')
 Verify that specifying an invalid direction raises an exception:
 Expecting TypeError exception from objectStore.openCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS objectStore.openCursor(0, 'invalid-direction') threw TypeError: Type error
+PASS objectStore.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBObjectStore.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 objectStore.add('', testData[nextToAdd])
 objectStore.add('', testData[nextToAdd])
index 508eb7a..6eff3da 100644 (file)
@@ -12,7 +12,7 @@ objectStore = db.createObjectStore('someObjectStore')
 Verify that specifying an invalid direction raises an exception:
 Expecting TypeError exception from objectStore.openCursor(0, 'invalid-direction')
 PASS Exception was thrown.
-PASS objectStore.openCursor(0, 'invalid-direction') threw TypeError: Type error
+PASS objectStore.openCursor(0, 'invalid-direction') threw TypeError: Argument 2 ('direction') to IDBObjectStore.openCursor must be one of: "next", "nextunique", "prev", "prevunique"
 
 objectStore.add('', testData[nextToAdd])
 objectStore.add('', testData[nextToAdd])
index 679d8eb..de41713 100644 (file)
@@ -182,6 +182,7 @@ set(WebCore_NON_SVG_IDL_FILES
 
     Modules/indexeddb/DOMWindowIndexedDatabase.idl
     Modules/indexeddb/IDBCursor.idl
+    Modules/indexeddb/IDBCursorDirection.idl
     Modules/indexeddb/IDBCursorWithValue.idl
     Modules/indexeddb/IDBDatabase.idl
     Modules/indexeddb/IDBFactory.idl
index 847e2c1..ae21407 100644 (file)
@@ -1,3 +1,112 @@
+2016-12-24  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove (most) custom bindings for the IndexedDB code
+        https://bugs.webkit.org/show_bug.cgi?id=166451
+
+        Reviewed by Darin Adler.
+
+        Removes the custom bindings for all but one attribute (IDBRequest.result) in
+        the IndexedDB code.
+        - Adds a new WebIDL extension type, IDBKey, to represent the complex key conversion
+          rules IndexedDB specifies.
+        - Replaces custom bindings for IDBCursor.source with use of a union.
+        - Replaces custom enum type checking for IDBCursor.direction with a WebIDL enum.
+        - Replaces custom code generation for IDBKeyPaths with a union.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * WebCore.xcodeproj/project.pbxproj:
+        Add new files.
+
+        * Modules/indexeddb/IDBCursor.cpp:
+        (WebCore::IDBCursor::source):
+        (WebCore::IDBCursor::direction):
+        (WebCore::IDBCursor::directionNext): Deleted.
+        (WebCore::IDBCursor::directionNextUnique): Deleted.
+        (WebCore::IDBCursor::directionPrev): Deleted.
+        (WebCore::IDBCursor::directionPrevUnique): Deleted.
+        (WebCore::IDBCursor::stringToDirection): Deleted.
+        (WebCore::IDBCursor::directionToString): Deleted.
+        * Modules/indexeddb/IDBCursor.h:
+        (WebCore::IDBCursor::objectStore): Deleted.
+        (WebCore::IDBCursor::index): Deleted.
+        Replace custom enum checking with direct use of the enum, letting the generator
+        handle the checks. Also adds source function which returns a Variant.
+
+        * Modules/indexeddb/IDBCursor.idl:
+        Remove custom annotation and use correct types.
+
+        * Modules/indexeddb/IDBCursorDirection.h: Added.
+        * Modules/indexeddb/IDBCursorDirection.idl: Added.
+
+        * Modules/indexeddb/IDBIndex.cpp:
+        (WebCore::IDBIndex::openCursor):
+        (WebCore::IDBIndex::openKeyCursor):
+        * Modules/indexeddb/IDBIndex.h:
+        * Modules/indexeddb/IDBIndex.idl:
+        * Modules/indexeddb/IDBObjectStore.cpp:
+        (WebCore::IDBObjectStore::openCursor):
+        (WebCore::IDBObjectStore::openKeyCursor):
+        * Modules/indexeddb/IDBObjectStore.h:
+        * Modules/indexeddb/IDBObjectStore.idl:
+        Replace Strings with IDBCursorDirection enums.
+
+        * Modules/indexeddb/IDBKeyRange.idl:
+        Remove annotation and use new IDBKey extension type.
+
+        * Modules/indexeddb/IDBOpenDBRequest.cpp:
+        (WebCore::IDBOpenDBRequest::onSuccess):
+        (WebCore::IDBOpenDBRequest::onUpgradeNeeded):
+        (WebCore::IDBOpenDBRequest::onDeleteDatabaseSuccess):
+        Use ReadyState enum in place of the old m_isDone boolean.
+
+        * Modules/indexeddb/IDBRequest.cpp:
+        (WebCore::IDBRequest::IDBRequest):
+        (WebCore::IDBRequest::error):
+        (WebCore::IDBRequest::source):
+        (WebCore::IDBRequest::dispatchEvent):
+        (WebCore::IDBRequest::willIterateCursor):
+        (WebCore::IDBRequest::completeRequestAndDispatchEvent):
+        (WebCore::IDBRequest::readyState): Deleted.
+        * Modules/indexeddb/IDBRequest.h:
+        (WebCore::IDBRequest::readyState):
+        (WebCore::IDBRequest::isDone):
+        (WebCore::IDBRequest::objectStoreSource): Deleted.
+        (WebCore::IDBRequest::indexSource): Deleted.
+        (WebCore::IDBRequest::cursorSource): Deleted.
+        * Modules/indexeddb/IDBRequest.idl:
+        Replace the readyState String with a enum, and the custom source binding with a
+        source function that returns a Variant.
+
+        * Modules/indexeddb/IndexedDB.h:
+        Add the missing values to CursorDirection to make it comply with the IDL definition.
+
+        * bindings/generic/IDLTypes.h:
+        * bindings/js/JSDOMConvert.h:
+        (WebCore::JSConverter<IDLIDBKey<T>>::convert):
+        Add new extension type IDLIDBKey.
+
+        * bindings/js/JSIDBCursorCustom.cpp:
+        (WebCore::JSIDBCursor::source): Deleted.
+        * bindings/js/JSIDBRequestCustom.cpp:
+        (WebCore::JSIDBRequest::source): Deleted.
+        Remove custom bindings.
+
+        * bindings/scripts/CodeGenerator.pm:
+        (IsBuiltinType):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GetBaseIDLType):
+        (NativeToJSValueDOMConvertNeedsState):
+        (NativeToJSValueDOMConvertNeedsGlobalObject):
+        (NativeToJSValue):
+        Add support for IDBKey, and remove custom code for IndexedDB in core conversion logic.
+
+        * bindings/scripts/IDLAttributes.txt:
+        Remove now unused ImplementationReturnType attribute.
+
+        * inspector/InspectorIndexedDBAgent.cpp:
+        Update to work with new functions taking enums rather than strings.
+
 2016-12-23  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION (r209299): Selection is broken when you zoom in webpage using trackpad
index 470b7c8..b57d729 100644 (file)
@@ -126,6 +126,7 @@ JS_BINDING_IDLS = \
     $(WebCore)/Modules/geolocation/PositionOptions.idl \
     $(WebCore)/Modules/indexeddb/DOMWindowIndexedDatabase.idl \
     $(WebCore)/Modules/indexeddb/IDBCursor.idl \
+    $(WebCore)/Modules/indexeddb/IDBCursorDirection.idl \
     $(WebCore)/Modules/indexeddb/IDBCursorWithValue.idl \
     $(WebCore)/Modules/indexeddb/IDBDatabase.idl \
     $(WebCore)/Modules/indexeddb/IDBFactory.idl \
index f12afc8..a09548f 100644 (file)
 #include <heap/HeapInlines.h>
 #include <heap/StrongInlines.h>
 #include <runtime/JSCJSValueInlines.h>
-#include <wtf/NeverDestroyed.h>
 
 using namespace JSC;
 
 namespace WebCore {
 
-const AtomicString& IDBCursor::directionNext()
-{
-    static NeverDestroyed<AtomicString> next("next", AtomicString::ConstructFromLiteral);
-    return next;
-}
-
-const AtomicString& IDBCursor::directionNextUnique()
-{
-    static NeverDestroyed<AtomicString> nextunique("nextunique", AtomicString::ConstructFromLiteral);
-    return nextunique;
-}
-
-const AtomicString& IDBCursor::directionPrev()
-{
-    static NeverDestroyed<AtomicString> prev("prev", AtomicString::ConstructFromLiteral);
-    return prev;
-}
-
-const AtomicString& IDBCursor::directionPrevUnique()
-{
-    static NeverDestroyed<AtomicString> prevunique("prevunique", AtomicString::ConstructFromLiteral);
-    return prevunique;
-}
-
-std::optional<IndexedDB::CursorDirection> IDBCursor::stringToDirection(const String& directionString)
-{
-    if (directionString == directionNext())
-        return IndexedDB::CursorDirection::Next;
-    if (directionString == directionNextUnique())
-        return IndexedDB::CursorDirection::NextNoDuplicate;
-    if (directionString == directionPrev())
-        return IndexedDB::CursorDirection::Prev;
-    if (directionString == directionPrevUnique())
-        return IndexedDB::CursorDirection::PrevNoDuplicate;
-
-    return std::nullopt;
-}
-
-const AtomicString& IDBCursor::directionToString(IndexedDB::CursorDirection direction)
-{
-    switch (direction) {
-    case IndexedDB::CursorDirection::Next:
-        return directionNext();
-
-    case IndexedDB::CursorDirection::NextNoDuplicate:
-        return directionNextUnique();
-
-    case IndexedDB::CursorDirection::Prev:
-        return directionPrev();
-
-    case IndexedDB::CursorDirection::PrevNoDuplicate:
-        return directionPrevUnique();
-
-    default:
-        ASSERT_NOT_REACHED();
-        return directionNext();
-    }
-}
-
 Ref<IDBCursor> IDBCursor::create(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
 {
     return adoptRef(*new IDBCursor(transaction, objectStore, info));
@@ -121,7 +61,7 @@ Ref<IDBCursor> IDBCursor::create(IDBTransaction& transaction, IDBIndex& index, c
 IDBCursor::IDBCursor(IDBTransaction& transaction, IDBObjectStore& objectStore, const IDBCursorInfo& info)
     : ActiveDOMObject(transaction.scriptExecutionContext())
     , m_info(info)
-    , m_objectStore(&objectStore)
+    , m_source(&objectStore)
 {
     ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
 
@@ -131,7 +71,7 @@ IDBCursor::IDBCursor(IDBTransaction& transaction, IDBObjectStore& objectStore, c
 IDBCursor::IDBCursor(IDBTransaction& transaction, IDBIndex& index, const IDBCursorInfo& info)
     : ActiveDOMObject(transaction.scriptExecutionContext())
     , m_info(info)
-    , m_index(&index)
+    , m_source(&index)
 {
     ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
 
@@ -147,20 +87,18 @@ bool IDBCursor::sourcesDeleted() const
 {
     ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
 
-    if (m_objectStore)
-        return m_objectStore->isDeleted();
-
-    ASSERT(m_index);
-    return m_index->isDeleted() || m_index->objectStore().isDeleted();
+    return WTF::switchOn(m_source,
+        [] (const RefPtr<IDBObjectStore>& objectStore) { return objectStore->isDeleted(); },
+        [] (const RefPtr<IDBIndex>& index) { return index->isDeleted() || index->objectStore().isDeleted(); }
+    );
 }
 
 IDBObjectStore& IDBCursor::effectiveObjectStore() const
 {
-    if (m_objectStore)
-        return *m_objectStore;
-
-    ASSERT(m_index);
-    return m_index->objectStore();
+    return WTF::switchOn(m_source,
+        [] (const RefPtr<IDBObjectStore>& objectStore) -> IDBObjectStore& { return *objectStore; },
+        [] (const RefPtr<IDBIndex>& index) -> IDBObjectStore& { return index->objectStore(); }
+    );
 }
 
 IDBTransaction& IDBCursor::transaction() const
@@ -169,12 +107,6 @@ IDBTransaction& IDBCursor::transaction() const
     return effectiveObjectStore().transaction();
 }
 
-const String& IDBCursor::direction() const
-{
-    ASSERT(currentThread() == effectiveObjectStore().transaction().database().originThreadID());
-    return directionToString(m_info.cursorDirection());
-}
-
 ExceptionOr<Ref<IDBRequest>> IDBCursor::update(ExecState& state, JSValue value)
 {
     LOG(IndexedDB, "IDBCursor::update");
@@ -251,7 +183,7 @@ ExceptionOr<void> IDBCursor::continuePrimaryKey(ExecState& state, JSValue keyVal
     if (sourcesDeleted())
         return Exception { IDBDatabaseException::InvalidStateError, ASCIILiteral("Failed to execute 'continuePrimaryKey' on 'IDBCursor': The cursor's source or effective object store has been deleted.") };
 
-    if (!m_index)
+    if (!WTF::holds_alternative<RefPtr<IDBIndex>>(m_source))
         return Exception { IDBDatabaseException::InvalidAccessError, ASCIILiteral("Failed to execute 'continuePrimaryKey' on 'IDBCursor': The cursor's source is not an index.") };
 
     auto direction = m_info.cursorDirection();
index cf20274..5c48e70 100644 (file)
 #include "ActiveDOMObject.h"
 #include "DOMWrapperWorld.h"
 #include "ExceptionOr.h"
+#include "IDBCursorDirection.h"
 #include "IDBCursorInfo.h"
 #include <heap/Strong.h>
+#include <wtf/Variant.h>
 
 namespace WebCore {
 
@@ -44,23 +46,16 @@ class IDBCursor : public ScriptWrappable, public RefCounted<IDBCursor>, public A
 public:
     static Ref<IDBCursor> create(IDBTransaction&, IDBObjectStore&, const IDBCursorInfo&);
     static Ref<IDBCursor> create(IDBTransaction&, IDBIndex&, const IDBCursorInfo&);
-
-    static const AtomicString& directionNext();
-    static const AtomicString& directionNextUnique();
-    static const AtomicString& directionPrev();
-    static const AtomicString& directionPrevUnique();
-
-    static std::optional<IndexedDB::CursorDirection> stringToDirection(const String& modeString);
-    static const AtomicString& directionToString(IndexedDB::CursorDirection mode);
     
     virtual ~IDBCursor();
 
-    const String& direction() const;
+    using Source = Variant<RefPtr<IDBObjectStore>, RefPtr<IDBIndex>>;
+
+    const Source& source() const;
+    IDBCursorDirection direction() const;
     JSC::JSValue key() const;
     JSC::JSValue primaryKey() const;
     JSC::JSValue value() const;
-    IDBObjectStore* objectStore() const { return m_objectStore.get(); }
-    IDBIndex* index() const { return m_index.get(); }
 
     ExceptionOr<Ref<IDBRequest>> update(JSC::ExecState&, JSC::JSValue);
     ExceptionOr<void> advance(unsigned);
@@ -103,8 +98,7 @@ private:
     unsigned m_outstandingRequestCount { 1 };
 
     IDBCursorInfo m_info;
-    RefPtr<IDBObjectStore> m_objectStore;
-    RefPtr<IDBIndex> m_index;
+    Source m_source;
     IDBRequest* m_request { nullptr };
 
     bool m_gotValue { false };
@@ -117,6 +111,17 @@ private:
     JSC::Strong<JSC::Unknown> m_currentValue;
 };
 
+
+inline const IDBCursor::Source& IDBCursor::source() const
+{
+    return m_source;
+}
+
+inline IDBCursorDirection IDBCursor::direction() const
+{
+    return m_info.cursorDirection();
+}
+
 inline JSC::JSValue IDBCursor::key() const
 {
     return m_currentKey.get();
index 4f64071..460ccf4 100644 (file)
@@ -31,8 +31,8 @@
     JSCustomMarkFunction,
     SkipVTableValidation,
 ] interface IDBCursor {
-    [CustomGetter] readonly attribute any source;
-    readonly attribute DOMString direction;
+    readonly attribute (IDBObjectStore or IDBIndex) source;
+    readonly attribute IDBCursorDirection direction;
     readonly attribute any key;
     readonly attribute any primaryKey;
 
diff --git a/Source/WebCore/Modules/indexeddb/IDBCursorDirection.h b/Source/WebCore/Modules/indexeddb/IDBCursorDirection.h
new file mode 100644 (file)
index 0000000..e40fb86
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include "IndexedDB.h"
+
+namespace WebCore {
+
+using IDBCursorDirection = IndexedDB::CursorDirection;
+
+}
diff --git a/Source/WebCore/Modules/indexeddb/IDBCursorDirection.idl b/Source/WebCore/Modules/indexeddb/IDBCursorDirection.idl
new file mode 100644 (file)
index 0000000..b85fdc0
--- /dev/null
@@ -0,0 +1,33 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+[
+    Conditional=INDEXED_DATABASE,
+] enum IDBCursorDirection {
+    "next",
+    "nextunique",
+    "prev",
+    "prevunique"
+};
index 7aa37b1..3ec5160 100644 (file)
@@ -151,7 +151,7 @@ void IDBIndex::rollbackInfoForVersionChangeAbort()
     m_deleted = false;
 }
 
-ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, IDBKeyRange* range, const String& directionString)
+ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, IDBKeyRange* range, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBIndex::openCursor");
     ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
@@ -162,21 +162,17 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, IDBKeyRa
     if (!m_objectStore.transaction().isActive())
         return Exception { IDBDatabaseException::TransactionInactiveError, ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The transaction is inactive or finished.") };
 
-    auto direction = IDBCursor::stringToDirection(directionString);
-    if (!direction)
-        return Exception { TypeError, ASCIILiteral("Failed to execute 'openCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.") };
-
     IDBKeyRangeData rangeData = range;
     if (rangeData.lowerKey.isNull())
         rangeData.lowerKey = IDBKeyData::minimum();
     if (rangeData.upperKey.isNull())
         rangeData.upperKey = IDBKeyData::maximum();
 
-    auto info = IDBCursorInfo::indexCursor(m_objectStore.transaction(), m_objectStore.info().identifier(), m_info.identifier(), rangeData, direction.value(), IndexedDB::CursorType::KeyAndValue);
+    auto info = IDBCursorInfo::indexCursor(m_objectStore.transaction(), m_objectStore.info().identifier(), m_info.identifier(), rangeData, direction, IndexedDB::CursorType::KeyAndValue);
     return m_objectStore.transaction().requestOpenCursor(execState, *this, info);
 }
 
-ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, JSValue key, const String& direction)
+ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, JSValue key, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBIndex::openCursor");
     ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
@@ -188,6 +184,31 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::openCursor(ExecState& execState, JSValue
     return openCursor(execState, keyRange.releaseReturnValue().ptr(), direction);
 }
 
+ExceptionOr<Ref<IDBRequest>> IDBIndex::openKeyCursor(ExecState& execState, IDBKeyRange* range, IDBCursorDirection direction)
+{
+    LOG(IndexedDB, "IDBIndex::openKeyCursor");
+    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
+
+    if (m_deleted || m_objectStore.isDeleted())
+        return Exception { IDBDatabaseException::InvalidStateError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The index or its object store has been deleted.") };
+
+    if (!m_objectStore.transaction().isActive())
+        return Exception { IDBDatabaseException::TransactionInactiveError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The transaction is inactive or finished.") };
+
+    auto info = IDBCursorInfo::indexCursor(m_objectStore.transaction(), m_objectStore.info().identifier(), m_info.identifier(), range, direction, IndexedDB::CursorType::KeyOnly);
+    return m_objectStore.transaction().requestOpenCursor(execState, *this, info);
+}
+
+ExceptionOr<Ref<IDBRequest>> IDBIndex::openKeyCursor(ExecState& execState, JSValue key, IDBCursorDirection direction)
+{
+    LOG(IndexedDB, "IDBIndex::openKeyCursor");
+
+    auto keyRange = IDBKeyRange::only(execState, key);
+    if (keyRange.hasException())
+        return Exception { IDBDatabaseException::DataError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The parameter is not a valid key.") };
+    return openKeyCursor(execState, keyRange.releaseReturnValue().ptr(), direction);
+}
+
 ExceptionOr<Ref<IDBRequest>> IDBIndex::count(ExecState& execState, IDBKeyRange* range)
 {
     LOG(IndexedDB, "IDBIndex::count");
@@ -223,35 +244,6 @@ ExceptionOr<Ref<IDBRequest>> IDBIndex::doCount(ExecState& execState, const IDBKe
     return transaction.requestCount(execState, *this, range);
 }
 
-ExceptionOr<Ref<IDBRequest>> IDBIndex::openKeyCursor(ExecState& execState, IDBKeyRange* range, const String& directionString)
-{
-    LOG(IndexedDB, "IDBIndex::openKeyCursor");
-    ASSERT(currentThread() == m_objectStore.transaction().database().originThreadID());
-
-    if (m_deleted || m_objectStore.isDeleted())
-        return Exception { IDBDatabaseException::InvalidStateError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The index or its object store has been deleted.") };
-
-    if (!m_objectStore.transaction().isActive())
-        return Exception { IDBDatabaseException::TransactionInactiveError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The transaction is inactive or finished.") };
-
-    auto direction = IDBCursor::stringToDirection(directionString);
-    if (!direction)
-        return Exception { TypeError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The direction provided ('invalid-direction') is not one of 'next', 'nextunique', 'prev', or 'prevunique'.") };
-
-    auto info = IDBCursorInfo::indexCursor(m_objectStore.transaction(), m_objectStore.info().identifier(), m_info.identifier(), range, direction.value(), IndexedDB::CursorType::KeyOnly);
-    return m_objectStore.transaction().requestOpenCursor(execState, *this, info);
-}
-
-ExceptionOr<Ref<IDBRequest>> IDBIndex::openKeyCursor(ExecState& execState, JSValue key, const String& direction)
-{
-    LOG(IndexedDB, "IDBIndex::openKeyCursor");
-
-    auto keyRange = IDBKeyRange::only(execState, key);
-    if (keyRange.hasException())
-        return Exception { IDBDatabaseException::DataError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBIndex': The parameter is not a valid key.") };
-    return openKeyCursor(execState, keyRange.releaseReturnValue().ptr(), direction);
-}
-
 ExceptionOr<Ref<IDBRequest>> IDBIndex::get(ExecState& execState, IDBKeyRange* range)
 {
     LOG(IndexedDB, "IDBIndex::get");
index ed8cd65..b3134fd 100644 (file)
@@ -56,15 +56,14 @@ public:
 
     void rollbackInfoForVersionChangeAbort();
 
-    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, IDBKeyRange*, const String& direction);
-    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, JSC::JSValue key, const String& direction);
+    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, IDBKeyRange*, IDBCursorDirection);
+    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, JSC::JSValue key, IDBCursorDirection);
+    ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, IDBKeyRange*, IDBCursorDirection);
+    ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, JSC::JSValue key, IDBCursorDirection);
 
     ExceptionOr<Ref<IDBRequest>> count(JSC::ExecState&, IDBKeyRange*);
     ExceptionOr<Ref<IDBRequest>> count(JSC::ExecState&, JSC::JSValue key);
 
-    ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, IDBKeyRange*, const String& direction);
-    ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, JSC::JSValue key, const String& direction);
-
     ExceptionOr<Ref<IDBRequest>> get(JSC::ExecState&, IDBKeyRange*);
     ExceptionOr<Ref<IDBRequest>> get(JSC::ExecState&, JSC::JSValue key);
     ExceptionOr<Ref<IDBRequest>> getKey(JSC::ExecState&, IDBKeyRange*);
index 2930c0b..f0d4ee6 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+// NOTE: This type is specified as 'any' in the IndexedDB specification, but is always
+// constrained to this union.
+typedef (DOMString or sequence<DOMString>) IDBKeyPath;
+
 [
     Conditional=INDEXED_DATABASE,
     EnabledAtRuntime=IndexedDB,
 ] interface IDBIndex {
     [SetterMayThrowException] attribute DOMString name;
     readonly attribute IDBObjectStore objectStore;
-    [ImplementationReturnType=IDBKeyPath] readonly attribute any keyPath;
+    readonly attribute IDBKeyPath? keyPath;
     readonly attribute boolean multiEntry;
     readonly attribute boolean unique;
 
-    [CallWith=ScriptState, MayThrowException] IDBRequest openCursor(optional IDBKeyRange? range = null, optional DOMString direction = "next");
-    [CallWith=ScriptState, MayThrowException] IDBRequest openCursor(any key, optional DOMString direction = "next");
+    [CallWith=ScriptState, MayThrowException] IDBRequest openCursor(optional IDBKeyRange? range = null, optional IDBCursorDirection direction = "next");
+    [CallWith=ScriptState, MayThrowException] IDBRequest openCursor(any key, optional IDBCursorDirection direction = "next");
 
-    [CallWith=ScriptState, MayThrowException] IDBRequest openKeyCursor(optional IDBKeyRange? range = null, optional DOMString direction = "next");
-    [CallWith=ScriptState, MayThrowException] IDBRequest openKeyCursor(any key, optional DOMString direction = "next");
+    [CallWith=ScriptState, MayThrowException] IDBRequest openKeyCursor(optional IDBKeyRange? range = null, optional IDBCursorDirection direction = "next");
+    [CallWith=ScriptState, MayThrowException] IDBRequest openKeyCursor(any key, optional IDBCursorDirection direction = "next");
 
     [CallWith=ScriptState, MayThrowException] IDBRequest get(IDBKeyRange? key);
     [CallWith=ScriptState, MayThrowException] IDBRequest get(any key);
@@ -53,4 +57,3 @@
     [CallWith=ScriptState, MayThrowException] IDBRequest count(optional IDBKeyRange? range = null);
     [CallWith=ScriptState, MayThrowException] IDBRequest count(any key);
 };
-
index 77e03b7..3ccc1a0 100644 (file)
     ImplementationLacksVTable,
     EnabledAtRuntime=IndexedDB,
 ] interface IDBKeyRange {
-    [ImplementationReturnType=IDBKey] readonly attribute any lower;
-    [ImplementationReturnType=IDBKey] readonly attribute any upper;
+    // NOTE: The 'lower' and 'upper' attributes are specified to be of type 'any'
+    // but we use the extension type IDBKey, to allow code generator to know our
+    // which conversion to use based on our actual implementation type.
+    readonly attribute IDBKey lower;
+    readonly attribute IDBKey upper;
     readonly attribute boolean lowerOpen;
     readonly attribute boolean upperOpen;
 
index 3876908..6f77a90 100644 (file)
@@ -150,7 +150,7 @@ bool IDBObjectStore::autoIncrement() const
     return m_info.autoIncrement();
 }
 
-ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, RefPtr<IDBKeyRange> range, const String& directionString)
+ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, RefPtr<IDBKeyRange> range, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBObjectStore::openCursor");
     ASSERT(currentThread() == m_transaction.database().originThreadID());
@@ -161,15 +161,11 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, Re
     if (!m_transaction.isActive())
         return Exception { IDBDatabaseException::TransactionInactiveError, ASCIILiteral("Failed to execute 'openCursor' on 'IDBObjectStore': The transaction is inactive or finished.") };
 
-    auto direction = IDBCursor::stringToDirection(directionString);
-    if (!direction)
-        return Exception { TypeError };
-
-    auto info = IDBCursorInfo::objectStoreCursor(m_transaction, m_info.identifier(), range.get(), direction.value(), IndexedDB::CursorType::KeyAndValue);
+    auto info = IDBCursorInfo::objectStoreCursor(m_transaction, m_info.identifier(), range.get(), direction, IndexedDB::CursorType::KeyAndValue);
     return m_transaction.requestOpenCursor(execState, *this, info);
 }
 
-ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, JSValue key, const String& direction)
+ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, JSValue key, IDBCursorDirection direction)
 {
     auto onlyResult = IDBKeyRange::only(execState, key);
     if (onlyResult.hasException())
@@ -178,7 +174,7 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openCursor(ExecState& execState, JS
     return openCursor(execState, onlyResult.releaseReturnValue(), direction);
 }
 
-ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState, RefPtr<IDBKeyRange> range, const String& directionString)
+ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState, RefPtr<IDBKeyRange> range, IDBCursorDirection direction)
 {
     LOG(IndexedDB, "IDBObjectStore::openCursor");
     ASSERT(currentThread() == m_transaction.database().originThreadID());
@@ -189,15 +185,11 @@ ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState,
     if (!m_transaction.isActive())
         return Exception { IDBDatabaseException::TransactionInactiveError, ASCIILiteral("Failed to execute 'openKeyCursor' on 'IDBObjectStore': The transaction is inactive or finished.") };
 
-    auto direction = IDBCursor::stringToDirection(directionString);
-    if (!direction)
-        return Exception { TypeError };
-
-    auto info = IDBCursorInfo::objectStoreCursor(m_transaction, m_info.identifier(), range.get(), direction.value(), IndexedDB::CursorType::KeyOnly);
+    auto info = IDBCursorInfo::objectStoreCursor(m_transaction, m_info.identifier(), range.get(), direction, IndexedDB::CursorType::KeyOnly);
     return m_transaction.requestOpenCursor(execState, *this, info);
 }
 
-ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState, JSValue key, const String& direction)
+ExceptionOr<Ref<IDBRequest>> IDBObjectStore::openKeyCursor(ExecState& execState, JSValue key, IDBCursorDirection direction)
 {
     auto onlyResult = IDBKeyRange::only(execState, key);
     if (onlyResult.hasException())
index b62b030..3be5690 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "ActiveDOMObject.h"
 #include "ExceptionOr.h"
+#include "IDBCursorDirection.h"
 #include "IDBKeyPath.h"
 #include "IDBObjectStoreInfo.h"
 #include <wtf/HashSet.h>
@@ -71,10 +72,10 @@ public:
         bool multiEntry;
     };
 
-    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, RefPtr<IDBKeyRange>, const String& direction);
-    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, JSC::JSValue key, const String& direction);
-    ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, RefPtr<IDBKeyRange>, const String& direction);
-    ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, JSC::JSValue key, const String& direction);
+    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, RefPtr<IDBKeyRange>, IDBCursorDirection);
+    ExceptionOr<Ref<IDBRequest>> openCursor(JSC::ExecState&, JSC::JSValue key, IDBCursorDirection);
+    ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, RefPtr<IDBKeyRange>, IDBCursorDirection);
+    ExceptionOr<Ref<IDBRequest>> openKeyCursor(JSC::ExecState&, JSC::JSValue key, IDBCursorDirection);
     ExceptionOr<Ref<IDBRequest>> get(JSC::ExecState&, JSC::JSValue key);
     ExceptionOr<Ref<IDBRequest>> get(JSC::ExecState&, IDBKeyRange*);
     ExceptionOr<Ref<IDBRequest>> getKey(JSC::ExecState&, JSC::JSValue key);
index d39a11f..cd188a7 100644 (file)
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+// NOTE: This type is specified as 'any' in the IndexedDB specification, but is always
+// constrained to this union.
+typedef (DOMString or sequence<DOMString>) IDBKeyPath;
+
 [
     Conditional=INDEXED_DATABASE,
     EnabledAtRuntime=IndexedDB,
@@ -31,7 +35,7 @@
     SkipVTableValidation,
 ] interface IDBObjectStore {
     [SetterMayThrowException] attribute DOMString name;
-    [ImplementationReturnType=IDBKeyPath] readonly attribute any keyPath;
+    readonly attribute IDBKeyPath? keyPath;
     readonly attribute DOMStringList indexNames;
     readonly attribute IDBTransaction transaction;
     readonly attribute boolean autoIncrement;
     [CallWith=ScriptState, MayThrowException] IDBRequest getKey(IDBKeyRange? key);
     [CallWith=ScriptState, MayThrowException] IDBRequest getKey(any key);
     [CallWith=ScriptState, MayThrowException] IDBRequest clear();
-    [CallWith=ScriptState, MayThrowException] IDBRequest openCursor(optional IDBKeyRange? range = null, optional DOMString direction = "next");
-    [CallWith=ScriptState, MayThrowException] IDBRequest openCursor(any key, optional DOMString direction = "next");
-    [CallWith=ScriptState, MayThrowException] IDBRequest openKeyCursor(optional IDBKeyRange? range = null, optional DOMString direction = "next");
-    [CallWith=ScriptState, MayThrowException] IDBRequest openKeyCursor(any key, optional DOMString direction = "next");
+    [CallWith=ScriptState, MayThrowException] IDBRequest openCursor(optional IDBKeyRange? range = null, optional IDBCursorDirection direction = "next");
+    [CallWith=ScriptState, MayThrowException] IDBRequest openCursor(any key, optional IDBCursorDirection direction = "next");
+    [CallWith=ScriptState, MayThrowException] IDBRequest openKeyCursor(optional IDBKeyRange? range = null, optional IDBCursorDirection direction = "next");
+    [CallWith=ScriptState, MayThrowException] IDBRequest openKeyCursor(any key, optional IDBCursorDirection direction = "next");
     [CallWith=ScriptState, MayThrowException] IDBRequest getAll(optional IDBKeyRange? range = null, [EnforceRange] optional unsigned long count);
     [CallWith=ScriptState, MayThrowException] IDBRequest getAll(any key,  [EnforceRange] optional unsigned long count);
     [CallWith=ScriptState, MayThrowException] IDBRequest getAllKeys(optional IDBKeyRange? range = null, [EnforceRange] optional unsigned long count);
index a7ba10a..6b79850 100644 (file)
@@ -136,7 +136,7 @@ void IDBOpenDBRequest::onSuccess(const IDBResultData& resultData)
     ASSERT(currentThread() == originThreadID());
 
     setResult(IDBDatabase::create(*scriptExecutionContext(), connectionProxy(), resultData));
-    m_isDone = true;
+    m_readyState = ReadyState::Done;
 
     enqueueEvent(IDBRequestCompletionEvent::create(eventNames().successEvent, false, false, *this));
 }
@@ -157,7 +157,7 @@ void IDBOpenDBRequest::onUpgradeNeeded(const IDBResultData& resultData)
     LOG(IndexedDB, "IDBOpenDBRequest::onUpgradeNeeded() - current version is %" PRIu64 ", new is %" PRIu64, oldVersion, newVersion);
 
     setResult(WTFMove(database));
-    m_isDone = true;
+    m_readyState = ReadyState::Done;
     m_transaction = WTFMove(transaction);
     m_transaction->addRequest(*this);
 
@@ -172,7 +172,7 @@ void IDBOpenDBRequest::onDeleteDatabaseSuccess(const IDBResultData& resultData)
 
     LOG(IndexedDB, "IDBOpenDBRequest::onDeleteDatabaseSuccess() - current version is %" PRIu64, oldVersion);
 
-    m_isDone = true;
+    m_readyState = ReadyState::Done;
     setResultToUndefined();
 
     enqueueEvent(IDBVersionChangeEvent::create(oldVersion, 0, eventNames().successEvent));
index 073d3fa..0c239b9 100644 (file)
@@ -48,7 +48,7 @@
 #include "ScriptExecutionContext.h"
 #include "ThreadSafeDataBuffer.h"
 #include <heap/StrongInlines.h>
-#include <wtf/NeverDestroyed.h>
+#include <wtf/Variant.h>
 
 using namespace JSC;
 
@@ -101,13 +101,16 @@ IDBRequest::IDBRequest(ScriptExecutionContext& context, IDBCursor& cursor, IDBTr
     : IDBActiveDOMObject(&context)
     , m_transaction(&transaction)
     , m_resourceIdentifier(transaction.connectionProxy())
-    , m_objectStoreSource(cursor.objectStore())
-    , m_indexSource(cursor.index())
     , m_pendingCursor(&cursor)
     , m_connectionProxy(transaction.database().connectionProxy())
 {
     suspendIfNeeded();
 
+    WTF::switchOn(cursor.source(),
+        [this] (const RefPtr<IDBIndex>& index) { this->m_indexSource = index; },
+        [this] (const RefPtr<IDBObjectStore>& objectStore) { this->m_objectStoreSource = objectStore; }
+    );
+
     cursor.setRequest(*this);
 }
 
@@ -150,12 +153,24 @@ ExceptionOr<DOMError*> IDBRequest::error() const
 {
     ASSERT(currentThread() == originThreadID());
 
-    if (!m_isDone)
+    if (!isDone())
         return Exception { IDBDatabaseException::InvalidStateError, ASCIILiteral("Failed to read the 'error' property from 'IDBRequest': The request has not finished.") };
 
     return m_domError.get();
 }
 
+std::optional<IDBRequest::Source> IDBRequest::source() const
+{
+    if (m_cursorSource)
+        return Source { m_cursorSource };
+    if (m_indexSource)
+        return Source { m_indexSource };
+    if (m_objectStoreSource)
+        return Source { m_objectStoreSource };
+
+    return std::nullopt;
+}
+
 void IDBRequest::setSource(IDBCursor& cursor)
 {
     ASSERT(currentThread() == originThreadID());
@@ -186,15 +201,6 @@ RefPtr<WebCore::IDBTransaction> IDBRequest::transaction() const
     return m_shouldExposeTransactionToDOM ? m_transaction : nullptr;
 }
 
-const String& IDBRequest::readyState() const
-{
-    ASSERT(currentThread() == originThreadID());
-
-    static NeverDestroyed<String> pendingString(ASCIILiteral("pending"));
-    static NeverDestroyed<String> doneString(ASCIILiteral("done"));
-    return m_isDone ? doneString : pendingString;
-}
-
 uint64_t IDBRequest::sourceObjectStoreIdentifier() const
 {
     ASSERT(currentThread() == originThreadID());
@@ -292,7 +298,7 @@ bool IDBRequest::dispatchEvent(Event& event)
     ASSERT(!m_contextStopped);
 
     if (event.type() != eventNames().blockedEvent)
-        m_isDone = true;
+        m_readyState = ReadyState::Done;
 
     Vector<RefPtr<EventTarget>> targets;
     targets.append(this);
@@ -457,7 +463,7 @@ IDBCursor* IDBRequest::resultCursor()
 void IDBRequest::willIterateCursor(IDBCursor& cursor)
 {
     ASSERT(currentThread() == originThreadID());
-    ASSERT(m_isDone);
+    ASSERT(isDone());
     ASSERT(scriptExecutionContext());
     ASSERT(m_transaction);
     ASSERT(!m_pendingCursor);
@@ -467,7 +473,7 @@ void IDBRequest::willIterateCursor(IDBCursor& cursor)
     m_pendingCursor = &cursor;
     m_hasPendingActivity = true;
     clearResult();
-    m_isDone = false;
+    m_readyState = ReadyState::Pending;
     m_domError = nullptr;
     m_idbError = { };
 
@@ -499,7 +505,7 @@ void IDBRequest::completeRequestAndDispatchEvent(const IDBResultData& resultData
 {
     ASSERT(currentThread() == originThreadID());
 
-    m_isDone = true;
+    m_readyState = ReadyState::Done;
 
     m_idbError = resultData.error();
     if (!m_idbError.isNull())
index 4ceb207..613499d 100644 (file)
@@ -70,14 +70,18 @@ public:
     IDBCursor* cursorResult() const { return m_cursorResult.get(); }
     IDBDatabase* databaseResult() const { return m_databaseResult.get(); }
     JSC::JSValue scriptResult() const { return m_scriptResult.get(); }
+
+    using Source = Variant<RefPtr<IDBObjectStore>, RefPtr<IDBIndex>, RefPtr<IDBCursor>>;
+    std::optional<Source> source() const;
+
     ExceptionOr<DOMError*> error() const;
-    IDBObjectStore* objectStoreSource() const { return m_objectStoreSource.get(); }
-    IDBIndex* indexSource() const { return m_indexSource.get(); }
-    IDBCursor* cursorSource() const { return m_cursorSource.get(); }
+
     RefPtr<IDBTransaction> transaction() const;
-    const String& readyState() const;
+    
+    enum class ReadyState { Pending, Done };
+    ReadyState readyState() const { return m_readyState; }
 
-    bool isDone() const { return m_isDone; }
+    bool isDone() const { return m_readyState == ReadyState::Done; }
 
     uint64_t sourceObjectStoreIdentifier() const;
     uint64_t sourceIndexIdentifier() const;
@@ -122,7 +126,7 @@ protected:
 
     // FIXME: Protected data members aren't great for maintainability.
     // Consider adding protected helper functions and making these private.
-    bool m_isDone { false };
+    ReadyState m_readyState { ReadyState::Pending };
     RefPtr<IDBTransaction> m_transaction;
     bool m_shouldExposeTransactionToDOM { true };
     RefPtr<DOMError> m_domError;
index cdf45b0..5bef588 100644 (file)
     GenerateIsReachable=Impl,
     SkipVTableValidation,
 ] interface IDBRequest : EventTarget {
-    [CustomGetter] readonly attribute any result;
+    [CustomGetter, GetterMayThrowException] readonly attribute any result;
     [GetterMayThrowException] readonly attribute DOMError? error;
-    [CustomGetter] readonly attribute any source;
+    readonly attribute (IDBObjectStore or IDBIndex or IDBCursor)? source;
     readonly attribute IDBTransaction transaction;
-    readonly attribute DOMString readyState;
+    readonly attribute IDBRequestReadyState readyState;
 
     attribute EventHandler onsuccess;
     attribute EventHandler onerror;
 };
+
+enum IDBRequestReadyState {
+    "pending",
+    "done"
+};
index d7df0e1..0ed653e 100644 (file)
@@ -40,10 +40,10 @@ enum class TransactionState {
 };
 
 enum class CursorDirection {
-    Next = 0,
-    NextNoDuplicate = 1,
-    Prev = 2,
-    PrevNoDuplicate = 3,
+    Next,
+    Nextunique,
+    Prev,
+    Prevunique,
 };
 const unsigned CursorDirectionMaximum = 3;
 
index eb3bb1d..72b6eab 100644 (file)
@@ -151,13 +151,13 @@ void MemoryIndexCursor::iterate(const IDBKeyData& key, const IDBKeyData& primary
         case IndexedDB::CursorDirection::Next:
             m_currentIterator = valueStore->find(m_currentKey, m_currentPrimaryKey);
             break;
-        case IndexedDB::CursorDirection::NextNoDuplicate:
+        case IndexedDB::CursorDirection::Nextunique:
             m_currentIterator = valueStore->find(m_currentKey, true);
             break;
         case IndexedDB::CursorDirection::Prev:
             m_currentIterator = valueStore->reverseFind(m_currentKey, m_currentPrimaryKey, m_info.duplicity());
             break;
-        case IndexedDB::CursorDirection::PrevNoDuplicate:
+        case IndexedDB::CursorDirection::Prevunique:
             m_currentIterator = valueStore->reverseFind(m_currentKey, m_info.duplicity(), true);
             break;
         }
index 78bcf97..0d3e829 100644 (file)
@@ -132,7 +132,7 @@ static String buildIndexStatement(const IDBKeyRangeData& keyRange, IndexedDB::Cu
         builder.append('<');
 
     builder.appendLiteral(" CAST(? AS TEXT) ORDER BY key");
-    if (cursorDirection == IndexedDB::CursorDirection::Prev || cursorDirection == IndexedDB::CursorDirection::PrevNoDuplicate)
+    if (cursorDirection == IndexedDB::CursorDirection::Prev || cursorDirection == IndexedDB::CursorDirection::Prevunique)
         builder.appendLiteral(" DESC");
 
     builder.appendLiteral(", value");
@@ -164,7 +164,7 @@ static String buildObjectStoreStatement(const IDBKeyRangeData& keyRange, Indexed
 
     builder.appendLiteral(" CAST(? AS TEXT) ORDER BY key");
 
-    if (cursorDirection == IndexedDB::CursorDirection::Prev || cursorDirection == IndexedDB::CursorDirection::PrevNoDuplicate)
+    if (cursorDirection == IndexedDB::CursorDirection::Prev || cursorDirection == IndexedDB::CursorDirection::Prevunique)
         builder.appendLiteral(" DESC");
 
     builder.append(';');
@@ -221,7 +221,7 @@ void SQLiteIDBCursor::objectStoreRecordsChanged()
     m_statementNeedsReset = true;
     ASSERT(!m_fetchedRecords.isEmpty());
 
-    if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) {
+    if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::Nextunique) {
         m_currentLowerKey = m_fetchedRecords.first().record.key;
         if (!m_keyRange.lowerOpen) {
             m_keyRange.lowerOpen = true;
@@ -366,7 +366,7 @@ bool SQLiteIDBCursor::fetch()
 
     m_fetchedRecords.append({ });
 
-    bool isUnique = m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate || m_cursorDirection == IndexedDB::CursorDirection::PrevNoDuplicate;
+    bool isUnique = m_cursorDirection == IndexedDB::CursorDirection::Nextunique || m_cursorDirection == IndexedDB::CursorDirection::Prevunique;
     if (!isUnique)
         return fetchNextRecord(m_fetchedRecords.last());
 
@@ -509,7 +509,7 @@ bool SQLiteIDBCursor::iterate(const IDBKeyData& targetKey, const IDBKeyData& tar
             return false;
 
         // Search for the next key >= the target if the cursor is a Next cursor, or the next key <= if the cursor is a Previous cursor.
-        if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) {
+        if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::Nextunique) {
             if (m_fetchedRecords.first().record.key.compare(targetKey) >= 0)
                 break;
         } else if (m_fetchedRecords.first().record.key.compare(targetKey) <= 0)
@@ -524,7 +524,7 @@ bool SQLiteIDBCursor::iterate(const IDBKeyData& targetKey, const IDBKeyData& tar
                 return false;
 
             // Search for the next primary key >= the primary target if the cursor is a Next cursor, or the next key <= if the cursor is a Previous cursor.
-            if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::NextNoDuplicate) {
+            if (m_cursorDirection == IndexedDB::CursorDirection::Next || m_cursorDirection == IndexedDB::CursorDirection::Nextunique) {
                 if (m_fetchedRecords.first().record.primaryKey.compare(targetPrimaryKey) >= 0)
                     break;
             } else if (m_fetchedRecords.first().record.primaryKey.compare(targetPrimaryKey) <= 0)
index 35a1f69..0d3e338 100644 (file)
@@ -86,12 +86,12 @@ IDBCursorInfo::IDBCursorInfo(const IDBResourceIdentifier& cursorIdentifier, cons
 
 bool IDBCursorInfo::isDirectionForward() const
 {
-    return m_direction == IndexedDB::CursorDirection::Next || m_direction == IndexedDB::CursorDirection::NextNoDuplicate;
+    return m_direction == IndexedDB::CursorDirection::Next || m_direction == IndexedDB::CursorDirection::Nextunique;
 }
 
 CursorDuplicity IDBCursorInfo::duplicity() const
 {
-    return m_direction == IndexedDB::CursorDirection::NextNoDuplicate || m_direction == IndexedDB::CursorDirection::PrevNoDuplicate ? CursorDuplicity::NoDuplicates : CursorDuplicity::Duplicates;
+    return m_direction == IndexedDB::CursorDirection::Nextunique || m_direction == IndexedDB::CursorDirection::Prevunique ? CursorDuplicity::NoDuplicates : CursorDuplicity::Duplicates;
 }
 
 IDBCursorInfo IDBCursorInfo::isolatedCopy() const
index 2c950a1..502ea7a 100644 (file)
                7C3A91E61C963B8800D1A7E3 /* ClipboardAccessPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C3B79711908757B00B47A2D /* UserMessageHandler.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3B796F1908757B00B47A2D /* UserMessageHandler.cpp */; };
                7C3B79721908757B00B47A2D /* UserMessageHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3B79701908757B00B47A2D /* UserMessageHandler.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7C3D8EEB1E0B15A70023B084 /* IDBCursorDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3D8EE91E0B15A70023B084 /* IDBCursorDirection.h */; };
+               7C3D8EEF1E0B21430023B084 /* JSIDBCursorDirection.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C3D8EED1E0B21430023B084 /* JSIDBCursorDirection.cpp */; };
+               7C3D8EF01E0B21430023B084 /* JSIDBCursorDirection.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3D8EEE1E0B21430023B084 /* JSIDBCursorDirection.h */; };
                7C3E510A18DF8F3500C112F7 /* HTMLConverter.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3E510818DF8F3500C112F7 /* HTMLConverter.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C3E510B18DF8F3500C112F7 /* HTMLConverter.mm in Sources */ = {isa = PBXBuildFile; fileRef = 7C3E510918DF8F3500C112F7 /* HTMLConverter.mm */; };
                7C3F01C11C8E5ABA00ADD962 /* UserContentProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = 7C3F01C01C8E5AB100ADD962 /* UserContentProvider.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7CD0BA051B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */; };
                7CD494CC1A86EB1D000A87EC /* RenderAttachment.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */; };
                7CD494CD1A86EB1D000A87EC /* RenderAttachment.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               7CD686561E0E26D300E97AA7 /* JSIDBRequestCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7CD686551E0E26D300E97AA7 /* JSIDBRequestCustom.cpp */; };
                7CE58D4A1DD64A5B00128552 /* SVGPoint.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D491DD64A5B00128552 /* SVGPoint.h */; };
                7CE58D4E1DD694FE00128552 /* SVGRectTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D4D1DD694FE00128552 /* SVGRectTraits.h */; };
                7CE58D501DD69A1E00128552 /* SVGNumber.h in Headers */ = {isa = PBXBuildFile; fileRef = 7CE58D4F1DD69A1E00128552 /* SVGNumber.h */; };
                934CC10A0EDB223900A658F2 /* ScriptSourceCode.h in Headers */ = {isa = PBXBuildFile; fileRef = 934CC1090EDB223900A658F2 /* ScriptSourceCode.h */; };
                934D9BA50B8C116B007B42A9 /* WebCoreNSStringExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = 934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */; };
                934D9BA70B8C1175007B42A9 /* WebCoreNSStringExtras.h in Headers */ = {isa = PBXBuildFile; fileRef = 934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               934F31B51CC0737200DB43DC /* JSIDBRequestCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 934F31B41CC0737200DB43DC /* JSIDBRequestCustom.cpp */; };
                934F71380D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 934F71370D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp */; };
                934F713A0D5A6F1000018D69 /* AuthenticationChallengeBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 934F71390D5A6F1000018D69 /* AuthenticationChallengeBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                934F713C0D5A6F1900018D69 /* ResourceErrorBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 934F713B0D5A6F1900018D69 /* ResourceErrorBase.h */; settings = {ATTRIBUTES = (Private, ); }; };
                7C3A91E51C963B8800D1A7E3 /* ClipboardAccessPolicy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClipboardAccessPolicy.h; sourceTree = "<group>"; };
                7C3B796F1908757B00B47A2D /* UserMessageHandler.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserMessageHandler.cpp; sourceTree = "<group>"; };
                7C3B79701908757B00B47A2D /* UserMessageHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UserMessageHandler.h; sourceTree = "<group>"; };
+               7C3D8EE91E0B15A70023B084 /* IDBCursorDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IDBCursorDirection.h; sourceTree = "<group>"; };
+               7C3D8EEA1E0B15A70023B084 /* IDBCursorDirection.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = IDBCursorDirection.idl; sourceTree = "<group>"; };
+               7C3D8EED1E0B21430023B084 /* JSIDBCursorDirection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBCursorDirection.cpp; sourceTree = "<group>"; };
+               7C3D8EEE1E0B21430023B084 /* JSIDBCursorDirection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSIDBCursorDirection.h; sourceTree = "<group>"; };
                7C3E510818DF8F3500C112F7 /* HTMLConverter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLConverter.h; sourceTree = "<group>"; };
                7C3E510918DF8F3500C112F7 /* HTMLConverter.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = HTMLConverter.mm; sourceTree = "<group>"; };
                7C3F01BF1C8E5AB100ADD962 /* UserContentProvider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UserContentProvider.cpp; sourceTree = "<group>"; };
                7CD0BA031B8F79C9005CEBBE /* ActiveDOMCallbackMicrotask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ActiveDOMCallbackMicrotask.h; sourceTree = "<group>"; };
                7CD494CA1A86EB1D000A87EC /* RenderAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RenderAttachment.cpp; sourceTree = "<group>"; };
                7CD494CB1A86EB1D000A87EC /* RenderAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RenderAttachment.h; sourceTree = "<group>"; };
+               7CD686551E0E26D300E97AA7 /* JSIDBRequestCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBRequestCustom.cpp; sourceTree = "<group>"; };
                7CE58D491DD64A5B00128552 /* SVGPoint.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGPoint.h; sourceTree = "<group>"; };
                7CE58D4D1DD694FE00128552 /* SVGRectTraits.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGRectTraits.h; sourceTree = "<group>"; };
                7CE58D4F1DD69A1E00128552 /* SVGNumber.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGNumber.h; sourceTree = "<group>"; };
                934CC1090EDB223900A658F2 /* ScriptSourceCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptSourceCode.h; sourceTree = "<group>"; };
                934D9BA40B8C116B007B42A9 /* WebCoreNSStringExtras.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = WebCoreNSStringExtras.mm; sourceTree = "<group>"; };
                934D9BA60B8C1175007B42A9 /* WebCoreNSStringExtras.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = WebCoreNSStringExtras.h; sourceTree = "<group>"; };
-               934F31B41CC0737200DB43DC /* JSIDBRequestCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSIDBRequestCustom.cpp; sourceTree = "<group>"; };
                934F71370D5A6EFF00018D69 /* AuthenticationChallengeBase.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = AuthenticationChallengeBase.cpp; sourceTree = "<group>"; };
                934F71390D5A6F1000018D69 /* AuthenticationChallengeBase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = AuthenticationChallengeBase.h; sourceTree = "<group>"; };
                934F713B0D5A6F1900018D69 /* ResourceErrorBase.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ResourceErrorBase.h; sourceTree = "<group>"; };
                                ADEC78F718EE5308001315C2 /* JSElementCustom.h */,
                                BCEFAF4D0C317E6900FA81F6 /* JSEventCustom.cpp */,
                                E34EE49F1DC2D57500EAA9D3 /* JSEventCustom.h */,
+                               512BDB4C1C46B0FF006494DF /* JSIDBCursorCustom.cpp */,
                                5141298D1C5FD7E90059E714 /* JSIDBCursorWithValueCustom.cpp */,
                                5141299A1C6C166D0059E714 /* JSIDBIndexCustom.cpp */,
                                511EF2CE17F0FDF100E4FA16 /* JSIDBObjectStoreCustom.cpp */,
                                51645B541B9F88E800F789CE /* IDBCursor.cpp */,
                                51645B411B9F889B00F789CE /* IDBCursor.h */,
                                51D71977181106DF0016DC51 /* IDBCursor.idl */,
+                               7C3D8EE91E0B15A70023B084 /* IDBCursorDirection.h */,
+                               7C3D8EEA1E0B15A70023B084 /* IDBCursorDirection.idl */,
                                51645B421B9F889B00F789CE /* IDBCursorWithValue.cpp */,
                                51645B431B9F889B00F789CE /* IDBCursorWithValue.h */,
                                51D7197B181106DF0016DC51 /* IDBCursorWithValue.idl */,
                                B59DD697119029E5007E9684 /* JSDatabaseCallback.h */,
                                511EF2A917F0FC4800E4FA16 /* JSIDBCursor.cpp */,
                                81BE20A811F4B66F00915DFA /* JSIDBCursor.h */,
+                               7C3D8EED1E0B21430023B084 /* JSIDBCursorDirection.cpp */,
+                               7C3D8EEE1E0B21430023B084 /* JSIDBCursorDirection.h */,
                                511EF2AA17F0FC4800E4FA16 /* JSIDBCursorWithValue.cpp */,
                                511EF2AB17F0FC4800E4FA16 /* JSIDBCursorWithValue.h */,
                                511EF2AC17F0FC4800E4FA16 /* JSIDBDatabase.cpp */,
                                BC17F9650B64EBB8004A65CB /* JSHTMLSelectElementCustom.cpp */,
                                AB4CB4EA0B8BDA3D009F40B0 /* JSHTMLSelectElementCustom.h */,
                                D6F7960C166FFECE0076DD18 /* JSHTMLTemplateElementCustom.cpp */,
-                               512BDB4C1C46B0FF006494DF /* JSIDBCursorCustom.cpp */,
-                               934F31B41CC0737200DB43DC /* JSIDBRequestCustom.cpp */,
+                               7CD686551E0E26D300E97AA7 /* JSIDBRequestCustom.cpp */,
                                7A74ECBC101839DA00BF939E /* JSInspectorFrontendHostCustom.cpp */,
                                BCE1C43F0D9830F4003B02F2 /* JSLocationCustom.cpp */,
                                2D9BF7481DBFDDF8007A7D99 /* JSMediaKeySessionCustom.cpp */,
                                41885B9311B6FDA6003383BB /* FormSubmission.h in Headers */,
                                A853123D11D0471B00D4D077 /* FragmentScriptingPermission.h in Headers */,
                                65BF022F0974816300C43196 /* Frame.h in Headers */,
+                               7C3D8EF01E0B21430023B084 /* JSIDBCursorDirection.h in Headers */,
                                974A862314B7ADBB003FDC76 /* FrameDestructionObserver.h in Headers */,
                                656D373C0ADBA5DE00A4554D /* FrameLoader.h in Headers */,
                                656D373E0ADBA5DE00A4554D /* FrameLoaderClient.h in Headers */,
                                FC54D05816A7676E00575E4D /* JSCSSSupportsRule.h in Headers */,
                                9BD4E9171C462872005065BC /* JSCustomElementInterface.h in Headers */,
                                9BE6710C1D5AEB2500345514 /* JSCustomElementRegistry.h in Headers */,
+                               7C3D8EEB1E0B15A70023B084 /* IDBCursorDirection.h in Headers */,
                                E4778B80115A581A00B5D372 /* JSCustomEvent.h in Headers */,
                                E10B937C0B73C00A003ED890 /* JSCustomXPathNSResolver.h in Headers */,
                                1AE82F900CAAFA9D002237AE /* JSDatabase.h in Headers */,
                                511EF2D117F0FDF100E4FA16 /* JSIDBObjectStoreCustom.cpp in Sources */,
                                511EF2C817F0FD3500E4FA16 /* JSIDBOpenDBRequest.cpp in Sources */,
                                511EF2C917F0FD3500E4FA16 /* JSIDBRequest.cpp in Sources */,
-                               934F31B51CC0737200DB43DC /* JSIDBRequestCustom.cpp in Sources */,
                                511EF2CA17F0FD3500E4FA16 /* JSIDBTransaction.cpp in Sources */,
                                51E269331DD3BC4E006B6A58 /* JSIDBTransactionCustom.cpp in Sources */,
                                838EF53B1DC14A7C008F0C39 /* JSIDBTransactionMode.cpp in Sources */,
                                7EE6847512D26E7000E79415 /* ResourceLoaderCFNet.cpp in Sources */,
                                51AA3F6F0BD5AA9E00892971 /* ResourceLoaderMac.mm in Sources */,
                                51EE7B3A1AA5123100F92B21 /* ResourceLoadInfo.cpp in Sources */,
+                               7C3D8EEF1E0B21430023B084 /* JSIDBCursorDirection.cpp in Sources */,
                                973E325610883B7C005BC493 /* ResourceLoadNotifier.cpp in Sources */,
                                6B693A341C51A95D00B03BEF /* ResourceLoadObserver.cpp in Sources */,
                                7A929CA61C598A9E004DF226 /* ResourceLoadStatistics.cpp in Sources */,
                                49C7B9D91042D32F0009D447 /* WebGLRenderbuffer.cpp in Sources */,
                                49C7B9DF1042D32F0009D447 /* WebGLRenderingContext.cpp in Sources */,
                                D3F3D3691A69B7B00059FC2B /* WebGLRenderingContextBase.cpp in Sources */,
+                               7CD686561E0E26D300E97AA7 /* JSIDBRequestCustom.cpp in Sources */,
                                6F995A211A7078B100A735F4 /* WebGLSampler.cpp in Sources */,
                                49C7B9E21042D32F0009D447 /* WebGLShader.cpp in Sources */,
                                A08CF154152B77B3009C5775 /* WebGLShaderPrecisionFormat.cpp in Sources */,
index 606715e..7422ad4 100644 (file)
@@ -170,10 +170,6 @@ struct IDLDate : IDLType<double> {
     static double extractValueFromNullable(double value) { return value; }
 };
 
-template<typename T> struct IDLSerializedScriptValue : IDLWrapper<T> { };
-template<typename T> struct IDLEventListener : IDLWrapper<T> { };
-template<typename T> struct IDLXPathNSResolver : IDLWrapper<T> { };
-
 struct IDLJSON : IDLType<String> { 
     using ParameterType = const String&;
 
@@ -183,6 +179,11 @@ struct IDLJSON : IDLType<String> {
     template <typename U> static U&& extractValueFromNullable(U&& value) { return std::forward<U>(value); }
 };
 
+template<typename T> struct IDLSerializedScriptValue : IDLWrapper<T> { };
+template<typename T> struct IDLEventListener : IDLWrapper<T> { };
+template<typename T> struct IDLXPathNSResolver : IDLWrapper<T> { };
+template<typename T> struct IDLIDBKey : IDLWrapper<T> { };
+
 // Non-WebIDL convenience type aliases
 
 using IDLBufferSource = IDLUnion<IDLInterface<JSC::ArrayBufferView>, IDLInterface<JSC::ArrayBuffer>>;
index 0e4a02d..524ebc6 100644 (file)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "BufferSource.h"
+#include "IDBBindingUtilities.h"
 #include "IDLTypes.h"
 #include "JSDOMBinding.h"
 #include <runtime/JSONObject.h>
@@ -210,6 +211,31 @@ template<typename T> struct DefaultConverter {
 };
 
 // MARK: -
+// MARK: Any type
+
+template<> struct Converter<IDLAny> : DefaultConverter<IDLAny> {
+    static JSC::JSValue convert(JSC::ExecState&, JSC::JSValue value)
+    {
+        return value;
+    }
+};
+
+template<> struct JSConverter<IDLAny> {
+    static constexpr bool needsState = false;
+    static constexpr bool needsGlobalObject = false;
+
+    static JSC::JSValue convert(const JSC::JSValue& value)
+    {
+        return value;
+    }
+
+    static JSC::JSValue convert(const JSC::Strong<JSC::Unknown>& value)
+    {
+        return value.get();
+    }
+};
+
+// MARK: -
 // MARK: Nullable type
 
 namespace Detail {
@@ -434,26 +460,6 @@ template<typename T> struct JSConverter<IDLInterface<T>> {
 };
 
 // MARK: -
-// MARK: Any type
-
-template<> struct Converter<IDLAny> : DefaultConverter<IDLAny> {
-    static JSC::JSValue convert(JSC::ExecState&, JSC::JSValue value)
-    {
-        return value;
-    }
-};
-
-template<> struct JSConverter<IDLAny> {
-    static constexpr bool needsState = false;
-    static constexpr bool needsGlobalObject = false;
-
-    static JSC::JSValue convert(const JSC::JSValue& value)
-    {
-        return value;
-    }
-};
-
-// MARK: -
 // MARK: Integer types
 
 template<> struct Converter<IDLByte> : DefaultConverter<IDLByte> {
@@ -1463,6 +1469,26 @@ template<> struct JSConverter<IDLDate> {
 };
 
 // MARK: -
+// MARK: IDLJSON type
+
+template<> struct Converter<IDLJSON> : DefaultConverter<IDLJSON> {
+    static String convert(JSC::ExecState& state, JSC::JSValue value)
+    {
+        return JSC::JSONStringify(&state, value, 0);
+    }
+};
+
+template<> struct JSConverter<IDLJSON> {
+    static constexpr bool needsState = true;
+    static constexpr bool needsGlobalObject = false;
+
+    static JSC::JSValue convert(JSC::ExecState& state, const String& value)
+    {
+        return JSC::JSONParse(&state, value);
+    }
+};
+
+// MARK: -
 // MARK: SerializedScriptValue type
 
 template<typename T> struct Converter<IDLSerializedScriptValue<T>> : DefaultConverter<IDLSerializedScriptValue<T>> {
@@ -1537,22 +1563,16 @@ template<typename T> struct JSConverter<IDLXPathNSResolver<T>> {
 };
 
 // MARK: -
-// MARK: IDLJSON type
+// MARK: IDLIDBKey type
 
-template<> struct Converter<IDLJSON> : DefaultConverter<IDLJSON> {
-    static String convert(JSC::ExecState& state, JSC::JSValue value)
-    {
-        return JSC::JSONStringify(&state, value, 0);
-    }
-};
-
-template<> struct JSConverter<IDLJSON> {
+template<typename T> struct JSConverter<IDLIDBKey<T>> {
     static constexpr bool needsState = true;
-    static constexpr bool needsGlobalObject = false;
+    static constexpr bool needsGlobalObject = true;
 
-    static JSC::JSValue convert(JSC::ExecState& state, const String& value)
+    template <typename U>
+    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, U&& value)
     {
-        return JSC::JSONParse(&state, value);
+        return toJS(state, globalObject, std::forward<U>(value));
     }
 };
 
index 4aa505f..c74cb90 100644 (file)
@@ -30,8 +30,6 @@
 
 #include "JSDOMBinding.h"
 #include "JSIDBCursorWithValue.h"
-#include "JSIDBIndex.h"
-#include "JSIDBObjectStore.h"
 
 using namespace JSC;
 
@@ -44,14 +42,6 @@ void JSIDBCursor::visitAdditionalChildren(SlotVisitor& visitor)
         visitor.addOpaqueRoot(request);
 }
 
-JSValue JSIDBCursor::source(ExecState& state) const
-{
-    auto& cursor = wrapped();
-    if (auto* index = cursor.index())
-        return toJS(&state, globalObject(), *index);
-    return toJS(&state, globalObject(), cursor.objectStore());
-}
-
 JSValue toJSNewlyCreated(JSC::ExecState*, JSDOMGlobalObject* globalObject, Ref<IDBCursor>&& cursor)
 {
     if (is<IDBCursorWithValue>(cursor))
index 24a22c3..01faeab 100644 (file)
@@ -45,6 +45,7 @@ JSValue JSIDBRequest::result(ExecState& state) const
         propagateException(state, Exception { IDBDatabaseException::InvalidStateError, ASCIILiteral("Failed to read the 'result' property from 'IDBRequest': The request has not finished.") });
         return { };
     }
+
     if (auto* cursor = request.cursorResult())
         return toJS(&state, globalObject(), *cursor);
     if (auto* database = request.databaseResult())
@@ -54,16 +55,6 @@ JSValue JSIDBRequest::result(ExecState& state) const
     return jsNull();
 }
 
-JSValue JSIDBRequest::source(ExecState& state) const
-{
-    auto& request = wrapped();
-    if (auto* cursor = request.cursorSource())
-        return toJS(&state, globalObject(), *cursor);
-    if (auto* index = request.indexSource())
-        return toJS(&state, globalObject(), *index);
-    return toJS(&state, globalObject(), request.objectStoreSource());
-}
-
 } // namespace WebCore
 
 #endif // ENABLE(INDEXED_DATABASE)
index 67384e5..c302d0a 100644 (file)
@@ -876,14 +876,15 @@ sub IsBuiltinType
     return 1 if $object->IsStringType($type);
     return 1 if $object->IsTypedArrayType($type);
     return 1 if $type->isUnion;
-    return 1 if $type->name eq "any";
-    return 1 if $type->name eq "object";
     return 1 if $type->name eq "BufferSource";
+    return 1 if $type->name eq "EventListener";
+    return 1 if $type->name eq "IDBKey";
+    return 1 if $type->name eq "JSON";
     return 1 if $type->name eq "Promise";
-    return 1 if $type->name eq "XPathNSResolver";    
-    return 1 if $type->name eq "EventListener";    
-    return 1 if $type->name eq "SerializedScriptValue";    
-    return 1 if $type->name eq "JSON";    
+    return 1 if $type->name eq "SerializedScriptValue";
+    return 1 if $type->name eq "XPathNSResolver";
+    return 1 if $type->name eq "any";
+    return 1 if $type->name eq "object";
 
     return 0;
 }
index 85c2a86..5ea56d9 100644 (file)
@@ -5107,10 +5107,11 @@ sub GetBaseIDLType
         
         # Non-WebIDL extensions
         "Date" => "IDLDate",
-        "SerializedScriptValue" => "IDLSerializedScriptValue<SerializedScriptValue>",
         "EventListener" => "IDLEventListener<JSEventListener>",
-        "XPathNSResolver" => "IDLXPathNSResolver<XPathNSResolver>",
+        "IDBKey" => "IDLIDBKey<IDBKey>",
         "JSON" => "IDLJSON",
+        "SerializedScriptValue" => "IDLSerializedScriptValue<SerializedScriptValue>",
+        "XPathNSResolver" => "IDLXPathNSResolver<XPathNSResolver>",
 
         # Convenience type aliases
         "BufferSource" => "IDLBufferSource",
@@ -5333,9 +5334,10 @@ sub NativeToJSValueDOMConvertNeedsState
     return 1 if $codeGenerator->IsInterfaceType($type);
     return 1 if $codeGenerator->IsTypedArrayType($type);
     return 1 if $type->name eq "Date";
+    return 1 if $type->name eq "IDBKey";
+    return 1 if $type->name eq "JSON";
     return 1 if $type->name eq "SerializedScriptValue";
     return 1 if $type->name eq "XPathNSResolver";
-    return 1 if $type->name eq "JSON";
 
     return 0;
 }
@@ -5351,6 +5353,7 @@ sub NativeToJSValueDOMConvertNeedsGlobalObject
     return 1 if $codeGenerator->IsDictionaryType($type);
     return 1 if $codeGenerator->IsInterfaceType($type);
     return 1 if $codeGenerator->IsTypedArrayType($type);
+    return 1 if $type->name eq "IDBKey";
     return 1 if $type->name eq "SerializedScriptValue";
     return 1 if $type->name eq "XPathNSResolver";
 
@@ -5402,14 +5405,6 @@ sub NativeToJSValue
         $value = "std::max(0, $value)";
     }
 
-    if ($type->name eq "any") {
-        my $returnType = $context->extendedAttributes->{ImplementationReturnType};
-        if (defined $returnType and ($returnType eq "IDBKeyPath" or $returnType eq "IDBKey")) {
-            AddToImplIncludes("IDBBindingUtilities.h", $conditional);
-            return "toJS($stateReference, $globalObjectReference, $value)";
-        }
-    }
-
     AddToImplIncludesForIDLType($type, $conditional);
     AddToImplIncludes("JSDOMConvert.h", $conditional);
 
index e052bc1..717617c 100644 (file)
@@ -71,7 +71,6 @@ Global=*
 Immutable
 ImplementedAs=*
 ImplementationLacksVTable
-ImplementationReturnType=*
 ImplicitThis
 InterfaceName=*
 IsImmutablePrototypeExoticObject
index 0823067..284a235 100644 (file)
@@ -127,6 +127,7 @@ public:
             m_executableWithDatabase->requestCallback().sendFailure("Could not get result in callback.");
             return;
         }
+
         auto databaseResult = request.databaseResult();
         if (!databaseResult) {
             m_executableWithDatabase->requestCallback().sendFailure("Unexpected result type.");
@@ -365,10 +366,12 @@ public:
             m_requestCallback->sendFailure("Could not get result in callback.");
             return;
         }
+        
         if (request.scriptResult()) {
             end(false);
             return;
         }
+        
         auto* cursorResult = request.cursorResult();
         if (!cursorResult) {
             end(false);
@@ -468,13 +471,13 @@ public:
             }
 
             if (exec) {
-                auto result = idbIndex->openCursor(*exec, m_idbKeyRange.get(), IDBCursor::directionNext());
+                auto result = idbIndex->openCursor(*exec, m_idbKeyRange.get(), IDBCursorDirection::Next);
                 if (!result.hasException())
                     idbRequest = result.releaseReturnValue();
             }
         } else {
             if (exec) {
-                auto result = idbObjectStore->openCursor(*exec, m_idbKeyRange.get(), IDBCursor::directionNext());
+                auto result = idbObjectStore->openCursor(*exec, m_idbKeyRange.get(), IDBCursorDirection::Next);
                 if (!result.hasException())
                     idbRequest = result.releaseReturnValue();
             }