[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)
commit98a7e1ce3ae5b929b1b3f464cee8dd7d8d8faf5c
tree7e4a64f61a78a6f476d09dbe6fd4bcb8a3379311
parentb57d09d653f18ae93b1184c498fe84e8eb852c88
[WebIDL] Add support for converting dictionaries to JS
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