[WebIDL] Add support for converting dictionaries to JS
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Dec 2016 07:59:02 +0000 (07:59 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Dec 2016 07:59:02 +0000 (07:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=165367

Patch by Sam Weinig <sam@webkit.org> on 2016-12-06
Reviewed by Darin Adler and Alex Christensen.

Source/WebCore:

- Adds support for converting dictionary types to JSValues via JSDOMConvert.
- Adopts that functionality to correct the CryptoKeyPair implementation, which
  is supposed to be a dictionary.
  (While doing this, I also update places that were passing both a CryptoKey
  and CryptoKeyPair to use a Variant, since they always only wanted one.)
- Re-works DOMPromise and DeferredPromise to be based on JSDOMConvert and IDLTypes.

* CMakeLists.txt:
* PlatformEfl.cmake:
* PlatformGTK.cmake:
* PlatformMac.cmake:
* WebCore.xcodeproj/project.pbxproj:
Remove JSCryptoKeyPairCustom.cpp and CryptoKeyPair.cpp.

* Modules/encryptedmedia/legacy/WebKitMediaKeys.cpp:
* Modules/mediasource/MediaSource.cpp:
* Modules/mediasource/SourceBuffer.cpp:
* bindings/js/JSMediaDevicesCustom.cpp:
* html/MediaController.cpp:
* html/track/TextTrack.cpp:
Add some missing includes.

* Modules/applepay/ApplePaySession.cpp:
(WebCore::ApplePaySession::canMakePaymentsWithActiveCard):
(WebCore::ApplePaySession::openPaymentSetup):
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::text):
(WebCore::FetchBody::consume):
(WebCore::FetchBody::loadingFailed):
* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::resolveWithData):
(WebCore::FetchBodyConsumer::resolve):
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::blob):
(WebCore::FetchBodyOwner::formData):
(WebCore::FetchBodyOwner::text):
* Modules/fetch/FetchResponse.h:
* Modules/mediastream/MediaDevices.h:
* Modules/mediastream/MediaEndpointPeerConnection.cpp:
(WebCore::MediaEndpointPeerConnection::replaceTrack):
(WebCore::MediaEndpointPeerConnection::replaceTrackTask):
* Modules/mediastream/MediaEndpointPeerConnection.h:
* Modules/mediastream/MediaStreamTrack.cpp:
(WebCore::MediaStreamTrack::applyConstraints):
* Modules/mediastream/PeerConnectionBackend.cpp:
(WebCore::PeerConnectionBackend::setLocalDescription):
(WebCore::PeerConnectionBackend::setRemoteDescription):
(WebCore::PeerConnectionBackend::addIceCandidate):
* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::queuedSetLocalDescription):
(WebCore::RTCPeerConnection::queuedSetRemoteDescription):
(WebCore::RTCPeerConnection::queuedAddIceCandidate):
(WebCore::RTCPeerConnection::replaceTrack):
* Modules/mediastream/RTCPeerConnection.h:
* Modules/mediastream/RTCRtpSender.cpp:
(WebCore::RTCRtpSender::replaceTrack):
* Modules/mediastream/RTCRtpSender.h:
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::deny):
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::suspend):
(WebCore::AudioContext::resume):
* bindings/js/JSCustomElementRegistryCustom.cpp:
(WebCore::whenDefinedPromise):
* bindings/js/ScriptModuleLoader.cpp:
(WebCore::ScriptModuleLoader::resolve):
(WebCore::ScriptModuleLoader::notifyFinished):
* css/FontFace.h:
* css/FontFaceSet.cpp:
(WebCore::FontFaceSet::load):
* css/FontFaceSet.h:
* dom/CustomElementRegistry.cpp:
(WebCore::CustomElementRegistry::addElementDefinition):
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::rejectPendingPlayPromises):
* html/HTMLMediaElement.h:
Update to use new IDLType based promises.

* bindings/generic/IDLTypes.h:
Add a new type, ParameterType, to use as the parameter to
DOMPromise/DeferredPromise.

* bindings/js/JSCryptoKeyPairCustom.cpp:
Removed.

* bindings/js/JSDOMConvert.h:
(WebCore::JSConverter<IDLDictionary<T>>::convert):
Add JSConverter specialization for IDLDictionary. Have it simply forward to a generated
convertDictionaryToJS function, following the convention set in place by IDLEnumeration.

* bindings/js/JSDOMPromise.cpp:
* bindings/js/JSDOMPromise.h:
Re-write to be based on IDLTypes and JSDOMConvert, simplifying the implementation.

* bindings/js/JSSubtleCryptoCustom.cpp:
* bindings/js/JSWebKitSubtleCryptoCustom.cpp:
Update for variant based KeyOrKeyPair.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateDictionaryHeaderContent):
(GenerateDictionaryImplementationContent):
Add generation of the convertDictionaryToJS function. I made it require the JSGenerateToJSObject
extended attribute for now, as the majority of dictionaries do not need this code generated for them.

* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::convertDictionaryToJS):
* bindings/scripts/test/JS/JSTestObj.h:
* bindings/scripts/test/TestObj.idl:
Add JSGenerateToJSObject to a dictionary to test generation in bindings tests.

* crypto/CryptoAlgorithm.h:
Change KeyOrKeyPairCallback to take a Variant<RefPtr<CryptoKey>, CryptoKeyPair>, rather
than two separate arguments.

* crypto/CryptoKeyPair.cpp:
Removed.

* crypto/CryptoKeyPair.h:
Convert to a struct.

* crypto/CryptoKeyPair.idl:
Convert to a dictionary.

* crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
(WebCore::CryptoAlgorithmAES_CBC::generateKey):
* crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
(WebCore::CryptoAlgorithmAES_KW::generateKey):
* crypto/algorithms/CryptoAlgorithmHMAC.cpp:
(WebCore::CryptoAlgorithmHMAC::generateKey):
* crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey):
* crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
(WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey):
* crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
(WebCore::CryptoAlgorithmRSA_OAEP::generateKey):
* crypto/keys/CryptoKeyRSA.h:
* crypto/mac/CryptoKeyRSAMac.cpp:
(WebCore::CryptoKeyRSA::generatePair):
Update for new signature of KeyOrKeyPairCallback.

Source/WebKit2:

* CMakeLists.txt:
Add missing directories to look in for headers.

LayoutTests:

* crypto/subtle/rsa-oaep-generate-key-expected.txt:
* crypto/subtle/rsa-oaep-generate-key.html:
* crypto/subtle/rsaes-pkcs1-v1_5-generate-key-expected.txt:
* crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable-expected.txt:
* crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html:
* crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html:
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt:
* crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html:
* crypto/webkitSubtle/rsa-oaep-generate-non-extractable-key-expected.txt:
* crypto/webkitSubtle/rsa-oaep-generate-non-extractable-key.html:
* crypto/webkitSubtle/rsa-oaep-key-manipulation-expected.txt:
* crypto/webkitSubtle/rsa-oaep-key-manipulation.html:
* crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-expected.txt:
* crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-with-leading-zeroes-in-exponent-expected.txt:
* crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-with-leading-zeroes-in-exponent.html:
* crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key.html:
* crypto/workers/subtle/resources/rsa-generate-key.js:
* crypto/workers/subtle/rsa-generate-key-expected.txt:
Update tests and expected results to show that CryptoKeyPair is now a vanilla object, not a platform object.

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

82 files changed:
LayoutTests/ChangeLog
LayoutTests/crypto/subtle/rsa-oaep-generate-key-expected.txt
LayoutTests/crypto/subtle/rsa-oaep-generate-key.html
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-expected.txt
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable-expected.txt
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html
LayoutTests/crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt
LayoutTests/crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html
LayoutTests/crypto/webkitSubtle/rsa-oaep-generate-non-extractable-key-expected.txt
LayoutTests/crypto/webkitSubtle/rsa-oaep-generate-non-extractable-key.html
LayoutTests/crypto/webkitSubtle/rsa-oaep-key-manipulation-expected.txt
LayoutTests/crypto/webkitSubtle/rsa-oaep-key-manipulation.html
LayoutTests/crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-expected.txt
LayoutTests/crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-with-leading-zeroes-in-exponent-expected.txt
LayoutTests/crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-with-leading-zeroes-in-exponent.html
LayoutTests/crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key.html
LayoutTests/crypto/workers/subtle/resources/rsa-generate-key.js
LayoutTests/crypto/workers/subtle/rsa-generate-key-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePaySession.cpp
Source/WebCore/Modules/encryptedmedia/legacy/WebKitMediaKeys.cpp
Source/WebCore/Modules/fetch/FetchBody.cpp
Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp
Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
Source/WebCore/Modules/fetch/FetchResponse.h
Source/WebCore/Modules/mediasource/MediaSource.cpp
Source/WebCore/Modules/mediasource/SourceBuffer.cpp
Source/WebCore/Modules/mediastream/MediaDevices.h
Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.cpp
Source/WebCore/Modules/mediastream/MediaEndpointPeerConnection.h
Source/WebCore/Modules/mediastream/MediaStreamTrack.cpp
Source/WebCore/Modules/mediastream/PeerConnectionBackend.cpp
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
Source/WebCore/Modules/mediastream/RTCPeerConnection.cpp
Source/WebCore/Modules/mediastream/RTCPeerConnection.h
Source/WebCore/Modules/mediastream/RTCRtpSender.cpp
Source/WebCore/Modules/mediastream/RTCRtpSender.h
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/webaudio/AudioContext.cpp
Source/WebCore/PlatformEfl.cmake
Source/WebCore/PlatformGTK.cmake
Source/WebCore/PlatformMac.cmake
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/generic/IDLTypes.h
Source/WebCore/bindings/js/JSCryptoKeyPairCustom.cpp [deleted file]
Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp
Source/WebCore/bindings/js/JSDOMConvert.h
Source/WebCore/bindings/js/JSDOMPromise.cpp
Source/WebCore/bindings/js/JSDOMPromise.h
Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp
Source/WebCore/bindings/js/ScriptModuleLoader.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.h
Source/WebCore/bindings/scripts/test/TestObj.idl
Source/WebCore/crypto/CryptoAlgorithm.h
Source/WebCore/crypto/CryptoKeyPair.cpp [deleted file]
Source/WebCore/crypto/CryptoKeyPair.h
Source/WebCore/crypto/CryptoKeyPair.idl
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_CBC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmAES_KW.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmHMAC.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp
Source/WebCore/crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp
Source/WebCore/crypto/keys/CryptoKeyRSA.h
Source/WebCore/crypto/mac/CryptoKeyRSAMac.cpp
Source/WebCore/css/FontFace.h
Source/WebCore/css/FontFaceSet.cpp
Source/WebCore/css/FontFaceSet.h
Source/WebCore/dom/CustomElementRegistry.cpp
Source/WebCore/html/HTMLMediaElement.cpp
Source/WebCore/html/HTMLMediaElement.h
Source/WebCore/html/MediaController.cpp
Source/WebCore/html/canvas/WebGLRenderingContext.cpp
Source/WebCore/html/track/TextTrack.cpp
Source/WebKit2/CMakeLists.txt
Source/WebKit2/ChangeLog

index 35c9742..31e4bbb 100644 (file)
@@ -1,3 +1,30 @@
+2016-12-06  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Add support for converting dictionaries to JS
+        https://bugs.webkit.org/show_bug.cgi?id=165367
+
+        Reviewed by Darin Adler and Alex Christensen.
+
+        * crypto/subtle/rsa-oaep-generate-key-expected.txt:
+        * crypto/subtle/rsa-oaep-generate-key.html:
+        * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-expected.txt:
+        * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable-expected.txt:
+        * crypto/subtle/rsaes-pkcs1-v1_5-generate-key-extractable.html:
+        * crypto/subtle/rsaes-pkcs1-v1_5-generate-key.html:
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-key-expected.txt:
+        * crypto/subtle/rsassa-pkcs1-v1_5-generate-key.html:
+        * crypto/webkitSubtle/rsa-oaep-generate-non-extractable-key-expected.txt:
+        * crypto/webkitSubtle/rsa-oaep-generate-non-extractable-key.html:
+        * crypto/webkitSubtle/rsa-oaep-key-manipulation-expected.txt:
+        * crypto/webkitSubtle/rsa-oaep-key-manipulation.html:
+        * crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-expected.txt:
+        * crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-with-leading-zeroes-in-exponent-expected.txt:
+        * crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key-with-leading-zeroes-in-exponent.html:
+        * crypto/webkitSubtle/rsassa-pkcs1-v1_5-generate-key.html:
+        * crypto/workers/subtle/resources/rsa-generate-key.js:
+        * crypto/workers/subtle/rsa-generate-key-expected.txt:
+        Update tests and expected results to show that CryptoKeyPair is now a vanilla object, not a platform object.
+
 2016-12-05  Antoine Quint  <graouts@apple.com>
 
         [Modern Media Controls] Controls bar in fullscreen cannot be dragged
index 5c5f2f5..25bcc21 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Generating a key pair...
-PASS keyPair.toString() is '[object CryptoKeyPair]'
+PASS keyPair.toString() is '[object Object]'
 PASS keyPair.publicKey.type is 'public'
 PASS keyPair.publicKey.extractable is true
 PASS keyPair.publicKey.algorithm.name is 'RSA-OAEP'
index 44f7f51..8f497a1 100644 (file)
@@ -25,7 +25,7 @@ var nonExtractable = false;
 debug("Generating a key pair...");
 crypto.subtle.generateKey(algorithmKeyGen, nonExtractable, ["decrypt", "encrypt", "wrapKey", "unwrapKey"]).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.extractable", "true");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSA-OAEP'");
index 1c51cf8..8c4ed41 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Generating a key pair...
-PASS keyPair.toString() is '[object CryptoKeyPair]'
+PASS keyPair.toString() is '[object Object]'
 PASS keyPair.publicKey.type is 'public'
 PASS keyPair.publicKey.extractable is true
 PASS keyPair.publicKey.algorithm.name is 'RSAES-PKCS1-v1_5'
index 8defaf6..cb8017e 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Generating a key pair...
-PASS keyPair.toString() is '[object CryptoKeyPair]'
+PASS keyPair.toString() is '[object Object]'
 PASS keyPair.publicKey.type is 'public'
 PASS keyPair.publicKey.extractable is true
 PASS keyPair.publicKey.algorithm.name is 'RSAES-PKCS1-v1_5'
index b596eed..d21a7a2 100644 (file)
@@ -24,7 +24,7 @@ var extractable = true;
 debug("Generating a key pair...");
 crypto.subtle.generateKey(algorithmKeyGen, extractable, ["decrypt", "encrypt"]).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.extractable", "true");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
index a68d135..8e6cff9 100644 (file)
@@ -24,7 +24,7 @@ var nonExtractable = false;
 debug("Generating a key pair...");
 crypto.subtle.generateKey(algorithmKeyGen, nonExtractable, ["decrypt", "encrypt"]).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.extractable", "true");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSAES-PKCS1-v1_5'");
index 9914441..720bc78 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Generating a key pair...
-PASS keyPair.toString() is '[object CryptoKeyPair]'
+PASS keyPair.toString() is '[object Object]'
 PASS keyPair.publicKey.type is 'public'
 PASS keyPair.publicKey.extractable is true
 PASS keyPair.publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
index 1c91ea1..e6ae97d 100644 (file)
@@ -25,7 +25,7 @@ var nonExtractable = false;
 debug("Generating a key pair...");
 crypto.subtle.generateKey(algorithmKeyGen, nonExtractable, ["sign", "verify"]).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.extractable", "true");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
index 52aca2b..9f595ec 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Generating a key pair...
-PASS keyPair.toString() is '[object CryptoKeyPair]'
+PASS keyPair.toString() is '[object Object]'
 PASS keyPair.publicKey.type is 'public'
 PASS keyPair.publicKey.extractable is true
 PASS keyPair.publicKey.algorithm.name is 'RSA-OAEP'
index 9290265..c0bf875 100644 (file)
@@ -24,7 +24,7 @@ var nonExtractable = false;
 debug("Generating a key pair...");
 crypto.webkitSubtle.generateKey(algorithmKeyGen, nonExtractable, []).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.extractable", "true");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSA-OAEP'");
index a3377b5..c098078 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Generating a key pair...
-PASS keyPair.toString() is '[object CryptoKeyPair]'
+PASS keyPair.toString() is '[object Object]'
 PASS keyPair.publicKey.type is 'public'
 PASS keyPair.publicKey.algorithm.name is 'RSA-OAEP'
 PASS keyPair.publicKey.algorithm.modulusLength is 2048
index a66b7d6..cb5c542 100644 (file)
@@ -24,7 +24,7 @@ var extractable = true;
 debug("Generating a key pair...");
 crypto.webkitSubtle.generateKey(algorithmKeyGen, extractable, ["encrypt", "decrypt", "wrapKey", "unwrapKey"]).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSA-OAEP'");
     shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048");
index 77638ab..c4bdc0c 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Generating a key pair...
-PASS keyPair.toString() is '[object CryptoKeyPair]'
+PASS keyPair.toString() is '[object Object]'
 PASS keyPair.publicKey.type is 'public'
 PASS keyPair.publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
 PASS keyPair.publicKey.algorithm.modulusLength is 2048
index d8ef934..bc72e2a 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 Generating a key pair...
-PASS keyPair.toString() is '[object CryptoKeyPair]'
+PASS keyPair.toString() is '[object Object]'
 PASS keyPair.publicKey.type is 'public'
 PASS keyPair.publicKey.algorithm.name is 'RSASSA-PKCS1-v1_5'
 PASS keyPair.publicKey.algorithm.modulusLength is 2048
index a6f60a8..a907b88 100644 (file)
@@ -24,7 +24,7 @@ var extractable = true;
 debug("Generating a key pair...");
 crypto.webkitSubtle.generateKey(algorithmKeyGen, extractable, ["sign", "verify"]).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
     shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048");
index 8b5eac2..0ae96b6 100644 (file)
@@ -24,7 +24,7 @@ var extractable = true;
 debug("Generating a key pair...");
 crypto.webkitSubtle.generateKey(algorithmKeyGen, extractable, ["sign", "verify"]).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSASSA-PKCS1-v1_5'");
     shouldBe("keyPair.publicKey.algorithm.modulusLength", "2048");
index f545582..42c9d1b 100644 (file)
@@ -13,7 +13,7 @@ shouldReject('crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLengt
     return crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: 'sha-1'}, extractable, ["decrypt", "encrypt", "wrapKey", "unwrapKey"]);
 }).then(function(result) {
     keyPair = result;
-    shouldBe("keyPair.toString()", "'[object CryptoKeyPair]'");
+    shouldBe("keyPair.toString()", "'[object Object]'");
     shouldBe("keyPair.publicKey.type", "'public'");
     shouldBe("keyPair.publicKey.extractable", "true");
     shouldBe("keyPair.publicKey.algorithm.name", "'RSA-OAEP'");
index 722d088..e9c10ef 100644 (file)
@@ -7,7 +7,7 @@ Starting worker: resources/rsa-generate-key.js
 PASS [Worker] crypto.subtle.generateKey({name: "RSA-OAEP", modulusLength: 2048, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign"]) rejected promise  with SyntaxError (DOM Exception 12): A required parameter was missing or out-of-range.
 PASS [Worker] crypto.subtle.generateKey({name: "RSASSA-PKCS1-v1_5", modulusLength: 0, publicExponent: publicExponent, hash: "sha-1"}, extractable, ["sign", "verify"]) rejected promise  with OperationError (DOM Exception 34): The operation failed for an operation-specific reason.
 [Worker] Generating a key...
-PASS [Worker] keyPair.toString() is '[object CryptoKeyPair]'
+PASS [Worker] keyPair.toString() is '[object Object]'
 PASS [Worker] keyPair.publicKey.type is 'public'
 PASS [Worker] keyPair.publicKey.extractable is true
 PASS [Worker] keyPair.publicKey.algorithm.name is 'RSA-OAEP'
index b991f59..9e5db62 100644 (file)
@@ -1105,7 +1105,6 @@ set(WebCore_SOURCES
     bindings/js/JSCryptoAlgorithmDictionary.cpp
     bindings/js/JSCryptoCustom.cpp
     bindings/js/JSCryptoKeyCustom.cpp
-    bindings/js/JSCryptoKeyPairCustom.cpp
     bindings/js/JSCryptoKeySerializationJWK.cpp
     bindings/js/JSCryptoOperationData.cpp
     bindings/js/JSCustomElementInterface.cpp
index 5d61741..7727b19 100644 (file)
@@ -1,3 +1,151 @@
+2016-12-06  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Add support for converting dictionaries to JS
+        https://bugs.webkit.org/show_bug.cgi?id=165367
+
+        Reviewed by Darin Adler and Alex Christensen.
+
+        - Adds support for converting dictionary types to JSValues via JSDOMConvert.
+        - Adopts that functionality to correct the CryptoKeyPair implementation, which
+          is supposed to be a dictionary.
+          (While doing this, I also update places that were passing both a CryptoKey 
+          and CryptoKeyPair to use a Variant, since they always only wanted one.)
+        - Re-works DOMPromise and DeferredPromise to be based on JSDOMConvert and IDLTypes.
+
+        * CMakeLists.txt:
+        * PlatformEfl.cmake:
+        * PlatformGTK.cmake:
+        * PlatformMac.cmake:
+        * WebCore.xcodeproj/project.pbxproj:
+        Remove JSCryptoKeyPairCustom.cpp and CryptoKeyPair.cpp.
+
+        * Modules/encryptedmedia/legacy/WebKitMediaKeys.cpp:
+        * Modules/mediasource/MediaSource.cpp:
+        * Modules/mediasource/SourceBuffer.cpp:
+        * bindings/js/JSMediaDevicesCustom.cpp:
+        * html/MediaController.cpp:
+        * html/track/TextTrack.cpp:
+        Add some missing includes.
+
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::ApplePaySession::canMakePaymentsWithActiveCard):
+        (WebCore::ApplePaySession::openPaymentSetup):
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::text):
+        (WebCore::FetchBody::consume):
+        (WebCore::FetchBody::loadingFailed):
+        * Modules/fetch/FetchBodyConsumer.cpp:
+        (WebCore::FetchBodyConsumer::resolveWithData):
+        (WebCore::FetchBodyConsumer::resolve):
+        * Modules/fetch/FetchBodyOwner.cpp:
+        (WebCore::FetchBodyOwner::blob):
+        (WebCore::FetchBodyOwner::formData):
+        (WebCore::FetchBodyOwner::text):
+        * Modules/fetch/FetchResponse.h:
+        * Modules/mediastream/MediaDevices.h:
+        * Modules/mediastream/MediaEndpointPeerConnection.cpp:
+        (WebCore::MediaEndpointPeerConnection::replaceTrack):
+        (WebCore::MediaEndpointPeerConnection::replaceTrackTask):
+        * Modules/mediastream/MediaEndpointPeerConnection.h:
+        * Modules/mediastream/MediaStreamTrack.cpp:
+        (WebCore::MediaStreamTrack::applyConstraints):
+        * Modules/mediastream/PeerConnectionBackend.cpp:
+        (WebCore::PeerConnectionBackend::setLocalDescription):
+        (WebCore::PeerConnectionBackend::setRemoteDescription):
+        (WebCore::PeerConnectionBackend::addIceCandidate):
+        * Modules/mediastream/PeerConnectionBackend.h:
+        * Modules/mediastream/RTCPeerConnection.cpp:
+        (WebCore::RTCPeerConnection::queuedSetLocalDescription):
+        (WebCore::RTCPeerConnection::queuedSetRemoteDescription):
+        (WebCore::RTCPeerConnection::queuedAddIceCandidate):
+        (WebCore::RTCPeerConnection::replaceTrack):
+        * Modules/mediastream/RTCPeerConnection.h:
+        * Modules/mediastream/RTCRtpSender.cpp:
+        (WebCore::RTCRtpSender::replaceTrack):
+        * Modules/mediastream/RTCRtpSender.h:
+        * Modules/mediastream/UserMediaRequest.cpp:
+        (WebCore::UserMediaRequest::deny):
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::suspend):
+        (WebCore::AudioContext::resume):
+        * bindings/js/JSCustomElementRegistryCustom.cpp:
+        (WebCore::whenDefinedPromise):
+        * bindings/js/ScriptModuleLoader.cpp:
+        (WebCore::ScriptModuleLoader::resolve):
+        (WebCore::ScriptModuleLoader::notifyFinished):
+        * css/FontFace.h:
+        * css/FontFaceSet.cpp:
+        (WebCore::FontFaceSet::load):
+        * css/FontFaceSet.h:
+        * dom/CustomElementRegistry.cpp:
+        (WebCore::CustomElementRegistry::addElementDefinition):
+        * html/HTMLMediaElement.cpp:
+        (WebCore::HTMLMediaElement::rejectPendingPlayPromises):
+        * html/HTMLMediaElement.h:
+        Update to use new IDLType based promises.
+
+        * bindings/generic/IDLTypes.h:
+        Add a new type, ParameterType, to use as the parameter to 
+        DOMPromise/DeferredPromise.
+
+        * bindings/js/JSCryptoKeyPairCustom.cpp:
+        Removed.
+
+        * bindings/js/JSDOMConvert.h:
+        (WebCore::JSConverter<IDLDictionary<T>>::convert):
+        Add JSConverter specialization for IDLDictionary. Have it simply forward to a generated 
+        convertDictionaryToJS function, following the convention set in place by IDLEnumeration.
+
+        * bindings/js/JSDOMPromise.cpp:
+        * bindings/js/JSDOMPromise.h:
+        Re-write to be based on IDLTypes and JSDOMConvert, simplifying the implementation.
+
+        * bindings/js/JSSubtleCryptoCustom.cpp:
+        * bindings/js/JSWebKitSubtleCryptoCustom.cpp:
+        Update for variant based KeyOrKeyPair.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateDictionaryHeaderContent):
+        (GenerateDictionaryImplementationContent):
+        Add generation of the convertDictionaryToJS function. I made it require the JSGenerateToJSObject
+        extended attribute for now, as the majority of dictionaries do not need this code generated for them.
+
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::convertDictionaryToJS):
+        * bindings/scripts/test/JS/JSTestObj.h:
+        * bindings/scripts/test/TestObj.idl:
+        Add JSGenerateToJSObject to a dictionary to test generation in bindings tests.
+
+        * crypto/CryptoAlgorithm.h:
+        Change KeyOrKeyPairCallback to take a Variant<RefPtr<CryptoKey>, CryptoKeyPair>, rather
+        than two separate arguments.
+
+        * crypto/CryptoKeyPair.cpp:
+        Removed.
+
+        * crypto/CryptoKeyPair.h:
+        Convert to a struct.
+
+        * crypto/CryptoKeyPair.idl:
+        Convert to a dictionary.
+
+        * crypto/algorithms/CryptoAlgorithmAES_CBC.cpp:
+        (WebCore::CryptoAlgorithmAES_CBC::generateKey):
+        * crypto/algorithms/CryptoAlgorithmAES_KW.cpp:
+        (WebCore::CryptoAlgorithmAES_KW::generateKey):
+        * crypto/algorithms/CryptoAlgorithmHMAC.cpp:
+        (WebCore::CryptoAlgorithmHMAC::generateKey):
+        * crypto/algorithms/CryptoAlgorithmRSAES_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey):
+        * crypto/algorithms/CryptoAlgorithmRSASSA_PKCS1_v1_5.cpp:
+        (WebCore::CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey):
+        * crypto/algorithms/CryptoAlgorithmRSA_OAEP.cpp:
+        (WebCore::CryptoAlgorithmRSA_OAEP::generateKey):
+        * crypto/keys/CryptoKeyRSA.h:
+        * crypto/mac/CryptoKeyRSAMac.cpp:
+        (WebCore::CryptoKeyRSA::generatePair):
+        Update for new signature of KeyOrKeyPairCallback.
+
 2016-12-05  Dave Hyatt  <hyatt@apple.com>
 
         [CSS Parser] Reject invalid hex colors on the fast path
index 6fc45fb..425cbe5 100644 (file)
@@ -735,7 +735,7 @@ ExceptionOr<void> ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecution
         bool canMakePayments = paymentCoordinator.canMakePayments();
 
         RunLoop::main().dispatch([promise, canMakePayments]() mutable {
-            promise->resolve(canMakePayments);
+            promise->resolve<IDLBoolean>(canMakePayments);
         });
         return { };
     }
@@ -743,7 +743,7 @@ ExceptionOr<void> ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecution
     auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator();
 
     paymentCoordinator.canMakePaymentsWithActiveCard(merchantIdentifier, document.domain(), [promise](bool canMakePayments) mutable {
-        promise->resolve(canMakePayments);
+        promise->resolve<IDLBoolean>(canMakePayments);
     });
     return { };
 }
@@ -768,7 +768,7 @@ ExceptionOr<void> ApplePaySession::openPaymentSetup(ScriptExecutionContext& scri
     auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator();
 
     paymentCoordinator.openPaymentSetup(merchantIdentifier, document.domain(), [promise](bool result) mutable {
-        promise->resolve(result);
+        promise->resolve<IDLBoolean>(result);
     });
 
     return { };
index ab49f0d..7f1b4cd 100644 (file)
@@ -29,6 +29,7 @@
 #if ENABLE(LEGACY_ENCRYPTED_MEDIA)
 
 #include "EventNames.h"
+#include "ExceptionCode.h"
 #include "HTMLMediaElement.h"
 #include "WebKitMediaKeySession.h"
 
index 3f23dac..a6cfe05 100644 (file)
@@ -107,7 +107,7 @@ void FetchBody::json(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 void FetchBody::text(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     if (isText()) {
-        promise->resolve(textBody());
+        promise->resolve<IDLDOMString>(textBody());
         return;
     }
     m_consumer.setType(FetchBodyConsumer::Type::Text);
@@ -144,7 +144,7 @@ void FetchBody::consume(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
     }
     if (isFormData()) {
         // FIXME: Support consuming FormData.
-        promise->reject(0);
+        promise->reject();
         return;
     }
     m_consumer.resolve(WTFMove(promise));
@@ -212,7 +212,7 @@ void FetchBody::consumeBlob(FetchBodyOwner& owner, Ref<DeferredPromise>&& promis
 void FetchBody::loadingFailed()
 {
     if (m_consumePromise) {
-        m_consumePromise->reject(0);
+        m_consumePromise->reject();
         m_consumePromise = nullptr;
     }
 }
index b6430ab..e82a74a 100644 (file)
@@ -65,13 +65,13 @@ void FetchBodyConsumer::resolveWithData(Ref<DeferredPromise>&& promise, const un
         fulfillPromiseWithArrayBuffer(WTFMove(promise), data, length);
         return;
     case Type::Blob:
-        promise->resolveWithNewlyCreated(blobFromData(data, length, m_contentType));
+        promise->resolveWithNewlyCreated<IDLInterface<Blob>>(blobFromData(data, length, m_contentType).get());
         return;
     case Type::JSON:
         fulfillPromiseWithJSON(WTFMove(promise), textFromUTF8(data, length));
         return;
     case Type::Text:
-        promise->resolve(textFromUTF8(data, length));
+        promise->resolve<IDLDOMString>(textFromUTF8(data, length));
         return;
     case Type::None:
         ASSERT_NOT_REACHED();
@@ -87,13 +87,13 @@ void FetchBodyConsumer::resolve(Ref<DeferredPromise>&& promise)
         fulfillPromiseWithArrayBuffer(WTFMove(promise), takeAsArrayBuffer().get());
         return;
     case Type::Blob:
-        promise->resolveWithNewlyCreated(takeAsBlob());
+        promise->resolveWithNewlyCreated<IDLInterface<Blob>>(takeAsBlob().get());
         return;
     case Type::JSON:
         fulfillPromiseWithJSON(WTFMove(promise), takeAsText());
         return;
     case Type::Text:
-        promise->resolve(takeAsText());
+        promise->resolve<IDLDOMString>(takeAsText());
         return;
     case Type::None:
         ASSERT_NOT_REACHED();
index 287c977..380c570 100644 (file)
@@ -90,7 +90,7 @@ void FetchBodyOwner::arrayBuffer(Ref<DeferredPromise>&& promise)
 void FetchBodyOwner::blob(Ref<DeferredPromise>&& promise)
 {
     if (isBodyNull()) {
-        promise->resolve(Blob::create(Vector<uint8_t>(), Blob::normalizedContentType(extractMIMETypeFromMediaType(m_contentType))));
+        promise->resolve<IDLInterface<Blob>>(Blob::create({ }, Blob::normalizedContentType(extractMIMETypeFromMediaType(m_contentType))).get());
         return;
     }
     if (isDisturbedOrLocked()) {
@@ -138,7 +138,7 @@ void FetchBodyOwner::consumeOnceLoadingFinished(FetchBodyConsumer::Type type, Re
 void FetchBodyOwner::formData(Ref<DeferredPromise>&& promise)
 {
     if (isBodyNull()) {
-        promise->reject(0);
+        promise->reject();
         return;
     }
     if (isDisturbedOrLocked()) {
@@ -166,7 +166,7 @@ void FetchBodyOwner::json(Ref<DeferredPromise>&& promise)
 void FetchBodyOwner::text(Ref<DeferredPromise>&& promise)
 {
     if (isBodyNull()) {
-        promise->resolve(String());
+        promise->resolve<IDLDOMString>({ });
         return;
     }
     if (isDisturbedOrLocked()) {
index c68701d..688d869 100644 (file)
@@ -52,7 +52,7 @@ public:
     static Ref<FetchResponse> error(ScriptExecutionContext&);
     static ExceptionOr<Ref<FetchResponse>> redirect(ScriptExecutionContext&, const String& url, int status);
 
-    using FetchPromise = DOMPromise<FetchResponse>;
+    using FetchPromise = DOMPromise<IDLInterface<FetchResponse>>;
     static void fetch(ScriptExecutionContext&, FetchRequest&, FetchPromise&&);
 
     void consume(unsigned, Ref<DeferredPromise>&&);
index 5952bd9..43c0d00 100644 (file)
@@ -38,6 +38,7 @@
 #include "ContentType.h"
 #include "Event.h"
 #include "EventNames.h"
+#include "ExceptionCode.h"
 #include "HTMLMediaElement.h"
 #include "Logging.h"
 #include "MediaSourcePrivate.h"
index f559811..fe8a4c9 100644 (file)
@@ -38,6 +38,7 @@
 #include "BufferSource.h"
 #include "Event.h"
 #include "EventNames.h"
+#include "ExceptionCode.h"
 #include "GenericEventQueue.h"
 #include "HTMLMediaElement.h"
 #include "InbandTextTrack.h"
index 63d0244..fb4b734 100644 (file)
@@ -32,6 +32,7 @@
 
 #if ENABLE(MEDIA_STREAM)
 
+#include "ExceptionOr.h"
 #include "JSDOMPromise.h"
 #include "MediaDeviceInfo.h"
 
@@ -48,8 +49,8 @@ public:
 
     Document* document() const;
 
-    using Promise = DOMPromise<MediaStream>;
-    using EnumerateDevicesPromise = DOMPromise<MediaDeviceInfoVector>;
+    using Promise = DOMPromise<IDLInterface<MediaStream>>;
+    using EnumerateDevicesPromise = DOMPromise<IDLSequence<IDLInterface<MediaDeviceInfo>>>;
 
     ExceptionOr<void> getUserMedia(Ref<MediaConstraintsImpl>&& audioConstraints, Ref<MediaConstraintsImpl>&& videoConstraints, Promise&&) const;
     void enumerateDevices(EnumerateDevicesPromise&&) const;
index ac97ba4..b17ff33 100644 (file)
@@ -703,7 +703,7 @@ std::unique_ptr<RTCDataChannelHandler> MediaEndpointPeerConnection::createDataCh
     return m_mediaEndpoint->createDataChannelHandler(label, options);
 }
 
-void MediaEndpointPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, PeerConnection::VoidPromise&& promise)
+void MediaEndpointPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, DOMPromise<void>&& promise)
 {
     RTCRtpTransceiver* transceiver = matchTransceiver(m_peerConnection.getTransceivers(), [&sender] (RTCRtpTransceiver& current) {
         return &current.sender() == &sender;
@@ -723,7 +723,7 @@ void MediaEndpointPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<Medi
     });
 }
 
-void MediaEndpointPeerConnection::replaceTrackTask(RTCRtpSender& sender, const String& mid, RefPtr<MediaStreamTrack>&& withTrack, PeerConnection::VoidPromise& promise)
+void MediaEndpointPeerConnection::replaceTrackTask(RTCRtpSender& sender, const String& mid, RefPtr<MediaStreamTrack>&& withTrack, DOMPromise<void>& promise)
 {
     if (m_peerConnection.internalSignalingState() == SignalingState::Closed)
         return;
index 7c80445..c546c79 100644 (file)
@@ -69,7 +69,7 @@ public:
     Vector<RefPtr<MediaStream>> getRemoteStreams() const override;
 
     Ref<RTCRtpReceiver> createReceiver(const String& transceiverMid, const String& trackKind, const String& trackId) override;
-    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, PeerConnection::VoidPromise&&) override;
+    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) override;
 
     bool isNegotiationNeeded() const override { return m_negotiationNeeded; };
     void markAsNeedingNegotiation() override;
@@ -96,7 +96,7 @@ private:
 
     void addIceCandidateTask(RTCIceCandidate&);
 
-    void replaceTrackTask(RTCRtpSender&, const String& mid, RefPtr<MediaStreamTrack>&&, PeerConnection::VoidPromise&);
+    void replaceTrackTask(RTCRtpSender&, const String& mid, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&);
 
     bool localDescriptionTypeValidForState(RTCSessionDescription::SdpType) const;
     bool remoteDescriptionTypeValidForState(RTCSessionDescription::SdpType) const;
index de0a11b..ce65c0d 100644 (file)
@@ -187,7 +187,7 @@ void MediaStreamTrack::applyConstraints(const MediaConstraints& constraints)
         if (!weakThis || !weakThis->m_promise)
             return;
 
-        weakThis->m_promise->reject(OverconstrainedError::create(failedConstraint, message).get());
+        weakThis->m_promise->rejectType<IDLInterface<OverconstrainedError>>(OverconstrainedError::create(failedConstraint, message).get());
     };
 
     std::function<void()> successHandler = [weakThis]() {
index 1446879..0a94126 100644 (file)
@@ -127,7 +127,7 @@ static inline bool isLocalDescriptionTypeValidForState(RTCSessionDescription::Sd
     return false;
 }
 
-void PeerConnectionBackend::setLocalDescription(RTCSessionDescription& sessionDescription, PeerConnection::VoidPromise&& promise)
+void PeerConnectionBackend::setLocalDescription(RTCSessionDescription& sessionDescription, DOMPromise<void>&& promise)
 {
     ASSERT(m_peerConnection.internalSignalingState() != PeerConnectionStates::SignalingState::Closed);
 
@@ -185,7 +185,7 @@ static inline bool isRemoteDescriptionTypeValidForState(RTCSessionDescription::S
     return false;
 }
 
-void PeerConnectionBackend::setRemoteDescription(RTCSessionDescription& sessionDescription, PeerConnection::VoidPromise&& promise)
+void PeerConnectionBackend::setRemoteDescription(RTCSessionDescription& sessionDescription, DOMPromise<void>&& promise)
 {
     ASSERT(m_peerConnection.internalSignalingState() != PeerConnectionStates::SignalingState::Closed);
 
@@ -224,7 +224,7 @@ void PeerConnectionBackend::setRemoteDescriptionFailed(Exception&& exception)
     m_setDescriptionPromise = std::nullopt;
 }
 
-void PeerConnectionBackend::addIceCandidate(RTCIceCandidate& iceCandidate, PeerConnection::VoidPromise&& promise)
+void PeerConnectionBackend::addIceCandidate(RTCIceCandidate& iceCandidate, DOMPromise<void>&& promise)
 {
     ASSERT(m_peerConnection.internalSignalingState() != PeerConnectionStates::SignalingState::Closed);
 
index ca86191..f7ce147 100644 (file)
@@ -59,9 +59,8 @@ struct RTCAnswerOptions;
 struct RTCOfferOptions;
 
 namespace PeerConnection {
-typedef DOMPromise<RTCSessionDescription> SessionDescriptionPromise;
-typedef DOMPromise<void> VoidPromise;
-typedef DOMPromise<RTCStatsResponse> StatsPromise;
+using SessionDescriptionPromise = DOMPromise<IDLInterface<RTCSessionDescription>>;
+using StatsPromise = DOMPromise<IDLInterface<RTCStatsResponse>>;
 }
 
 typedef std::unique_ptr<PeerConnectionBackend> (*CreatePeerConnectionBackend)(RTCPeerConnection&);
@@ -75,9 +74,9 @@ public:
 
     void createOffer(RTCOfferOptions&&, PeerConnection::SessionDescriptionPromise&&);
     void createAnswer(RTCAnswerOptions&&, PeerConnection::SessionDescriptionPromise&&);
-    void setLocalDescription(RTCSessionDescription&, PeerConnection::VoidPromise&&);
-    void setRemoteDescription(RTCSessionDescription&, PeerConnection::VoidPromise&&);
-    void addIceCandidate(RTCIceCandidate&, PeerConnection::VoidPromise&&);
+    void setLocalDescription(RTCSessionDescription&, DOMPromise<void>&&);
+    void setRemoteDescription(RTCSessionDescription&, DOMPromise<void>&&);
+    void addIceCandidate(RTCIceCandidate&, DOMPromise<void>&&);
 
     virtual std::unique_ptr<RTCDataChannelHandler> createDataChannelHandler(const String&, const RTCDataChannelInit&) = 0;
 
@@ -98,7 +97,7 @@ public:
     virtual Vector<RefPtr<MediaStream>> getRemoteStreams() const = 0;
 
     virtual Ref<RTCRtpReceiver> createReceiver(const String& transceiverMid, const String& trackKind, const String& trackId) = 0;
-    virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, PeerConnection::VoidPromise&&) = 0;
+    virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) = 0;
 
     virtual bool isNegotiationNeeded() const = 0;
     virtual void markAsNeedingNegotiation() = 0;
@@ -140,8 +139,8 @@ protected:
 
 private:
     std::optional<PeerConnection::SessionDescriptionPromise> m_offerAnswerPromise;
-    std::optional<PeerConnection::VoidPromise> m_setDescriptionPromise;
-    std::optional<PeerConnection::VoidPromise> m_addIceCandidatePromise;
+    std::optional<DOMPromise<void>> m_setDescriptionPromise;
+    std::optional<DOMPromise<void>> m_addIceCandidatePromise;
 };
 
 } // namespace WebCore
index c1fc64b..ade3c9e 100644 (file)
@@ -228,7 +228,7 @@ void RTCPeerConnection::queuedCreateAnswer(RTCAnswerOptions&& options, SessionDe
     m_backend->createAnswer(WTFMove(options), WTFMove(promise));
 }
 
-void RTCPeerConnection::queuedSetLocalDescription(RTCSessionDescription& description, PeerConnection::VoidPromise&& promise)
+void RTCPeerConnection::queuedSetLocalDescription(RTCSessionDescription& description, DOMPromise<void>&& promise)
 {
     if (m_signalingState == SignalingState::Closed) {
         promise.reject(INVALID_STATE_ERR);
@@ -253,7 +253,7 @@ RefPtr<RTCSessionDescription> RTCPeerConnection::pendingLocalDescription() const
     return m_backend->pendingLocalDescription();
 }
 
-void RTCPeerConnection::queuedSetRemoteDescription(RTCSessionDescription& description, PeerConnection::VoidPromise&& promise)
+void RTCPeerConnection::queuedSetRemoteDescription(RTCSessionDescription& description, DOMPromise<void>&& promise)
 {
     if (m_signalingState == SignalingState::Closed) {
         promise.reject(INVALID_STATE_ERR);
@@ -278,7 +278,7 @@ RefPtr<RTCSessionDescription> RTCPeerConnection::pendingRemoteDescription() cons
     return m_backend->pendingRemoteDescription();
 }
 
-void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate& rtcCandidate, VoidPromise&& promise)
+void RTCPeerConnection::queuedAddIceCandidate(RTCIceCandidate& rtcCandidate, DOMPromise<void>&& promise)
 {
     if (m_signalingState == SignalingState::Closed) {
         promise.reject(INVALID_STATE_ERR);
@@ -469,7 +469,7 @@ void RTCPeerConnection::fireEvent(Event& event)
     dispatchEvent(event);
 }
 
-void RTCPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, PeerConnection::VoidPromise&& promise)
+void RTCPeerConnection::replaceTrack(RTCRtpSender& sender, RefPtr<MediaStreamTrack>&& withTrack, DOMPromise<void>&& promise)
 {
     m_backend->replaceTrack(sender, WTFMove(withTrack), WTFMove(promise));
 }
index e26d559..7850853 100644 (file)
@@ -90,19 +90,19 @@ public:
     void queuedCreateOffer(RTCOfferOptions&&, PeerConnection::SessionDescriptionPromise&&);
     void queuedCreateAnswer(RTCAnswerOptions&&, PeerConnection::SessionDescriptionPromise&&);
 
-    void queuedSetLocalDescription(RTCSessionDescription&, PeerConnection::VoidPromise&&);
+    void queuedSetLocalDescription(RTCSessionDescription&, DOMPromise<void>&&);
     RefPtr<RTCSessionDescription> localDescription() const;
     RefPtr<RTCSessionDescription> currentLocalDescription() const;
     RefPtr<RTCSessionDescription> pendingLocalDescription() const;
 
-    void queuedSetRemoteDescription(RTCSessionDescription&, PeerConnection::VoidPromise&&);
+    void queuedSetRemoteDescription(RTCSessionDescription&, DOMPromise<void>&&);
     RefPtr<RTCSessionDescription> remoteDescription() const;
     RefPtr<RTCSessionDescription> currentRemoteDescription() const;
     RefPtr<RTCSessionDescription> pendingRemoteDescription() const;
 
     String signalingState() const;
 
-    void queuedAddIceCandidate(RTCIceCandidate&, PeerConnection::VoidPromise&&);
+    void queuedAddIceCandidate(RTCIceCandidate&, DOMPromise<void>&&);
 
     String iceGatheringState() const;
     String iceConnectionState() const;
@@ -155,7 +155,7 @@ private:
     bool canSuspendForDocumentSuspension() const final;
 
     // RTCRtpSenderClient
-    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, PeerConnection::VoidPromise&&) final;
+    void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) final;
 
     PeerConnectionStates::SignalingState m_signalingState { PeerConnectionStates::SignalingState::Stable };
     PeerConnectionStates::IceGatheringState m_iceGatheringState { PeerConnectionStates::IceGatheringState::New };
index 8850bbf..53b6f2c 100644 (file)
@@ -67,7 +67,7 @@ void RTCRtpSender::setTrack(RefPtr<MediaStreamTrack>&& track)
     m_track = WTFMove(track);
 }
 
-ExceptionOr<void> RTCRtpSender::replaceTrack(Ref<MediaStreamTrack>&& withTrack, PeerConnection::VoidPromise&& promise)
+ExceptionOr<void> RTCRtpSender::replaceTrack(Ref<MediaStreamTrack>&& withTrack, DOMPromise<void>&& promise)
 {
     if (isStopped()) {
         promise.reject(INVALID_STATE_ERR);
index de63e66..95bea8b 100644 (file)
@@ -39,7 +39,7 @@ namespace WebCore {
 
 class RTCRtpSenderClient {
 public:
-    virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, PeerConnection::VoidPromise&&) = 0;
+    virtual void replaceTrack(RTCRtpSender&, RefPtr<MediaStreamTrack>&&, DOMPromise<void>&&) = 0;
 
     virtual ~RTCRtpSenderClient() { }
 };
@@ -59,7 +59,7 @@ public:
     void stop() { m_client = nullptr; }
     void setTrack(RefPtr<MediaStreamTrack>&&);
 
-    ExceptionOr<void> replaceTrack(Ref<MediaStreamTrack>&&, PeerConnection::VoidPromise&&);
+    ExceptionOr<void> replaceTrack(Ref<MediaStreamTrack>&&, DOMPromise<void>&&);
 
 private:
     RTCRtpSender(RefPtr<MediaStreamTrack>&&, const String& trackKind, Vector<String>&& mediaStreamIds, RTCRtpSenderClient&);
index b4c9f77..c4584ce 100644 (file)
@@ -212,7 +212,7 @@ void UserMediaRequest::deny(MediaAccessDenialReason reason, const String& invali
         m_promise.reject(NOT_FOUND_ERR);
         break;
     case MediaAccessDenialReason::InvalidConstraint:
-        m_promise.reject(OverconstrainedError::create(invalidConstraint, ASCIILiteral("Invalid constraint")).get());
+        m_promise.rejectType<IDLInterface<OverconstrainedError>>(OverconstrainedError::create(invalidConstraint, ASCIILiteral("Invalid constraint")).get());
         break;
     case MediaAccessDenialReason::HardwareError:
         m_promise.reject(NotReadableError);
index 4c1e8a8..1358152 100644 (file)
@@ -1031,7 +1031,7 @@ void AudioContext::suspend(DOMPromise<void>&& promise)
     }
 
     if (m_state == State::Closed || m_state == State::Interrupted || !m_destinationNode) {
-        promise.reject(0);
+        promise.reject();
         return;
     }
 
@@ -1060,7 +1060,7 @@ void AudioContext::resume(DOMPromise<void>&& promise)
     }
 
     if (m_state == State::Closed || !m_destinationNode) {
-        promise.reject(0);
+        promise.reject();
         return;
     }
 
index c6b2ccc..c9cef4c 100644 (file)
@@ -407,7 +407,6 @@ if (ENABLE_SUBTLE_CRYPTO)
         crypto/CryptoAlgorithm.cpp
         crypto/CryptoAlgorithmRegistry.cpp
         crypto/CryptoKey.cpp
-        crypto/CryptoKeyPair.cpp
         crypto/SubtleCrypto.cpp
         crypto/WebKitSubtleCrypto.cpp
 
index c2bd548..7ef36cd 100644 (file)
@@ -399,7 +399,6 @@ if (ENABLE_SUBTLE_CRYPTO)
         crypto/CryptoAlgorithm.cpp
         crypto/CryptoAlgorithmRegistry.cpp
         crypto/CryptoKey.cpp
-        crypto/CryptoKeyPair.cpp
         crypto/SubtleCrypto.cpp
         crypto/WebKitSubtleCrypto.cpp
 
index 2b67e3a..cad9791 100644 (file)
@@ -180,7 +180,6 @@ list(APPEND WebCore_SOURCES
     crypto/CryptoAlgorithm.cpp
     crypto/CryptoAlgorithmRegistry.cpp
     crypto/CryptoKey.cpp
-    crypto/CryptoKeyPair.cpp
     crypto/SubtleCrypto.cpp
     crypto/WebKitSubtleCrypto.cpp
 
index 9242455..4bbce73 100644 (file)
                E1ED8AC30CC49BE000BFC557 /* CSSPrimitiveValueMappings.h in Headers */ = {isa = PBXBuildFile; fileRef = E1ED8AC20CC49BE000BFC557 /* CSSPrimitiveValueMappings.h */; };
                E1F1E82F0C3C2BB9006DB391 /* XSLTExtensions.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */; };
                E1F1E8300C3C2BB9006DB391 /* XSLTExtensions.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */; };
-               E1F80B8718317252007885C3 /* CryptoKeyPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F80B8518317252007885C3 /* CryptoKeyPair.cpp */; };
-               E1F80B8818317252007885C3 /* CryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8618317252007885C3 /* CryptoKeyPair.h */; };
-               E1F80B8A183172A2007885C3 /* JSCryptoKeyPairCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */; };
+               E1F80B8818317252007885C3 /* CryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8618317252007885C3 /* CryptoKeyPair.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E1F80B8D183172B5007885C3 /* JSCryptoKeyPair.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */; };
                E1F80B8E183172B5007885C3 /* JSCryptoKeyPair.h in Headers */ = {isa = PBXBuildFile; fileRef = E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */; };
                E1FE13641834351100892F13 /* CryptoDigestCommonCrypto.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E1FE13621834351100892F13 /* CryptoDigestCommonCrypto.cpp */; };
                5DB1BC6810715A6400EFAA49 /* TransformSource.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TransformSource.h; sourceTree = "<group>"; };
                5DB1BC6910715A6400EFAA49 /* TransformSourceLibxslt.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TransformSourceLibxslt.cpp; sourceTree = "<group>"; };
                5DFEBAB618592B6D00C75BEB /* WebKitAvailability.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitAvailability.h; sourceTree = "<group>"; };
-               5E16A2E21BFA64FB0029A21E /* MediaEndpointPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaEndpointPeerConnection.cpp; sourceTree = "<group>"; };
-               5E16A2E31BFA64FB0029A21E /* MediaEndpointPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaEndpointPeerConnection.h; sourceTree = "<group>"; };
+               5E16A2E21BFA64FB0029A21E /* MediaEndpointPeerConnection.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; lineEnding = 0; path = MediaEndpointPeerConnection.cpp; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
+               5E16A2E31BFA64FB0029A21E /* MediaEndpointPeerConnection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = MediaEndpointPeerConnection.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
                5E2C434D1BCEE2E50001E2BC /* PeerConnectionBackend.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PeerConnectionBackend.h; sourceTree = "<group>"; };
                5E2C434F1BCEE2E50001E2BC /* RTCConfiguration.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = RTCConfiguration.cpp; sourceTree = "<group>"; };
                5E2C43541BCEE30D0001E2BC /* RTCPeerConnection.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = RTCPeerConnection.js; sourceTree = "<group>"; };
                E1F1E82D0C3C2BB9006DB391 /* XSLTExtensions.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XSLTExtensions.cpp; sourceTree = "<group>"; };
                E1F1E82E0C3C2BB9006DB391 /* XSLTExtensions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSLTExtensions.h; sourceTree = "<group>"; };
                E1F80B8418317247007885C3 /* CryptoKeyPair.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = CryptoKeyPair.idl; sourceTree = "<group>"; };
-               E1F80B8518317252007885C3 /* CryptoKeyPair.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoKeyPair.cpp; sourceTree = "<group>"; };
                E1F80B8618317252007885C3 /* CryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CryptoKeyPair.h; sourceTree = "<group>"; };
-               E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyPairCustom.cpp; sourceTree = "<group>"; };
                E1F80B8B183172B5007885C3 /* JSCryptoKeyPair.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSCryptoKeyPair.cpp; sourceTree = "<group>"; };
                E1F80B8C183172B5007885C3 /* JSCryptoKeyPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSCryptoKeyPair.h; sourceTree = "<group>"; };
                E1FE13621834351100892F13 /* CryptoDigestCommonCrypto.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CryptoDigestCommonCrypto.cpp; sourceTree = "<group>"; };
                                A584FE371864DAC100843B10 /* JSCommandLineAPIHostCustom.cpp */,
                                7CEF26181D6A92E300BE905D /* JSCryptoCustom.cpp */,
                                E157A8E618184C67009F821D /* JSCryptoKeyCustom.cpp */,
-                               E1F80B89183172A2007885C3 /* JSCryptoKeyPairCustom.cpp */,
                                BC46C1ED0C0DDBDF0020CFC3 /* JSCSSRuleCustom.cpp */,
                                AD726FE916D9F40A003A4E6D /* JSCSSRuleCustom.h */,
                                9392262E10321084006E7D5D /* JSCSSRuleListCustom.cpp */,
                                E157A8E318173A3A009F821D /* CryptoKey.h */,
                                E157A8DC18172C2C009F821D /* CryptoKey.idl */,
                                E125F85D182C2DF600D84CD9 /* CryptoKeyData.h */,
-                               E1F80B8518317252007885C3 /* CryptoKeyPair.cpp */,
                                E1F80B8618317252007885C3 /* CryptoKeyPair.h */,
                                E1F80B8418317247007885C3 /* CryptoKeyPair.idl */,
                                E125F855182C0F8300D84CD9 /* CryptoKeySerialization.h */,
                                E1C266DE18319F31003F8B33 /* CryptoKeyDataRSAComponents.cpp in Sources */,
                                E125F8351822F18A00D84CD9 /* CryptoKeyHMAC.cpp in Sources */,
                                E19AC3F9182566F700349426 /* CryptoKeyMac.cpp in Sources */,
-                               E1F80B8718317252007885C3 /* CryptoKeyPair.cpp in Sources */,
                                57E2336B1DCC262400F28D01 /* CryptoKeyRSA.cpp in Sources */,
                                E164FAA518315E1A00DB4E61 /* CryptoKeyRSAMac.cpp in Sources */,
                                E125F859182C1AA600D84CD9 /* CryptoKeySerializationRaw.cpp in Sources */,
                                E157A8E01817331C009F821D /* JSCryptoKey.cpp in Sources */,
                                E157A8E818184C67009F821D /* JSCryptoKeyCustom.cpp in Sources */,
                                E1F80B8D183172B5007885C3 /* JSCryptoKeyPair.cpp in Sources */,
-                               E1F80B8A183172A2007885C3 /* JSCryptoKeyPairCustom.cpp in Sources */,
                                E125F85118283A5600D84CD9 /* JSCryptoKeySerializationJWK.cpp in Sources */,
                                E125F83D182411E700D84CD9 /* JSCryptoOperationData.cpp in Sources */,
                                409EBDC516B7F3CA00CBA3FC /* JSCSSFontFaceLoadEvent.cpp in Sources */,
index 63c3736..b33666c 100644 (file)
@@ -40,15 +40,12 @@ template<typename T> class Strong;
 
 namespace WebCore {
 
-class Dictionary;
-class EventListener;
-class XPathNSResolver;
-
-template <typename Value> class DOMPromise;
+template<typename> class DOMPromise;
 
 template<typename T>
 struct IDLType {
     using ImplementationType = T;
+    using ParameterType = T;
 
     using NullableType = std::optional<ImplementationType>;
     static NullableType nullValue() { return std::nullopt; }
@@ -87,6 +84,8 @@ struct IDLDouble : IDLFloatingPoint<double> { };
 struct IDLUnrestrictedDouble : IDLFloatingPoint<double, true> { };
 
 struct IDLString : IDLType<String> {
+    using ParameterType = const String&;
+
     using NullableType = String;
     static String nullValue() { return String(); }
     static bool isNullValue(const String& value) { return value.isNull(); }
@@ -100,8 +99,10 @@ struct IDLObject : IDLType<JSC::Strong<JSC::JSObject>> { };
 
 template<typename T> struct IDLWrapper : IDLType<RefPtr<T>> {
     using RawType = T;
-    using NullableType = RefPtr<T>;
 
+    using ParameterType = T&;
+
+    using NullableType = RefPtr<T>;
     static inline std::nullptr_t nullValue() { return nullptr; }
     template<typename U> static inline bool isNullValue(U&& value) { return !value; }
     template<typename U> static inline U&& extractValueFromNullable(U&& value) { return std::forward<U>(value); }
@@ -111,7 +112,10 @@ template<typename T> struct IDLInterface : IDLWrapper<T> { };
 template<typename T> struct IDLCallbackInterface : IDLWrapper<T> { };
 template<typename T> struct IDLCallbackFunction : IDLWrapper<T> { };
 
-template<typename T> struct IDLDictionary : IDLType<T> { };
+template<typename T> struct IDLDictionary : IDLType<T> {
+    using ParameterType = const T&;
+};
+
 template<typename T> struct IDLEnumeration : IDLType<T> { };
 
 template<typename T> struct IDLNullable : IDLType<typename T::NullableType> {
@@ -120,15 +124,21 @@ template<typename T> struct IDLNullable : IDLType<typename T::NullableType> {
 
 template<typename T> struct IDLSequence : IDLType<Vector<typename T::ImplementationType>> {
     using InnerType = T;
+
+    using ParameterType = const Vector<typename T::ImplementationType>&;
 };
 
 template<typename T> struct IDLFrozenArray : IDLType<Vector<typename T::ImplementationType>> {
     using InnerType = T;
+
+    using ParameterType = const Vector<typename T::ImplementationType>&;
 };
 
 template<typename K, typename V> struct IDLRecord : IDLType<HashMap<typename K::ImplementationType, typename V::ImplementationType>> {
     using KeyType = K;
     using ValueType = V;
+
+    using ParameterType = const HashMap<typename K::ImplementationType, typename V::ImplementationType>&;
 };
 
 template<typename T> struct IDLPromise : IDLType<DOMPromise<T>> {
@@ -141,6 +151,8 @@ struct IDLDOMException : IDLUnsupportedType { };
 template<typename... Ts>
 struct IDLUnion : IDLType<Variant<typename Ts::ImplementationType...>> {
     using TypeList = brigand::list<Ts...>;
+
+    using ParameterType = const Variant<typename Ts::ImplementationType...>&;
 };
 
 // Non-WebIDL extensions
diff --git a/Source/WebCore/bindings/js/JSCryptoKeyPairCustom.cpp b/Source/WebCore/bindings/js/JSCryptoKeyPairCustom.cpp
deleted file mode 100644 (file)
index b4ad046..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include "config.h"
-#include "JSCryptoKeyPair.h"
-
-#include <heap/SlotVisitorInlines.h>
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-void JSCryptoKeyPair::visitAdditionalChildren(JSC::SlotVisitor& visitor)
-{
-    visitor.addOpaqueRoot(wrapped().publicKey());
-    visitor.addOpaqueRoot(wrapped().privateKey());
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
index 9b9c9af..ebff8dd 100644 (file)
@@ -171,7 +171,7 @@ static JSValue whenDefinedPromise(ExecState& state, JSDOMGlobalObject& globalObj
     }
 
     if (registry.findInterface(localName)) {
-        DeferredPromise::create(globalObject, promiseDeferred)->resolve(nullptr);
+        DeferredPromise::create(globalObject, promiseDeferred)->resolve();
         return promiseDeferred.promise();
     }
 
index 965383e..da48085 100644 (file)
@@ -1066,6 +1066,16 @@ template<typename T> struct Converter<IDLDictionary<T>> : DefaultConverter<IDLDi
     }
 };
 
+template<typename T> struct JSConverter<IDLDictionary<T>> {
+    static constexpr bool needsState = true;
+    static constexpr bool needsGlobalObject = true;
+
+    static JSC::JSValue convert(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const T& dictionary)
+    {
+        return convertDictionaryToJS(state, globalObject, dictionary);
+    }
+};
+
 // MARK: -
 // MARK: Enumeration type
 
index 292e73f..bca4bf5 100644 (file)
@@ -89,6 +89,30 @@ void DeferredPromise::callFunction(ExecState& exec, JSValue function, JSValue re
     clear();
 }
 
+void DeferredPromise::reject()
+{
+    if (isSuspended())
+        return;
+
+    ASSERT(m_deferred);
+    ASSERT(m_globalObject);
+    auto& state = *m_globalObject->globalExec();
+    JSC::JSLockHolder locker(&state);
+    reject(state, JSC::jsUndefined());
+}
+
+void DeferredPromise::reject(std::nullptr_t)
+{
+    if (isSuspended())
+        return;
+
+    ASSERT(m_deferred);
+    ASSERT(m_globalObject);
+    auto& state = *m_globalObject->globalExec();
+    JSC::JSLockHolder locker(&state);
+    reject(state, JSC::jsNull());
+}
+
 void DeferredPromise::reject(Exception&& exception)
 {
     if (isSuspended())
@@ -113,6 +137,18 @@ void DeferredPromise::reject(ExceptionCode ec, const String& message)
     reject(*state, createDOMException(state, ec, message));
 }
 
+void DeferredPromise::reject(const JSC::PrivateName& privateName)
+{
+    if (isSuspended())
+        return;
+
+    ASSERT(m_deferred);
+    ASSERT(m_globalObject);
+    JSC::ExecState* state = m_globalObject->globalExec();
+    JSC::JSLockHolder locker(state);
+    reject(*state, toJS(state, m_globalObject.get(), privateName));
+}
+
 void rejectPromiseWithExceptionIfAny(JSC::ExecState& state, JSDOMGlobalObject& globalObject, JSPromiseDeferred& promiseDeferred)
 {
     VM& vm = state.vm();
@@ -124,7 +160,7 @@ void rejectPromiseWithExceptionIfAny(JSC::ExecState& state, JSDOMGlobalObject& g
     JSValue error = scope.exception()->value();
     scope.clearException();
 
-    DeferredPromise::create(globalObject, promiseDeferred)->reject(error);
+    DeferredPromise::create(globalObject, promiseDeferred)->reject<IDLAny>(error);
 }
 
 Ref<DeferredPromise> createDeferredPromise(JSC::ExecState& state, JSDOMWindow& domWindow)
@@ -166,16 +202,16 @@ void fulfillPromiseWithJSON(Ref<DeferredPromise>&& promise, const String& data)
     if (!value)
         promise->reject(SYNTAX_ERR);
     else
-        promise->resolve(value);
+        promise->resolve<IDLAny>(value);
 }
 
 void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&& promise, ArrayBuffer* arrayBuffer)
 {
     if (!arrayBuffer) {
-        promise->reject<JSValue>(createOutOfMemoryError(promise->globalObject()->globalExec()));
+        promise->reject<IDLAny>(createOutOfMemoryError(promise->globalObject()->globalExec()));
         return;
     }
-    promise->resolve(arrayBuffer);
+    promise->resolve<IDLInterface<ArrayBuffer>>(*arrayBuffer);
 }
 
 void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&& promise, const void* data, size_t length)
index cb1c329..6405e1b 100644 (file)
 #pragma once
 
 #include "ActiveDOMCallback.h"
-#include "JSDOMBinding.h"
+#include "JSDOMConvert.h"
 #include <heap/StrongInlines.h>
 #include <runtime/JSPromiseDeferred.h>
 
 namespace WebCore {
 
-template<typename DOMClass>
-struct TypeInspector {
-private:
-    template<typename T> static constexpr auto testIsVector(int) -> decltype(std::declval<T>().shrinkToFit(), bool()) { return true; }
-    template<typename T> static constexpr bool testIsVector(...) { return false; }
-
-    template<typename T> static constexpr auto testIsRef(int) -> decltype(T::isRef) { return true; }
-    template<typename T> static constexpr bool testIsRef(...) { return false; }
-
-    template<typename T> static constexpr auto testIsRefPtr(int) -> decltype(T::isRefPtr) { return true; }
-    template<typename T> static constexpr bool testIsRefPtr(...) { return false; }
-
-public:
-    static constexpr bool isRefOrRefPtr = testIsRef<DOMClass>(0) || testIsRefPtr<DOMClass>(0);
-    static constexpr bool isPassByValueType = std::is_pointer<DOMClass>::value
-        || std::is_same<DOMClass, std::nullptr_t>::value
-        || std::is_same<DOMClass, JSC::JSValue>::value
-        || std::is_same<DOMClass, bool>::value;
-    static constexpr bool isPassByConstRefType = testIsVector<DOMClass>(0)
-        || std::is_same<DOMClass, String>::value;
-};
-
-template<typename DOMClass, typename Enable = void>
-struct PromiseResultInspector {
-public:
-    static constexpr bool passByValue = false;
-    static constexpr bool passByRef = true;
-    static constexpr bool passByURef = false;
-    static constexpr bool passByConstRef = false;
-
-    typedef DOMClass& Type;
-};
-
-template<>
-struct PromiseResultInspector<void> {
-public:
-    typedef int Type;
-};
-
-template<typename DOMClass>
-struct PromiseResultInspector<DOMClass, typename std::enable_if<TypeInspector<DOMClass>::isPassByValueType>::type> {
-public:
-    static constexpr bool passByValue = true;
-    static constexpr bool passByRef = false;
-    static constexpr bool passByURef = false;
-    static constexpr bool passByConstRef = false;
-
-    typedef DOMClass Type;
-};
-
-template<typename DOMClass>
-struct PromiseResultInspector<DOMClass, typename std::enable_if<TypeInspector<DOMClass>::isPassByConstRefType>::type> {
-public:
-    static constexpr bool passByValue = false;
-    static constexpr bool passByRef = false;
-    static constexpr bool passByURef = false;
-    static constexpr bool passByConstRef = true;
-
-    typedef const DOMClass& Type;
-};
-
-template<typename DOMClass>
-struct PromiseResultInspector<DOMClass, typename std::enable_if<TypeInspector<DOMClass>::isRefOrRefPtr>::type> {
-    static constexpr bool passByValue = false;
-    static constexpr bool passByRef = false;
-    static constexpr bool passByURef = true;
-    static constexpr bool passByConstRef = false;
-};
-
 class DeferredPromise : public RefCounted<DeferredPromise>, public ActiveDOMCallback {
 public:
     static Ref<DeferredPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromiseDeferred& deferred)
@@ -110,28 +41,58 @@ public:
 
     ~DeferredPromise();
 
-    template<class ResolveResultType> typename std::enable_if<PromiseResultInspector<ResolveResultType>::passByValue, void>::type
-    resolve(ResolveResultType result) { resolveWithValue(result); }
-    template<class ResolveResultType> typename std::enable_if<PromiseResultInspector<ResolveResultType>::passByRef, void>::type
-    resolve(ResolveResultType& result) { resolveWithValue(result); }
-    template<class ResolveResultType> typename std::enable_if<PromiseResultInspector<ResolveResultType>::passByURef, void>::type
-    resolve(ResolveResultType&& result) { resolveWithValue(std::forward<ResolveResultType>(result)); }
-    template<class ResolveResultType> typename std::enable_if<PromiseResultInspector<ResolveResultType>::passByConstRef, void>::type
-    resolve(const ResolveResultType& result) { resolveWithValue(result); }
-
-    template<class RejectResultType> typename std::enable_if<PromiseResultInspector<RejectResultType>::passByValue, void>::type
-    reject(RejectResultType result) { rejectWithValue(result); }
-    template<class RejectResultType> typename std::enable_if<PromiseResultInspector<RejectResultType>::passByRef, void>::type
-    reject(RejectResultType& result) { rejectWithValue(result); }
-    template<class RejectResultType> typename std::enable_if<PromiseResultInspector<RejectResultType>::passByURef, void>::type
-    reject(RejectResultType&& result) { rejectWithValue(std::forward<RejectResultType>(result)); }
-    template<class RejectResultType> typename std::enable_if<PromiseResultInspector<RejectResultType>::passByConstRef, void>::type
-    reject(const RejectResultType& result) { rejectWithValue(result); }
-
-    template<class ResolveResultType> void resolveWithNewlyCreated(Ref<ResolveResultType>&&);
+    template<class IDLType> 
+    void resolve(typename IDLType::ParameterType value)
+    {
+        if (isSuspended())
+            return;
+        ASSERT(m_deferred);
+        ASSERT(m_globalObject);
+        JSC::ExecState* exec = m_globalObject->globalExec();
+        JSC::JSLockHolder locker(exec);
+        resolve(*exec, toJS<IDLType>(*exec, *m_globalObject.get(), std::forward<typename IDLType::ParameterType>(value)));
+    }
+
+    void resolve()
+    {
+        if (isSuspended())
+            return;
+        ASSERT(m_deferred);
+        ASSERT(m_globalObject);
+        JSC::ExecState* exec = m_globalObject->globalExec();
+        JSC::JSLockHolder locker(exec);
+        resolve(*exec, JSC::jsUndefined());
+    }
+
+    template<class IDLType>
+    void resolveWithNewlyCreated(typename IDLType::ParameterType value)
+    {
+        if (isSuspended())
+            return;
+        ASSERT(m_deferred);
+        ASSERT(m_globalObject);
+        JSC::ExecState* exec = m_globalObject->globalExec();
+        JSC::JSLockHolder locker(exec);
+        resolve(*exec, toJSNewlyCreated<IDLType>(*exec, *m_globalObject.get(), std::forward<typename IDLType::ParameterType>(value)));
+    }
+
+    template<class IDLType> 
+    void reject(typename IDLType::ParameterType value)
+    {
+        if (isSuspended())
+            return;
+        ASSERT(m_deferred);
+        ASSERT(m_globalObject);
+        JSC::ExecState* exec = m_globalObject->globalExec();
+        JSC::JSLockHolder locker(exec);
+        reject(*exec, toJS<IDLType>(*exec, *m_globalObject.get(), std::forward<typename IDLType::ParameterType>(value)));
+    }
 
+    void reject();
+    void reject(std::nullptr_t);
     void reject(Exception&&);
     void reject(ExceptionCode, const String& = { });
+    void reject(const JSC::PrivateName&);
 
     JSC::JSValue promise() const;
 
@@ -150,13 +111,90 @@ private:
     void resolve(JSC::ExecState& state, JSC::JSValue resolution) { callFunction(state, m_deferred->resolve(), resolution); }
     void reject(JSC::ExecState& state, JSC::JSValue resolution) { callFunction(state, m_deferred->reject(), resolution); }
 
-    template<class RejectResultType> void rejectWithValue(RejectResultType&&);
-    template<class ResolveResultType> void resolveWithValue(ResolveResultType&&);
-
     JSC::Weak<JSC::JSPromiseDeferred> m_deferred;
     JSC::Weak<JSDOMGlobalObject> m_globalObject;
 };
 
+class DOMPromiseBase {
+public:
+    DOMPromiseBase(Ref<DeferredPromise>&& genericPromise)
+        : m_promiseDeferred(WTFMove(genericPromise))
+    {
+    }
+
+    DOMPromiseBase(DOMPromiseBase&& promise)
+        : m_promiseDeferred(WTFMove(promise.m_promiseDeferred))
+    {
+    }
+
+    DOMPromiseBase(const DOMPromiseBase& other)
+        : m_promiseDeferred(other.m_promiseDeferred.copyRef())
+    {
+    }
+
+    DOMPromiseBase& operator=(const DOMPromiseBase& other)
+    {
+        m_promiseDeferred = other.m_promiseDeferred.copyRef();
+        return *this;
+    }
+
+    DOMPromiseBase& operator=(DOMPromiseBase&& other)
+    {
+        m_promiseDeferred = WTFMove(other.m_promiseDeferred);
+        return *this;
+    }
+
+    void reject()
+    {
+        m_promiseDeferred->reject();
+    }
+
+    template<typename... ErrorType> 
+    void reject(ErrorType&&... error)
+    {
+        m_promiseDeferred->reject(std::forward<ErrorType>(error)...);
+    }
+
+    template<typename IDLType>
+    void rejectType(typename IDLType::ParameterType value)
+    {
+        m_promiseDeferred->reject<IDLType>(std::forward<typename IDLType::ParameterType>(value));
+    }
+
+    JSC::JSValue promise() const { return m_promiseDeferred->promise(); };
+
+protected:
+    Ref<DeferredPromise> m_promiseDeferred;
+};
+
+template<typename IDLType> 
+class DOMPromise : public DOMPromiseBase {
+public:
+    using DOMPromiseBase::DOMPromiseBase;
+    using DOMPromiseBase::operator=;
+    using DOMPromiseBase::promise;
+    using DOMPromiseBase::reject;
+
+    void resolve(typename IDLType::ParameterType value)
+    { 
+        m_promiseDeferred->resolve<IDLType>(std::forward<typename IDLType::ParameterType>(value));
+    }
+};
+
+template<> class DOMPromise<void> : public DOMPromiseBase {
+public:
+    using DOMPromiseBase::DOMPromiseBase;
+    using DOMPromiseBase::operator=;
+    using DOMPromiseBase::promise;
+    using DOMPromiseBase::reject;
+
+    void resolve()
+    { 
+        m_promiseDeferred->resolve();
+    }
+};
+
+
 Ref<DeferredPromise> createDeferredPromise(JSC::ExecState&, JSDOMWindow&);
 
 void fulfillPromiseWithJSON(Ref<DeferredPromise>&&, const String&);
@@ -202,156 +240,4 @@ inline JSC::JSValue callPromiseFunction(JSC::ExecState& state)
     return callPromiseFunction<bindingPromiseFunctionAdapter<bindingPromiseFunction>, executionScope>(state);
 }
 
-// At the moment, Value cannot be a Ref<T> or RefPtr<T>, it should be a DOM class.
-template<typename Value> class DOMPromise {
-public:
-    DOMPromise(Ref<DeferredPromise>&& genericPromise) : m_promiseDeferred(WTFMove(genericPromise)) { }
-    DOMPromise(DOMPromise&& promise) : m_promiseDeferred(WTFMove(promise.m_promiseDeferred)) { }
-    DOMPromise(const DOMPromise& other) : m_promiseDeferred(other.m_promiseDeferred.copyRef()) { }
-
-    DOMPromise& operator=(const DOMPromise& other)
-    {
-        m_promiseDeferred = other.copyRef();
-        return *this;
-    }
-
-    DOMPromise& operator=(DOMPromise&& other)
-    {
-        m_promiseDeferred = WTFMove(other.m_promiseDeferred);
-        return *this;
-    }
-
-    template<typename T = Value>
-    typename std::enable_if<!std::is_void<T>::value, void>::type resolve(typename PromiseResultInspector<Value>::Type value) { m_promiseDeferred->resolve(value); }
-
-    template<typename T = Value>
-    typename std::enable_if<std::is_void<T>::value, void>::type resolve() { m_promiseDeferred->resolve(nullptr); }
-
-    template<typename... ErrorType> void reject(ErrorType&&... error) { m_promiseDeferred->reject(std::forward<ErrorType>(error)...); }
-
-    JSC::JSValue promise() const { return m_promiseDeferred->promise(); };
-
-private:
-    Ref<DeferredPromise> m_promiseDeferred;
-};
-
-template<class ResolveResultType>
-inline void DeferredPromise::resolveWithValue(ResolveResultType&& result)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    resolve(*exec, toJS(exec, m_globalObject.get(), std::forward<ResolveResultType>(result)));
-}
-
-template<class ResolveResultType>
-inline void DeferredPromise::resolveWithNewlyCreated(Ref<ResolveResultType>&& result)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    resolve(*exec, toJSNewlyCreated(exec, m_globalObject.get(), WTFMove(result)));
-}
-
-template<class RejectResultType>
-inline void DeferredPromise::rejectWithValue(RejectResultType&& result)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    reject(*exec, toJS(exec, m_globalObject.get(), std::forward<RejectResultType>(result)));
-}
-
-template<>
-inline void DeferredPromise::resolve(bool result)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    resolve(*exec, JSC::jsBoolean(result));
-}
-
-template<>
-inline void DeferredPromise::resolve(JSC::JSValue value)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    resolve(*exec, value);
-}
-
-template<>
-inline void DeferredPromise::reject(JSC::JSValue value)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    reject(*exec, value);
-}
-
-template<>
-inline void DeferredPromise::resolve(std::nullptr_t)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    resolve(*exec, JSC::jsUndefined());
-}
-
-template<>
-inline void DeferredPromise::reject(std::nullptr_t)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    reject(*exec, JSC::jsNull());
-}
-
-template<>
-inline void DeferredPromise::resolve(const String& result)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    resolve(*exec, jsString(exec, result));
-}
-
-template<>
-inline void DeferredPromise::reject(const String& result)
-{
-    if (isSuspended())
-        return;
-    ASSERT(m_deferred);
-    ASSERT(m_globalObject);
-    JSC::ExecState* exec = m_globalObject->globalExec();
-    JSC::JSLockHolder locker(exec);
-    reject(*exec, jsString(exec, result));
-}
-
 } // namespace WebCore
index 352969f..6130d7f 100644 (file)
@@ -31,6 +31,7 @@
 #include "ArrayValue.h"
 #include "Dictionary.h"
 #include "ExceptionCode.h"
+#include "JSDOMPromise.h"
 #include "JSMediaDevices.h"
 #include "Logging.h"
 #include "MediaConstraintsImpl.h"
index 5b4b44a..83eac54 100644 (file)
@@ -477,7 +477,7 @@ static void jsSubtleCryptoFunctionEncryptPromise(ExecState& state, Ref<DeferredP
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 3)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -522,7 +522,7 @@ static void jsSubtleCryptoFunctionDecryptPromise(ExecState& state, Ref<DeferredP
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 3)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -567,7 +567,7 @@ static void jsSubtleCryptoFunctionSignPromise(ExecState& state, Ref<DeferredProm
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 3)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -612,7 +612,7 @@ static void jsSubtleCryptoFunctionVerifyPromise(ExecState& state, Ref<DeferredPr
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 4)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -642,7 +642,7 @@ static void jsSubtleCryptoFunctionVerifyPromise(ExecState& state, Ref<DeferredPr
     RETURN_IF_EXCEPTION(scope, void());
 
     auto callback = [capturedPromise = promise.copyRef()](bool result) mutable {
-        capturedPromise->resolve(result);
+        capturedPromise->resolve<IDLBoolean>(result);
         return;
     };
     auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
@@ -660,7 +660,7 @@ static void jsSubtleCryptoFunctionDigestPromise(ExecState& state, Ref<DeferredPr
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 2)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -692,7 +692,7 @@ static void jsSubtleCryptoFunctionDeriveKeyPromise(ExecState& state, Ref<Deferre
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 5)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -709,7 +709,7 @@ static void jsSubtleCryptoFunctionDeriveBitsPromise(ExecState& state, Ref<Deferr
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 3)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -726,7 +726,7 @@ static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<Defer
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 3)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -742,22 +742,23 @@ static void jsSubtleCryptoFunctionGenerateKeyPromise(ExecState& state, Ref<Defer
     auto algorithm = createAlgorithm(state, params->identifier);
     RETURN_IF_EXCEPTION(scope, void());
 
-    auto callback = [capturedPromise = promise.copyRef()](CryptoKey* key, CryptoKeyPair* keyPair) mutable {
-        ASSERT(key || keyPair);
-        ASSERT(!key || !keyPair);
-        if (key) {
-            if ((key->type() == CryptoKeyType::Private || key->type() == CryptoKeyType::Secret) && !key->usagesBitmap()) {
-                rejectWithException(WTFMove(capturedPromise), SYNTAX_ERR);
-                return;
-            }
-            capturedPromise->resolve(key);
-        } else {
-            if (!keyPair->privateKey()->usagesBitmap()) {
-                rejectWithException(WTFMove(capturedPromise), SYNTAX_ERR);
-                return;
+    auto callback = [capturedPromise = promise.copyRef()](KeyOrKeyPair&& keyOrKeyPair) mutable {
+        WTF::switchOn(keyOrKeyPair,
+            [&capturedPromise] (RefPtr<CryptoKey>& key) {
+                if ((key->type() == CryptoKeyType::Private || key->type() == CryptoKeyType::Secret) && !key->usagesBitmap()) {
+                    rejectWithException(WTFMove(capturedPromise), SYNTAX_ERR);
+                    return;
+                }
+                capturedPromise->resolve<IDLInterface<CryptoKey>>(*key);
+            },
+            [&capturedPromise] (CryptoKeyPair& keyPair) {
+                if (!keyPair.privateKey->usagesBitmap()) {
+                    rejectWithException(WTFMove(capturedPromise), SYNTAX_ERR);
+                    return;
+                }
+                capturedPromise->resolve<IDLDictionary<CryptoKeyPair>>(keyPair);
             }
-            capturedPromise->resolve(keyPair);
-        }
+        );
     };
     auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
         rejectWithException(WTFMove(capturedPromise), ec);
@@ -775,7 +776,7 @@ static void jsSubtleCryptoFunctionImportKeyPromise(ExecState& state, Ref<Deferre
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 5)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -802,7 +803,7 @@ static void jsSubtleCryptoFunctionImportKeyPromise(ExecState& state, Ref<Deferre
             rejectWithException(WTFMove(capturedPromise), SYNTAX_ERR);
             return;
         }
-        capturedPromise->resolve(key);
+        capturedPromise->resolve<IDLInterface<CryptoKey>>(key);
     };
     auto exceptionCallback = [capturedPromise = WTFMove(promise)](ExceptionCode ec) mutable {
         rejectWithException(WTFMove(capturedPromise), ec);
@@ -820,7 +821,7 @@ static void jsSubtleCryptoFunctionExportKeyPromise(ExecState& state, Ref<Deferre
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 2)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -851,7 +852,7 @@ static void jsSubtleCryptoFunctionExportKeyPromise(ExecState& state, Ref<Deferre
             return;
         }
         case SubtleCrypto::KeyFormat::Jwk:
-            capturedPromise->resolve(toJSValueFromJsonWebKey(*(capturedPromise->globalObject()), WTFMove(WTF::get<JsonWebKey>(key))));
+            capturedPromise->resolve<IDLAny>(toJSValueFromJsonWebKey(*(capturedPromise->globalObject()), WTFMove(WTF::get<JsonWebKey>(key))));
             return;
         }
         ASSERT_NOT_REACHED();
@@ -872,7 +873,7 @@ static void jsSubtleCryptoFunctionWrapKeyPromise(ExecState& state, Ref<DeferredP
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 4)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -973,7 +974,7 @@ static void jsSubtleCryptoFunctionUnwrapKeyPromise(ExecState& state, Ref<Deferre
     auto scope = DECLARE_THROW_SCOPE(vm);
 
     if (UNLIKELY(state.argumentCount() < 7)) {
-        promise->reject<JSValue>(createNotEnoughArgumentsError(&state));
+        promise->reject<IDLAny>(createNotEnoughArgumentsError(&state));
         return;
     }
 
@@ -1051,7 +1052,7 @@ static void jsSubtleCryptoFunctionUnwrapKeyPromise(ExecState& state, Ref<Deferre
                 rejectWithException(WTFMove(promise), SYNTAX_ERR);
                 return;
             }
-            promise->resolve(key);
+            promise->resolve<IDLInterface<CryptoKey>>(key);
         };
         auto exceptionCallback = [promise = WTFMove(promise)](ExceptionCode ec) mutable {
             rejectWithException(WTFMove(promise), ec);
index b3caa2c..544a982 100644 (file)
@@ -178,7 +178,7 @@ JSValue JSWebKitSubtleCrypto::encrypt(ExecState& state)
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
     auto failureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     auto result = algorithm->encrypt(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback));
@@ -230,7 +230,7 @@ JSValue JSWebKitSubtleCrypto::decrypt(ExecState& state)
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
     auto failureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     auto result = algorithm->decrypt(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback));
@@ -282,7 +282,7 @@ JSValue JSWebKitSubtleCrypto::sign(ExecState& state)
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
     auto failureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     auto result = algorithm->sign(*parameters, *key, data, WTFMove(successCallback), WTFMove(failureCallback));
@@ -337,10 +337,10 @@ JSValue JSWebKitSubtleCrypto::verify(ExecState& state)
     RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
     auto promise = wrapper->promise();
     auto successCallback = [wrapper](bool result) mutable {
-        wrapper->resolve(result);
+        wrapper->resolve<IDLBoolean>(result);
     };
     auto failureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     auto result = algorithm->verify(*parameters, *key, signature, data, WTFMove(successCallback), WTFMove(failureCallback));
@@ -382,7 +382,7 @@ JSValue JSWebKitSubtleCrypto::digest(ExecState& state)
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
     auto failureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     auto result = algorithm->digest(*parameters, data, WTFMove(successCallback), WTFMove(failureCallback));
@@ -428,16 +428,18 @@ JSValue JSWebKitSubtleCrypto::generateKey(ExecState& state)
 
     RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
     auto promise = wrapper->promise();
-    auto successCallback = [wrapper](CryptoKey* key, CryptoKeyPair* keyPair) mutable {
-        ASSERT(key || keyPair);
-        ASSERT(!key || !keyPair);
-        if (key)
-            wrapper->resolve(key);
-        else
-            wrapper->resolve(keyPair);
+    auto successCallback = [wrapper](KeyOrKeyPair&& keyOrKeyPair) mutable {
+        WTF::switchOn(keyOrKeyPair,
+            [&wrapper] (RefPtr<CryptoKey>& key) {
+                wrapper->resolve<IDLInterface<CryptoKey>>(*key);
+            },
+            [&wrapper] (CryptoKeyPair& keyPair) {
+                wrapper->resolve<IDLDictionary<CryptoKeyPair>>(keyPair);
+            }
+        );
     };
     auto failureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     auto result = algorithm->generateKey(*parameters, extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback), *scriptExecutionContextFromExecState(&state));
@@ -555,10 +557,10 @@ JSValue JSWebKitSubtleCrypto::importKey(ExecState& state)
     RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
     auto promise = wrapper->promise();
     auto successCallback = [wrapper](CryptoKey& result) mutable {
-        wrapper->resolve(result);
+        wrapper->resolve<IDLInterface<CryptoKey>>(result);
     };
     auto failureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     WebCore::importKey(state, keyFormat, data, WTFMove(algorithm), WTFMove(parameters), extractable, keyUsages, WTFMove(successCallback), WTFMove(failureCallback));
@@ -625,7 +627,7 @@ JSValue JSWebKitSubtleCrypto::exportKey(ExecState& state)
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
     auto failureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     WebCore::exportKey(state, keyFormat, *key, WTFMove(successCallback), WTFMove(failureCallback));
@@ -680,17 +682,17 @@ JSValue JSWebKitSubtleCrypto::wrapKey(ExecState& state)
             fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), encryptedData.data(), encryptedData.size());
         };
         auto encryptFailureCallback = [wrapper]() mutable {
-            wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
         };
         auto result = algorithm->encryptForWrapKey(*parameters, *wrappingKey, std::make_pair(exportedKeyData.data(), exportedKeyData.size()), WTFMove(encryptSuccessCallback), WTFMove(encryptFailureCallback));
         if (result.hasException()) {
             // FIXME: Report failure details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
-            wrapper->reject(nullptr);
+            wrapper->reject(); // FIXME: This should reject with an Exception.
         }
     };
 
     auto exportFailureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     WebCore::exportKey(state, keyFormat, *key, WTFMove(exportSuccessCallback), WTFMove(exportFailureCallback));
@@ -771,10 +773,10 @@ JSValue JSWebKitSubtleCrypto::unwrapKey(ExecState& state)
 
     auto decryptSuccessCallback = [domGlobalObject, keyFormat, unwrappedKeyAlgorithm, unwrappedKeyAlgorithmParameters, extractable, keyUsages, wrapper](const Vector<uint8_t>& result) mutable {
         auto importSuccessCallback = [wrapper](CryptoKey& key) mutable {
-            wrapper->resolve(key);
+            wrapper->resolve<IDLInterface<CryptoKey>>(key);
         };
         auto importFailureCallback = [wrapper]() mutable {
-            wrapper->reject(nullptr);
+            wrapper->reject(); // FIXME: This should reject with an Exception.
         };
 
         VM& vm = domGlobalObject->vm();
@@ -785,12 +787,12 @@ JSValue JSWebKitSubtleCrypto::unwrapKey(ExecState& state)
         if (UNLIKELY(scope.exception())) {
             // FIXME: Report exception details to console, and possibly to calling script once there is a standardized way to pass errors to WebCrypto promise reject functions.
             scope.clearException();
-            wrapper->reject(nullptr);
+            wrapper->reject(); // FIXME: This should reject with an Exception.
         }
     };
 
     auto decryptFailureCallback = [wrapper]() mutable {
-        wrapper->reject(nullptr);
+        wrapper->reject(); // FIXME: This should reject with an Exception.
     };
 
     auto result = unwrapAlgorithm->decryptForUnwrapKey(*unwrapAlgorithmParameters, *unwrappingKey, wrappedKeyData, WTFMove(decryptSuccessCallback), WTFMove(decryptFailureCallback));
index 6f9402b..9fa2940 100644 (file)
@@ -72,7 +72,7 @@ JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGloba
     // So there is no correct URL to retrieve the module source code. If the module name
     // value is a Symbol, it is used directly as a module key.
     if (moduleNameValue.isSymbol()) {
-        promise->resolve(asSymbol(moduleNameValue)->privateName());
+        promise->resolve<IDLAny>(toJS(exec, &globalObject, asSymbol(moduleNameValue)->privateName()));
         return jsPromise.promise();
     }
 
@@ -88,7 +88,7 @@ JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGloba
     // 1. Apply the URL parser to specifier. If the result is not failure, return the result.
     URL absoluteURL(URL(), specifier);
     if (absoluteURL.isValid()) {
-        promise->resolve(absoluteURL.string());
+        promise->resolve<IDLDOMString>(absoluteURL.string());
         return jsPromise.promise();
     }
 
@@ -129,7 +129,7 @@ JSC::JSInternalPromise* ScriptModuleLoader::resolve(JSC::JSGlobalObject* jsGloba
         return jsPromise.promise();
     }
 
-    promise->resolve(completedURL.string());
+    promise->resolve<IDLDOMString>(completedURL.string());
     return jsPromise.promise();
 }
 
@@ -247,7 +247,7 @@ void ScriptModuleLoader::notifyFinished(CachedModuleScriptLoader& loader, RefPtr
 
     m_requestURLToResponseURLMap.add(cachedScript.url(), cachedScript.response().url());
     // FIXME: Let's wrap around ScriptSourceCode to propagate it directly through the module pipeline.
-    promise->resolve(ScriptSourceCode(&cachedScript, JSC::SourceProviderSourceType::Module).source().toString());
+    promise->resolve<IDLDOMString>(ScriptSourceCode(&cachedScript, JSC::SourceProviderSourceType::Module).source().toString());
 }
 
 }
index 6b6c973..fb91aef 100644 (file)
@@ -1204,7 +1204,12 @@ sub GenerateDictionaryHeaderContent
 
     my $result = "";
     $result .= "#if ${conditionalString}\n\n" if $conditionalString;
-    $result .= "template<> $className convertDictionary<$className>(JSC::ExecState&, JSC::JSValue);\n\n";
+    $result .= "template<> ${className} convertDictionary<$className>(JSC::ExecState&, JSC::JSValue);\n\n";
+
+    if ($dictionary->extendedAttributes->{JSGenerateToJSObject}) {
+        $result .= "JSC::JSObject* convertDictionaryToJS(JSC::ExecState&, JSDOMGlobalObject&, const ${className}&);\n\n";
+    }
+
     $result .= "#endif\n\n" if $conditionalString;
     return $result;
 }
@@ -1247,6 +1252,7 @@ sub GenerateDictionaryImplementationContent
     $result .= "    auto throwScope = DECLARE_THROW_SCOPE(vm);\n";
     $result .= "    bool isNullOrUndefined = value.isUndefinedOrNull();\n";
     $result .= "    auto* object = isNullOrUndefined ? nullptr : value.getObject();\n";
+
     # 1. If Type(V) is not Undefined, Null or Object, then throw a TypeError.
     $result .= "    if (UNLIKELY(!isNullOrUndefined && !object)) {\n";
     $result .= "        throwTypeError(&state, throwScope);\n";
@@ -1320,6 +1326,48 @@ sub GenerateDictionaryImplementationContent
 
     $result .= "    return result;\n";
     $result .= "}\n\n";
+
+    if ($dictionary->extendedAttributes->{JSGenerateToJSObject}) {
+        $result .= "JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject& globalObject, const ${className}& dictionary)\n";
+        $result .= "{\n";
+        $result .= "    auto& vm = state.vm();\n\n";
+
+        # 1. Let O be ! ObjectCreate(%ObjectPrototype%).
+        $result .= "    auto result = constructEmptyObject(&state);\n\n";
+
+        # 2. Let dictionaries be a list consisting of D and all of D’s inherited dictionaries,
+        #    in order from least to most derived.
+        #    NOTE: This was done above.
+
+        # 3. For each dictionary dictionary in dictionaries, in order:
+        foreach my $dictionary (@dictionaries) {
+            # 3.1. For each dictionary member member declared on dictionary, in lexicographical order:
+            my @sortedMembers = sort { $a->name cmp $b->name } @{$dictionary->members};
+            foreach my $member (@sortedMembers) {
+                my $key = $member->name;
+                my $IDLType = GetIDLType($interface, $member->type);
+
+                # 1. Let key be the identifier of member.
+                # 2. If the dictionary member named key is present in V, then:
+                    # 1. Let idlValue be the value of member on V.
+                    # 2. Let value be the result of converting idlValue to an ECMAScript value.
+                    # 3. Perform ! CreateDataProperty(O, key, value).
+                if (!$member->isRequired && not defined $member->default) {
+                    $result .= "    if (dictionary.${key}) {\n";
+                    $result .= "        auto ${key}Value = toJS<$IDLType>(state, globalObject, dictionary.${key});\n";
+                    $result .= "        result->putDirect(vm, JSC::Identifier::fromString(&vm, \"${key}\"), ${key}Value);\n";
+                    $result .= "    }\n";
+                } else {
+                    $result .= "    auto ${key}Value = toJS<$IDLType>(state, globalObject, dictionary.${key});\n";
+                    $result .= "    result->putDirect(vm, JSC::Identifier::fromString(&vm, \"${key}\"), ${key}Value);\n";
+                }
+            }
+        }
+
+        $result .= "    return result;\n";
+        $result .= "}\n\n";
+    }
+
     $result .= "#endif\n\n" if $conditionalString;
 
     return $result;
index cc6354b..dc552af 100644 (file)
@@ -682,6 +682,127 @@ template<> TestObj::Dictionary convertDictionary<TestObj::Dictionary>(ExecState&
     return result;
 }
 
+template<> JSC::JSObject* convertDictionaryToJS(JSC::ExecState& state, JSDOMGlobalObject&, const TestObj::Dictionary& dictionary)
+{
+    auto& vm = state.vm();
+
+    auto result = constructEmptyObject(&state)
+
+    auto anyTypedefValueValue = toJS<IDLAny>(state, globalObject, dictionary.anyTypedefValue);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "anyTypedefValue"), anyTypedefValueValue);
+    auto anyValueValue = toJS<IDLAny>(state, globalObject, dictionary.anyValue);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "anyValue"), anyValueValue);
+    auto anyValueWithNullDefaultValue = toJS<IDLAny>(state, globalObject, dictionary.anyValueWithNullDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "anyValueWithNullDefault"), anyValueWithNullDefaultValue);
+    auto booleanWithDefaultValue = toJS<IDLBoolean>(state, globalObject, dictionary.booleanWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "booleanWithDefault"), booleanWithDefaultValue);
+    if (dictionary.booleanWithoutDefault) {
+        auto booleanWithoutDefaultValue = toJS<IDLBoolean>(state, globalObject, dictionary.booleanWithoutDefault);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "booleanWithoutDefault"), booleanWithoutDefaultValue);
+    }
+    if (dictionary.bufferSourceValue) {
+        auto bufferSourceValueValue = toJS<IDLBufferSource>(state, globalObject, dictionary.bufferSourceValue);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "bufferSourceValue"), bufferSourceValueValue);
+    }
+    if (dictionary.dictionaryMember) {
+        auto dictionaryMemberValue = toJS<IDLDictionary<TestObj::DictionaryThatShouldTolerateNull>>(state, globalObject, dictionary.dictionaryMember);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "dictionaryMember"), dictionaryMemberValue);
+    }
+    auto enumerationValueWithDefaultValue = toJS<IDLEnumeration<TestObj::EnumType>>(state, globalObject, dictionary.enumerationValueWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "enumerationValueWithDefault"), enumerationValueWithDefaultValue);
+    auto enumerationValueWithEmptyStringDefaultValue = toJS<IDLEnumeration<TestObj::EnumType>>(state, globalObject, dictionary.enumerationValueWithEmptyStringDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "enumerationValueWithEmptyStringDefault"), enumerationValueWithEmptyStringDefaultValue);
+    if (dictionary.enumerationValueWithoutDefault) {
+        auto enumerationValueWithoutDefaultValue = toJS<IDLEnumeration<TestObj::EnumType>>(state, globalObject, dictionary.enumerationValueWithoutDefault);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "enumerationValueWithoutDefault"), enumerationValueWithoutDefaultValue);
+    }
+    if (dictionary.integer) {
+        auto integerValue = toJS<IDLLong>(state, globalObject, dictionary.integer);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "integer"), integerValue);
+    }
+    auto integerWithDefaultValue = toJS<IDLLong>(state, globalObject, dictionary.integerWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "integerWithDefault"), integerWithDefaultValue);
+    if (dictionary.largeInteger) {
+        auto largeIntegerValue = toJS<IDLLongLong>(state, globalObject, dictionary.largeInteger);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "largeInteger"), largeIntegerValue);
+    }
+    auto largeIntegerWithDefaultValue = toJS<IDLLongLong>(state, globalObject, dictionary.largeIntegerWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "largeIntegerWithDefault"), largeIntegerWithDefaultValue);
+    auto nullableIntegerWithDefaultValue = toJS<IDLNullable<IDLLong>>(state, globalObject, dictionary.nullableIntegerWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "nullableIntegerWithDefault"), nullableIntegerWithDefaultValue);
+    auto nullableNodeValue = toJS<IDLNullable<IDLInterface<Node>>>(state, globalObject, dictionary.nullableNode);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "nullableNode"), nullableNodeValue);
+    auto nullableStringWithDefaultValue = toJS<IDLNullable<IDLDOMString>>(state, globalObject, dictionary.nullableStringWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "nullableStringWithDefault"), nullableStringWithDefaultValue);
+    auto nullableUnionMemberValue = toJS<IDLNullable<IDLUnion<IDLLong, IDLInterface<Node>>>>(state, globalObject, dictionary.nullableUnionMember);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "nullableUnionMember"), nullableUnionMemberValue);
+    if (dictionary.restrictedDouble) {
+        auto restrictedDoubleValue = toJS<IDLDouble>(state, globalObject, dictionary.restrictedDouble);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "restrictedDouble"), restrictedDoubleValue);
+    }
+    auto restrictedDoubleWithDefaultValue = toJS<IDLDouble>(state, globalObject, dictionary.restrictedDoubleWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "restrictedDoubleWithDefault"), restrictedDoubleWithDefaultValue);
+    if (dictionary.restrictedFloat) {
+        auto restrictedFloatValue = toJS<IDLFloat>(state, globalObject, dictionary.restrictedFloat);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "restrictedFloat"), restrictedFloatValue);
+    }
+    auto restrictedFloatWithDefaultValue = toJS<IDLFloat>(state, globalObject, dictionary.restrictedFloatWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "restrictedFloatWithDefault"), restrictedFloatWithDefaultValue);
+    if (dictionary.sequenceOfStrings) {
+        auto sequenceOfStringsValue = toJS<IDLSequence<IDLDOMString>>(state, globalObject, dictionary.sequenceOfStrings);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "sequenceOfStrings"), sequenceOfStringsValue);
+    }
+    if (dictionary.smallIntegerClamped) {
+        auto smallIntegerClampedValue = toJS<IDLByte>(state, globalObject, dictionary.smallIntegerClamped);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "smallIntegerClamped"), smallIntegerClampedValue);
+    }
+    if (dictionary.smallIntegerWithDefault) {
+        auto smallIntegerWithDefaultValue = toJS<IDLByte>(state, globalObject, dictionary.smallIntegerWithDefault);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "smallIntegerWithDefault"), smallIntegerWithDefaultValue);
+    }
+    if (dictionary.smallUnsignedIntegerEnforcedRange) {
+        auto smallUnsignedIntegerEnforcedRangeValue = toJS<IDLOctet>(state, globalObject, dictionary.smallUnsignedIntegerEnforcedRange);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "smallUnsignedIntegerEnforcedRange"), smallUnsignedIntegerEnforcedRangeValue);
+    }
+    auto smallUnsignedIntegerWithDefaultValue = toJS<IDLOctet>(state, globalObject, dictionary.smallUnsignedIntegerWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "smallUnsignedIntegerWithDefault"), smallUnsignedIntegerWithDefaultValue);
+    auto stringWithDefaultValue = toJS<IDLDOMString>(state, globalObject, dictionary.stringWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "stringWithDefault"), stringWithDefaultValue);
+    if (dictionary.stringWithoutDefault) {
+        auto stringWithoutDefaultValue = toJS<IDLDOMString>(state, globalObject, dictionary.stringWithoutDefault);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "stringWithoutDefault"), stringWithoutDefaultValue);
+    }
+    if (dictionary.unionMember) {
+        auto unionMemberValue = toJS<IDLUnion<IDLLong, IDLInterface<Node>>>(state, globalObject, dictionary.unionMember);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "unionMember"), unionMemberValue);
+    }
+    if (dictionary.unrestrictedDouble) {
+        auto unrestrictedDoubleValue = toJS<IDLUnrestrictedDouble>(state, globalObject, dictionary.unrestrictedDouble);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "unrestrictedDouble"), unrestrictedDoubleValue);
+    }
+    auto unrestrictedDoubleWithDefaultValue = toJS<IDLUnrestrictedDouble>(state, globalObject, dictionary.unrestrictedDoubleWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "unrestrictedDoubleWithDefault"), unrestrictedDoubleWithDefaultValue);
+    if (dictionary.unrestrictedFloat) {
+        auto unrestrictedFloatValue = toJS<IDLUnrestrictedFloat>(state, globalObject, dictionary.unrestrictedFloat);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "unrestrictedFloat"), unrestrictedFloatValue);
+    }
+    auto unrestrictedFloatWithDefaultValue = toJS<IDLUnrestrictedFloat>(state, globalObject, dictionary.unrestrictedFloatWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "unrestrictedFloatWithDefault"), unrestrictedFloatWithDefaultValue);
+    if (dictionary.unsignedInteger) {
+        auto unsignedIntegerValue = toJS<IDLUnsignedLong>(state, globalObject, dictionary.unsignedInteger);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "unsignedInteger"), unsignedIntegerValue);
+    }
+    auto unsignedIntegerWithDefaultValue = toJS<IDLUnsignedLong>(state, globalObject, dictionary.unsignedIntegerWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "unsignedIntegerWithDefault"), unsignedIntegerWithDefaultValue);
+    if (dictionary.unsignedLargeInteger) {
+        auto unsignedLargeIntegerValue = toJS<IDLUnsignedLongLong>(state, globalObject, dictionary.unsignedLargeInteger);
+        result->putDirect(vm, JSC::Identifier::fromString(&vm, "unsignedLargeInteger"), unsignedLargeIntegerValue);
+    }
+    auto unsignedLargeIntegerWithDefaultValue = toJS<IDLUnsignedLongLong>(state, globalObject, dictionary.unsignedLargeIntegerWithDefault);
+    result->putDirect(vm, JSC::Identifier::fromString(&vm, "unsignedLargeIntegerWithDefault"), unsignedLargeIntegerWithDefaultValue);
+    return result;
+}
+
 template<> TestObj::DictionaryThatShouldNotTolerateNull convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(ExecState& state, JSValue value)
 {
     VM& vm = state.vm();
index 2f1df75..c4865f2 100644 (file)
@@ -169,6 +169,8 @@ template<> const char* expectedEnumerationValues<TestObj::Confidence>();
 
 template<> TestObj::Dictionary convertDictionary<TestObj::Dictionary>(JSC::ExecState&, JSC::JSValue);
 
+template<> JSC::JSObject* convertDictionaryToJS(JSC::ExecState&, JSDOMGlobalObject&, const TestObj::Dictionary&);
+
 template<> TestObj::DictionaryThatShouldNotTolerateNull convertDictionary<TestObj::DictionaryThatShouldNotTolerateNull>(JSC::ExecState&, JSC::JSValue);
 
 template<> TestObj::DictionaryThatShouldTolerateNull convertDictionary<TestObj::DictionaryThatShouldTolerateNull>(JSC::ExecState&, JSC::JSValue);
index 1de4fe6..e41bef8 100644 (file)
@@ -433,7 +433,9 @@ enum TestConfidence { "high", "kinda-low" };
 
 typedef any AnyTypedef;
 
-dictionary TestDictionary {
+[
+    JSGenerateToJSObject
+]dictionary TestDictionary {
     TestEnumType enumerationValueWithoutDefault;
     TestEnumType enumerationValueWithDefault = "enumValue1";
     TestEnumType enumerationValueWithEmptyStringDefault = "";
index 7fa0ca5..a8d2327 100644 (file)
@@ -26,6 +26,7 @@
 #pragma once
 
 #include "CryptoAlgorithmIdentifier.h"
+#include "CryptoKeyPair.h"
 #include "CryptoKeyUsage.h"
 #include "ExceptionOr.h"
 #include "JsonWebKey.h"
@@ -41,7 +42,6 @@ namespace WebCore {
 class CryptoAlgorithmParameters;
 class CryptoAlgorithmParametersDeprecated;
 class CryptoKey;
-class CryptoKeyPair;
 class CryptoKeyData;
 class ScriptExecutionContext;
 
@@ -49,6 +49,7 @@ class ScriptExecutionContext;
 using CryptoOperationData = std::pair<const uint8_t*, size_t>;
 
 using KeyData = Variant<Vector<uint8_t>, JsonWebKey>;
+using KeyOrKeyPair = Variant<RefPtr<CryptoKey>, CryptoKeyPair>;
 
 class CryptoAlgorithm : public RefCounted<CryptoAlgorithm> {
 public:
@@ -58,7 +59,7 @@ public:
 
     using BoolCallback = WTF::Function<void(bool)>;
     using KeyCallback = WTF::Function<void(CryptoKey&)>;
-    using KeyOrKeyPairCallback = WTF::Function<void(CryptoKey*, CryptoKeyPair*)>;
+    using KeyOrKeyPairCallback = WTF::Function<void(KeyOrKeyPair&&)>;
     using VectorCallback = WTF::Function<void(const Vector<uint8_t>&)>;
     using VoidCallback = WTF::Function<void()>;
     using ExceptionCallback = WTF::Function<void(ExceptionCode)>;
diff --git a/Source/WebCore/crypto/CryptoKeyPair.cpp b/Source/WebCore/crypto/CryptoKeyPair.cpp
deleted file mode 100644 (file)
index 565ad4a..0000000
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#include "config.h"
-#include "CryptoKeyPair.h"
-
-#if ENABLE(SUBTLE_CRYPTO)
-
-namespace WebCore {
-
-CryptoKeyPair::CryptoKeyPair(RefPtr<CryptoKey>&& publicKey, RefPtr<CryptoKey>&& privateKey)
-    : m_publicKey(WTFMove(publicKey))
-    , m_privateKey(WTFMove(privateKey))
-{
-}
-
-CryptoKeyPair::~CryptoKeyPair()
-{
-}
-
-} // namespace WebCore
-
-#endif // ENABLE(SUBTLE_CRYPTO)
index 1bc83df..d188fed 100644 (file)
@@ -25,7 +25,6 @@
 
 #pragma once
 
-#include "CryptoKey.h"
 #include <wtf/RefCounted.h>
 #include <wtf/RefPtr.h>
 
 
 namespace WebCore {
 
-class CryptoKeyPair : public RefCounted<CryptoKeyPair> {
-public:
-    static Ref<CryptoKeyPair> create(RefPtr<CryptoKey>&& publicKey, RefPtr<CryptoKey>&& privateKey)
-    {
-        return adoptRef(*new CryptoKeyPair(WTFMove(publicKey), WTFMove(privateKey)));
-    }
-    ~CryptoKeyPair();
+class CryptoKey;
 
-    CryptoKey* publicKey() { return m_publicKey.get(); }
-    CryptoKey* privateKey() { return m_privateKey.get(); }
-
-private:
-    CryptoKeyPair(RefPtr<CryptoKey>&& publicKey, RefPtr<CryptoKey>&& privateKey);
-
-    RefPtr<CryptoKey> m_publicKey;
-    RefPtr<CryptoKey> m_privateKey;
+struct CryptoKeyPair {
+    RefPtr<CryptoKey> publicKey;
+    RefPtr<CryptoKey> privateKey;
 };
 
 } // namespace WebCore
index c67b0d6..961f5b1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2013-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
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-// FIXME: The spec suggests that CryptoKeyPair should be of type Dictionary
-// as of 11 December 2014: https://www.w3.org/TR/WebCryptoAPI/#keypair
-// Since we don't support convert a Dictionary type object from its native
-// type to JSValue yet, we use a NoInterfaceObject hack for now. See:
-// https://bugs.webkit.org/show_bug.cgi?id=163711
 [
     Conditional=SUBTLE_CRYPTO,
-    ImplementationLacksVTable,
-    JSCustomMarkFunction,
-    NoInterfaceObject
-] interface CryptoKeyPair {
-    readonly attribute CryptoKey publicKey;
-    readonly attribute CryptoKey privateKey;
+    JSGenerateToJSObject
+] dictionary CryptoKeyPair {
+    CryptoKey publicKey;
+    CryptoKey privateKey;
 };
index 7e061a2..ac231fa 100644 (file)
@@ -103,7 +103,7 @@ void CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParameters& parame
         return;
     }
 
-    callback(result.get(), nullptr);
+    callback(WTFMove(result));
 }
 
 void CryptoAlgorithmAES_CBC::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
@@ -212,7 +212,7 @@ ExceptionOr<void> CryptoAlgorithmAES_CBC::generateKey(const CryptoAlgorithmParam
         return { };
     }
 
-    callback(result.get(), nullptr);
+    callback(WTFMove(result));
     return { };
 }
 
index dfb4bfb..afa7c5d 100644 (file)
@@ -76,7 +76,7 @@ void CryptoAlgorithmAES_KW::generateKey(const CryptoAlgorithmParameters& paramet
         return;
     }
 
-    callback(result.get(), nullptr);
+    callback(WTFMove(result));
 }
 
 void CryptoAlgorithmAES_KW::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
@@ -193,7 +193,8 @@ ExceptionOr<void> CryptoAlgorithmAES_KW::generateKey(const CryptoAlgorithmParame
         failureCallback();
         return { };
     }
-    callback(result.get(), nullptr);
+
+    callback(WTFMove(result));
     return { };
 }
 
index 06ac7b9..4bca92a 100644 (file)
@@ -99,7 +99,7 @@ void CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParameters& parameter
         return;
     }
 
-    callback(result.get(), nullptr);
+    callback(WTFMove(result));
 }
 
 void CryptoAlgorithmHMAC::importKey(SubtleCrypto::KeyFormat format, KeyData&& data, const std::unique_ptr<CryptoAlgorithmParameters>&& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyCallback&& callback, ExceptionCallback&& exceptionCallback)
@@ -220,7 +220,7 @@ ExceptionOr<void> CryptoAlgorithmHMAC::generateKey(const CryptoAlgorithmParamete
         failureCallback();
         return { };
     }
-    callback(result.get(), nullptr);
+    callback(WTFMove(result));
     return { };
 }
 
index 3b48ee3..2d3ef57 100644 (file)
@@ -86,10 +86,10 @@ void CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const CryptoAlgorithmParameter
         return;
     }
 
-    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair& pair) {
-        pair.publicKey()->setUsagesBitmap(pair.publicKey()->usagesBitmap() & CryptoKeyUsageEncrypt);
-        pair.privateKey()->setUsagesBitmap(pair.privateKey()->usagesBitmap() & CryptoKeyUsageDecrypt);
-        capturedCallback(nullptr, &pair);
+    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair&& pair) {
+        pair.publicKey->setUsagesBitmap(pair.publicKey->usagesBitmap() & CryptoKeyUsageEncrypt);
+        pair.privateKey->setUsagesBitmap(pair.privateKey->usagesBitmap() & CryptoKeyUsageDecrypt);
+        capturedCallback(WTFMove(pair));
     };
     auto failureCallback = [capturedCallback = WTFMove(exceptionCallback)]() {
         capturedCallback(OperationError);
@@ -174,8 +174,8 @@ ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::decrypt(const CryptoAlgorithm
 ExceptionOr<void> CryptoAlgorithmRSAES_PKCS1_v1_5::generateKey(const CryptoAlgorithmParametersDeprecated& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, VoidCallback&& failureCallback, ScriptExecutionContext& context)
 {
     auto& rsaParameters = downcast<CryptoAlgorithmRsaKeyGenParamsDeprecated>(parameters);
-    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair& pair) {
-        capturedCallback(nullptr, &pair);
+    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair&& pair) {
+        capturedCallback(WTFMove(pair));
     };
     CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier::RSAES_PKCS1_v1_5, rsaParameters.hash, rsaParameters.hasHash, rsaParameters.modulusLength, rsaParameters.publicExponent, extractable, usages, WTFMove(keyPairCallback), WTFMove(failureCallback), &context);
     return { };
index 8059fda..a026784 100644 (file)
@@ -95,10 +95,10 @@ void CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const CryptoAlgorithmParamete
         return;
     }
 
-    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair& pair) {
-        pair.publicKey()->setUsagesBitmap(pair.publicKey()->usagesBitmap() & CryptoKeyUsageVerify);
-        pair.privateKey()->setUsagesBitmap(pair.privateKey()->usagesBitmap() & CryptoKeyUsageSign);
-        capturedCallback(nullptr, &pair);
+    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair&& pair) {
+        pair.publicKey->setUsagesBitmap(pair.publicKey->usagesBitmap() & CryptoKeyUsageVerify);
+        pair.privateKey->setUsagesBitmap(pair.privateKey->usagesBitmap() & CryptoKeyUsageSign);
+        capturedCallback(WTFMove(pair));
     };
     auto failureCallback = [capturedCallback = WTFMove(exceptionCallback)]() {
         capturedCallback(OperationError);
@@ -227,8 +227,8 @@ ExceptionOr<void> CryptoAlgorithmRSASSA_PKCS1_v1_5::verify(const CryptoAlgorithm
 ExceptionOr<void> CryptoAlgorithmRSASSA_PKCS1_v1_5::generateKey(const CryptoAlgorithmParametersDeprecated& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, VoidCallback&& failureCallback, ScriptExecutionContext& context)
 {
     auto& rsaParameters = downcast<CryptoAlgorithmRsaKeyGenParamsDeprecated>(parameters);
-    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair& pair) {
-        capturedCallback(nullptr, &pair);
+    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair&& pair) {
+        capturedCallback(WTFMove(pair));
     };
     CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier::RSASSA_PKCS1_v1_5, rsaParameters.hash, rsaParameters.hasHash, rsaParameters.modulusLength, rsaParameters.publicExponent, extractable, usages, WTFMove(keyPairCallback), WTFMove(failureCallback), &context);
     return { };
index 79afc54..d2cd1ee 100644 (file)
@@ -97,10 +97,10 @@ void CryptoAlgorithmRSA_OAEP::generateKey(const CryptoAlgorithmParameters& param
         return;
     }
 
-    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair& pair) {
-        pair.publicKey()->setUsagesBitmap(pair.publicKey()->usagesBitmap() & (CryptoKeyUsageEncrypt | CryptoKeyUsageWrapKey));
-        pair.privateKey()->setUsagesBitmap(pair.privateKey()->usagesBitmap() & (CryptoKeyUsageDecrypt | CryptoKeyUsageUnwrapKey));
-        capturedCallback(nullptr, &pair);
+    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair&& pair) {
+        pair.publicKey->setUsagesBitmap(pair.publicKey->usagesBitmap() & (CryptoKeyUsageEncrypt | CryptoKeyUsageWrapKey));
+        pair.privateKey->setUsagesBitmap(pair.privateKey->usagesBitmap() & (CryptoKeyUsageDecrypt | CryptoKeyUsageUnwrapKey));
+        capturedCallback(WTFMove(pair));
     };
     auto failureCallback = [capturedCallback = WTFMove(exceptionCallback)]() {
         capturedCallback(OperationError);
@@ -240,8 +240,8 @@ ExceptionOr<void> CryptoAlgorithmRSA_OAEP::decrypt(const CryptoAlgorithmParamete
 ExceptionOr<void> CryptoAlgorithmRSA_OAEP::generateKey(const CryptoAlgorithmParametersDeprecated& parameters, bool extractable, CryptoKeyUsageBitmap usages, KeyOrKeyPairCallback&& callback, VoidCallback&& failureCallback, ScriptExecutionContext& context)
 {
     auto& rsaParameters = downcast<CryptoAlgorithmRsaKeyGenParamsDeprecated>(parameters);
-    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair& pair) {
-        capturedCallback(nullptr, &pair);
+    auto keyPairCallback = [capturedCallback = WTFMove(callback)](CryptoKeyPair&& pair) {
+        capturedCallback(WTFMove(pair));
     };
     CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier::RSA_OAEP, rsaParameters.hash, rsaParameters.hasHash, rsaParameters.modulusLength, rsaParameters.publicExponent, extractable, usages, WTFMove(keyPairCallback), WTFMove(failureCallback), &context);
     return { };
index 6aee735..dc53414 100644 (file)
@@ -43,10 +43,10 @@ typedef PlatformRSAKeyGnuTLS *PlatformRSAKey;
 namespace WebCore {
 
 class CryptoKeyDataRSAComponents;
-class CryptoKeyPair;
 class PromiseWrapper;
 class ScriptExecutionContext;
 
+struct CryptoKeyPair;
 struct JsonWebKey;
 
 class RsaKeyAlgorithm : public KeyAlgorithm {
@@ -97,7 +97,7 @@ public:
 
     size_t keySizeInBits() const;
 
-    using KeyPairCallback = WTF::Function<void(CryptoKeyPair&)>;
+    using KeyPairCallback = WTF::Function<void(CryptoKeyPair&&)>;
     using VoidCallback = WTF::Function<void()>;
     static void generatePair(CryptoAlgorithmIdentifier, CryptoAlgorithmIdentifier hash, bool hasHash, unsigned modulusLength, const Vector<uint8_t>& publicExponent, bool extractable, CryptoKeyUsageBitmap, KeyPairCallback&&, VoidCallback&& failureCallback, ScriptExecutionContext*);
     static RefPtr<CryptoKeyRSA> importJwk(CryptoAlgorithmIdentifier, std::optional<CryptoAlgorithmIdentifier> hash, JsonWebKey&&, bool extractable, CryptoKeyUsageBitmap);
index a798c31..e9ddc0b 100644 (file)
@@ -270,7 +270,9 @@ void CryptoKeyRSA::generatePair(CryptoAlgorithmIdentifier algorithm, CryptoAlgor
         context->postTask([algorithm, hash, hasHash, extractable, usage, localCallback, localFailureCallback, ccPublicKey, ccPrivateKey](ScriptExecutionContext& context) {
             auto publicKey = CryptoKeyRSA::create(algorithm, hash, hasHash, CryptoKeyType::Public, ccPublicKey, true, usage);
             auto privateKey = CryptoKeyRSA::create(algorithm, hash, hasHash, CryptoKeyType::Private, ccPrivateKey, extractable, usage);
-            (*localCallback)(CryptoKeyPair::create(WTFMove(publicKey), WTFMove(privateKey)));
+
+            (*localCallback)(CryptoKeyPair { WTFMove(publicKey), WTFMove(privateKey) });
+
             delete localCallback;
             delete localFailureCallback;
             context.deref();
index 23cef7d..e612546 100644 (file)
@@ -65,7 +65,7 @@ public:
     enum class LoadStatus { Unloaded, Loading, Loaded, Error };
     LoadStatus status() const;
 
-    typedef DOMPromise<FontFace&> Promise;
+    using Promise = DOMPromise<IDLInterface<FontFace>>;
     std::optional<Promise>& promise() { return m_promise; }
     void registerLoaded(Promise&&);
 
index 738b08e..5b5268b 100644 (file)
@@ -133,7 +133,7 @@ void FontFaceSet::load(const String& font, const String& text, LoadPromise&& pro
     auto matchingFaces = matchingFacesResult.releaseReturnValue();
 
     if (matchingFaces.isEmpty()) {
-        promise.resolve(Vector<RefPtr<FontFace>>());
+        promise.resolve({ });
         return;
     }
 
index 03f4f42..fa8fe2a 100644 (file)
@@ -46,14 +46,14 @@ public:
     bool remove(FontFace&);
     void clear();
 
-    typedef DOMPromise<Vector<RefPtr<FontFace>>> LoadPromise;
+    using LoadPromise = DOMPromise<IDLSequence<IDLInterface<FontFace>>>;
     void load(const String& font, const String& text, LoadPromise&&);
     ExceptionOr<bool> check(const String& font, const String& text);
 
     enum class LoadStatus { Loading, Loaded };
     LoadStatus status() const;
 
-    typedef DOMPromise<FontFaceSet&> ReadyPromise;
+    using ReadyPromise = DOMPromise<IDLInterface<FontFaceSet>>;
     void registerReady(ReadyPromise&&);
 
     CSSFontFaceSet& backing() { return m_backing; }
index d4f4d09..150485f 100644 (file)
@@ -77,7 +77,7 @@ void CustomElementRegistry::addElementDefinition(Ref<JSCustomElementInterface>&&
         enqueueUpgradeInShadowIncludingTreeOrder(*document, elementInterface.get());
 
     if (auto promise = m_promiseMap.take(localName))
-        promise.value()->resolve(nullptr);
+        promise.value()->resolve();
 }
 
 JSCustomElementInterface* CustomElementRegistry::findInterface(const Element& element) const
index 3dda7a7..07bb1d4 100644 (file)
@@ -54,6 +54,7 @@
 #include "HTMLSourceElement.h"
 #include "HTMLVideoElement.h"
 #include "JSDOMError.h"
+#include "JSDOMPromise.h"
 #include "JSHTMLMediaElement.h"
 #include "Language.h"
 #include "Logging.h"
@@ -977,7 +978,7 @@ void HTMLMediaElement::rejectPendingPlayPromises(DOMError& error)
     Vector<DOMPromise<void>> pendingPlayPromises = WTFMove(m_pendingPlayPromises);
 
     for (auto& promise : pendingPlayPromises)
-        promise.reject(error);
+        promise.rejectType<IDLInterface<DOMError>>(error);
 }
 
 void HTMLMediaElement::resolvePendingPlayPromises()
index 8559885..023cc33 100644 (file)
@@ -32,7 +32,6 @@
 #include "GenericEventQueue.h"
 #include "GenericTaskQueue.h"
 #include "HTMLMediaElementEnums.h"
-#include "JSDOMPromise.h"
 #include "MediaCanStartListener.h"
 #include "MediaControllerInterface.h"
 #include "MediaElementSession.h"
@@ -59,6 +58,7 @@ class AudioSourceProvider;
 class AudioTrackList;
 class AudioTrackPrivate;
 class DOMError;
+class DeferredPromise;
 class DisplaySleepDisabler;
 class Event;
 class HTMLSourceElement;
@@ -87,6 +87,8 @@ class VideoTrackList;
 class VideoTrackPrivate;
 class WebKitMediaKeys;
 
+template<typename> class DOMPromise;
+
 #if ENABLE(VIDEO_TRACK)
 using CueIntervalTree = PODIntervalTree<MediaTime, TextTrackCue*>;
 using CueInterval = CueIntervalTree::IntervalType;
index 9540525..25763ad 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "Clock.h"
 #include "EventNames.h"
+#include "ExceptionCode.h"
 #include "HTMLMediaElement.h"
 #include "TimeRanges.h"
 #include <wtf/CurrentTime.h>
index 024c185..fe94bf0 100644 (file)
@@ -61,6 +61,7 @@
 #include <JavaScriptCore/JSCJSValueInlines.h>
 #include <JavaScriptCore/JSCellInlines.h>
 #include <JavaScriptCore/JSGenericTypedArrayViewInlines.h>
+#include <heap/HeapInlines.h>
 
 namespace WebCore {
 
index 45814f1..96bcd7e 100644 (file)
@@ -36,6 +36,7 @@
 #include "TextTrack.h"
 
 #include "Event.h"
+#include "ExceptionCode.h"
 #include "HTMLMediaElement.h"
 #include "SourceBuffer.h"
 #include "TextTrackCueList.h"
index 872668e..a99a01e 100644 (file)
@@ -92,6 +92,10 @@ set(WebKit2_INCLUDE_DIRECTORIES
     "${WEBCORE_DIR}/bridge"
     "${WEBCORE_DIR}/bridge/jsc"
     "${WEBCORE_DIR}/contentextensions"
+    "${WEBCORE_DIR}/crypto"
+    "${WEBCORE_DIR}/crypto/algorithms"
+    "${WEBCORE_DIR}/crypto/keys"
+    "${WEBCORE_DIR}/crypto/parameters"
     "${WEBCORE_DIR}/css"
     "${WEBCORE_DIR}/css/parser"
     "${WEBCORE_DIR}/dom"
index 7c2d198..b28927b 100644 (file)
@@ -1,3 +1,13 @@
+2016-12-06  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Add support for converting dictionaries to JS
+        https://bugs.webkit.org/show_bug.cgi?id=165367
+
+        Reviewed by Darin Adler and Alex Christensen.
+
+        * CMakeLists.txt:
+        Add missing directories to look in for headers.
+
 2016-12-05  Tim Horton  <timothy_horton@apple.com>
 
         Try to fix the iOS Simulator build.