DOMPromise should only restrict the resolution type
authoryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 May 2016 11:03:00 +0000 (11:03 +0000)
committeryouenn.fablet@crf.canon.fr <youenn.fablet@crf.canon.fr@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 13 May 2016 11:03:00 +0000 (11:03 +0000)
commit682870eb3a0a2d49c553d61e8a7531493c5ba4ac
treebd5808fe0820bc643cf39b509c3bd2b123ee5c22
parente06eab5e5ef9bc36dc54bd5ec4be0a5302b4958e
DOMPromise should only restrict the resolution type
https://bugs.webkit.org/show_bug.cgi?id=157307

Reviewed by Darin Adler.

Source/WebCore:

Removing from DOMPromise the rejection template parameter.
Supported rejection types are integers (Exception codes) and DOM objects (DOMError typically).

Updated toJS and DeferredWrapper to accept Ref<>&& and RefPtr<>&&.
Previously Ref<>&& were not accepted and only "const RefPtr<>&" was accepted.
This in turn created an unecessary churn count when calling toJS.

Changes also allow in most cases to remove the need for explictly declaring the
rejection/resolution type.

Minor refactoring of FontFaceSet promise handling to use DOMPromise in lieu of DeferredWrapper.

Covered by existing tests.
Changes should not be visible from user scripts.

* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::consume):
(WebCore::FetchBody::consumeText):
(WebCore::blobFromArrayBuffer):
(WebCore::FetchBody::loadingFailed):
* Modules/fetch/FetchBody.h:
(WebCore::FetchBody::formData):
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::arrayBuffer):
(WebCore::FetchBodyOwner::blob):
(WebCore::FetchBodyOwner::formData):
(WebCore::FetchBodyOwner::json):
(WebCore::FetchBodyOwner::text):
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::BodyLoader::didReceiveResponse):
* Modules/fetch/FetchResponse.h:
* Modules/mediastream/MediaDevices.h:
* Modules/mediastream/PeerConnectionBackend.h:
* Modules/mediastream/UserMediaRequest.cpp:
(WebCore::UserMediaRequest::didCreateStream):
* Modules/streams/ReadableStreamSource.h:
* Modules/webaudio/AudioContext.h:
* bindings/js/JSDOMBinding.h:
(WebCore::toJS):
(WebCore::jsPair):
* bindings/js/JSDOMPromise.cpp:
(WebCore::fulfillPromiseWithJSON):
* bindings/js/JSDOMPromise.h:
(WebCore::TypeInspector::decltype):
(WebCore::TypeInspector::testIsVector):
(WebCore::TypeInspector::testIsRefOrRefPtr):
(WebCore::DeferredWrapper::resolve):
(WebCore::DeferredWrapper::reject):
(WebCore::DOMPromise::resolve):
(WebCore::DOMPromise::reject):
(WebCore::DeferredWrapper::resolveWithValue):
(WebCore::DeferredWrapper::rejectWithValue):
(WebCore::callPromiseFunction):
* bindings/js/JSSubtleCryptoCustom.cpp:
(WebCore::JSSubtleCrypto::importKey):
(WebCore::JSSubtleCrypto::unwrapKey):
* css/FontFace.h:
* css/FontFaceSet.cpp:
(WebCore::FontFaceSet::PendingPromise::PendingPromise):
(WebCore::FontFaceSet::load):
(WebCore::FontFaceSet::registerReady):
* css/FontFaceSet.h:
* html/HTMLMediaElement.h:

Source/WTF:

* wtf/Ref.h: Adding static constexpr to ease detection of Ref for templates.
* wtf/RefPtr.h: Ditto.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@200837 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
Source/WTF/ChangeLog
Source/WTF/wtf/Ref.h
Source/WTF/wtf/RefPtr.h
Source/WebCore/ChangeLog
Source/WebCore/Modules/fetch/FetchBody.cpp
Source/WebCore/Modules/fetch/FetchBody.h
Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/Modules/fetch/FetchResponse.h
Source/WebCore/Modules/mediastream/MediaDevices.h
Source/WebCore/Modules/mediastream/PeerConnectionBackend.h
Source/WebCore/Modules/mediastream/UserMediaRequest.cpp
Source/WebCore/Modules/streams/ReadableStreamSource.h
Source/WebCore/Modules/webaudio/AudioContext.h
Source/WebCore/bindings/js/JSDOMBinding.h
Source/WebCore/bindings/js/JSDOMPromise.cpp
Source/WebCore/bindings/js/JSDOMPromise.h
Source/WebCore/bindings/js/JSSubtleCryptoCustom.cpp
Source/WebCore/css/FontFace.h
Source/WebCore/css/FontFaceSet.cpp
Source/WebCore/css/FontFaceSet.h
Source/WebCore/html/HTMLMediaElement.h