Improve DeferredWrapper code
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Sep 2016 07:35:46 +0000 (07:35 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 22 Sep 2016 07:35:46 +0000 (07:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=161787

Patch by Youenn Fablet <youenn@apple.com> on 2016-09-22
Reviewed by Darin Adler.

No change of behavior.

Renaming DeferredWrapper to DeferredPromise.
Adding create method that creates the underlying JSC::JSPromiseDeferred in non-worker environments.
Updated create method to take references.
Introducing domWindow helper accessor into JSDOMObject to ease creation of promise in non-worker environments.
Doing some minor clean up (renaming of m_wrapper to m_promiseDeferred, accessor change).

* Modules/applepay/ApplePaySession.cpp:
(WebCore::ApplePaySession::canMakePaymentsWithActiveCard):
* Modules/applepay/ApplePaySession.h:
* Modules/fetch/DOMWindowFetch.cpp:
(WebCore::DOMWindowFetch::fetch):
* Modules/fetch/DOMWindowFetch.h: Updated to take a DeferredPromise to make it consistent with WorkerGlobalScopeFetch.
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::arrayBuffer):
(WebCore::FetchBody::blob):
(WebCore::FetchBody::json):
(WebCore::FetchBody::text):
(WebCore::FetchBody::consume):
(WebCore::FetchBody::consumeArrayBuffer):
(WebCore::FetchBody::consumeArrayBufferView):
(WebCore::FetchBody::consumeText):
(WebCore::FetchBody::consumeBlob):
* Modules/fetch/FetchBody.h:
(WebCore::FetchBody::formData):
* Modules/fetch/FetchBodyConsumer.cpp:
(WebCore::FetchBodyConsumer::resolveWithData):
(WebCore::FetchBodyConsumer::resolve):
* Modules/fetch/FetchBodyConsumer.h:
* Modules/fetch/FetchBodyOwner.cpp:
(WebCore::FetchBodyOwner::arrayBuffer):
(WebCore::FetchBodyOwner::blob):
(WebCore::FetchBodyOwner::formData):
(WebCore::FetchBodyOwner::json):
(WebCore::FetchBodyOwner::text):
* Modules/fetch/FetchBodyOwner.h:
* Modules/fetch/FetchResponse.cpp:
(WebCore::FetchResponse::consume):
(WebCore::FetchResponse::finishConsumingStream):
* Modules/fetch/FetchResponse.h:
* Modules/fetch/WorkerGlobalScopeFetch.cpp:
(WebCore::WorkerGlobalScopeFetch::fetch):
* Modules/fetch/WorkerGlobalScopeFetch.h:
* bindings/js/JSCustomElementRegistryCustom.cpp:
(WebCore::whenDefinedPromise):
(WebCore::JSCustomElementRegistry::whenDefined):
* bindings/js/JSDOMGlobalObject.cpp:
(WebCore::JSDOMGlobalObject::visitChildren):
* bindings/js/JSDOMGlobalObject.h:
* bindings/js/JSDOMPromise.cpp:
(WebCore::DOMDeferredPromise::DOMDeferredPromise):
(WebCore::DOMDeferredPromise::~DOMDeferredPromise):
(WebCore::DOMDeferredPromise::clear):
(WebCore::DOMDeferredPromise::contextDestroyed):
(WebCore::DOMDeferredPromise::promise):
(WebCore::DOMDeferredPromise::callFunction):
(WebCore::DOMDeferredPromise::reject):
(WebCore::rejectPromiseWithExceptionIfAny):
(WebCore::fulfillPromiseWithJSON):
(WebCore::fulfillPromiseWithArrayBuffer):
(WebCore::DeferredWrapper::DeferredWrapper): Deleted.
(WebCore::DeferredWrapper::~DeferredWrapper): Deleted.
(WebCore::DeferredWrapper::clear): Deleted.
(WebCore::DeferredWrapper::contextDestroyed): Deleted.
(WebCore::DeferredWrapper::promise): Deleted.
(WebCore::DeferredWrapper::callFunction): Deleted.
(WebCore::DeferredWrapper::reject): Deleted.
* bindings/js/JSDOMPromise.h:
(WebCore::DOMDeferredPromise::create):
(WebCore::callPromiseFunction):
(WebCore::DOMPromise::DOMPromise):
(WebCore::DOMPromise::deferredPromise):
(WebCore::DOMDeferredPromise::resolveWithValue):
(WebCore::DOMDeferredPromise::resolveWithNewlyCreated):
(WebCore::DOMDeferredPromise::rejectWithValue):
(WebCore::DOMDeferredPromise::resolve):
(WebCore::DOMDeferredPromise::reject):
(WebCore::DeferredWrapper::create): Deleted.
(WebCore::DOMPromise::deferredWrapper): Deleted.
(WebCore::DeferredWrapper::resolveWithValue): Deleted.
(WebCore::DeferredWrapper::resolveWithNewlyCreated): Deleted.
(WebCore::DeferredWrapper::rejectWithValue): Deleted.
(WebCore::DeferredWrapper::resolve): Deleted.
(WebCore::DeferredWrapper::reject): Deleted.
* bindings/js/JSDOMWrapper.cpp: Introducing domWindow() accessor.
* bindings/js/JSDOMWrapper.h:
* bindings/js/JSFontFaceCustom.cpp:
(WebCore::JSFontFace::loaded):
* bindings/js/JSFontFaceSetCustom.cpp:
(WebCore::JSFontFaceSet::ready):
* bindings/js/JSMediaDevicesCustom.cpp:
(WebCore::JSMediaDevices::getUserMedia):
* bindings/js/JSMediaStreamTrackCustom.cpp:
(WebCore::JSMediaStreamTrack::applyConstraints):
* bindings/js/JSReadableStreamSourceCustom.cpp:
(WebCore::JSReadableStreamSource::start):
* bindings/js/JSWebKitSubtleCryptoCustom.cpp:
(WebCore::JSWebKitSubtleCrypto::encrypt):
(WebCore::JSWebKitSubtleCrypto::decrypt):
(WebCore::JSWebKitSubtleCrypto::sign):
(WebCore::JSWebKitSubtleCrypto::verify):
(WebCore::JSWebKitSubtleCrypto::digest):
(WebCore::JSWebKitSubtleCrypto::generateKey):
(WebCore::JSWebKitSubtleCrypto::importKey):
(WebCore::JSWebKitSubtleCrypto::exportKey):
(WebCore::JSWebKitSubtleCrypto::wrapKey):
(WebCore::JSWebKitSubtleCrypto::unwrapKey):
* bindings/scripts/CodeGeneratorJS.pm:
(GenerateImplementation):
(GenerateReturnParameters):
* bindings/scripts/test/JS/JSTestObj.cpp:
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionPromise):
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise):
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise):
(WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise):
(WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise):
(WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise):
(WebCore::jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise):
(WebCore::jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise):
* dom/CustomElementRegistry.h:
(WebCore::CustomElementRegistry::promiseMap):

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

34 files changed:
Source/WebCore/ChangeLog
Source/WebCore/Modules/applepay/ApplePaySession.cpp
Source/WebCore/Modules/applepay/ApplePaySession.h
Source/WebCore/Modules/fetch/DOMWindowFetch.cpp
Source/WebCore/Modules/fetch/DOMWindowFetch.h
Source/WebCore/Modules/fetch/FetchBody.cpp
Source/WebCore/Modules/fetch/FetchBody.h
Source/WebCore/Modules/fetch/FetchBodyConsumer.cpp
Source/WebCore/Modules/fetch/FetchBodyConsumer.h
Source/WebCore/Modules/fetch/FetchBodyOwner.cpp
Source/WebCore/Modules/fetch/FetchBodyOwner.h
Source/WebCore/Modules/fetch/FetchResponse.cpp
Source/WebCore/Modules/fetch/FetchResponse.h
Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.cpp
Source/WebCore/Modules/fetch/WorkerGlobalScopeFetch.h
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp
Source/WebCore/bindings/js/JSDOMGlobalObject.cpp
Source/WebCore/bindings/js/JSDOMGlobalObject.h
Source/WebCore/bindings/js/JSDOMPromise.cpp
Source/WebCore/bindings/js/JSDOMPromise.h
Source/WebCore/bindings/js/JSDOMWrapper.cpp
Source/WebCore/bindings/js/JSDOMWrapper.h
Source/WebCore/bindings/js/JSFontFaceCustom.cpp
Source/WebCore/bindings/js/JSFontFaceSetCustom.cpp
Source/WebCore/bindings/js/JSMediaDevicesCustom.cpp
Source/WebCore/bindings/js/JSMediaStreamTrackCustom.cpp
Source/WebCore/bindings/js/JSReadableStreamSourceCustom.cpp
Source/WebCore/bindings/js/JSWebKitSubtleCryptoCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/test/JS/JSTestNode.cpp
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/dom/CustomElementRegistry.cpp
Source/WebCore/dom/CustomElementRegistry.h

index aa9d81f5c64f35b0841e9a3f335bbd5dc56fb611..c0cd450a79e8847baa0ad5209d1ee898e91d243c 100644 (file)
@@ -1,3 +1,133 @@
+2016-09-22  Youenn Fablet  <youenn@apple.com>
+
+        Improve DeferredWrapper code
+        https://bugs.webkit.org/show_bug.cgi?id=161787
+
+        Reviewed by Darin Adler.
+
+        No change of behavior.
+
+        Renaming DeferredWrapper to DeferredPromise.
+        Adding create method that creates the underlying JSC::JSPromiseDeferred in non-worker environments.
+        Updated create method to take references.
+        Introducing domWindow helper accessor into JSDOMObject to ease creation of promise in non-worker environments.
+        Doing some minor clean up (renaming of m_wrapper to m_promiseDeferred, accessor change).
+
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::ApplePaySession::canMakePaymentsWithActiveCard):
+        * Modules/applepay/ApplePaySession.h:
+        * Modules/fetch/DOMWindowFetch.cpp:
+        (WebCore::DOMWindowFetch::fetch):
+        * Modules/fetch/DOMWindowFetch.h: Updated to take a DeferredPromise to make it consistent with WorkerGlobalScopeFetch.
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::arrayBuffer):
+        (WebCore::FetchBody::blob):
+        (WebCore::FetchBody::json):
+        (WebCore::FetchBody::text):
+        (WebCore::FetchBody::consume):
+        (WebCore::FetchBody::consumeArrayBuffer):
+        (WebCore::FetchBody::consumeArrayBufferView):
+        (WebCore::FetchBody::consumeText):
+        (WebCore::FetchBody::consumeBlob):
+        * Modules/fetch/FetchBody.h:
+        (WebCore::FetchBody::formData):
+        * Modules/fetch/FetchBodyConsumer.cpp:
+        (WebCore::FetchBodyConsumer::resolveWithData):
+        (WebCore::FetchBodyConsumer::resolve):
+        * Modules/fetch/FetchBodyConsumer.h:
+        * Modules/fetch/FetchBodyOwner.cpp:
+        (WebCore::FetchBodyOwner::arrayBuffer):
+        (WebCore::FetchBodyOwner::blob):
+        (WebCore::FetchBodyOwner::formData):
+        (WebCore::FetchBodyOwner::json):
+        (WebCore::FetchBodyOwner::text):
+        * Modules/fetch/FetchBodyOwner.h:
+        * Modules/fetch/FetchResponse.cpp:
+        (WebCore::FetchResponse::consume):
+        (WebCore::FetchResponse::finishConsumingStream):
+        * Modules/fetch/FetchResponse.h:
+        * Modules/fetch/WorkerGlobalScopeFetch.cpp:
+        (WebCore::WorkerGlobalScopeFetch::fetch):
+        * Modules/fetch/WorkerGlobalScopeFetch.h:
+        * bindings/js/JSCustomElementRegistryCustom.cpp:
+        (WebCore::whenDefinedPromise):
+        (WebCore::JSCustomElementRegistry::whenDefined):
+        * bindings/js/JSDOMGlobalObject.cpp:
+        (WebCore::JSDOMGlobalObject::visitChildren):
+        * bindings/js/JSDOMGlobalObject.h:
+        * bindings/js/JSDOMPromise.cpp:
+        (WebCore::DOMDeferredPromise::DOMDeferredPromise):
+        (WebCore::DOMDeferredPromise::~DOMDeferredPromise):
+        (WebCore::DOMDeferredPromise::clear):
+        (WebCore::DOMDeferredPromise::contextDestroyed):
+        (WebCore::DOMDeferredPromise::promise):
+        (WebCore::DOMDeferredPromise::callFunction):
+        (WebCore::DOMDeferredPromise::reject):
+        (WebCore::rejectPromiseWithExceptionIfAny):
+        (WebCore::fulfillPromiseWithJSON):
+        (WebCore::fulfillPromiseWithArrayBuffer):
+        (WebCore::DeferredWrapper::DeferredWrapper): Deleted.
+        (WebCore::DeferredWrapper::~DeferredWrapper): Deleted.
+        (WebCore::DeferredWrapper::clear): Deleted.
+        (WebCore::DeferredWrapper::contextDestroyed): Deleted.
+        (WebCore::DeferredWrapper::promise): Deleted.
+        (WebCore::DeferredWrapper::callFunction): Deleted.
+        (WebCore::DeferredWrapper::reject): Deleted.
+        * bindings/js/JSDOMPromise.h:
+        (WebCore::DOMDeferredPromise::create):
+        (WebCore::callPromiseFunction):
+        (WebCore::DOMPromise::DOMPromise):
+        (WebCore::DOMPromise::deferredPromise):
+        (WebCore::DOMDeferredPromise::resolveWithValue):
+        (WebCore::DOMDeferredPromise::resolveWithNewlyCreated):
+        (WebCore::DOMDeferredPromise::rejectWithValue):
+        (WebCore::DOMDeferredPromise::resolve):
+        (WebCore::DOMDeferredPromise::reject):
+        (WebCore::DeferredWrapper::create): Deleted.
+        (WebCore::DOMPromise::deferredWrapper): Deleted.
+        (WebCore::DeferredWrapper::resolveWithValue): Deleted.
+        (WebCore::DeferredWrapper::resolveWithNewlyCreated): Deleted.
+        (WebCore::DeferredWrapper::rejectWithValue): Deleted.
+        (WebCore::DeferredWrapper::resolve): Deleted.
+        (WebCore::DeferredWrapper::reject): Deleted.
+        * bindings/js/JSDOMWrapper.cpp: Introducing domWindow() accessor.
+        * bindings/js/JSDOMWrapper.h:
+        * bindings/js/JSFontFaceCustom.cpp:
+        (WebCore::JSFontFace::loaded):
+        * bindings/js/JSFontFaceSetCustom.cpp:
+        (WebCore::JSFontFaceSet::ready):
+        * bindings/js/JSMediaDevicesCustom.cpp:
+        (WebCore::JSMediaDevices::getUserMedia):
+        * bindings/js/JSMediaStreamTrackCustom.cpp:
+        (WebCore::JSMediaStreamTrack::applyConstraints):
+        * bindings/js/JSReadableStreamSourceCustom.cpp:
+        (WebCore::JSReadableStreamSource::start):
+        * bindings/js/JSWebKitSubtleCryptoCustom.cpp:
+        (WebCore::JSWebKitSubtleCrypto::encrypt):
+        (WebCore::JSWebKitSubtleCrypto::decrypt):
+        (WebCore::JSWebKitSubtleCrypto::sign):
+        (WebCore::JSWebKitSubtleCrypto::verify):
+        (WebCore::JSWebKitSubtleCrypto::digest):
+        (WebCore::JSWebKitSubtleCrypto::generateKey):
+        (WebCore::JSWebKitSubtleCrypto::importKey):
+        (WebCore::JSWebKitSubtleCrypto::exportKey):
+        (WebCore::JSWebKitSubtleCrypto::wrapKey):
+        (WebCore::JSWebKitSubtleCrypto::unwrapKey):
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateImplementation):
+        (GenerateReturnParameters):
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionPromise):
+        (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise):
+        (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise):
+        (WebCore::jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise):
+        (WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise):
+        (WebCore::jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise):
+        (WebCore::jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise):
+        (WebCore::jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise):
+        * dom/CustomElementRegistry.h:
+        (WebCore::CustomElementRegistry::promiseMap):
+
 2016-09-21  Alexey Proskuryakov  <ap@apple.com>
 
         Rolling out r206244, as it caused flaky crashes on tests.
index c37bf1dcf59ac871723bf0497f44ae8953e7e316..2fd9391414fd25ff62bef64b03de4282c9e095a4 100644 (file)
@@ -733,7 +733,7 @@ bool ApplePaySession::canMakePayments(ScriptExecutionContext& scriptExecutionCon
     return paymentCoordinator.canMakePayments();
 }
 
-void ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredWrapper>&& passedPromise, ExceptionCode& ec)
+void ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise, ExceptionCode& ec)
 {
     auto& document = downcast<Document>(scriptExecutionContext);
     DOMWindow& window = *document.domWindow();
@@ -745,7 +745,7 @@ void ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecutionContext& scri
         return;
     }
 
-    RefPtr<DeferredWrapper> promise(WTFMove(passedPromise));
+    RefPtr<DeferredPromise> promise(WTFMove(passedPromise));
     if (!shouldDiscloseApplePayCapability(document)) {
         auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator();
         bool canMakePayments = paymentCoordinator.canMakePayments();
@@ -763,7 +763,7 @@ void ApplePaySession::canMakePaymentsWithActiveCard(ScriptExecutionContext& scri
     });
 }
 
-void ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredWrapper>&& passedPromise, ExceptionCode& ec)
+void ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionContext, const String& merchantIdentifier, Ref<DeferredPromise>&& passedPromise, ExceptionCode& ec)
 {
     auto& document = downcast<Document>(scriptExecutionContext);
     DOMWindow& window = *document.domWindow();
@@ -781,7 +781,7 @@ void ApplePaySession::openPaymentSetup(ScriptExecutionContext& scriptExecutionCo
         return;
     }
 
-    RefPtr<DeferredWrapper> promise(WTFMove(passedPromise));
+    RefPtr<DeferredPromise> promise(WTFMove(passedPromise));
     auto& paymentCoordinator = document.frame()->mainFrame().paymentCoordinator();
 
     paymentCoordinator.openPaymentSetup(merchantIdentifier, document.domain(), [promise](bool result) mutable {
index bcec069ccf3539a20aa4be339ddecb5739e31905..a381c162503c52d68bedef275daf08ee9d624d45 100644 (file)
@@ -37,7 +37,7 @@
 namespace WebCore {
 
 class ArrayValue;
-class DeferredWrapper;
+class DeferredPromise;
 class Dictionary;
 class Document;
 class Payment;
@@ -63,8 +63,8 @@ public:
 
     static bool supportsVersion(ScriptExecutionContext&, unsigned version, ExceptionCode&);
     static bool canMakePayments(ScriptExecutionContext&, ExceptionCode&);
-    static void canMakePaymentsWithActiveCard(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredWrapper>&&, ExceptionCode&);
-    static void openPaymentSetup(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredWrapper>&&, ExceptionCode&);
+    static void canMakePaymentsWithActiveCard(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&, ExceptionCode&);
+    static void openPaymentSetup(ScriptExecutionContext&, const String& merchantIdentifier, Ref<DeferredPromise>&&, ExceptionCode&);
 
     void begin(ExceptionCode&);
     void abort(ExceptionCode&);
index c480a7db98ef15aa420eba34eba8f9d0174898bc..adadacd83c260cfa9d7699d34f6a4bec91d61f06 100644 (file)
@@ -37,7 +37,7 @@
 
 namespace WebCore {
 
-void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest& request, DOMPromise<FetchResponse>&& promise)
+void DOMWindowFetch::fetch(DOMWindow& window, FetchRequest& request, Ref<DeferredPromise>&& promise)
 {
     if (!window.scriptExecutionContext())
         return;
index d371f2c38b682ddea083a6aff2e347a01d9afa4b..8b16511b3ef863c68228ddb1c42ccad2d7bbdd47 100644 (file)
 namespace WebCore {
 
 class DOMWindow;
-class DeferredWrapper;
 class Dictionary;
 class FetchRequest;
-class FetchResponse;
 
 class DOMWindowFetch {
 public:
-    static void fetch(DOMWindow&, FetchRequest&, DOMPromise<FetchResponse>&&);
+    static void fetch(DOMWindow&, FetchRequest&, Ref<DeferredPromise>&&);
 };
 
 } // namespace WebCore
index 25ed1f381dec46ec3ddb06ad25631aa4bdea6106..032399436869c3df4c9a96edcf15eef95c327635 100644 (file)
@@ -124,14 +124,14 @@ void FetchBody::updateContentType(FetchHeaders& headers)
         headers.fastSet(HTTPHeaderName::ContentType, m_contentType);
 }
 
-void FetchBody::arrayBuffer(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
+void FetchBody::arrayBuffer(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     ASSERT(m_type != Type::None);
     m_consumer.setType(FetchBodyConsumer::Type::ArrayBuffer);
     consume(owner, WTFMove(promise));
 }
 
-void FetchBody::blob(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
+void FetchBody::blob(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     ASSERT(m_type != Type::None);
     m_consumer.setType(FetchBodyConsumer::Type::Blob);
@@ -139,7 +139,7 @@ void FetchBody::blob(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
     consume(owner, WTFMove(promise));
 }
 
-void FetchBody::json(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
+void FetchBody::json(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     ASSERT(m_type != Type::None);
 
@@ -151,7 +151,7 @@ void FetchBody::json(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
     consume(owner, WTFMove(promise));
 }
 
-void FetchBody::text(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
+void FetchBody::text(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     ASSERT(m_type != Type::None);
 
@@ -163,7 +163,7 @@ void FetchBody::text(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
     consume(owner, WTFMove(promise));
 }
 
-void FetchBody::consume(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
+void FetchBody::consume(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     // This should be handled by FetchBodyOwner
     ASSERT(m_type != Type::None);
@@ -246,28 +246,28 @@ void FetchBody::consumeAsStream(FetchBodyOwner& owner, FetchResponseSource& sour
 }
 #endif
 
-void FetchBody::consumeArrayBuffer(Ref<DeferredWrapper>&& promise)
+void FetchBody::consumeArrayBuffer(Ref<DeferredPromise>&& promise)
 {
     ASSERT(m_data);
     m_consumer.resolveWithData(WTFMove(promise), static_cast<const uint8_t*>(m_data->data()), m_data->byteLength());
     m_data = nullptr;
 }
 
-void FetchBody::consumeArrayBufferView(Ref<DeferredWrapper>&& promise)
+void FetchBody::consumeArrayBufferView(Ref<DeferredPromise>&& promise)
 {
     ASSERT(m_dataView);
     m_consumer.resolveWithData(WTFMove(promise), static_cast<const uint8_t*>(m_dataView->baseAddress()), m_dataView->byteLength());
     m_dataView = nullptr;
 }
 
-void FetchBody::consumeText(Ref<DeferredWrapper>&& promise)
+void FetchBody::consumeText(Ref<DeferredPromise>&& promise)
 {
     Vector<uint8_t> data = extractFromText();
     m_consumer.resolveWithData(WTFMove(promise), data.data(), data.size());
     m_text = { };
 }
 
-void FetchBody::consumeBlob(FetchBodyOwner& owner, Ref<DeferredWrapper>&& promise)
+void FetchBody::consumeBlob(FetchBodyOwner& owner, Ref<DeferredPromise>&& promise)
 {
     ASSERT(m_blob);
 
index 850e664b4f275d57639bc757dd67151041199622..400d22d1e0484291969bf8c77ea8fced3a1df344 100644 (file)
@@ -52,11 +52,11 @@ class ScriptExecutionContext;
 
 class FetchBody {
 public:
-    void arrayBuffer(FetchBodyOwner&, Ref<DeferredWrapper>&&);
-    void blob(FetchBodyOwner&, Ref<DeferredWrapper>&&);
-    void json(FetchBodyOwner&, Ref<DeferredWrapper>&&);
-    void text(FetchBodyOwner&, Ref<DeferredWrapper>&&);
-    void formData(FetchBodyOwner&, Ref<DeferredWrapper>&& promise) { promise.get().reject(0); }
+    void arrayBuffer(FetchBodyOwner&, Ref<DeferredPromise>&&);
+    void blob(FetchBodyOwner&, Ref<DeferredPromise>&&);
+    void json(FetchBodyOwner&, Ref<DeferredPromise>&&);
+    void text(FetchBodyOwner&, Ref<DeferredPromise>&&);
+    void formData(FetchBodyOwner&, Ref<DeferredPromise>&& promise) { promise.get().reject(0); }
 
 #if ENABLE(READABLE_STREAM_API)
     void consumeAsStream(FetchBodyOwner&, FetchResponseSource&);
@@ -93,13 +93,13 @@ private:
     FetchBody(String&&);
     FetchBody(Type type) : m_type(type) { }
 
-    void consume(FetchBodyOwner&, Ref<DeferredWrapper>&&);
+    void consume(FetchBodyOwner&, Ref<DeferredPromise>&&);
 
     Vector<uint8_t> extractFromText() const;
-    void consumeArrayBuffer(Ref<DeferredWrapper>&&);
-    void consumeArrayBufferView(Ref<DeferredWrapper>&&);
-    void consumeText(Ref<DeferredWrapper>&&);
-    void consumeBlob(FetchBodyOwner&, Ref<DeferredWrapper>&&);
+    void consumeArrayBuffer(Ref<DeferredPromise>&&);
+    void consumeArrayBufferView(Ref<DeferredPromise>&&);
+    void consumeText(Ref<DeferredPromise>&&);
+    void consumeBlob(FetchBodyOwner&, Ref<DeferredPromise>&&);
 
     Type m_type { Type::None };
     String m_contentType;
@@ -112,7 +112,7 @@ private:
     String m_text;
 
     FetchBodyConsumer m_consumer { FetchBodyConsumer::Type::None };
-    RefPtr<DeferredWrapper> m_consumePromise;
+    RefPtr<DeferredPromise> m_consumePromise;
 };
 
 } // namespace WebCore
index 7264b8d2d979402f920dcf5056fd31c6b69cb20a..70f499150149584e53571c37bb41e19c42906179 100644 (file)
@@ -59,7 +59,7 @@ static String textFromUTF8(const unsigned char* data, unsigned length)
     return decoder->decodeAndFlush(reinterpret_cast<const char*>(data), length);
 }
 
-void FetchBodyConsumer::resolveWithData(Ref<DeferredWrapper>&& promise, const unsigned char* data, unsigned length)
+void FetchBodyConsumer::resolveWithData(Ref<DeferredPromise>&& promise, const unsigned char* data, unsigned length)
 {
     switch (m_type) {
     case Type::ArrayBuffer:
@@ -80,7 +80,7 @@ void FetchBodyConsumer::resolveWithData(Ref<DeferredWrapper>&& promise, const un
     }
 }
 
-void FetchBodyConsumer::resolve(Ref<DeferredWrapper>&& promise)
+void FetchBodyConsumer::resolve(Ref<DeferredPromise>&& promise)
 {
     ASSERT(m_type != Type::None);
     switch (m_type) {
index f949ac086713b98438effe1ee90bf28954779bbb..4a0fb39f10e60c2cc6b1d498d814824fe7972542 100644 (file)
 
 #if ENABLE(FETCH_API)
 
+#include "JSDOMPromise.h"
 #include "SharedBuffer.h"
 
 namespace WebCore {
 
 class Blob;
-class DeferredWrapper;
 
 class FetchBodyConsumer {
 public:
@@ -57,8 +57,8 @@ public:
 
     void clean() { m_buffer = nullptr; }
 
-    void resolve(Ref<DeferredWrapper>&&);
-    void resolveWithData(Ref<DeferredWrapper>&&, const unsigned char*, unsigned);
+    void resolve(Ref<DeferredPromise>&&);
+    void resolveWithData(Ref<DeferredPromise>&&, const unsigned char*, unsigned);
 
     bool hasData() const { return !!m_buffer; }
 
index c29434f351b621e6994abf55c04ba03b25dee28a..6476094a8e3393c3840c46dc62d9a0acf724f12a 100644 (file)
@@ -71,7 +71,7 @@ bool FetchBodyOwner::isDisturbedOrLocked() const
     return false;
 }
 
-void FetchBodyOwner::arrayBuffer(Ref<DeferredWrapper>&& promise)
+void FetchBodyOwner::arrayBuffer(Ref<DeferredPromise>&& promise)
 {
     if (m_body.isEmpty()) {
         fulfillPromiseWithArrayBuffer(WTFMove(promise), nullptr, 0);
@@ -85,7 +85,7 @@ void FetchBodyOwner::arrayBuffer(Ref<DeferredWrapper>&& promise)
     m_body.arrayBuffer(*this, WTFMove(promise));
 }
 
-void FetchBodyOwner::blob(Ref<DeferredWrapper>&& promise)
+void FetchBodyOwner::blob(Ref<DeferredPromise>&& promise)
 {
     if (m_body.isEmpty()) {
         promise->resolve(Blob::create(Vector<uint8_t>(), Blob::normalizedContentType(extractMIMETypeFromMediaType(m_body.contentType()))));
@@ -99,7 +99,7 @@ void FetchBodyOwner::blob(Ref<DeferredWrapper>&& promise)
     m_body.blob(*this, WTFMove(promise));
 }
 
-void FetchBodyOwner::formData(Ref<DeferredWrapper>&& promise)
+void FetchBodyOwner::formData(Ref<DeferredPromise>&& promise)
 {
     if (m_body.isEmpty()) {
         promise->reject(0);
@@ -113,7 +113,7 @@ void FetchBodyOwner::formData(Ref<DeferredWrapper>&& promise)
     m_body.formData(*this, WTFMove(promise));
 }
 
-void FetchBodyOwner::json(Ref<DeferredWrapper>&& promise)
+void FetchBodyOwner::json(Ref<DeferredPromise>&& promise)
 {
     if (m_body.isEmpty()) {
         promise->reject(SYNTAX_ERR);
@@ -127,7 +127,7 @@ void FetchBodyOwner::json(Ref<DeferredWrapper>&& promise)
     m_body.json(*this, WTFMove(promise));
 }
 
-void FetchBodyOwner::text(Ref<DeferredWrapper>&& promise)
+void FetchBodyOwner::text(Ref<DeferredPromise>&& promise)
 {
     if (m_body.isEmpty()) {
         promise->resolve(String());
index 0df30b75482eda880bfc7a977d74a29086f695bb..53fd3d995b5114e17b4eed20ddb0e5e35f182ce9 100644 (file)
@@ -46,11 +46,11 @@ public:
     // Exposed Body API
     bool isDisturbed() const { return m_isDisturbed; };
 
-    void arrayBuffer(Ref<DeferredWrapper>&&);
-    void blob(Ref<DeferredWrapper>&&);
-    void formData(Ref<DeferredWrapper>&&);
-    void json(Ref<DeferredWrapper>&&);
-    void text(Ref<DeferredWrapper>&&);
+    void arrayBuffer(Ref<DeferredPromise>&&);
+    void blob(Ref<DeferredPromise>&&);
+    void formData(Ref<DeferredPromise>&&);
+    void json(Ref<DeferredPromise>&&);
+    void text(Ref<DeferredPromise>&&);
 
     bool isDisturbedOrLocked() const;
 
index b8641d43f0e5178c2d4580c11c57f1dc78a440fe..d93a6ebfd29610da686bb3805a2c63d4a2918af7 100644 (file)
@@ -206,7 +206,7 @@ void FetchResponse::BodyLoader::stop()
         m_loader->stop();
 }
 
-void FetchResponse::consume(unsigned type, Ref<DeferredWrapper>&& wrapper)
+void FetchResponse::consume(unsigned type, Ref<DeferredPromise>&& wrapper)
 {
     ASSERT(type <= static_cast<unsigned>(FetchBodyConsumer::Type::Text));
 
@@ -241,7 +241,7 @@ void FetchResponse::consumeChunk(Ref<JSC::Uint8Array>&& chunk)
     m_consumer.append(chunk->data(), chunk->byteLength());
 }
 
-void FetchResponse::finishConsumingStream(Ref<DeferredWrapper>&& promise)
+void FetchResponse::finishConsumingStream(Ref<DeferredPromise>&& promise)
 {
     m_consumer.resolve(WTFMove(promise));
 }
index ee9936885bcbc968fcbdbc920e4f5e77122c1cee..a6fbb42e5d4efa6d2f2c43d79563683bfd0c244a 100644 (file)
@@ -60,11 +60,11 @@ public:
     using FetchPromise = DOMPromise<FetchResponse>;
     static void fetch(ScriptExecutionContext&, FetchRequest&, FetchPromise&&);
 
-    void consume(unsigned, Ref<DeferredWrapper>&&);
+    void consume(unsigned, Ref<DeferredPromise>&&);
 #if ENABLE(READABLE_STREAM_API)
     void startConsumingStream(unsigned);
     void consumeChunk(Ref<JSC::Uint8Array>&&);
-    void finishConsumingStream(Ref<DeferredWrapper>&&);
+    void finishConsumingStream(Ref<DeferredPromise>&&);
 #endif
 
     void setStatus(int, const String&, ExceptionCode&);
index 535516c11cb34c3cc70c4c72116e69dda3e5b8f5..8f5c98aeaa659b302c8a672ac8307216f72a0bed 100644 (file)
@@ -36,7 +36,7 @@
 
 namespace WebCore {
 
-void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& request, Ref<DeferredWrapper>&& promise)
+void WorkerGlobalScopeFetch::fetch(WorkerGlobalScope& scope, FetchRequest& request, Ref<DeferredPromise>&& promise)
 {
     if (!scope.scriptExecutionContext())
         return;
index 20b262576e7dc090712df3da98308de2a0ecbe0a..5bbb28b8853bf211a7d828e6d80a919d0eaeefb5 100644 (file)
 #if ENABLE(FETCH_API)
 
 #include "JSDOMPromise.h"
-#include <wtf/Forward.h>
 
 namespace WebCore {
 
-class WorkerGlobalScope;
-class DeferredWrapper;
 class FetchRequest;
+class WorkerGlobalScope;
 
 class WorkerGlobalScopeFetch {
 public:
-    static void fetch(WorkerGlobalScope&, FetchRequest&, Ref<DeferredWrapper>&&);
+    static void fetch(WorkerGlobalScope&, FetchRequest&, Ref<DeferredPromise>&&);
 };
 
 } // namespace WebCore
index 501483e6d36334fb9556d46381e31b424b29db99..ad739dc7eccec59c9ecd66ae1d5fbca0bea49c4f 100644 (file)
                416E6FE81BBD12DF000A6053 /* WritableStreamInternalsBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764E9 /* WritableStreamInternalsBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
                416E6FE91BBD12E5000A6043 /* ReadableStreamBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764D8 /* ReadableStreamBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
                416E6FE91BBD12E5000A6053 /* WritableStreamBuiltins.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B03D8061BB3110D00B764E8 /* WritableStreamBuiltins.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4170A2EA1D8C0CCA00318452 /* JSDOMWrapper.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4170A2E91D8C0CC000318452 /* JSDOMWrapper.cpp */; };
                417253AA1354BBBC00360F2A /* MediaControlElements.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 417253A81354BBBC00360F2A /* MediaControlElements.cpp */; };
                417253AB1354BBBC00360F2A /* MediaControlElements.h in Headers */ = {isa = PBXBuildFile; fileRef = 417253A91354BBBC00360F2A /* MediaControlElements.h */; };
                417DA6D913734E6E007C57FB /* Internals.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 417DA4CF13734326007C57FB /* Internals.cpp */; };
                4162A4551011464700DFF3ED /* JSDedicatedWorkerGlobalScope.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDedicatedWorkerGlobalScope.cpp; sourceTree = "<group>"; };
                4162A4561011464700DFF3ED /* JSDedicatedWorkerGlobalScope.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSDedicatedWorkerGlobalScope.h; sourceTree = "<group>"; };
                416E29A5102FA962007FC14E /* WorkerReportingProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkerReportingProxy.h; sourceTree = "<group>"; };
+               4170A2E91D8C0CC000318452 /* JSDOMWrapper.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSDOMWrapper.cpp; sourceTree = "<group>"; };
                417253A81354BBBC00360F2A /* MediaControlElements.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MediaControlElements.cpp; sourceTree = "<group>"; };
                417253A91354BBBC00360F2A /* MediaControlElements.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MediaControlElements.h; sourceTree = "<group>"; };
                417DA4CE13734326007C57FB /* Internals.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Internals.h; sourceTree = "<group>"; };
                                460CBF341D4BCCFE0092E88E /* JSDOMWindowProperties.h */,
                                BCBFB53A0DCD29CF0019B3E5 /* JSDOMWindowShell.cpp */,
                                BCBFB53B0DCD29CF0019B3E5 /* JSDOMWindowShell.h */,
+                               4170A2E91D8C0CC000318452 /* JSDOMWrapper.cpp */,
                                65E0E9431133C89F00B4CB10 /* JSDOMWrapper.h */,
                                F3D461461161D53200CA0D09 /* JSErrorHandler.cpp */,
                                F3D461471161D53200CA0D09 /* JSErrorHandler.h */,
                                314BE3A61B3103FB00141982 /* NamedImageGeneratedImage.cpp in Sources */,
                                BCF34A3711A231CD00C71804 /* NamedNodeMap.cpp in Sources */,
                                A81872240977D3C0005826D9 /* NameNodeList.cpp in Sources */,
+                               4170A2EA1D8C0CCA00318452 /* JSDOMWrapper.cpp in Sources */,
                                8306EFF11B8BCEA50031D032 /* NativeNodeFilter.cpp in Sources */,
                                E10B9B6D0B747599003ED890 /* NativeXPathNSResolver.cpp in Sources */,
                                93CCF0600AF6CA7600018E89 /* NavigationAction.cpp in Sources */,
index c97b93b0065897477064b2275e8833e2acb02111..3cb80b8522eae2bc661d3d32d7f4d19d0d9d429f 100644 (file)
@@ -162,7 +162,7 @@ JSValue JSCustomElementRegistry::define(ExecState& state)
 }
 
 // https://html.spec.whatwg.org/#dom-customelementregistry-whendefined
-static JSValue whenDefinedPromise(ExecState& state, JSDOMGlobalObject& globalObject, CustomElementRegistry& registry)
+static JSValue whenDefinedPromise(ExecState& state, JSDOMGlobalObject& globalObject, CustomElementRegistry& registry, JSPromiseDeferred& promiseDeferred)
 {
     auto scope = DECLARE_THROW_SCOPE(state.vm());
 
@@ -173,17 +173,18 @@ static JSValue whenDefinedPromise(ExecState& state, JSDOMGlobalObject& globalObj
     if (UNLIKELY(scope.exception()))
         return jsUndefined();
 
-    if (!validateCustomElementNameAndThrowIfNeeded(state, localName))
+    if (!validateCustomElementNameAndThrowIfNeeded(state, localName)) {
+        ASSERT(scope.exception());
         return jsUndefined();
+    }
 
     if (registry.findInterface(localName)) {
-        auto& jsPromise = *JSPromiseDeferred::create(&state, &globalObject);
-        DeferredWrapper::create(&state, &globalObject, &jsPromise)->resolve(nullptr);
-        return jsPromise.promise();
+        DeferredPromise::create(globalObject, promiseDeferred)->resolve(nullptr);
+        return promiseDeferred.promise();
     }
 
     auto result = registry.promiseMap().ensure(localName, [&] {
-        return DeferredWrapper::create(&state, &globalObject, JSPromiseDeferred::create(&state, &globalObject));
+        return DeferredPromise::create(globalObject, promiseDeferred);
     });
 
     return result.iterator->value->promise();
@@ -193,14 +194,15 @@ JSValue JSCustomElementRegistry::whenDefined(ExecState& state)
 {
     auto scope = DECLARE_CATCH_SCOPE(state.vm());
 
-    JSDOMGlobalObject& globalObject = *jsCast<JSDOMGlobalObject*>(state.lexicalGlobalObject());
-    auto& promiseDeferred = *JSPromiseDeferred::create(&state, &globalObject);
-    JSValue promise = whenDefinedPromise(state, globalObject, wrapped());
+    ASSERT(globalObject());
+    auto promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
+    ASSERT(promiseDeferred);
+    JSValue promise = whenDefinedPromise(state, *globalObject(), wrapped(), *promiseDeferred);
 
     if (UNLIKELY(scope.exception())) {
-        rejectPromiseWithExceptionIfAny(state, globalObject, promiseDeferred);
+        rejectPromiseWithExceptionIfAny(state, *globalObject(), *promiseDeferred);
         ASSERT(!scope.exception());
-        return promiseDeferred.promise();
+        return promiseDeferred->promise();
     }
 
     return promise;
index 35f895c80c75b79a096529f6c5dc191a260e56ad..e870aeb67f51d8c16482e1132ffe7cc8fca30bea 100644 (file)
@@ -178,8 +178,8 @@ void JSDOMGlobalObject::visitChildren(JSCell* cell, SlotVisitor& visitor)
     for (auto& constructor : thisObject->constructors().values())
         visitor.append(&constructor);
 
-    for (auto& deferredWrapper : thisObject->deferredWrappers())
-        deferredWrapper->visitAggregate(visitor);
+    for (auto& deferredPromise : thisObject->deferredPromises())
+        deferredPromise->visitAggregate(visitor);
 
     thisObject->m_builtinInternalFunctions.visit(visitor);
 }
index c672e4b92d2253785948b5da216afeab47bbb57c..d40c43f63d57e7e5970c7e62efa856ae64e32f29 100644 (file)
@@ -34,7 +34,7 @@
 
 namespace WebCore {
 
-    class DeferredWrapper;
+    class DeferredPromise;
     class Document;
     class Event;
     class DOMWrapperWorld;
@@ -42,7 +42,7 @@ namespace WebCore {
 
     typedef HashMap<const JSC::ClassInfo*, JSC::WriteBarrier<JSC::Structure>> JSDOMStructureMap;
     typedef HashMap<const JSC::ClassInfo*, JSC::WriteBarrier<JSC::JSObject>> JSDOMConstructorMap;
-    typedef HashSet<DeferredWrapper*> DeferredWrapperSet;
+    typedef HashSet<DeferredPromise*> DeferredPromiseSet;
 
     class WEBCORE_EXPORT JSDOMGlobalObject : public JSC::JSGlobalObject {
         typedef JSC::JSGlobalObject Base;
@@ -58,7 +58,7 @@ namespace WebCore {
         JSDOMStructureMap& structures() { return m_structures; }
         JSDOMConstructorMap& constructors() { return m_constructors; }
 
-        DeferredWrapperSet& deferredWrappers() { return m_deferredWrappers; }
+        DeferredPromiseSet& deferredPromises() { return m_deferredPromises; }
 
         ScriptExecutionContext* scriptExecutionContext() const;
 
@@ -91,7 +91,7 @@ namespace WebCore {
     protected:
         JSDOMStructureMap m_structures;
         JSDOMConstructorMap m_constructors;
-        DeferredWrapperSet m_deferredWrappers;
+        DeferredPromiseSet m_deferredPromises;
 
         Event* m_currentEvent;
         Ref<DOMWrapperWorld> m_world;
index bea7ee005b35e8a2539a646d48f5a3dd828425c0..afe920d8d954677e2d561cecdc903d21d8fcb39d 100644 (file)
@@ -28,6 +28,7 @@
 
 #include "ExceptionCode.h"
 #include "JSDOMError.h"
+#include "JSDOMWindow.h"
 #include <builtins/BuiltinNames.h>
 #include <runtime/Exception.h>
 #include <runtime/JSONObject.h>
@@ -37,41 +38,41 @@ using namespace JSC;
 
 namespace WebCore {
 
-DeferredWrapper::DeferredWrapper(ExecState*, JSDOMGlobalObject* globalObject, JSPromiseDeferred* promiseDeferred)
-    : ActiveDOMCallback(globalObject->scriptExecutionContext())
-    , m_deferred(promiseDeferred)
-    , m_globalObject(globalObject)
+DeferredPromise::DeferredPromise(JSDOMGlobalObject& globalObject, JSPromiseDeferred& promiseDeferred)
+    : ActiveDOMCallback(globalObject.scriptExecutionContext())
+    , m_deferred(&promiseDeferred)
+    , m_globalObject(&globalObject)
 {
-    globalObject->vm().heap.writeBarrier(globalObject, promiseDeferred);
-    m_globalObject->deferredWrappers().add(this);
+    globalObject.vm().heap.writeBarrier(&globalObject, &promiseDeferred);
+    globalObject.deferredPromises().add(this);
 }
 
-DeferredWrapper::~DeferredWrapper()
+DeferredPromise::~DeferredPromise()
 {
     clear();
 }
 
-void DeferredWrapper::clear()
+void DeferredPromise::clear()
 {
     ASSERT(!m_deferred || m_globalObject);
     if (m_deferred && m_globalObject)
-        m_globalObject->deferredWrappers().remove(this);
+        m_globalObject->deferredPromises().remove(this);
     m_deferred.clear();
 }
 
-void DeferredWrapper::contextDestroyed()
+void DeferredPromise::contextDestroyed()
 {
     ActiveDOMCallback::contextDestroyed();
     clear();
 }
 
-JSC::JSValue DeferredWrapper::promise() const
+JSC::JSValue DeferredPromise::promise() const
 {
     ASSERT(m_deferred);
     return m_deferred->promise();
 }
 
-void DeferredWrapper::callFunction(ExecState& exec, JSValue function, JSValue resolution)
+void DeferredPromise::callFunction(ExecState& exec, JSValue function, JSValue resolution)
 {
     if (!canInvokeCallback())
         return;
@@ -88,7 +89,7 @@ void DeferredWrapper::callFunction(ExecState& exec, JSValue function, JSValue re
     clear();
 }
 
-void DeferredWrapper::reject(ExceptionCode ec, const String& message)
+void DeferredPromise::reject(ExceptionCode ec, const String& message)
 {
     if (isSuspended())
         return;
@@ -111,7 +112,15 @@ void rejectPromiseWithExceptionIfAny(JSC::ExecState& state, JSDOMGlobalObject& g
     JSValue error = scope.exception()->value();
     scope.clearException();
 
-    DeferredWrapper::create(&state, &globalObject, &promiseDeferred)->reject(error);
+    DeferredPromise::create(globalObject, promiseDeferred)->reject(error);
+}
+
+Ref<DeferredPromise> createDeferredPromise(JSC::ExecState& state, JSDOMWindow& domWindow)
+{
+    JSC::JSPromiseDeferred* deferred = JSC::JSPromiseDeferred::create(&state, &domWindow);
+    // deferred can only be null in workers.
+    ASSERT(deferred);
+    return DeferredPromise::create(domWindow, *deferred);
 }
 
 JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::ExecState& state, const String& errorMessage)
@@ -139,7 +148,7 @@ static inline JSC::JSValue parseAsJSON(JSC::ExecState* state, const String& data
     return JSC::JSONParse(state, data);
 }
 
-void fulfillPromiseWithJSON(Ref<DeferredWrapper>&& promise, const String& data)
+void fulfillPromiseWithJSON(Ref<DeferredPromise>&& promise, const String& data)
 {
     JSC::JSValue value = parseAsJSON(promise->globalObject()->globalExec(), data);
     if (!value)
@@ -148,7 +157,7 @@ void fulfillPromiseWithJSON(Ref<DeferredWrapper>&& promise, const String& data)
         promise->resolve(value);
 }
 
-void fulfillPromiseWithArrayBuffer(Ref<DeferredWrapper>&& promise, ArrayBuffer* arrayBuffer)
+void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&& promise, ArrayBuffer* arrayBuffer)
 {
     if (!arrayBuffer) {
         promise->reject<JSValue>(createOutOfMemoryError(promise->globalObject()->globalExec()));
@@ -157,7 +166,7 @@ void fulfillPromiseWithArrayBuffer(Ref<DeferredWrapper>&& promise, ArrayBuffer*
     promise->resolve(arrayBuffer);
 }
 
-void fulfillPromiseWithArrayBuffer(Ref<DeferredWrapper>&& promise, const void* data, size_t length)
+void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&& promise, const void* data, size_t length)
 {
     fulfillPromiseWithArrayBuffer(WTFMove(promise), ArrayBuffer::tryCreate(data, length).get());
 }
index 4d49ed9834fbc582adc792776edc7e0dadf2cf35..f587cb3a1909da1120fadeaca5672fa625b9c9b6 100644 (file)
@@ -96,15 +96,14 @@ struct PromiseResultInspector<DOMClass, typename std::enable_if<TypeInspector<DO
     static constexpr bool passByConstRef = false;
 };
 
-class DeferredWrapper : public RefCounted<DeferredWrapper>, public ActiveDOMCallback {
+class DeferredPromise : public RefCounted<DeferredPromise>, public ActiveDOMCallback {
 public:
-    // FIXME: We should pass references here, not pointers, see bug 161787
-    static Ref<DeferredWrapper> create(JSC::ExecState* state, JSDOMGlobalObject* globalObject, JSC::JSPromiseDeferred* deferred)
+    static Ref<DeferredPromise> create(JSDOMGlobalObject& globalObject, JSC::JSPromiseDeferred& deferred)
     {
-        return adoptRef(*new DeferredWrapper(state, globalObject, deferred));
+        return adoptRef(*new DeferredPromise(globalObject, deferred));
     }
 
-    ~DeferredWrapper();
+    ~DeferredPromise();
 
     template<class ResolveResultType> typename std::enable_if<PromiseResultInspector<ResolveResultType>::passByValue, void>::type
     resolve(ResolveResultType result) { resolveWithValue(result); }
@@ -136,7 +135,7 @@ public:
     void visitAggregate(JSC::SlotVisitor& visitor) { visitor.appendUnbarrieredWeak(&m_deferred); }
 
 private:
-    DeferredWrapper(JSC::ExecState*, JSDOMGlobalObject*, JSC::JSPromiseDeferred*);
+    DeferredPromise(JSDOMGlobalObject&, JSC::JSPromiseDeferred&);
 
     void clear();
     void contextDestroyed() override;
@@ -152,13 +151,15 @@ private:
     JSC::Weak<JSDOMGlobalObject> m_globalObject;
 };
 
-void fulfillPromiseWithJSON(Ref<DeferredWrapper>&&, const String&);
-void fulfillPromiseWithArrayBuffer(Ref<DeferredWrapper>&&, ArrayBuffer*);
-void fulfillPromiseWithArrayBuffer(Ref<DeferredWrapper>&&, const void*, size_t);
+Ref<DeferredPromise> createDeferredPromise(JSC::ExecState&, JSDOMWindow&);
+
+void fulfillPromiseWithJSON(Ref<DeferredPromise>&&, const String&);
+void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&&, ArrayBuffer*);
+void fulfillPromiseWithArrayBuffer(Ref<DeferredPromise>&&, const void*, size_t);
 void rejectPromiseWithExceptionIfAny(JSC::ExecState&, JSDOMGlobalObject&, JSC::JSPromiseDeferred&);
 JSC::EncodedJSValue createRejectedPromiseWithTypeError(JSC::ExecState&, const String&);
 
-using PromiseFunction = void(JSC::ExecState&, Ref<DeferredWrapper>&&);
+using PromiseFunction = void(JSC::ExecState&, Ref<DeferredPromise>&&);
 
 enum class PromiseExecutionScope { WindowOnly, WindowOrWorker };
 
@@ -175,16 +176,16 @@ inline JSC::JSValue callPromiseFunction(JSC::ExecState& state)
     if (executionScope == PromiseExecutionScope::WindowOrWorker && !promiseDeferred)
         return JSC::jsUndefined();
 
-    promiseFunction(state, DeferredWrapper::create(&state, &globalObject, promiseDeferred));
+    promiseFunction(state, DeferredPromise::create(globalObject, *promiseDeferred));
 
     rejectPromiseWithExceptionIfAny(state, globalObject, *promiseDeferred);
     ASSERT_UNUSED(scope, !scope.exception());
     return promiseDeferred->promise();
 }
 
-using BindingPromiseFunction = JSC::EncodedJSValue(JSC::ExecState*, Ref<DeferredWrapper>&&);
+using BindingPromiseFunction = JSC::EncodedJSValue(JSC::ExecState*, Ref<DeferredPromise>&&);
 template<BindingPromiseFunction bindingFunction>
-inline void bindingPromiseFunctionAdapter(JSC::ExecState& state, Ref<DeferredWrapper>&& promise)
+inline void bindingPromiseFunctionAdapter(JSC::ExecState& state, Ref<DeferredPromise>&& promise)
 {
     bindingFunction(&state, WTFMove(promise));
 }
@@ -199,28 +200,25 @@ inline JSC::JSValue callPromiseFunction(JSC::ExecState& state)
 template <typename Value>
 class DOMPromise {
 public:
-    DOMPromise(Ref<DeferredWrapper>&& wrapper)
-        : m_wrapper(WTFMove(wrapper))
-    {
-    }
+    DOMPromise(Ref<DeferredPromise>&& genericPromise) : m_promiseDeferred(WTFMove(genericPromise)) { }
 
-    DOMPromise(DOMPromise&& promise) : m_wrapper(WTFMove(promise.m_wrapper)) { }
+    DOMPromise(DOMPromise&& promise) : m_promiseDeferred(WTFMove(promise.m_promiseDeferred)) { }
 
     DOMPromise(const DOMPromise&) = default;
     DOMPromise& operator=(DOMPromise const&) = default;
 
-    void resolve(typename PromiseResultInspector<Value>::Type value) { m_wrapper->resolve(value); }
+    void resolve(typename PromiseResultInspector<Value>::Type value) { m_promiseDeferred->resolve(value); }
 
-    template<typename... ErrorType> void reject(ErrorType&&... error) { m_wrapper->reject(std::forward<ErrorType>(error)...); }
+    template<typename... ErrorType> void reject(ErrorType&&... error) { m_promiseDeferred->reject(std::forward<ErrorType>(error)...); }
 
-    DeferredWrapper& deferredWrapper() { return m_wrapper; }
+    JSC::JSValue promise() const { return m_promiseDeferred->promise(); };
 
 private:
-    Ref<DeferredWrapper> m_wrapper;
+    Ref<DeferredPromise> m_promiseDeferred;
 };
 
 template<class ResolveResultType>
-inline void DeferredWrapper::resolveWithValue(ResolveResultType&& result)
+inline void DeferredPromise::resolveWithValue(ResolveResultType&& result)
 {
     if (isSuspended())
         return;
@@ -231,7 +229,7 @@ inline void DeferredWrapper::resolveWithValue(ResolveResultType&& result)
 }
 
 template<class ResolveResultType>
-inline void DeferredWrapper::resolveWithNewlyCreated(Ref<ResolveResultType>&& result)
+inline void DeferredPromise::resolveWithNewlyCreated(Ref<ResolveResultType>&& result)
 {
     if (isSuspended())
         return;
@@ -243,7 +241,7 @@ inline void DeferredWrapper::resolveWithNewlyCreated(Ref<ResolveResultType>&& re
 }
 
 template<class RejectResultType>
-inline void DeferredWrapper::rejectWithValue(RejectResultType&& result)
+inline void DeferredPromise::rejectWithValue(RejectResultType&& result)
 {
     if (isSuspended())
         return;
@@ -255,7 +253,7 @@ inline void DeferredWrapper::rejectWithValue(RejectResultType&& result)
 }
 
 template<>
-inline void DeferredWrapper::resolve(bool result)
+inline void DeferredPromise::resolve(bool result)
 {
     if (isSuspended())
         return;
@@ -267,7 +265,7 @@ inline void DeferredWrapper::resolve(bool result)
 }
 
 template<>
-inline void DeferredWrapper::resolve(JSC::JSValue value)
+inline void DeferredPromise::resolve(JSC::JSValue value)
 {
     if (isSuspended())
         return;
@@ -279,7 +277,7 @@ inline void DeferredWrapper::resolve(JSC::JSValue value)
 }
 
 template<>
-inline void DeferredWrapper::reject(JSC::JSValue value)
+inline void DeferredPromise::reject(JSC::JSValue value)
 {
     if (isSuspended())
         return;
@@ -291,7 +289,7 @@ inline void DeferredWrapper::reject(JSC::JSValue value)
 }
 
 template<>
-inline void DeferredWrapper::resolve(std::nullptr_t)
+inline void DeferredPromise::resolve(std::nullptr_t)
 {
     if (isSuspended())
         return;
@@ -303,7 +301,7 @@ inline void DeferredWrapper::resolve(std::nullptr_t)
 }
 
 template<>
-inline void DeferredWrapper::reject(std::nullptr_t)
+inline void DeferredPromise::reject(std::nullptr_t)
 {
     if (isSuspended())
         return;
@@ -315,7 +313,7 @@ inline void DeferredWrapper::reject(std::nullptr_t)
 }
 
 template<>
-inline void DeferredWrapper::resolve(const String& result)
+inline void DeferredPromise::resolve(const String& result)
 {
     if (isSuspended())
         return;
@@ -327,7 +325,7 @@ inline void DeferredWrapper::resolve(const String& result)
 }
 
 template<>
-inline void DeferredWrapper::reject(const String& result)
+inline void DeferredPromise::reject(const String& result)
 {
     if (isSuspended())
         return;
index 45ac21d940e8848aa026b9299da2a1f6df56d8fc..325e72be877bffe2df4a939a16b1f6678b97040e 100644 (file)
@@ -27,6 +27,7 @@
 #include "JSDOMWrapper.h"
 
 #include "DOMWrapperWorld.h"
+#include "JSDOMWindow.h"
 #include <runtime/Error.h>
 
 using namespace JSC;
@@ -35,4 +36,11 @@ namespace WebCore {
 
 STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(JSDOMObject);
 
+JSDOMWindow& JSDOMObject::domWindow() const
+{
+    auto* domWindow = JSC::jsCast<JSDOMWindow*>(JSC::JSNonFinalObject::globalObject());
+    ASSERT(domWindow);
+    return *domWindow;
+}
+
 } // namespace WebCore
index 22a2a2c2c01c94258e8e635f9a0bf977d91e26b8..cd50aef801b85929d67386ae626c7cae5872f4a4 100644 (file)
@@ -27,6 +27,7 @@
 
 namespace WebCore {
 
+class JSDOMWindow;
 class ScriptExecutionContext;
 
 static const uint8_t JSNodeType = JSC::LastJSCObjectType + 1;
@@ -41,8 +42,10 @@ public:
     JSDOMGlobalObject* globalObject() const { return JSC::jsCast<JSDOMGlobalObject*>(JSC::JSNonFinalObject::globalObject()); }
     ScriptExecutionContext* scriptExecutionContext() const { return globalObject()->scriptExecutionContext(); }
 
+    JSDOMWindow& domWindow() const;
+
 protected:
-    JSDOMObject(JSC::Structure* structure, JSC::JSGlobalObject& globalObject) 
+    JSDOMObject(JSC::Structure* structure, JSC::JSGlobalObject& globalObject)
         : Base(globalObject.vm(), structure)
     {
         ASSERT(scriptExecutionContext());
index b741e5366b7f976e832482bc4cf20086f6826b8c..29bdef2b58fe9692c85001acfcbe19a8eab847e7 100644 (file)
@@ -39,11 +39,11 @@ JSC::JSValue JSFontFace::loaded(JSC::ExecState& state) const
 {
     if (!m_loaded) {
         if (!wrapped().promise()) {
-            Ref<DeferredWrapper> promise = DeferredWrapper::create(&state, globalObject(), JSC::JSPromiseDeferred::create(&state, globalObject()));
+            auto promise = createDeferredPromise(state, domWindow());
             m_loaded.set(state.vm(), this, promise->promise());
             wrapped().registerLoaded(WTFMove(promise));
         } else
-            m_loaded.set(state.vm(), this, wrapped().promise().value().deferredWrapper().promise());
+            m_loaded.set(state.vm(), this, wrapped().promise().value().promise());
     }
     return m_loaded.get();
 }
index 2870b486d24c286d923eeecf4ea65fe62cc8091a..22560d44fed9e49f616574f1d726a04f989836c9 100644 (file)
@@ -34,7 +34,7 @@ namespace WebCore {
 JSC::JSValue JSFontFaceSet::ready(JSC::ExecState& state) const
 {
     if (!m_ready) {
-        Ref<DeferredWrapper> promise = DeferredWrapper::create(&state, globalObject(), JSC::JSPromiseDeferred::create(&state, globalObject()));
+        auto promise = createDeferredPromise(state, domWindow());
         m_ready.set(state.vm(), this, promise->promise());
         wrapped().registerReady(WTFMove(promise));
     }
index c31e94e3e3e85cbc4d8755166ac2ddb889b84be7..ed523ab3a3b9333be49e7eb3a8bd939b41a1a16f 100644 (file)
@@ -340,7 +340,7 @@ void parseMediaConstraintsDictionary(const Dictionary& mediaTrackConstraints, Me
     }
 }
 
-static void JSMediaDevicesGetUserMediaPromiseFunction(ExecState& state, Ref<DeferredWrapper>&& promise)
+static void JSMediaDevicesGetUserMediaPromiseFunction(ExecState& state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state.vm();
     auto scope = DECLARE_THROW_SCOPE(vm);
index fdf66a7d0c38013402a5d2a0aebf7eb1fa295a26..b22b2822736dd3a9fcfa79a06342fc7d0cc8d09a 100644 (file)
@@ -184,11 +184,13 @@ JSValue JSMediaStreamTrack::applyConstraints(ExecState& state)
         valid = !advancedConstraints.isEmpty() || !mandatoryConstraints.isEmpty();
     }
 
-    JSC::JSPromiseDeferred* promiseDeferred = JSC::JSPromiseDeferred::create(&state, globalObject());
+    auto deferredPromise = createDeferredPromise(state, domWindow());
+    auto promise = deferredPromise->promise();
+
     auto constraints = MediaConstraintsImpl::create(WTFMove(mandatoryConstraints), WTFMove(advancedConstraints), valid);
-    wrapped().applyConstraints(WTFMove(constraints), DeferredWrapper::create(&state, globalObject(), promiseDeferred));
+    wrapped().applyConstraints(WTFMove(constraints), WTFMove(deferredPromise));
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 JSValue JSMediaStreamTrack::getConstraints(ExecState& state)
index 39a73f53748d10267012989605c7d532b8b10852..7751410a1b5395f55b8617d6d4991ecffb5e909a 100644 (file)
@@ -43,8 +43,11 @@ JSValue JSReadableStreamSource::start(ExecState& state)
     JSReadableStreamSource* jsSource = const_cast<JSReadableStreamSource*>(this);
     m_controller.set(state.vm(), jsSource, state.argument(0));
 
+    ASSERT(globalObject());
     JSC::JSPromiseDeferred* promiseDeferred = JSC::JSPromiseDeferred::create(&state, globalObject());
-    wrapped().start(ReadableStreamDefaultController(controller), DeferredWrapper::create(&state, globalObject(), promiseDeferred));
+    if (!promiseDeferred)
+        return jsUndefined();
+    wrapped().start(ReadableStreamDefaultController(controller), DeferredPromise::create(*globalObject(), *promiseDeferred));
     return promiseDeferred->promise();
 }
 
index ca9e14b8b6646dd64a84a9293e6f9b89e93fb8c4..5859b79e3f5d0e3b0ff4095bd5c8bbc9b9026ca2 100644 (file)
@@ -173,9 +173,8 @@ JSValue JSWebKitSubtleCrypto::encrypt(ExecState& state)
     if (!success)
         return jsUndefined();
 
-    
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
@@ -190,7 +189,7 @@ JSValue JSWebKitSubtleCrypto::encrypt(ExecState& state)
         return jsUndefined();
     }
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 JSValue JSWebKitSubtleCrypto::decrypt(ExecState& state)
@@ -227,8 +226,8 @@ JSValue JSWebKitSubtleCrypto::decrypt(ExecState& state)
     if (!success)
         return jsUndefined();
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
@@ -243,7 +242,7 @@ JSValue JSWebKitSubtleCrypto::decrypt(ExecState& state)
         return jsUndefined();
     }
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 JSValue JSWebKitSubtleCrypto::sign(ExecState& state)
@@ -280,8 +279,8 @@ JSValue JSWebKitSubtleCrypto::sign(ExecState& state)
     if (!success)
         return jsUndefined();
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
@@ -296,7 +295,7 @@ JSValue JSWebKitSubtleCrypto::sign(ExecState& state)
         return jsUndefined();
     }
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 JSValue JSWebKitSubtleCrypto::verify(ExecState& state)
@@ -339,8 +338,8 @@ JSValue JSWebKitSubtleCrypto::verify(ExecState& state)
     if (!success)
         return jsUndefined();
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     auto successCallback = [wrapper](bool result) mutable {
         wrapper->resolve(result);
     };
@@ -355,7 +354,7 @@ JSValue JSWebKitSubtleCrypto::verify(ExecState& state)
         return jsUndefined();
     }
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 JSValue JSWebKitSubtleCrypto::digest(ExecState& state)
@@ -382,8 +381,8 @@ JSValue JSWebKitSubtleCrypto::digest(ExecState& state)
     if (!success)
         return jsUndefined();
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
@@ -398,7 +397,7 @@ JSValue JSWebKitSubtleCrypto::digest(ExecState& state)
         return jsUndefined();
     }
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 JSValue JSWebKitSubtleCrypto::generateKey(ExecState& state)
@@ -434,8 +433,8 @@ JSValue JSWebKitSubtleCrypto::generateKey(ExecState& state)
             return jsUndefined();
     }
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     auto successCallback = [wrapper](CryptoKey* key, CryptoKeyPair* keyPair) mutable {
         ASSERT(key || keyPair);
         ASSERT(!key || !keyPair);
@@ -455,7 +454,7 @@ JSValue JSWebKitSubtleCrypto::generateKey(ExecState& state)
         return jsUndefined();
     }
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 static void importKey(ExecState& state, CryptoKeyFormat keyFormat, CryptoOperationData data, RefPtr<CryptoAlgorithm> algorithm, RefPtr<CryptoAlgorithmParameters> parameters, bool extractable, CryptoKeyUsage keyUsages, CryptoAlgorithm::KeyCallback callback, CryptoAlgorithm::VoidCallback failureCallback)
@@ -570,8 +569,8 @@ JSValue JSWebKitSubtleCrypto::importKey(ExecState& state)
             return jsUndefined();
     }
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     auto successCallback = [wrapper](CryptoKey& result) mutable {
         wrapper->resolve(result);
     };
@@ -583,7 +582,7 @@ JSValue JSWebKitSubtleCrypto::importKey(ExecState& state)
     if (UNLIKELY(scope.exception()))
         return jsUndefined();
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 static void exportKey(ExecState& state, CryptoKeyFormat keyFormat, const CryptoKey& key, CryptoAlgorithm::VectorCallback callback, CryptoAlgorithm::VoidCallback failureCallback)
@@ -639,8 +638,8 @@ JSValue JSWebKitSubtleCrypto::exportKey(ExecState& state)
     if (!key)
         return throwTypeError(&state, scope);
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     auto successCallback = [wrapper](const Vector<uint8_t>& result) mutable {
         fulfillPromiseWithArrayBuffer(wrapper.releaseNonNull(), result.data(), result.size());
     };
@@ -652,7 +651,7 @@ JSValue JSWebKitSubtleCrypto::exportKey(ExecState& state)
     if (UNLIKELY(scope.exception()))
         return jsUndefined();
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 JSValue JSWebKitSubtleCrypto::wrapKey(ExecState& state)
@@ -693,8 +692,8 @@ JSValue JSWebKitSubtleCrypto::wrapKey(ExecState& state)
     if (!parameters)
         return jsUndefined();
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
 
     auto exportSuccessCallback = [keyFormat, algorithm, parameters, wrappingKey, wrapper](const Vector<uint8_t>& exportedKeyData) mutable {
         auto encryptSuccessCallback = [wrapper](const Vector<uint8_t>& encryptedData) mutable {
@@ -722,7 +721,7 @@ JSValue JSWebKitSubtleCrypto::wrapKey(ExecState& state)
         return jsUndefined();
     }
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 JSValue JSWebKitSubtleCrypto::unwrapKey(ExecState& state)
@@ -793,8 +792,8 @@ JSValue JSWebKitSubtleCrypto::unwrapKey(ExecState& state)
             return jsUndefined();
     }
 
-    JSPromiseDeferred* promiseDeferred = JSPromiseDeferred::create(&state, globalObject());
-    RefPtr<DeferredWrapper> wrapper = DeferredWrapper::create(&state, globalObject(), promiseDeferred);
+    RefPtr<DeferredPromise> wrapper = createDeferredPromise(state, domWindow());
+    auto promise = wrapper->promise();
     Strong<JSDOMGlobalObject> domGlobalObject(state.vm(), globalObject());
 
     auto decryptSuccessCallback = [domGlobalObject, keyFormat, unwrappedKeyAlgorithm, unwrappedKeyAlgorithmParameters, extractable, keyUsages, wrapper](const Vector<uint8_t>& result) mutable {
@@ -828,7 +827,7 @@ JSValue JSWebKitSubtleCrypto::unwrapKey(ExecState& state)
         return jsUndefined();
     }
 
-    return promiseDeferred->promise();
+    return promise;
 }
 
 } // namespace WebCore
index d9ce0548d979c6d9a03bba2f66d4257430af8cde..afb9030252ba76daacabb0be7640ea3b765df9f0 100644 (file)
@@ -3425,7 +3425,7 @@ sub GenerateImplementation
 
                 my $scope = $interface->extendedAttributes->{"Exposed"} ? "WindowOrWorker" : "WindowOnly";
                 push(@implContent, <<END);
-static EncodedJSValue ${functionName}Promise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue ${functionName}Promise(ExecState*, Ref<DeferredPromise>&&);
 
 ${functionReturn} ${functionName}(ExecState* state)
 {
@@ -3433,7 +3433,7 @@ ${functionReturn} ${functionName}(ExecState* state)
     return JSValue::encode(callPromiseFunction<${functionName}Promise, PromiseExecutionScope::${scope}>(*state));
 }
 
-static inline EncodedJSValue ${functionName}Promise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue ${functionName}Promise(ExecState* state, Ref<DeferredPromise>&& promise)
 END
             }
             else {
@@ -4146,7 +4146,7 @@ sub GenerateReturnParameters
     my @arguments;
 
     if (IsReturningPromise($function)) {
-        push(@arguments, "WTFMove(deferredWrapper)");
+        push(@arguments, "WTFMove(promise)");
     }
     push(@arguments, "ec") if $function->signature->extendedAttributes->{"RaisesException"} || $function->signature->extendedAttributes->{"RaisesExceptionWithMessage"};
     return @arguments;
index cd77115f943201fdc7508a35f739ef49fdd0a72b..550437aa7322eeaf5468b7ff4eb6f80a5e8464b2 100644 (file)
@@ -231,7 +231,7 @@ JSValue JSTestNode::getConstructor(VM& vm, const JSGlobalObject* globalObject)
     return getDOMConstructor<JSTestNodeConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
 }
 
-static EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromisePromise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromisePromise(ExecState*, Ref<DeferredPromise>&&);
 
 EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(ExecState* state)
 {
@@ -239,7 +239,7 @@ EncodedJSValue JSC_HOST_CALL jsTestNodePrototypeFunctionTestWorkerPromise(ExecSt
     return JSValue::encode(callPromiseFunction<jsTestNodePrototypeFunctionTestWorkerPromisePromise, PromiseExecutionScope::WindowOrWorker>(*state));
 }
 
-static inline EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromisePromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromisePromise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -250,7 +250,7 @@ static inline EncodedJSValue jsTestNodePrototypeFunctionTestWorkerPromisePromise
         return throwThisTypeError(*state, throwScope, "TestNode", "testWorkerPromise");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestNode::info());
     auto& impl = castedThis->wrapped();
-    impl.testWorkerPromise(WTFMove(deferredWrapper));
+    impl.testWorkerPromise(WTFMove(promise));
     return JSValue::encode(jsUndefined());
 }
 
index eda82baadc3c55a4e7981f6acd789c8a202f9b4e..30db87c0f901755a59c30e2b43a8bf773ba0bded 100644 (file)
@@ -7160,7 +7160,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionAny(ExecState* state)
     return JSValue::encode(jsUndefined());
 }
 
-static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionPromise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionPromise(ExecState*, Ref<DeferredPromise>&&);
 
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunction(ExecState* state)
 {
@@ -7168,7 +7168,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunction(ExecS
     return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseFunctionPromise, PromiseExecutionScope::WindowOnly>(*state));
 }
 
-static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionPromise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -7179,11 +7179,11 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionPromis
         return throwThisTypeError(*state, throwScope, "TestObject", "testPromiseFunction");
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->wrapped();
-    impl.testPromiseFunction(WTFMove(deferredWrapper));
+    impl.testPromiseFunction(WTFMove(promise));
     return JSValue::encode(jsUndefined());
 }
 
-static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise(ExecState*, Ref<DeferredPromise>&&);
 
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgument(ExecState* state)
 {
@@ -7191,7 +7191,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithFl
     return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise, PromiseExecutionScope::WindowOnly>(*state));
 }
 
-static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithFloatArgumentPromise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -7207,11 +7207,11 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithFl
     auto a = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::No);
     if (UNLIKELY(throwScope.exception()))
         return JSValue::encode(jsUndefined());
-    impl.testPromiseFunctionWithFloatArgument(WTFMove(a), WTFMove(deferredWrapper));
+    impl.testPromiseFunctionWithFloatArgument(WTFMove(a), WTFMove(promise));
     return JSValue::encode(jsUndefined());
 }
 
-static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise(ExecState*, Ref<DeferredPromise>&&);
 
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithException(ExecState* state)
 {
@@ -7219,7 +7219,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithEx
     return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise, PromiseExecutionScope::WindowOnly>(*state));
 }
 
-static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithExceptionPromise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -7231,12 +7231,12 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithEx
     ASSERT_GC_OBJECT_INHERITS(castedThis, JSTestObj::info());
     auto& impl = castedThis->wrapped();
     ExceptionCode ec = 0;
-    impl.testPromiseFunctionWithException(WTFMove(deferredWrapper), ec);
+    impl.testPromiseFunctionWithException(WTFMove(promise), ec);
     setDOMException(state, ec);
     return JSValue::encode(jsUndefined());
 }
 
-static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise(ExecState*, Ref<DeferredPromise>&&);
 
 EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgument(ExecState* state)
 {
@@ -7244,7 +7244,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseFunctionWithOp
     return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise, PromiseExecutionScope::WindowOnly>(*state));
 }
 
-static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithOptionalIntArgumentPromise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -7258,11 +7258,11 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseFunctionWithOp
     auto a = state->argument(0).isUndefined() ? Optional<int32_t>() : convert<int32_t>(*state, state->uncheckedArgument(0), NormalConversion);
     if (UNLIKELY(throwScope.exception()))
         return JSValue::encode(jsUndefined());
-    impl.testPromiseFunctionWithOptionalIntArgument(WTFMove(a), WTFMove(deferredWrapper));
+    impl.testPromiseFunctionWithOptionalIntArgument(WTFMove(a), WTFMove(promise));
     return JSValue::encode(jsUndefined());
 }
 
-static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise(ExecState*, Ref<DeferredPromise>&&);
 
 static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1(ExecState* state)
 {
@@ -7270,7 +7270,7 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunc
     return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise, PromiseExecutionScope::WindowOnly>(*state));
 }
 
-static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction1Promise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -7286,11 +7286,11 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunc
     auto a = convert<float>(*state, state->argument(0), ShouldAllowNonFinite::No);
     if (UNLIKELY(throwScope.exception()))
         return JSValue::encode(jsUndefined());
-    impl.testPromiseOverloadedFunction(WTFMove(a), WTFMove(deferredWrapper));
+    impl.testPromiseOverloadedFunction(WTFMove(a), WTFMove(promise));
     return JSValue::encode(jsUndefined());
 }
 
-static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise(ExecState*, Ref<DeferredPromise>&&);
 
 static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2(ExecState* state)
 {
@@ -7298,7 +7298,7 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunc
     return JSValue::encode(callPromiseFunction<jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise, PromiseExecutionScope::WindowOnly>(*state));
 }
 
-static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunction2Promise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
@@ -7314,7 +7314,7 @@ static inline EncodedJSValue jsTestObjPrototypeFunctionTestPromiseOverloadedFunc
     auto request = JSFetchRequest::toWrapped(state->argument(0));
     if (UNLIKELY(!request))
         return throwArgumentTypeError(*state, throwScope, 0, "request", "TestObject", "testPromiseOverloadedFunction", "FetchRequest");
-    impl.testPromiseOverloadedFunction(*request, WTFMove(deferredWrapper));
+    impl.testPromiseOverloadedFunction(*request, WTFMove(promise));
     return JSValue::encode(jsUndefined());
 }
 
@@ -7335,7 +7335,7 @@ EncodedJSValue JSC_HOST_CALL jsTestObjPrototypeFunctionTestPromiseOverloadedFunc
     return argsCount < 1 ? throwVMError(state, throwScope, createNotEnoughArgumentsError(state)) : throwVMTypeError(state, throwScope);
 }
 
-static EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise(ExecState*, Ref<DeferredPromise>&&);
 
 EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunction(ExecState* state)
 {
@@ -7343,16 +7343,16 @@ EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFuncti
     return JSValue::encode(callPromiseFunction<jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise, PromiseExecutionScope::WindowOnly>(*state));
 }
 
-static inline EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionPromise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
     UNUSED_PARAM(throwScope);
-    TestObj::testStaticPromiseFunction(WTFMove(deferredWrapper));
+    TestObj::testStaticPromiseFunction(WTFMove(promise));
     return JSValue::encode(jsUndefined());
 }
 
-static EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise(ExecState*, Ref<DeferredWrapper>&&);
+static EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise(ExecState*, Ref<DeferredPromise>&&);
 
 EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFunctionWithException(ExecState* state)
 {
@@ -7360,13 +7360,13 @@ EncodedJSValue JSC_HOST_CALL jsTestObjConstructorFunctionTestStaticPromiseFuncti
     return JSValue::encode(callPromiseFunction<jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise, PromiseExecutionScope::WindowOnly>(*state));
 }
 
-static inline EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise(ExecState* state, Ref<DeferredWrapper>&& deferredWrapper)
+static inline EncodedJSValue jsTestObjConstructorFunctionTestStaticPromiseFunctionWithExceptionPromise(ExecState* state, Ref<DeferredPromise>&& promise)
 {
     VM& vm = state->vm();
     auto throwScope = DECLARE_THROW_SCOPE(vm);
     UNUSED_PARAM(throwScope);
     ExceptionCode ec = 0;
-    TestObj::testStaticPromiseFunctionWithException(WTFMove(deferredWrapper), ec);
+    TestObj::testStaticPromiseFunctionWithException(WTFMove(promise), ec);
     setDOMException(state, ec);
     return JSValue::encode(jsUndefined());
 }
index e0dd103aa9d06922df1ca0609e2a967c9bebc7fd..81f7ca17237e718822c5811c90eaf57b7517abd2 100644 (file)
@@ -34,7 +34,6 @@
 #include "Element.h"
 #include "ElementTraversal.h"
 #include "JSCustomElementInterface.h"
-#include "JSDOMPromise.h"
 #include "MathMLNames.h"
 #include "QualifiedName.h"
 #include "SVGNames.h"
index 5761a474cf1608efd6fb552451d37c2c0cf5d3d4..18e4beefea4bdb87e1b4da3ae0cf9faf20c5f64a 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(CUSTOM_ELEMENTS)
 
+#include "JSDOMPromise.h"
 #include "QualifiedName.h"
 #include <wtf/HashMap.h>
 #include <wtf/TemporaryChange.h>
@@ -44,7 +45,6 @@ namespace WebCore {
 
 class CustomElementRegistry;
 class DOMWindow;
-class DeferredWrapper;
 class Element;
 class JSCustomElementInterface;
 class QualifiedName;
@@ -66,7 +66,7 @@ public:
 
     JSC::JSValue get(const AtomicString&);
 
-    HashMap<AtomicString, Ref<DeferredWrapper>>& promiseMap() { return m_promiseMap; }
+    HashMap<AtomicString, Ref<DeferredPromise>>& promiseMap() { return m_promiseMap; }
 
 private:
     CustomElementRegistry(DOMWindow&);
@@ -74,7 +74,7 @@ private:
     DOMWindow& m_window;
     HashMap<AtomicString, Ref<JSCustomElementInterface>> m_nameMap;
     HashMap<const JSC::JSObject*, JSCustomElementInterface*> m_constructorMap;
-    HashMap<AtomicString, Ref<DeferredWrapper>> m_promiseMap;
+    HashMap<AtomicString, Ref<DeferredPromise>> m_promiseMap;
 
     bool m_elementDefinitionIsRunning { false };