Title: [286344] trunk/Source/WebCore
Revision
286344
Author
[email protected]
Date
2021-11-30 18:21:59 -0800 (Tue, 30 Nov 2021)

Log Message

[Apple Pay] use `#if` inside `ApplePayPaymentTiming` instead of guarding the entire `enum`
https://bugs.webkit.org/show_bug.cgi?id=232696
<rdar://problem/83097245>

Reviewed by Tim Horton.

* Modules/applepay/ApplePayPaymentTiming.idl:
* Modules/applepay/ApplePayPaymentTiming.h:
* Modules/applepay/ApplePayLineItem.idl:
* Modules/applepay/ApplePayLineItem.h:
(WebCore::ApplePayLineItem::encode const):
(WebCore::ApplePayLineItem::decode):
Rather than have the entire `ApplePayPaymentTiming` be guarded, have it always exist and
just guard `Recurring` and `Deferred` since those are really the things that need guarding.

* Modules/applepay/PaymentSummaryItems.h:
* Modules/applepay/cocoa/PaymentSummaryItemsCocoa.mm:
(WebCore::platformSummaryItem):
Add WKA hooks.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286343 => 286344)


--- trunk/Source/WebCore/ChangeLog	2021-12-01 02:19:17 UTC (rev 286343)
+++ trunk/Source/WebCore/ChangeLog	2021-12-01 02:21:59 UTC (rev 286344)
@@ -1,3 +1,25 @@
+2021-11-30  Devin Rousso  <[email protected]>
+
+        [Apple Pay] use `#if` inside `ApplePayPaymentTiming` instead of guarding the entire `enum`
+        https://bugs.webkit.org/show_bug.cgi?id=232696
+        <rdar://problem/83097245>
+
+        Reviewed by Tim Horton.
+
+        * Modules/applepay/ApplePayPaymentTiming.idl:
+        * Modules/applepay/ApplePayPaymentTiming.h:
+        * Modules/applepay/ApplePayLineItem.idl:
+        * Modules/applepay/ApplePayLineItem.h:
+        (WebCore::ApplePayLineItem::encode const):
+        (WebCore::ApplePayLineItem::decode):
+        Rather than have the entire `ApplePayPaymentTiming` be guarded, have it always exist and
+        just guard `Recurring` and `Deferred` since those are really the things that need guarding.
+
+        * Modules/applepay/PaymentSummaryItems.h:
+        * Modules/applepay/cocoa/PaymentSummaryItemsCocoa.mm:
+        (WebCore::platformSummaryItem):
+        Add WKA hooks.
+
 2021-11-30  ujwal koneru  <[email protected]>
 
         Fix Playstation build after r286171

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayLineItem.h (286343 => 286344)


--- trunk/Source/WebCore/Modules/applepay/ApplePayLineItem.h	2021-12-01 02:19:17 UTC (rev 286343)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayLineItem.h	2021-12-01 02:21:59 UTC (rev 286344)
@@ -33,6 +33,10 @@
 #include <optional>
 #include <wtf/text/WTFString.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ApplePayLineItemAdditions.h>
+#endif
+
 namespace WebCore {
 
 struct ApplePayLineItem final {
@@ -45,9 +49,7 @@
     String label;
     String amount;
 
-#if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM) || ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
     ApplePayPaymentTiming paymentTiming { ApplePayPaymentTiming::Immediate };
-#endif
 
 #if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM)
     double recurringPaymentStartDate { std::numeric_limits<double>::quiet_NaN() };
@@ -60,6 +62,10 @@
     double deferredPaymentDate { std::numeric_limits<double>::quiet_NaN() };
 #endif
 
+#if defined(ApplePayLineItemAdditions_members)
+    ApplePayLineItemAdditions_members
+#endif
+
     template<class Encoder> void encode(Encoder&) const;
     template<class Decoder> static std::optional<ApplePayLineItem> decode(Decoder&);
 };
@@ -70,9 +76,7 @@
     encoder << type;
     encoder << label;
     encoder << amount;
-#if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM) || ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
     encoder << paymentTiming;
-#endif
 #if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM)
     encoder << recurringPaymentStartDate;
     encoder << recurringPaymentIntervalUnit;
@@ -82,6 +86,9 @@
 #if ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
     encoder << deferredPaymentDate;
 #endif
+#if defined(ApplePayLineItemAdditions_encode)
+    ApplePayLineItemAdditions_encode
+#endif
 }
 
 template<class Decoder>
@@ -96,9 +103,7 @@
     DECODE(type, Type)
     DECODE(label, String)
     DECODE(amount, String)
-#if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM) || ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
     DECODE(paymentTiming, ApplePayPaymentTiming)
-#endif
 #if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM)
     DECODE(recurringPaymentStartDate, double)
     DECODE(recurringPaymentIntervalUnit, ApplePayRecurringPaymentDateUnit)
@@ -108,6 +113,9 @@
 #if ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
     DECODE(deferredPaymentDate, double)
 #endif
+#if defined(ApplePayLineItemAdditions_decode_members)
+    ApplePayLineItemAdditions_decode_members
+#endif
 
 #undef DECODE
 
@@ -115,9 +123,7 @@
         WTFMove(*type),
         WTFMove(*label),
         WTFMove(*amount),
-#if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM) || ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
         WTFMove(*paymentTiming),
-#endif
 #if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM)
         WTFMove(*recurringPaymentStartDate),
         WTFMove(*recurringPaymentIntervalUnit),
@@ -127,6 +133,9 @@
 #if ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
         WTFMove(*deferredPaymentDate),
 #endif
+#if defined(ApplePayLineItemAdditions_decode_return)
+    ApplePayLineItemAdditions_decode_return
+#endif
     } };
 }
 

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayLineItem.idl (286343 => 286344)


--- trunk/Source/WebCore/Modules/applepay/ApplePayLineItem.idl	2021-12-01 02:19:17 UTC (rev 286343)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayLineItem.idl	2021-12-01 02:21:59 UTC (rev 286344)
@@ -39,7 +39,7 @@
     DOMString label;
     DOMString amount;
 
-    [Conditional=APPLE_PAY_RECURRING_LINE_ITEM|APPLE_PAY_DEFERRED_LINE_ITEM] ApplePayPaymentTiming paymentTiming = "immediate";
+    ApplePayPaymentTiming paymentTiming = "immediate";
 
     [Conditional=APPLE_PAY_RECURRING_LINE_ITEM] Date recurringPaymentStartDate;
     [Conditional=APPLE_PAY_RECURRING_LINE_ITEM] ApplePayRecurringPaymentDateUnit recurringPaymentIntervalUnit = "month";

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentTiming.h (286343 => 286344)


--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentTiming.h	2021-12-01 02:19:17 UTC (rev 286343)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentTiming.h	2021-12-01 02:21:59 UTC (rev 286344)
@@ -25,16 +25,25 @@
 
 #pragma once
 
-#if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM) || ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
-
 #include <wtf/Forward.h>
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ApplePayPaymentTimingAdditions.h>
+#endif
+
 namespace WebCore {
 
 enum class ApplePayPaymentTiming : uint8_t {
     Immediate,
+#if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM)
     Recurring,
+#endif
+#if ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
     Deferred,
+#endif
+#if defined(ApplePayPaymentTimingAdditions_members)
+    ApplePayPaymentTimingAdditions_members
+#endif
 };
 
 } // namespace WebCore
@@ -44,12 +53,17 @@
 template<> struct EnumTraits<WebCore::ApplePayPaymentTiming> {
     using values = EnumValues<
         WebCore::ApplePayPaymentTiming,
-        WebCore::ApplePayPaymentTiming::Immediate,
-        WebCore::ApplePayPaymentTiming::Recurring,
-        WebCore::ApplePayPaymentTiming::Deferred
+        WebCore::ApplePayPaymentTiming::Immediate
+#if ENABLE(APPLE_PAY_RECURRING_LINE_ITEM)
+        , WebCore::ApplePayPaymentTiming::Recurring
+#endif
+#if ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)
+        , WebCore::ApplePayPaymentTiming::Deferred
+#endif
+#if defined(ApplePayPaymentTimingAdditions_EnumTraits)
+    ApplePayPaymentTimingAdditions_EnumTraits
+#endif
     >;
 };
 
 } // namespace WTF
-
-#endif // ENABLE(APPLE_PAY_RECURRING_LINE_ITEM) || ENABLE(APPLE_PAY_DEFERRED_LINE_ITEM)

Modified: trunk/Source/WebCore/Modules/applepay/ApplePayPaymentTiming.idl (286343 => 286344)


--- trunk/Source/WebCore/Modules/applepay/ApplePayPaymentTiming.idl	2021-12-01 02:19:17 UTC (rev 286343)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayPaymentTiming.idl	2021-12-01 02:21:59 UTC (rev 286344)
@@ -23,10 +23,12 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-[
-    Conditional=APPLE_PAY_RECURRING_LINE_ITEM|APPLE_PAY_DEFERRED_LINE_ITEM,
-] enum ApplePayPaymentTiming {
-    "immediate",
-    "recurring",
-    "deferred"
+enum ApplePayPaymentTiming {
+    "immediate"
+#if defined(ENABLE_APPLE_PAY_RECURRING_LINE_ITEM) && ENABLE_APPLE_PAY_RECURRING_LINE_ITEM
+    , "recurring"
+#endif
+#if defined(ENABLE_APPLE_PAY_DEFERRED_LINE_ITEM) && ENABLE_APPLE_PAY_DEFERRED_LINE_ITEM
+    , "deferred"
+#endif
 };

Modified: trunk/Source/WebCore/Modules/applepay/PaymentSummaryItems.h (286343 => 286344)


--- trunk/Source/WebCore/Modules/applepay/PaymentSummaryItems.h	2021-12-01 02:19:17 UTC (rev 286343)
+++ trunk/Source/WebCore/Modules/applepay/PaymentSummaryItems.h	2021-12-01 02:21:59 UTC (rev 286344)
@@ -49,4 +49,8 @@
 
 } // namespace WebCore
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/PaymentSummaryItemsAdditions.h>
+#endif
+
 #endif // ENABLE(APPLE_PAY)

Modified: trunk/Source/WebCore/Modules/applepay/cocoa/PaymentSummaryItemsCocoa.mm (286343 => 286344)


--- trunk/Source/WebCore/Modules/applepay/cocoa/PaymentSummaryItemsCocoa.mm	2021-12-01 02:19:17 UTC (rev 286343)
+++ trunk/Source/WebCore/Modules/applepay/cocoa/PaymentSummaryItemsCocoa.mm	2021-12-01 02:21:59 UTC (rev 286344)
@@ -50,6 +50,14 @@
     }
 }
 
+} // namespace WebCore
+
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/PaymentSummaryItemsCocoaAdditions.mm>
+#endif
+
+namespace WebCore {
+
 #if HAVE(PASSKIT_RECURRING_SUMMARY_ITEM) || HAVE(PASSKIT_DEFERRED_SUMMARY_ITEM)
 
 static NSDate *toDate(double date)
@@ -111,26 +119,24 @@
 
 PKPaymentSummaryItem *platformSummaryItem(const ApplePayLineItem& lineItem)
 {
-#if HAVE(PASSKIT_RECURRING_SUMMARY_ITEM) || HAVE(PASSKIT_DEFERRED_SUMMARY_ITEM)
     switch (lineItem.paymentTiming) {
     case ApplePayPaymentTiming::Immediate:
         break;
 
+#if HAVE(PASSKIT_RECURRING_SUMMARY_ITEM)
     case ApplePayPaymentTiming::Recurring:
-#if HAVE(PASSKIT_RECURRING_SUMMARY_ITEM)
         return platformRecurringSummaryItem(lineItem);
-#else
-        break;
 #endif
 
+#if HAVE(PASSKIT_DEFERRED_SUMMARY_ITEM)
     case ApplePayPaymentTiming::Deferred:
-#if HAVE(PASSKIT_DEFERRED_SUMMARY_ITEM)
         return platformDeferredSummaryItem(lineItem);
-#else
-        break;
 #endif
+
+#if defined(PaymentSummaryItemsCocoaAdditions_platformSummaryItem)
+    PaymentSummaryItemsCocoaAdditions_platformSummaryItem
+#endif
     }
-#endif
 
     return [PAL::getPKPaymentSummaryItemClass() summaryItemWithLabel:lineItem.label amount:toDecimalNumber(lineItem.amount) type:toPKPaymentSummaryItemType(lineItem.type)];
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to