Title: [236429] trunk/Source/WebCore
Revision
236429
Author
[email protected]
Date
2018-09-24 14:48:13 -0700 (Mon, 24 Sep 2018)

Log Message

[Payment Request] Events cleanup
https://bugs.webkit.org/show_bug.cgi?id=189925

Reviewed by Simon Fraser.

1. Constructed MerchantValidationEvents (and ApplePayValidateMerchantEvents) with rvalue
references to validationURLs.
2. Instead of MerchantValidationEvent and PaymentRequestUpdateEvent having a
RefPtr<PaymentRequest>, downcasted their target to a PaymentRequest. Trusted versions of
these events are always dispatched to a PaymentRequest object.
3. Defined MerchantValidationEventInit in MerchantValidationEvent.idl instead of having a
separate .idl and .h for this dictionary.

No new tests. No change in behavior.

* CMakeLists.txt:
* DerivedSources.make:
* Modules/applepay/ApplePaySession.cpp:
(WebCore::ApplePaySession::validateMerchant):
* Modules/applepay/ApplePaySession.h:
* Modules/applepay/ApplePayValidateMerchantEvent.cpp:
(WebCore::ApplePayValidateMerchantEvent::ApplePayValidateMerchantEvent):
* Modules/applepay/ApplePayValidateMerchantEvent.h:
(WebCore::ApplePayValidateMerchantEvent::create):
* Modules/applepay/PaymentCoordinator.cpp:
(WebCore::PaymentCoordinator::validateMerchant):
* Modules/applepay/PaymentCoordinator.h:
* Modules/applepay/PaymentSession.h:
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
(WebCore::ApplePayPaymentHandler::validateMerchant):
* Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
* Modules/paymentrequest/MerchantValidationEvent.cpp:
(WebCore::MerchantValidationEvent::create):
(WebCore::MerchantValidationEvent::MerchantValidationEvent):
(WebCore::MerchantValidationEvent::complete):
* Modules/paymentrequest/MerchantValidationEvent.h:
* Modules/paymentrequest/MerchantValidationEvent.idl:
* Modules/paymentrequest/MerchantValidationEventInit.h: Removed.
* Modules/paymentrequest/MerchantValidationEventInit.idl: Removed.
* Modules/paymentrequest/PaymentMethodChangeEvent.cpp:
(WebCore::PaymentMethodChangeEvent::PaymentMethodChangeEvent):
* Modules/paymentrequest/PaymentMethodChangeEvent.h:
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged):
(WebCore::PaymentRequest::shippingOptionChanged):
(WebCore::PaymentRequest::paymentMethodChanged):
* Modules/paymentrequest/PaymentRequest.h:
(isType):
* Modules/paymentrequest/PaymentRequestUpdateEvent.cpp:
(WebCore::PaymentRequestUpdateEvent::PaymentRequestUpdateEvent):
(WebCore::PaymentRequestUpdateEvent::updateWith):
* Modules/paymentrequest/PaymentRequestUpdateEvent.h:
* Sources.txt:
* WebCore.xcodeproj/project.pbxproj:
* dom/EventTarget.cpp:
(WebCore::EventTarget::isPaymentRequest const):
* dom/EventTarget.h:

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (236428 => 236429)


--- trunk/Source/WebCore/CMakeLists.txt	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/CMakeLists.txt	2018-09-24 21:48:13 UTC (rev 236429)
@@ -346,7 +346,6 @@
 
     Modules/paymentrequest/AddressErrors.idl
     Modules/paymentrequest/MerchantValidationEvent.idl
-    Modules/paymentrequest/MerchantValidationEventInit.idl
     Modules/paymentrequest/PayerErrorFields.idl
     Modules/paymentrequest/PaymentAddress.idl
     Modules/paymentrequest/PaymentComplete.idl

Modified: trunk/Source/WebCore/ChangeLog (236428 => 236429)


--- trunk/Source/WebCore/ChangeLog	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/ChangeLog	2018-09-24 21:48:13 UTC (rev 236429)
@@ -1,3 +1,63 @@
+2018-09-24  Andy Estes  <[email protected]>
+
+        [Payment Request] Events cleanup
+        https://bugs.webkit.org/show_bug.cgi?id=189925
+
+        Reviewed by Simon Fraser.
+
+        1. Constructed MerchantValidationEvents (and ApplePayValidateMerchantEvents) with rvalue
+        references to validationURLs.
+        2. Instead of MerchantValidationEvent and PaymentRequestUpdateEvent having a
+        RefPtr<PaymentRequest>, downcasted their target to a PaymentRequest. Trusted versions of
+        these events are always dispatched to a PaymentRequest object.
+        3. Defined MerchantValidationEventInit in MerchantValidationEvent.idl instead of having a
+        separate .idl and .h for this dictionary.
+
+        No new tests. No change in behavior.
+
+        * CMakeLists.txt:
+        * DerivedSources.make:
+        * Modules/applepay/ApplePaySession.cpp:
+        (WebCore::ApplePaySession::validateMerchant):
+        * Modules/applepay/ApplePaySession.h:
+        * Modules/applepay/ApplePayValidateMerchantEvent.cpp:
+        (WebCore::ApplePayValidateMerchantEvent::ApplePayValidateMerchantEvent):
+        * Modules/applepay/ApplePayValidateMerchantEvent.h:
+        (WebCore::ApplePayValidateMerchantEvent::create):
+        * Modules/applepay/PaymentCoordinator.cpp:
+        (WebCore::PaymentCoordinator::validateMerchant):
+        * Modules/applepay/PaymentCoordinator.h:
+        * Modules/applepay/PaymentSession.h:
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+        (WebCore::ApplePayPaymentHandler::validateMerchant):
+        * Modules/applepay/paymentrequest/ApplePayPaymentHandler.h:
+        * Modules/paymentrequest/MerchantValidationEvent.cpp:
+        (WebCore::MerchantValidationEvent::create):
+        (WebCore::MerchantValidationEvent::MerchantValidationEvent):
+        (WebCore::MerchantValidationEvent::complete):
+        * Modules/paymentrequest/MerchantValidationEvent.h:
+        * Modules/paymentrequest/MerchantValidationEvent.idl:
+        * Modules/paymentrequest/MerchantValidationEventInit.h: Removed.
+        * Modules/paymentrequest/MerchantValidationEventInit.idl: Removed.
+        * Modules/paymentrequest/PaymentMethodChangeEvent.cpp:
+        (WebCore::PaymentMethodChangeEvent::PaymentMethodChangeEvent):
+        * Modules/paymentrequest/PaymentMethodChangeEvent.h:
+        * Modules/paymentrequest/PaymentRequest.cpp:
+        (WebCore::PaymentRequest::shippingAddressChanged):
+        (WebCore::PaymentRequest::shippingOptionChanged):
+        (WebCore::PaymentRequest::paymentMethodChanged):
+        * Modules/paymentrequest/PaymentRequest.h:
+        (isType):
+        * Modules/paymentrequest/PaymentRequestUpdateEvent.cpp:
+        (WebCore::PaymentRequestUpdateEvent::PaymentRequestUpdateEvent):
+        (WebCore::PaymentRequestUpdateEvent::updateWith):
+        * Modules/paymentrequest/PaymentRequestUpdateEvent.h:
+        * Sources.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * dom/EventTarget.cpp:
+        (WebCore::EventTarget::isPaymentRequest const):
+        * dom/EventTarget.h:
+
 2018-09-24  Daniel Bates  <[email protected]>
 
         Separate Mac and iOS implementation of windowsKeyCodeForCharCode()

Modified: trunk/Source/WebCore/DerivedSources.make (236428 => 236429)


--- trunk/Source/WebCore/DerivedSources.make	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/DerivedSources.make	2018-09-24 21:48:13 UTC (rev 236429)
@@ -266,7 +266,6 @@
     $(WebCore)/Modules/notifications/NotificationPermissionCallback.idl \
     $(WebCore)/Modules/paymentrequest/AddressErrors.idl \
     $(WebCore)/Modules/paymentrequest/MerchantValidationEvent.idl \
-    $(WebCore)/Modules/paymentrequest/MerchantValidationEventInit.idl \
     $(WebCore)/Modules/paymentrequest/PayerErrorFields.idl \
     $(WebCore)/Modules/paymentrequest/PaymentAddress.idl \
     $(WebCore)/Modules/paymentrequest/PaymentComplete.idl \

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -755,7 +755,7 @@
     return m_version;
 }
 
-void ApplePaySession::validateMerchant(const URL& validationURL)
+void ApplePaySession::validateMerchant(URL&& validationURL)
 {
     if (m_state == State::Aborted) {
         // ApplePaySession::abort has been called.
@@ -773,7 +773,7 @@
 
     m_merchantValidationState = MerchantValidationState::ValidatingMerchant;
 
-    auto event = ApplePayValidateMerchantEvent::create(eventNames().validatemerchantEvent, validationURL);
+    auto event = ApplePayValidateMerchantEvent::create(eventNames().validatemerchantEvent, WTFMove(validationURL));
     dispatchEvent(event.get());
 }
 

Modified: trunk/Source/WebCore/Modules/applepay/ApplePaySession.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/ApplePaySession.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/ApplePaySession.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -112,7 +112,7 @@
 
     // PaymentSession
     unsigned version() const override;
-    void validateMerchant(const URL&) override;
+    void validateMerchant(URL&&) override;
     void didAuthorizePayment(const Payment&) override;
     void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) override;
     void didSelectShippingContact(const PaymentContact&) override;

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayValidateMerchantEvent.cpp (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/ApplePayValidateMerchantEvent.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayValidateMerchantEvent.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -30,9 +30,9 @@
 
 namespace WebCore {
 
-ApplePayValidateMerchantEvent::ApplePayValidateMerchantEvent(const AtomicString& type, const URL& validationURL)
+ApplePayValidateMerchantEvent::ApplePayValidateMerchantEvent(const AtomicString& type, URL&& validationURL)
     : Event(type, CanBubble::No, IsCancelable::No)
-    , m_validationURL(validationURL)
+    , m_validationURL(WTFMove(validationURL))
 {
 }
 

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayValidateMerchantEvent.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/ApplePayValidateMerchantEvent.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayValidateMerchantEvent.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -34,9 +34,9 @@
 
 class ApplePayValidateMerchantEvent : public Event {
 public:
-    static Ref<ApplePayValidateMerchantEvent> create(const AtomicString& type, const URL& validationURL)
+    static Ref<ApplePayValidateMerchantEvent> create(const AtomicString& type, URL&& validationURL)
     {
-        return adoptRef(*new ApplePayValidateMerchantEvent(type, validationURL));
+        return adoptRef(*new ApplePayValidateMerchantEvent(type, WTFMove(validationURL)));
     }
 
     virtual ~ApplePayValidateMerchantEvent();
@@ -44,7 +44,7 @@
     const String& validationURL() const { return m_validationURL.string(); }
 
 protected:
-    ApplePayValidateMerchantEvent(const AtomicString& type, const URL& validationURL);
+    ApplePayValidateMerchantEvent(const AtomicString& type, URL&& validationURL);
 
     // Event.
     EventInterface eventInterface() const override;

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -133,7 +133,7 @@
     m_client.cancelPaymentSession();
 }
 
-void PaymentCoordinator::validateMerchant(const URL& validationURL)
+void PaymentCoordinator::validateMerchant(URL&& validationURL)
 {
     if (!m_activeSession) {
         // It's possible that the payment has been aborted already.
@@ -140,7 +140,7 @@
         return;
     }
 
-    m_activeSession->validateMerchant(validationURL);
+    m_activeSession->validateMerchant(WTFMove(validationURL));
 }
 
 void PaymentCoordinator::didAuthorizePayment(const Payment& payment)

Modified: trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/PaymentCoordinator.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -66,7 +66,7 @@
     void abortPaymentSession();
     void cancelPaymentSession();
 
-    WEBCORE_EXPORT void validateMerchant(const URL& validationURL);
+    WEBCORE_EXPORT void validateMerchant(URL&& validationURL);
     WEBCORE_EXPORT void didAuthorizePayment(const Payment&);
     WEBCORE_EXPORT void didSelectPaymentMethod(const PaymentMethod&);
     WEBCORE_EXPORT void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&);

Modified: trunk/Source/WebCore/Modules/applepay/PaymentSession.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/PaymentSession.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/PaymentSession.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -44,7 +44,7 @@
     static ExceptionOr<void> canCreateSession(Document&);
 
     virtual unsigned version() const = 0;
-    virtual void validateMerchant(const URL&) = 0;
+    virtual void validateMerchant(URL&&) = 0;
     virtual void didAuthorizePayment(const Payment&) = 0;
     virtual void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) = 0;
     virtual void didSelectShippingContact(const PaymentContact&) = 0;

Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -430,10 +430,10 @@
     return version;
 }
 
-void ApplePayPaymentHandler::validateMerchant(const URL& validationURL)
+void ApplePayPaymentHandler::validateMerchant(URL&& validationURL)
 {
     if (validationURL.isValid())
-        m_paymentRequest->dispatchEvent(MerchantValidationEvent::create(eventNames().merchantvalidationEvent, validationURL, m_paymentRequest.get()).get());
+        m_paymentRequest->dispatchEvent(MerchantValidationEvent::create(eventNames().merchantvalidationEvent, WTFMove(validationURL)).get());
 }
 
 static Ref<PaymentAddress> convert(const ApplePayPaymentContact& contact)

Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -69,7 +69,7 @@
 
     // PaymentSession
     unsigned version() const final;
-    void validateMerchant(const URL&) final;
+    void validateMerchant(URL&&) final;
     void didAuthorizePayment(const Payment&) final;
     void didSelectShippingMethod(const ApplePaySessionPaymentRequest::ShippingMethod&) final;
     void didSelectShippingContact(const PaymentContact&) final;

Modified: trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.cpp (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -29,17 +29,16 @@
 #if ENABLE(PAYMENT_REQUEST)
 
 #include "Document.h"
-#include "MerchantValidationEventInit.h"
 #include "PaymentRequest.h"
 
 namespace WebCore {
 
-Ref<MerchantValidationEvent> MerchantValidationEvent::create(const AtomicString& type, const URL& validationURL, PaymentRequest& paymentRequest)
+Ref<MerchantValidationEvent> MerchantValidationEvent::create(const AtomicString& type, URL&& validationURL)
 {
-    return adoptRef(*new MerchantValidationEvent(type, validationURL, paymentRequest));
+    return adoptRef(*new MerchantValidationEvent(type, WTFMove(validationURL)));
 }
 
-ExceptionOr<Ref<MerchantValidationEvent>> MerchantValidationEvent::create(Document& document, const AtomicString& type, MerchantValidationEventInit&& eventInit)
+ExceptionOr<Ref<MerchantValidationEvent>> MerchantValidationEvent::create(Document& document, const AtomicString& type, Init&& eventInit)
 {
     URL validationURL { document.url(), eventInit.validationURL };
     if (!validationURL.isValid())
@@ -48,16 +47,15 @@
     return adoptRef(*new MerchantValidationEvent(type, WTFMove(validationURL), WTFMove(eventInit)));
 }
 
-MerchantValidationEvent::MerchantValidationEvent(const AtomicString& type, const URL& validationURL, PaymentRequest& paymentRequest)
+MerchantValidationEvent::MerchantValidationEvent(const AtomicString& type, URL&& validationURL)
     : Event { type, Event::CanBubble::No, Event::IsCancelable::No }
-    , m_validationURL { validationURL }
-    , m_paymentRequest { &paymentRequest }
+    , m_validationURL { WTFMove(validationURL) }
 {
     ASSERT(isTrusted());
     ASSERT(m_validationURL.isValid());
 }
 
-MerchantValidationEvent::MerchantValidationEvent(const AtomicString& type, URL&& validationURL, MerchantValidationEventInit&& eventInit)
+MerchantValidationEvent::MerchantValidationEvent(const AtomicString& type, URL&& validationURL, Init&& eventInit)
     : Event { type, WTFMove(eventInit), IsTrusted::No }
     , m_validationURL { WTFMove(validationURL) }
 {
@@ -75,12 +73,10 @@
     if (!isTrusted())
         return Exception { InvalidStateError };
 
-    ASSERT(m_paymentRequest);
-
     if (m_isCompleted)
         return Exception { InvalidStateError };
 
-    auto exception = m_paymentRequest->completeMerchantValidation(*this, WTFMove(merchantSessionPromise));
+    auto exception = downcast<PaymentRequest>(target())->completeMerchantValidation(*this, WTFMove(merchantSessionPromise));
     if (exception.hasException())
         return exception.releaseException();
 

Modified: trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -34,20 +34,22 @@
 
 class DOMPromise;
 class Document;
-class PaymentRequest;
-struct MerchantValidationEventInit;
 
 class MerchantValidationEvent final : public Event {
 public:
-    static Ref<MerchantValidationEvent> create(const AtomicString&, const URL&, PaymentRequest&);
-    static ExceptionOr<Ref<MerchantValidationEvent>> create(Document&, const AtomicString&, MerchantValidationEventInit&&);
+    struct Init final : EventInit {
+        String validationURL;
+    };
 
+    static Ref<MerchantValidationEvent> create(const AtomicString&, URL&&);
+    static ExceptionOr<Ref<MerchantValidationEvent>> create(Document&, const AtomicString&, Init&&);
+
     const String& validationURL() const { return m_validationURL.string(); }
     ExceptionOr<void> complete(Ref<DOMPromise>&&);
 
 private:
-    MerchantValidationEvent(const AtomicString&, const URL&, PaymentRequest&);
-    MerchantValidationEvent(const AtomicString&, URL&&, MerchantValidationEventInit&&);
+    MerchantValidationEvent(const AtomicString&, URL&&);
+    MerchantValidationEvent(const AtomicString&, URL&&, Init&&);
 
     // Event
     EventInterface eventInterface() const final;
@@ -54,7 +56,6 @@
 
     bool m_isCompleted { false };
     URL m_validationURL;
-    RefPtr<PaymentRequest> m_paymentRequest;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.idl (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.idl	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEvent.idl	2018-09-24 21:48:13 UTC (rev 236429)
@@ -35,3 +35,9 @@
     readonly attribute DOMString validationURL;
     [MayThrowException] void complete(Promise<any> merchantSessionPromise);
 };
+
+[
+    Conditional=PAYMENT_REQUEST,
+] dictionary MerchantValidationEventInit : EventInit {
+    USVString validationURL = "";
+};

Deleted: trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEventInit.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEventInit.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEventInit.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -1,40 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(PAYMENT_REQUEST)
-
-#include "EventInit.h"
-
-namespace WebCore {
-
-struct MerchantValidationEventInit final : EventInit {
-    String validationURL;
-};
-
-} // namespace WebCore
-
-#endif // ENABLE(PAYMENT_REQUEST)

Deleted: trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEventInit.idl (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEventInit.idl	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/MerchantValidationEventInit.idl	2018-09-24 21:48:13 UTC (rev 236429)
@@ -1,30 +0,0 @@
-/*
- * Copyright (C) 2018 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-[
-    Conditional=PAYMENT_REQUEST,
-] dictionary MerchantValidationEventInit : EventInit {
-    USVString validationURL = "";
-};

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.cpp (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -42,8 +42,8 @@
 {
 }
 
-PaymentMethodChangeEvent::PaymentMethodChangeEvent(const AtomicString& type, PaymentRequest& request, const String& methodName, MethodDetailsFunction&& methodDetailsFunction)
-    : PaymentRequestUpdateEvent { type, request }
+PaymentMethodChangeEvent::PaymentMethodChangeEvent(const AtomicString& type, const String& methodName, MethodDetailsFunction&& methodDetailsFunction)
+    : PaymentRequestUpdateEvent { type }
     , m_methodName { methodName }
     , m_methodDetails { WTFMove(methodDetailsFunction) }
 {

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentMethodChangeEvent.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -63,7 +63,7 @@
 
 private:
     PaymentMethodChangeEvent(const AtomicString& type, Init&&);
-    PaymentMethodChangeEvent(const AtomicString& type, PaymentRequest&, const String& methodName, MethodDetailsFunction&&);
+    PaymentMethodChangeEvent(const AtomicString& type, const String& methodName, MethodDetailsFunction&&);
 
     String m_methodName;
     MethodDetailsType m_methodDetails;

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -540,7 +540,7 @@
 {
     whenDetailsSettled([this, protectedThis = makeRefPtr(this), shippingAddress = makeRefPtr(shippingAddress.get())]() mutable {
         m_shippingAddress = WTFMove(shippingAddress);
-        dispatchEvent(PaymentRequestUpdateEvent::create(eventNames().shippingaddresschangeEvent, *this));
+        dispatchEvent(PaymentRequestUpdateEvent::create(eventNames().shippingaddresschangeEvent));
     });
 }
 
@@ -548,7 +548,7 @@
 {
     whenDetailsSettled([this, protectedThis = makeRefPtr(this), shippingOption]() mutable {
         m_shippingOption = shippingOption;
-        dispatchEvent(PaymentRequestUpdateEvent::create(eventNames().shippingoptionchangeEvent, *this));
+        dispatchEvent(PaymentRequestUpdateEvent::create(eventNames().shippingoptionchangeEvent));
     });
 }
 
@@ -557,7 +557,7 @@
     whenDetailsSettled([this, protectedThis = makeRefPtr(this), methodName, methodDetailsFunction = WTFMove(methodDetailsFunction)]() mutable {
         auto& eventName = eventNames().paymentmethodchangeEvent;
         if (hasEventListeners(eventName))
-            dispatchEvent(PaymentMethodChangeEvent::create(eventName, *this, methodName, WTFMove(methodDetailsFunction)));
+            dispatchEvent(PaymentMethodChangeEvent::create(eventName, methodName, WTFMove(methodDetailsFunction)));
         else
             m_activePaymentHandler->detailsUpdated(UpdateReason::PaymentMethodChanged, { });
     });

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -120,6 +120,7 @@
     // EventTarget
     EventTargetInterface eventTargetInterface() const final { return PaymentRequestEventTargetInterfaceType; }
     ScriptExecutionContext* scriptExecutionContext() const final { return ActiveDOMObject::scriptExecutionContext(); }
+    bool isPaymentRequest() const final { return true; }
     void refEventTarget() final { ref(); }
     void derefEventTarget() final { deref(); }
 
@@ -141,4 +142,8 @@
 
 } // namespace WebCore
 
+SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::PaymentRequest)
+    static bool isType(const WebCore::EventTarget& eventTarget) { return eventTarget.isPaymentRequest(); }
+SPECIALIZE_TYPE_TRAITS_END()
+
 #endif // ENABLE(PAYMENT_REQUEST)

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -39,9 +39,8 @@
     ASSERT(!isTrusted());
 }
 
-PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(const AtomicString& type, PaymentRequest& paymentRequest)
+PaymentRequestUpdateEvent::PaymentRequestUpdateEvent(const AtomicString& type)
     : Event { type, CanBubble::No, IsCancelable::No }
-    , m_paymentRequest { &paymentRequest }
 {
     ASSERT(isTrusted());
 }
@@ -53,8 +52,6 @@
     if (!isTrusted())
         return Exception { InvalidStateError };
 
-    ASSERT(m_paymentRequest);
-
     if (m_waitForUpdate)
         return Exception { InvalidStateError };
 
@@ -73,7 +70,7 @@
         return Exception { TypeError };
     }
 
-    auto exception = m_paymentRequest->updateWith(reason, WTFMove(detailsPromise));
+    auto exception = downcast<PaymentRequest>(target())->updateWith(reason, WTFMove(detailsPromise));
     if (exception.hasException())
         return exception.releaseException();
 

Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.h (236428 => 236429)


--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequestUpdateEvent.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -33,7 +33,6 @@
 namespace WebCore {
 
 class DOMPromise;
-class PaymentRequest;
 struct PaymentRequestUpdateEventInit;
 
 class PaymentRequestUpdateEvent : public Event {
@@ -46,7 +45,7 @@
     ExceptionOr<void> updateWith(Ref<DOMPromise>&&);
 
 protected:
-    PaymentRequestUpdateEvent(const AtomicString& type, PaymentRequest&);
+    explicit PaymentRequestUpdateEvent(const AtomicString& type);
     PaymentRequestUpdateEvent(const AtomicString& type, const PaymentRequestUpdateEventInit&);
 
     // Event
@@ -53,7 +52,6 @@
     EventInterface eventInterface() const override;
 
 private:
-    RefPtr<PaymentRequest> m_paymentRequest;
     bool m_waitForUpdate { false };
 };
 

Modified: trunk/Source/WebCore/Sources.txt (236428 => 236429)


--- trunk/Source/WebCore/Sources.txt	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/Sources.txt	2018-09-24 21:48:13 UTC (rev 236429)
@@ -2770,7 +2770,6 @@
 JSMediaTrackConstraints.cpp
 JSMediaTrackSupportedConstraints.cpp
 JSMerchantValidationEvent.cpp
-JSMerchantValidationEventInit.cpp
 JSMessageChannel.cpp
 JSMessageEvent.cpp
 JSMessagePort.cpp

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (236428 => 236429)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2018-09-24 21:48:13 UTC (rev 236429)
@@ -2933,8 +2933,6 @@
 		A15E6BF11E212A6A0080AF34 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A15E6BF01E212A6A0080AF34 /* Foundation.framework */; };
 		A164A2472134BC7100509156 /* PaymentMethodChangeEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A164A2442134BC7100509156 /* PaymentMethodChangeEvent.h */; };
 		A164A2552134C1CC00509156 /* JSPaymentMethodChangeEvent.h in Headers */ = {isa = PBXBuildFile; fileRef = A164A2512134C1CB00509156 /* JSPaymentMethodChangeEvent.h */; };
-		A1677DE9213CDFAA00A08C34 /* MerchantValidationEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = A1677DE6213CDFAA00A08C34 /* MerchantValidationEventInit.h */; };
-		A1677DF0213CE0B100A08C34 /* JSMerchantValidationEventInit.h in Headers */ = {isa = PBXBuildFile; fileRef = A1677DEE213CE0B000A08C34 /* JSMerchantValidationEventInit.h */; };
 		A1677DFD213E006600A08C34 /* PaymentValidationErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = A1677DFA213E006600A08C34 /* PaymentValidationErrors.h */; };
 		A1677E03213E01C700A08C34 /* JSPaymentValidationErrors.h in Headers */ = {isa = PBXBuildFile; fileRef = A1677E01213E01C500A08C34 /* JSPaymentValidationErrors.h */; };
 		A1677E08213E024C00A08C34 /* PayerErrorFields.h in Headers */ = {isa = PBXBuildFile; fileRef = A1677E05213E024C00A08C34 /* PayerErrorFields.h */; };
@@ -11006,10 +11004,6 @@
 		A164A2462134BC7100509156 /* PaymentMethodChangeEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PaymentMethodChangeEvent.idl; sourceTree = "<group>"; };
 		A164A2512134C1CB00509156 /* JSPaymentMethodChangeEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPaymentMethodChangeEvent.h; sourceTree = "<group>"; };
 		A164A2532134C1CB00509156 /* JSPaymentMethodChangeEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSPaymentMethodChangeEvent.cpp; sourceTree = "<group>"; };
-		A1677DE6213CDFAA00A08C34 /* MerchantValidationEventInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MerchantValidationEventInit.h; sourceTree = "<group>"; };
-		A1677DE8213CDFAA00A08C34 /* MerchantValidationEventInit.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = MerchantValidationEventInit.idl; sourceTree = "<group>"; };
-		A1677DED213CE0AF00A08C34 /* JSMerchantValidationEventInit.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSMerchantValidationEventInit.cpp; sourceTree = "<group>"; };
-		A1677DEE213CE0B000A08C34 /* JSMerchantValidationEventInit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSMerchantValidationEventInit.h; sourceTree = "<group>"; };
 		A1677DFA213E006600A08C34 /* PaymentValidationErrors.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PaymentValidationErrors.h; sourceTree = "<group>"; };
 		A1677DFC213E006600A08C34 /* PaymentValidationErrors.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = PaymentValidationErrors.idl; sourceTree = "<group>"; };
 		A1677E01213E01C500A08C34 /* JSPaymentValidationErrors.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSPaymentValidationErrors.h; sourceTree = "<group>"; };
@@ -21395,8 +21389,6 @@
 				A1677E11213E03C500A08C34 /* JSAddressErrors.h */,
 				A11AE0D01FFD61DE0047348B /* JSMerchantValidationEvent.cpp */,
 				A11AE0D11FFD61DF0047348B /* JSMerchantValidationEvent.h */,
-				A1677DED213CE0AF00A08C34 /* JSMerchantValidationEventInit.cpp */,
-				A1677DEE213CE0B000A08C34 /* JSMerchantValidationEventInit.h */,
 				A1677E16213E03F000A08C34 /* JSPayerErrorFields.cpp */,
 				A1677E15213E03F000A08C34 /* JSPayerErrorFields.h */,
 				A1CC565F1F46146100A4555B /* JSPaymentAddress.cpp */,
@@ -21460,8 +21452,6 @@
 				A11AE0CA1FFD60530047348B /* MerchantValidationEvent.cpp */,
 				A11AE0C91FFD60530047348B /* MerchantValidationEvent.h */,
 				A11AE0CB1FFD60530047348B /* MerchantValidationEvent.idl */,
-				A1677DE6213CDFAA00A08C34 /* MerchantValidationEventInit.h */,
-				A1677DE8213CDFAA00A08C34 /* MerchantValidationEventInit.idl */,
 				A1677E05213E024C00A08C34 /* PayerErrorFields.h */,
 				A1677E07213E024C00A08C34 /* PayerErrorFields.idl */,
 				A1CFE0311F9E71290065C345 /* PaymentAddress.cpp */,
@@ -26410,6 +26400,8 @@
 				B6D9D23314EABD260090D75E /* FocusEvent.h */,
 				B6D9D27214EABF030090D75E /* FocusEvent.idl */,
 				A853123C11D0471B00D4D077 /* FragmentScriptingPermission.h */,
+				9BAAC4582151E77A003D4A98 /* GCReachableRef.cpp */,
+				9BAAC4562151E39E003D4A98 /* GCReachableRef.h */,
 				0720B09E14D3323500642955 /* GenericEventQueue.cpp */,
 				0720B09F14D3323500642955 /* GenericEventQueue.h */,
 				7C4189AB1B07C170000FA757 /* GlobalEventHandlers.idl */,
@@ -26600,8 +26592,6 @@
 				8102C5871325BB1100DDE67A /* StringCallback.cpp */,
 				81AC6C35131C57D30009A7E0 /* StringCallback.h */,
 				81AC6C34131C57C20009A7E0 /* StringCallback.idl */,
-				9BAAC4582151E77A003D4A98 /* GCReachableRef.cpp */,
-				9BAAC4562151E39E003D4A98 /* GCReachableRef.h */,
 				A8C4A7EC09D563270003AC8D /* StyledElement.cpp */,
 				A8C4A7EB09D563270003AC8D /* StyledElement.h */,
 				C99058121E32B7340073BDDA /* SuccessOr.h */,
@@ -28133,6 +28123,7 @@
 				8EC6C963201A251600FBFA53 /* GapLength.h in Headers */,
 				935C477509AC4D8E00A6AAB4 /* GapRects.h in Headers */,
 				1432E8470C51493800B1500F /* GCController.h in Headers */,
+				9BAAC45C21520128003D4A98 /* GCReachableRef.h in Headers */,
 				C0C054CC1118C8E400CE2636 /* generate-bindings.pl in Headers */,
 				BC23F0DB0DAFF4A4009FDC91 /* GeneratedImage.h in Headers */,
 				830030F61B7D33B500ED3AAC /* GenericCachedHTMLCollection.h in Headers */,
@@ -28940,7 +28931,6 @@
 				932CC0D51DFFD667004C0F9F /* JSMediaTrackConstraints.h in Headers */,
 				0787C46A1BFBDF6F006DCD7F /* JSMediaTrackSupportedConstraints.h in Headers */,
 				A11AE0D31FFD61DF0047348B /* JSMerchantValidationEvent.h in Headers */,
-				A1677DF0213CE0B100A08C34 /* JSMerchantValidationEventInit.h in Headers */,
 				E107400E0E77BDC00033AF24 /* JSMessageChannel.h in Headers */,
 				75793EC90D0CE72D007FC0AC /* JSMessageEvent.h in Headers */,
 				E1ADEDDA0E76BD93004A1A5E /* JSMessagePort.h in Headers */,
@@ -29582,7 +29572,6 @@
 				517139061BF64DEC000D5F01 /* MemoryObjectStoreCursor.h in Headers */,
 				413E00791DB0E4F2002341D2 /* MemoryRelease.h in Headers */,
 				A11AE0CC1FFD60530047348B /* MerchantValidationEvent.h in Headers */,
-				A1677DE9213CDFAA00A08C34 /* MerchantValidationEventInit.h in Headers */,
 				93309DFA099E64920056E581 /* MergeIdenticalElementsCommand.h in Headers */,
 				E1ADECCE0E76AD8B004A1A5E /* MessageChannel.h in Headers */,
 				75793E840D0CE0B3007FC0AC /* MessageEvent.h in Headers */,
@@ -30438,7 +30427,6 @@
 				ECA680C71E67724500731D20 /* StringUtilities.h in Headers */,
 				9B6C41531344949000085B62 /* StringWithDirection.h in Headers */,
 				849F77760EFEC6200090849D /* StrokeStyleApplier.h in Headers */,
-				9BAAC45C21520128003D4A98 /* GCReachableRef.h in Headers */,
 				414B82051D6DF0E50077EBE3 /* StructuredClone.h in Headers */,
 				BC5EB6A30E81DC4F00B25965 /* StyleBackgroundData.h in Headers */,
 				BC5EB67B0E81D3BE00B25965 /* StyleBoxData.h in Headers */,

Modified: trunk/Source/WebCore/dom/EventTarget.cpp (236428 => 236429)


--- trunk/Source/WebCore/dom/EventTarget.cpp	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/dom/EventTarget.cpp	2018-09-24 21:48:13 UTC (rev 236429)
@@ -58,6 +58,11 @@
     return false;
 }
 
+bool EventTarget::isPaymentRequest() const
+{
+    return false;
+}
+
 bool EventTarget::addEventListener(const AtomicString& eventType, Ref<EventListener>&& listener, const AddEventListenerOptions& options)
 {
     auto passive = options.passive;

Modified: trunk/Source/WebCore/dom/EventTarget.h (236428 => 236429)


--- trunk/Source/WebCore/dom/EventTarget.h	2018-09-24 20:49:25 UTC (rev 236428)
+++ trunk/Source/WebCore/dom/EventTarget.h	2018-09-24 21:48:13 UTC (rev 236429)
@@ -59,6 +59,7 @@
     virtual ScriptExecutionContext* scriptExecutionContext() const = 0;
 
     virtual bool isNode() const;
+    virtual bool isPaymentRequest() const;
 
     struct ListenerOptions {
         ListenerOptions(bool capture = false)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to