Diff
Modified: trunk/LayoutTests/ChangeLog (285520 => 285521)
--- trunk/LayoutTests/ChangeLog 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/LayoutTests/ChangeLog 2021-11-09 20:04:19 UTC (rev 285521)
@@ -1,3 +1,16 @@
+2021-11-09 Devin Rousso <drou...@apple.com>
+
+ REGRESSION(r271735): PaymentShippingOption.selected ignored
+ https://bugs.webkit.org/show_bug.cgi?id=221960
+ <rdar://problem/73464404>
+
+ Reviewed by Tim Horton.
+
+ * http/tests/paymentrequest/payment-request-change-shipping-option.https.html:
+ * http/tests/paymentrequest/payment-request-change-shipping-option.https-expected.txt:
+ * http/tests/paymentrequest/updateWith-shippingOptions.https.html:
+ * http/tests/paymentrequest/updateWith-shippingOptions.https-expected.txt:
+
2021-11-09 Rob Buis <rb...@igalia.com>
Import css/css-sizing/aspect-ratio tests from WPT
Modified: trunk/LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https-expected.txt (285520 => 285521)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https-expected.txt 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https-expected.txt 2021-11-09 20:04:19 UTC (rev 285521)
@@ -1,4 +1,4 @@
CONSOLE MESSAGE: WebKit currently uses the first shipping option even if other shipping options are marked as selected.
-PASS Test for PaymentRequest shippingOption attribute
+FAIL Test for PaymentRequest shippingOption attribute assert_equals: Must be 'initially-selected', as the selected member is true expected "initially-selected" but got "valid-1"
Modified: trunk/LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https.html (285520 => 285521)
--- trunk/LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https.html 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https.html 2021-11-09 20:04:19 UTC (rev 285521)
@@ -63,9 +63,11 @@
event.complete({ });
internals.mockPaymentCoordinator.changeShippingOption("valid-1");
};
- // FIXME: <rdar://problem/73464404>
- // assert_equals(request.shippingOption, "initially-selected", "Must be 'initially-selected', as the selected member is true");
- assert_equals(request.shippingOption, "valid-1", "Must be the first shipping option regardless of the selected property.");
+ assert_equals(
+ request.shippingOption,
+ "initially-selected",
+ "Must be 'initially-selected', as the selected member is true"
+ );
const listenerPromise = new Promise(resolve => {
request.addEventListener("shippingoptionchange", () => {
resolve(request.shippingOption);
Modified: trunk/LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https-expected.txt (285520 => 285521)
--- trunk/LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https-expected.txt 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https-expected.txt 2021-11-09 20:04:19 UTC (rev 285521)
@@ -1,5 +1,5 @@
CONSOLE MESSAGE: WebKit currently uses the first shipping option even if other shipping options are marked as selected.
PASS Calling `updateWith` with a new `shippingOptions` without `requestShipping` should not update any values.
-PASS Calling `updateWith` with a new `shippingOptions` should not update any other values.
+FAIL Calling `updateWith` with a new `shippingOptions` should not update any other values. assert_equals: selected shipping option should change expected "shippingId4" but got "shippingId3"
Modified: trunk/LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https.html (285520 => 285521)
--- trunk/LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https.html 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https.html 2021-11-09 20:04:19 UTC (rev 285521)
@@ -93,8 +93,7 @@
assert_equals(internals.mockPaymentCoordinator.shippingMethods[i].label, detailsUpdate.shippingOptions[i].label, `shipping option ${i} label should change`);
assert_equals(internals.mockPaymentCoordinator.shippingMethods[i].amount, detailsUpdate.shippingOptions[i].amount.value, `shipping option ${i} amount should change`);
}
- // FIXME: <rdar://problem/73464404>
- // assert_equals(request.shippingOption, detailsUpdate.shippingOptions.find((shippingOption) => shippingOption.selected).id, "selected shipping option should change");
+ assert_equals(request.shippingOption, detailsUpdate.shippingOptions.findLast((shippingOption) => shippingOption.selected).id, "selected shipping option should change");
assert_equals(request.shippingOption, detailsUpdate.shippingOptions[0].id, "selected shipping option should change");
assert_equals(response.shippingOption, request.shippingOption, "selected shipping option should also be exposed on the response");
Modified: trunk/Source/WTF/ChangeLog (285520 => 285521)
--- trunk/Source/WTF/ChangeLog 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WTF/ChangeLog 2021-11-09 20:04:19 UTC (rev 285521)
@@ -1,3 +1,17 @@
+2021-11-09 Devin Rousso <drou...@apple.com>
+
+ REGRESSION(r271735): PaymentShippingOption.selected ignored
+ https://bugs.webkit.org/show_bug.cgi?id=221960
+ <rdar://problem/73464404>
+
+ Reviewed by Tim Horton.
+
+ Leverage new `PKShippingMethods` SPI to provide both the general list of `PKShippingMethod`
+ and the default selected `PKShippingMethods` when creating/updating a payment request.
+
+ * wtf/PlatformEnableCocoa.h:
+ * wtf/PlatformHave.h:
+
2021-11-08 Myles C. Maxfield <mmaxfi...@apple.com>
Make WebGPU.xcodeproj and WebGPU.framework
Modified: trunk/Source/WTF/wtf/PlatformEnableCocoa.h (285520 => 285521)
--- trunk/Source/WTF/wtf/PlatformEnableCocoa.h 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WTF/wtf/PlatformEnableCocoa.h 2021-11-09 20:04:19 UTC (rev 285521)
@@ -75,6 +75,10 @@
#define ENABLE_APPLE_PAY_NEW_BUTTON_TYPES 1
#endif
+#if !defined(ENABLE_APPLE_PAY_SELECTED_SHIPPING_METHOD) && HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+#define ENABLE_APPLE_PAY_SELECTED_SHIPPING_METHOD 1
+#endif
+
#if !defined(ENABLE_APPLE_PAY_SHIPPING_CONTACT_EDITING_MODE) && HAVE(PASSKIT_SHIPPING_CONTACT_EDITING_MODE)
#define ENABLE_APPLE_PAY_SHIPPING_CONTACT_EDITING_MODE 1
#endif
@@ -446,6 +450,10 @@
#define ENABLE_PAYMENT_REQUEST 1
#endif
+#if !defined(ENABLE_PAYMENT_REQUEST_SELECTED_SHIPPING_OPTION) && HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+#define ENABLE_PAYMENT_REQUEST_SELECTED_SHIPPING_OPTION 1
+#endif
+
#if !defined(ENABLE_PICTURE_IN_PICTURE_API) && !PLATFORM(MACCATALYST) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
#define ENABLE_PICTURE_IN_PICTURE_API 1
#endif
Modified: trunk/Source/WTF/wtf/PlatformHave.h (285520 => 285521)
--- trunk/Source/WTF/wtf/PlatformHave.h 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WTF/wtf/PlatformHave.h 2021-11-09 20:04:19 UTC (rev 285521)
@@ -649,6 +649,10 @@
#define HAVE_PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS 1
#endif
+#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150400)
+#define HAVE_PASSKIT_DEFAULT_SHIPPING_METHOD 1
+#endif
+
#if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV)
#define HAVE_QUICKLOOK_THUMBNAILING 1
#endif
Modified: trunk/Source/WebCore/ChangeLog (285520 => 285521)
--- trunk/Source/WebCore/ChangeLog 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/ChangeLog 2021-11-09 20:04:19 UTC (rev 285521)
@@ -1,3 +1,26 @@
+2021-11-09 Devin Rousso <drou...@apple.com>
+
+ REGRESSION(r271735): PaymentShippingOption.selected ignored
+ https://bugs.webkit.org/show_bug.cgi?id=221960
+ <rdar://problem/73464404>
+
+ Reviewed by Tim Horton.
+
+ Leverage new `PKShippingMethods` SPI to provide both the general list of `PKShippingMethod`
+ and the default selected `PKShippingMethods` when creating/updating a payment request.
+
+ * Modules/applepay/ApplePayShippingMethod.idl:
+ * Modules/applepay/ApplePayShippingMethod.h:
+ (WebCore::ApplePayShippingMethod::encode const):
+ (WebCore::ApplePayShippingMethod::decode):
+ Add new `selected` boolean property.
+
+ * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp:
+ (WebCore::ApplePayPaymentHandler::computeShippingMethods const):
+
+ * Modules/paymentrequest/PaymentRequest.cpp:
+ (WebCore::checkAndCanonicalizeDetails):
+
2021-11-09 Sihui Liu <sihui_...@apple.com>
Keep track of captured data time in SpeechRecognizer
Modified: trunk/Source/WebCore/Modules/applepay/ApplePayShippingMethod.h (285520 => 285521)
--- trunk/Source/WebCore/Modules/applepay/ApplePayShippingMethod.h 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayShippingMethod.h 2021-11-09 20:04:19 UTC (rev 285521)
@@ -43,6 +43,10 @@
std::optional<ApplePayDateComponentsRange> dateComponentsRange;
#endif
+#if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD)
+ bool selected { false };
+#endif
+
template<class Encoder> void encode(Encoder&) const;
template<class Decoder> static std::optional<ApplePayShippingMethod> decode(Decoder&);
};
@@ -57,6 +61,9 @@
#if ENABLE(APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
encoder << dateComponentsRange;
#endif
+#if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD)
+ encoder << selected;
+#endif
}
template<class Decoder>
@@ -75,6 +82,9 @@
#if ENABLE(APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
DECODE(dateComponentsRange, std::optional<ApplePayDateComponentsRange>)
#endif
+#if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD)
+ DECODE(selected, bool)
+#endif
#undef DECODE
@@ -86,6 +96,9 @@
#if ENABLE(APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
WTFMove(*dateComponentsRange),
#endif
+#if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD)
+ WTFMove(*selected),
+#endif
} };
}
Modified: trunk/Source/WebCore/Modules/applepay/ApplePayShippingMethod.idl (285520 => 285521)
--- trunk/Source/WebCore/Modules/applepay/ApplePayShippingMethod.idl 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/Modules/applepay/ApplePayShippingMethod.idl 2021-11-09 20:04:19 UTC (rev 285521)
@@ -34,4 +34,6 @@
required DOMString identifier;
[Conditional=APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE] ApplePayDateComponentsRange dateComponentsRange;
+
+ [Conditional=APPLE_PAY_SELECTED_SHIPPING_METHOD] boolean selected = false;
};
Modified: trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (285520 => 285521)
--- trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp 2021-11-09 20:04:19 UTC (rev 285521)
@@ -299,10 +299,18 @@
shippingOptions.reserveInitialCapacity(details.shippingOptions->size());
for (auto& shippingOption : *details.shippingOptions) {
- auto shippingMethod = convertAndValidate(shippingOption, currency);
- if (shippingMethod.hasException())
- return shippingMethod.releaseException();
- shippingOptions.uncheckedAppend(shippingMethod.releaseReturnValue());
+ auto shippingMethodOrException = convertAndValidate(shippingOption, currency);
+ if (shippingMethodOrException.hasException())
+ return shippingMethodOrException.releaseException();
+
+ auto shippingMethod = shippingMethodOrException.releaseReturnValue();
+
+#if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD)
+ if (shippingMethod.identifier == m_paymentRequest->shippingOption())
+ shippingMethod.selected = true;
+#endif
+
+ shippingOptions.uncheckedAppend(WTFMove(shippingMethod));
}
}
Modified: trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (285520 => 285521)
--- trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp 2021-11-09 20:04:19 UTC (rev 285521)
@@ -218,7 +218,12 @@
if (!addResult.isNewEntry)
return Exception { TypeError, "Shipping option IDs must be unique." };
- // FIXME: <rdar://problem/73464404>
+#if ENABLE(PAYMENT_REQUEST_SELECTED_SHIPPING_OPTION)
+ if (shippingOption.selected)
+ selectedShippingOption = shippingOption.id;
+ UNUSED_PARAM(context);
+ UNUSED_VARIABLE(didLog);
+#else
if (!selectedShippingOption)
selectedShippingOption = shippingOption.id;
else if (!didLog && shippingOption.selected) {
@@ -225,6 +230,7 @@
context.addConsoleMessage(JSC::MessageSource::PaymentRequest, JSC::MessageLevel::Warning, "WebKit currently uses the first shipping option even if other shipping options are marked as selected."_s);
didLog = true;
}
+#endif
}
} else if (isUpdate == IsUpdate::No)
details.shippingOptions = { { } };
Modified: trunk/Source/WebCore/PAL/ChangeLog (285520 => 285521)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-11-09 20:04:19 UTC (rev 285521)
@@ -1,3 +1,18 @@
+2021-11-09 Devin Rousso <drou...@apple.com>
+
+ REGRESSION(r271735): PaymentShippingOption.selected ignored
+ https://bugs.webkit.org/show_bug.cgi?id=221960
+ <rdar://problem/73464404>
+
+ Reviewed by Tim Horton.
+
+ Leverage new `PKShippingMethods` SPI to provide both the general list of `PKShippingMethod`
+ and the default selected `PKShippingMethods` when creating/updating a payment request.
+
+ * pal/cocoa/PassKitSoftLink.h:
+ * pal/cocoa/PassKitSoftLink.mm:
+ * pal/spi/cocoa/PassKitSPI.h:
+
2021-11-09 Commit Queue <commit-qu...@webkit.org>
Unreviewed, reverting r285318.
Modified: trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.h (285520 => 285521)
--- trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.h 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.h 2021-11-09 20:04:19 UTC (rev 285521)
@@ -60,6 +60,10 @@
SOFT_LINK_CLASS_FOR_HEADER(PAL, PKDeferredPaymentSummaryItem)
#endif
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+SOFT_LINK_CLASS_FOR_HEADER(PAL, PKShippingMethods)
+#endif
+
#if HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
SOFT_LINK_CLASS_FOR_HEADER(PAL, PKDateComponentsRange)
#endif
Modified: trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.mm (285520 => 285521)
--- trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.mm 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.mm 2021-11-09 20:04:19 UTC (rev 285521)
@@ -64,6 +64,10 @@
SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKDeferredPaymentSummaryItem, PAL_EXPORT)
#endif
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKShippingMethods, PAL_EXPORT)
+#endif
+
#if HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKDateComponentsRange, PAL_EXPORT)
#endif
Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h (285520 => 285521)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h 2021-11-09 20:04:19 UTC (rev 285521)
@@ -71,6 +71,10 @@
#import <PassKitCore/PKRecurringPaymentSummaryItem.h>
#endif
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+#import <PassKitCore/PKShippingMethods.h>
+#endif
+
#if HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
#import <PassKitCore/PKDateComponentsRange.h>
#endif
@@ -258,6 +262,12 @@
@end
#endif
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+@interface PKShippingMethods : NSObject
+- (instancetype)initWithMethods:(NSArray<PKShippingMethod *> *)methods defaultMethod:(nullable PKShippingMethod *)defaultMethod;
+@end
+#endif
+
#if HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
@interface PKDateComponentsRange : NSObject <NSCopying, NSSecureCoding>
- (nullable instancetype)initWithStartDateComponents:(NSDateComponents *)startDateComponents endDateComponents:(NSDateComponents *)endDateComponents;
@@ -304,6 +314,10 @@
@property (nonatomic, copy, nullable) NSString *couponCode;
#endif
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+@property (nonatomic, copy) PKShippingMethods *availableShippingMethods;
+#endif
+
#if HAVE(PASSKIT_SHIPPING_CONTACT_EDITING_MODE)
@property (nonatomic, assign) PKShippingContactEditingMode shippingContactEditingMode;
#endif
@@ -459,16 +473,18 @@
#if HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS)
@property (nonatomic, copy) NSArray<PKShippingMethod *> *shippingMethods;
#endif
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+@property (nonatomic, copy) PKShippingMethods *availableShippingMethods;
+#endif
@end
@interface PKPaymentRequestPaymentMethodUpdate : PKPaymentRequestUpdate
-- (instancetype)initWithErrors:(nullable NSArray<NSError *> *)errors paymentSummaryItems:(nonnull NSArray<PKPaymentSummaryItem *> *)summaryItems;
@property (null_resettable, nonatomic, copy) NSArray<NSError *> *errors;
@end
@interface PKPaymentRequestShippingContactUpdate : PKPaymentRequestUpdate
-- (instancetype)initWithErrors:(nullable NSArray<NSError *> *)errors paymentSummaryItems:(nonnull NSArray<PKPaymentSummaryItem *> *)summaryItems shippingMethods:(nonnull NSArray<PKShippingMethod *> *)shippingMethods;
@property (nonatomic, copy) NSArray<PKShippingMethod *> *shippingMethods;
+@property (nonatomic, copy, null_resettable) NSArray<NSError *> *errors;
@end
@interface PKPaymentRequestShippingMethodUpdate : PKPaymentRequestUpdate
@@ -476,7 +492,7 @@
#if HAVE(PASSKIT_COUPON_CODE)
@interface PKPaymentRequestCouponCodeUpdate : PKPaymentRequestUpdate
-- (instancetype)initWithErrors:(nullable NSArray<NSError *> *)errors paymentSummaryItems:(NSArray<PKPaymentSummaryItem *> *)paymentSummaryItems shippingMethods:(NSArray<PKShippingMethod *> *)shippingMethods;
+@property (nonatomic, copy, null_resettable) NSArray<NSError *> *errors;
@end
#endif
Modified: trunk/Source/WebKit/ChangeLog (285520 => 285521)
--- trunk/Source/WebKit/ChangeLog 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebKit/ChangeLog 2021-11-09 20:04:19 UTC (rev 285521)
@@ -1,3 +1,39 @@
+2021-11-09 Devin Rousso <drou...@apple.com>
+
+ REGRESSION(r271735): PaymentShippingOption.selected ignored
+ https://bugs.webkit.org/show_bug.cgi?id=221960
+ <rdar://problem/73464404>
+
+ Reviewed by Tim Horton.
+
+ Leverage new `PKShippingMethods` SPI to provide both the general list of `PKShippingMethod`
+ and the default selected `PKShippingMethods` when creating/updating a payment request.
+
+ * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h:
+ * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm:
+ (WebKit::toPKShippingMethods): Added.
+ (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest):
+ Add new helper to generate the `PKShippingMethods` from WebCore objects.
+
+ * Platform/cocoa/PaymentAuthorizationPresenter.mm:
+ (WebKit::PaymentAuthorizationPresenter::completePaymentMethodSelection):
+ (WebKit::PaymentAuthorizationPresenter::completeShippingContactSelection):
+ (WebKit::PaymentAuthorizationPresenter::completeShippingMethodSelection):
+ (WebKit::PaymentAuthorizationPresenter::completeCouponCodeChange):
+ (WebKit::toPKShippingMethods): Deleted.
+
+ * Platform/cocoa/WKPaymentAuthorizationDelegate.mm:
+ (-[WKPaymentAuthorizationDelegate completePaymentMethodSelection:]):
+ (-[WKPaymentAuthorizationDelegate completeShippingContactSelection:]):
+ (-[WKPaymentAuthorizationDelegate completeShippingMethodSelection:]):
+ (-[WKPaymentAuthorizationDelegate completeCouponCodeChange:]):
+ (-[WKPaymentAuthorizationDelegate _initWithRequest:presenter:]):
+ (toShippingMethod):
+ (-[WKPaymentAuthorizationDelegate _didSelectShippingMethod:completion:]):
+ (-[WKPaymentAuthorizationDelegate summaryItems]): Deleted.
+ (-[WKPaymentAuthorizationDelegate shippingMethods]): Deleted.
+ Drive-by: Delete unused methods.
+
2021-11-09 Sihui Liu <sihui_...@apple.com>
Keep track of captured data time in SpeechRecognizer
Modified: trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.mm (285520 => 285521)
--- trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.mm 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.mm 2021-11-09 20:04:19 UTC (rev 285521)
@@ -195,13 +195,6 @@
});
}
-static RetainPtr<NSArray> toPKShippingMethods(const Vector<WebCore::ApplePayShippingMethod>& shippingMethods)
-{
- return createNSArray(shippingMethods, [] (auto& method) {
- return toPKShippingMethod(method);
- });
-}
-
void PaymentAuthorizationPresenter::completeMerchantValidation(const WebCore::PaymentMerchantSession& merchantSession)
{
ASSERT(platformDelegate());
@@ -223,8 +216,14 @@
auto paymentMethodUpdate = adoptNS([PAL::allocPKPaymentRequestPaymentMethodUpdateInstance() initWithPaymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems))]);
#if HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS)
[paymentMethodUpdate setErrors:toNSErrors(WTFMove(update->errors)).get()];
- [paymentMethodUpdate setShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods)).get()];
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [paymentMethodUpdate setAvailableShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods))];
+#else
+ [paymentMethodUpdate setShippingMethods:createNSArray(WTFMove(update->newShippingMethods), [] (auto& method) {
+ return toPKShippingMethod(method);
+ }).get()];
#endif
+#endif
#if HAVE(PASSKIT_INSTALLMENTS) && ENABLE(APPLE_PAY_INSTALLMENTS)
[paymentMethodUpdate setInstallmentGroupIdentifier:WTFMove(update->installmentGroupIdentifier)];
#endif // HAVE(PASSKIT_INSTALLMENTS) && ENABLE(APPLE_PAY_INSTALLMENTS)
@@ -248,9 +247,15 @@
return;
}
- auto shippingContactUpdate = adoptNS([PAL::allocPKPaymentRequestShippingContactUpdateInstance() initWithErrors:toNSErrors(WTFMove(update->errors)).get()
- paymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems))
- shippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods)).get()]);
+ auto shippingContactUpdate = adoptNS([PAL::allocPKPaymentRequestShippingContactUpdateInstance() initWithPaymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems))]);
+ [shippingContactUpdate setErrors:toNSErrors(WTFMove(update->errors)).get()];
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [shippingContactUpdate setAvailableShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods))];
+#else
+ [shippingContactUpdate setShippingMethods:createNSArray(WTFMove(update->newShippingMethods), [] (auto& method) {
+ return toPKShippingMethod(method);
+ }).get()];
+#endif
merge(shippingContactUpdate.get(), *update);
[platformDelegate() completeShippingContactSelection:shippingContactUpdate.get()];
}
@@ -264,8 +269,12 @@
}
auto shippingMethodUpdate = adoptNS([PAL::allocPKPaymentRequestShippingMethodUpdateInstance() initWithPaymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems))]);
-#if HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS)
- [shippingMethodUpdate setShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods)).get()];
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [shippingMethodUpdate setAvailableShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods))];
+#elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS)
+ [shippingMethodUpdate setShippingMethods:createNSArray(WTFMove(update->newShippingMethods), [] (auto& method) {
+ return toPKShippingMethod(method);
+ }).get()];
#endif
merge(shippingMethodUpdate.get(), *update);
[platformDelegate() completeShippingMethodSelection:shippingMethodUpdate.get()];
@@ -281,7 +290,14 @@
return;
}
- auto couponCodeUpdate = adoptNS([PAL::allocPKPaymentRequestCouponCodeUpdateInstance() initWithErrors:toNSErrors(WTFMove(update->errors)).get() paymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems)) shippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods)).get()]);
+ auto couponCodeUpdate = adoptNS([PAL::allocPKPaymentRequestCouponCodeUpdateInstance() initWithPaymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems))]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [couponCodeUpdate setAvailableShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods))];
+#else
+ [couponCodeUpdate setShippingMethods:createNSArray(WTFMove(update->newShippingMethods), [] (auto& method) {
+ return toPKShippingMethod(method);
+ }).get()];
+#endif
merge(couponCodeUpdate.get(), *update);
[platformDelegate() completeCouponCodeChange:couponCodeUpdate.get()];
}
Modified: trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm (285520 => 285521)
--- trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm 2021-11-09 20:04:19 UTC (rev 285521)
@@ -35,7 +35,11 @@
@implementation WKPaymentAuthorizationDelegate {
RetainPtr<NSArray<PKPaymentSummaryItem *>> _summaryItems;
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ RetainPtr<PKShippingMethods> _availableShippingMethods;
+#else
RetainPtr<NSArray<PKShippingMethod *>> _shippingMethods;
+#endif
RetainPtr<NSError> _sessionError;
WebKit::DidAuthorizePaymentCompletion _didAuthorizePaymentCompletion;
WebKit::DidRequestMerchantSessionCompletion _didRequestMerchantSessionCompletion;
@@ -47,16 +51,6 @@
#endif
}
-- (NSArray<PKPaymentSummaryItem *> *)summaryItems
-{
- return _summaryItems.get();
-}
-
-- (NSArray<PKShippingMethod *> *)shippingMethods
-{
- return _shippingMethods.get();
-}
-
- (void)completeMerchantValidation:(PKPaymentMerchantSession *)session error:(NSError *)error
{
std::exchange(_didRequestMerchantSessionCompletion, nil)(session, error);
@@ -64,8 +58,23 @@
- (void)completePaymentMethodSelection:(PKPaymentRequestPaymentMethodUpdate *)paymentMethodUpdate
{
- auto update = paymentMethodUpdate ? retainPtr(paymentMethodUpdate) : adoptNS([PAL::allocPKPaymentRequestPaymentMethodUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]);
- _summaryItems = adoptNS([[update paymentSummaryItems] copy]);
+ RetainPtr update = paymentMethodUpdate;
+ if (update) {
+ _summaryItems = adoptNS([[update paymentSummaryItems] copy]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ _availableShippingMethods = adoptNS([[update availableShippingMethods] copy]);
+#elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS)
+ _shippingMethods = adoptNS([[update shippingMethods] copy]);
+#endif
+ } else {
+ update = adoptNS([PAL::allocPKPaymentRequestPaymentMethodUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [update setAvailableShippingMethods:_availableShippingMethods.get()];
+#elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS)
+ [update setShippingMethods:_shippingMethods.get()];
+#endif
+ }
+
std::exchange(_didSelectPaymentMethodCompletion, nil)(update.get());
}
@@ -76,16 +85,45 @@
}
- (void)completeShippingContactSelection:(PKPaymentRequestShippingContactUpdate *)shippingContactUpdate
{
- auto update = shippingContactUpdate ? retainPtr(shippingContactUpdate) : adoptNS([PAL::allocPKPaymentRequestShippingContactUpdateInstance() initWithErrors:@[] paymentSummaryItems:_summaryItems.get() shippingMethods:_shippingMethods.get()]);
- _summaryItems = adoptNS([[update paymentSummaryItems] copy]);
- _shippingMethods = adoptNS([[update shippingMethods] copy]);
+ RetainPtr update = shippingContactUpdate;
+ if (update) {
+ _summaryItems = adoptNS([[update paymentSummaryItems] copy]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ _availableShippingMethods = adoptNS([[update availableShippingMethods] copy]);
+#else
+ _shippingMethods = adoptNS([[update shippingMethods] copy]);
+#endif
+ } else {
+ update = adoptNS([PAL::allocPKPaymentRequestShippingContactUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [update setAvailableShippingMethods:_availableShippingMethods.get()];
+#else
+ [update setShippingMethods:_shippingMethods.get()];
+#endif
+ }
+
std::exchange(_didSelectShippingContactCompletion, nil)(update.get());
}
- (void)completeShippingMethodSelection:(PKPaymentRequestShippingMethodUpdate *)shippingMethodUpdate
{
- auto update = shippingMethodUpdate ? retainPtr(shippingMethodUpdate) : adoptNS([PAL::allocPKPaymentRequestShippingMethodUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]);
- _summaryItems = adoptNS([[update paymentSummaryItems] copy]);
+ RetainPtr update = shippingMethodUpdate;
+ if (update) {
+ _summaryItems = adoptNS([[update paymentSummaryItems] copy]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ _availableShippingMethods = adoptNS([[update availableShippingMethods] copy]);
+#elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS)
+ _shippingMethods = adoptNS([[update shippingMethods] copy]);
+#endif
+ } else {
+ update = adoptNS([PAL::allocPKPaymentRequestShippingMethodUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [update setAvailableShippingMethods:_availableShippingMethods.get()];
+#elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS)
+ [update setShippingMethods:_shippingMethods.get()];
+#endif
+ }
+
std::exchange(_didSelectShippingMethodCompletion, nil)(update.get());
}
@@ -93,10 +131,24 @@
- (void)completeCouponCodeChange:(PKPaymentRequestCouponCodeUpdate *)couponCodeUpdate
{
- PKPaymentRequestCouponCodeUpdate *update = couponCodeUpdate ?: adoptNS([PAL::allocPKPaymentRequestCouponCodeUpdateInstance() initWithErrors:@[] paymentSummaryItems:_summaryItems.get() shippingMethods:_shippingMethods.get()]).autorelease();
- _summaryItems = adoptNS([update.paymentSummaryItems copy]);
- _shippingMethods = adoptNS([update.shippingMethods copy]);
- std::exchange(_didChangeCouponCodeCompletion, nil)(update);
+ RetainPtr update = couponCodeUpdate;
+ if (update) {
+ _summaryItems = adoptNS([[update paymentSummaryItems] copy]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ _availableShippingMethods = adoptNS([[update availableShippingMethods] copy]);
+#else
+ _shippingMethods = adoptNS([[update shippingMethods] copy]);
+#endif
+ } else {
+ update = adoptNS([PAL::allocPKPaymentRequestCouponCodeUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [update setAvailableShippingMethods:_availableShippingMethods.get()];
+#else
+ [update setShippingMethods:_shippingMethods.get()];
+#endif
+ }
+
+ std::exchange(_didChangeCouponCodeCompletion, nil)(update.get());
}
#endif // HAVE(PASSKIT_COUPON_CODE)
@@ -118,7 +170,11 @@
_presenter = presenter;
_request = request;
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ _availableShippingMethods = request.availableShippingMethods;
+#else
_shippingMethods = request.shippingMethods;
+#endif
_summaryItems = request.paymentSummaryItems;
return self;
}
@@ -214,7 +270,7 @@
#endif // HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE)
-static WebCore::ApplePayShippingMethod toShippingMethod(PKShippingMethod *shippingMethod)
+static WebCore::ApplePayShippingMethod toShippingMethod(PKShippingMethod *shippingMethod, bool selected)
{
ASSERT(shippingMethod);
@@ -227,6 +283,11 @@
if (shippingMethod.dateComponentsRange)
result.dateComponentsRange = toDateComponentsRange(shippingMethod.dateComponentsRange);
#endif
+#if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD)
+ result.selected = selected;
+#else
+ UNUSED_PARAM(selected);
+#endif
return result;
}
@@ -239,7 +300,7 @@
if (!presenter)
return [self completeShippingMethodSelection:nil];
- presenter->client().presenterDidSelectShippingMethod(*presenter, toShippingMethod(shippingMethod));
+ presenter->client().presenterDidSelectShippingMethod(*presenter, toShippingMethod(shippingMethod, true));
}
#if HAVE(PASSKIT_COUPON_CODE)
Modified: trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h (285520 => 285521)
--- trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h 2021-11-09 20:04:19 UTC (rev 285521)
@@ -28,6 +28,7 @@
#if ENABLE(APPLE_PAY)
OBJC_CLASS PKShippingMethod;
+OBJC_CLASS PKShippingMethods;
namespace WebCore {
struct ApplePayShippingMethod;
@@ -39,6 +40,9 @@
// how to convert themselves to and from their platform representations.
NSDecimalNumber *toDecimalNumber(const String& amount);
PKShippingMethod *toPKShippingMethod(const WebCore::ApplePayShippingMethod&);
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+PKShippingMethods *toPKShippingMethods(const Vector<WebCore::ApplePayShippingMethod>&);
+#endif
} // namespace WebKit
Modified: trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (285520 => 285521)
--- trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2021-11-09 19:50:56 UTC (rev 285520)
+++ trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm 2021-11-09 20:04:19 UTC (rev 285521)
@@ -201,6 +201,22 @@
return result;
}
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+
+PKShippingMethods *toPKShippingMethods(const Vector<WebCore::ApplePayShippingMethod>& webShippingMethods)
+{
+ RetainPtr<PKShippingMethod> defaultMethod;
+ auto methods = createNSArray(webShippingMethods, [&defaultMethod] (const auto& webShippingMethod) {
+ auto pkShippingMethod = toPKShippingMethod(webShippingMethod);
+ if (webShippingMethod.selected)
+ defaultMethod = pkShippingMethod;
+ return pkShippingMethod;
+ });
+ return [PAL::allocPKShippingMethodsInstance() initWithMethods:methods.get() defaultMethod:defaultMethod.get()];
+}
+
+#endif // HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+
#if HAVE(PASSKIT_SHIPPING_CONTACT_EDITING_MODE)
static PKShippingContactEditingMode toPKShippingContactEditingMode(WebCore::ApplePayShippingContactEditingMode shippingContactEditingMode)
@@ -267,9 +283,13 @@
[result setShippingType:toPKShippingType(paymentRequest.shippingType())];
+#if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD)
+ [result setAvailableShippingMethods:toPKShippingMethods(paymentRequest.shippingMethods())];
+#else
[result setShippingMethods:createNSArray(paymentRequest.shippingMethods(), [] (auto& method) {
return toPKShippingMethod(method);
}).get()];
+#endif
[result setPaymentSummaryItems:WebCore::platformSummaryItems(paymentRequest.total(), paymentRequest.lineItems())];