Changeset 285521 in webkit
- Timestamp:
- Nov 9, 2021, 12:04:19 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 22 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https-expected.txt (modified) (1 diff)
-
LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https.html (modified) (1 diff)
-
LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https-expected.txt (modified) (1 diff)
-
LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https.html (modified) (1 diff)
-
Source/WTF/ChangeLog (modified) (1 diff)
-
Source/WTF/wtf/PlatformEnableCocoa.h (modified) (2 diffs)
-
Source/WTF/wtf/PlatformHave.h (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/Modules/applepay/ApplePayShippingMethod.h (modified) (4 diffs)
-
Source/WebCore/Modules/applepay/ApplePayShippingMethod.idl (modified) (1 diff)
-
Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp (modified) (1 diff)
-
Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp (modified) (2 diffs)
-
Source/WebCore/PAL/ChangeLog (modified) (1 diff)
-
Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.h (modified) (1 diff)
-
Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.mm (modified) (1 diff)
-
Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h (modified) (5 diffs)
-
Source/WebKit/ChangeLog (modified) (1 diff)
-
Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.mm (modified) (5 diffs)
-
Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm (modified) (10 diffs)
-
Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h (modified) (2 diffs)
-
Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r285505 r285521 1 2021-11-09 Devin Rousso <drousso@apple.com> 2 3 REGRESSION(r271735): PaymentShippingOption.selected ignored 4 https://bugs.webkit.org/show_bug.cgi?id=221960 5 <rdar://problem/73464404> 6 7 Reviewed by Tim Horton. 8 9 * http/tests/paymentrequest/payment-request-change-shipping-option.https.html: 10 * http/tests/paymentrequest/payment-request-change-shipping-option.https-expected.txt: 11 * http/tests/paymentrequest/updateWith-shippingOptions.https.html: 12 * http/tests/paymentrequest/updateWith-shippingOptions.https-expected.txt: 13 1 14 2021-11-09 Rob Buis <rbuis@igalia.com> 2 15 -
trunk/LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https-expected.txt
r271735 r285521 1 1 CONSOLE MESSAGE: WebKit currently uses the first shipping option even if other shipping options are marked as selected. 2 2 3 PASS Test for PaymentRequest shippingOption attribute 3 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" 4 4 -
trunk/LayoutTests/http/tests/paymentrequest/payment-request-change-shipping-option.https.html
r273562 r285521 64 64 internals.mockPaymentCoordinator.changeShippingOption("valid-1"); 65 65 }; 66 // FIXME: <rdar://problem/73464404> 67 // assert_equals(request.shippingOption, "initially-selected", "Must be 'initially-selected', as the selected member is true"); 68 assert_equals(request.shippingOption, "valid-1", "Must be the first shipping option regardless of the selected property."); 66 assert_equals( 67 request.shippingOption, 68 "initially-selected", 69 "Must be 'initially-selected', as the selected member is true" 70 ); 69 71 const listenerPromise = new Promise(resolve => { 70 72 request.addEventListener("shippingoptionchange", () => { -
trunk/LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https-expected.txt
r271735 r285521 2 2 3 3 PASS Calling `updateWith` with a new `shippingOptions` without `requestShipping` should not update any values. 4 PASS Calling `updateWith` with a new `shippingOptions` should not update any other values. 4 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" 5 5 -
trunk/LayoutTests/http/tests/paymentrequest/updateWith-shippingOptions.https.html
r274012 r285521 94 94 assert_equals(internals.mockPaymentCoordinator.shippingMethods[i].amount, detailsUpdate.shippingOptions[i].amount.value, `shipping option ${i} amount should change`); 95 95 } 96 // FIXME: <rdar://problem/73464404> 97 // assert_equals(request.shippingOption, detailsUpdate.shippingOptions.find((shippingOption) => shippingOption.selected).id, "selected shipping option should change"); 96 assert_equals(request.shippingOption, detailsUpdate.shippingOptions.findLast((shippingOption) => shippingOption.selected).id, "selected shipping option should change"); 98 97 assert_equals(request.shippingOption, detailsUpdate.shippingOptions[0].id, "selected shipping option should change"); 99 98 assert_equals(response.shippingOption, request.shippingOption, "selected shipping option should also be exposed on the response"); -
trunk/Source/WTF/ChangeLog
r285480 r285521 1 2021-11-09 Devin Rousso <drousso@apple.com> 2 3 REGRESSION(r271735): PaymentShippingOption.selected ignored 4 https://bugs.webkit.org/show_bug.cgi?id=221960 5 <rdar://problem/73464404> 6 7 Reviewed by Tim Horton. 8 9 Leverage new `PKShippingMethods` SPI to provide both the general list of `PKShippingMethod` 10 and the default selected `PKShippingMethods` when creating/updating a payment request. 11 12 * wtf/PlatformEnableCocoa.h: 13 * wtf/PlatformHave.h: 14 1 15 2021-11-08 Myles C. Maxfield <mmaxfield@apple.com> 2 16 -
trunk/Source/WTF/wtf/PlatformEnableCocoa.h
r285242 r285521 76 76 #endif 77 77 78 #if !defined(ENABLE_APPLE_PAY_SELECTED_SHIPPING_METHOD) && HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 79 #define ENABLE_APPLE_PAY_SELECTED_SHIPPING_METHOD 1 80 #endif 81 78 82 #if !defined(ENABLE_APPLE_PAY_SHIPPING_CONTACT_EDITING_MODE) && HAVE(PASSKIT_SHIPPING_CONTACT_EDITING_MODE) 79 83 #define ENABLE_APPLE_PAY_SHIPPING_CONTACT_EDITING_MODE 1 … … 447 451 #endif 448 452 453 #if !defined(ENABLE_PAYMENT_REQUEST_SELECTED_SHIPPING_OPTION) && HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 454 #define ENABLE_PAYMENT_REQUEST_SELECTED_SHIPPING_OPTION 1 455 #endif 456 449 457 #if !defined(ENABLE_PICTURE_IN_PICTURE_API) && !PLATFORM(MACCATALYST) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) 450 458 #define ENABLE_PICTURE_IN_PICTURE_API 1 -
trunk/Source/WTF/wtf/PlatformHave.h
r285019 r285521 650 650 #endif 651 651 652 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120400) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 150400) 653 #define HAVE_PASSKIT_DEFAULT_SHIPPING_METHOD 1 654 #endif 655 652 656 #if PLATFORM(COCOA) && !PLATFORM(WATCHOS) && !PLATFORM(APPLETV) 653 657 #define HAVE_QUICKLOOK_THUMBNAILING 1 -
trunk/Source/WebCore/ChangeLog
r285520 r285521 1 2021-11-09 Devin Rousso <drousso@apple.com> 2 3 REGRESSION(r271735): PaymentShippingOption.selected ignored 4 https://bugs.webkit.org/show_bug.cgi?id=221960 5 <rdar://problem/73464404> 6 7 Reviewed by Tim Horton. 8 9 Leverage new `PKShippingMethods` SPI to provide both the general list of `PKShippingMethod` 10 and the default selected `PKShippingMethods` when creating/updating a payment request. 11 12 * Modules/applepay/ApplePayShippingMethod.idl: 13 * Modules/applepay/ApplePayShippingMethod.h: 14 (WebCore::ApplePayShippingMethod::encode const): 15 (WebCore::ApplePayShippingMethod::decode): 16 Add new `selected` boolean property. 17 18 * Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp: 19 (WebCore::ApplePayPaymentHandler::computeShippingMethods const): 20 21 * Modules/paymentrequest/PaymentRequest.cpp: 22 (WebCore::checkAndCanonicalizeDetails): 23 1 24 2021-11-09 Sihui Liu <sihui_liu@apple.com> 2 25 -
trunk/Source/WebCore/Modules/applepay/ApplePayShippingMethod.h
r278630 r285521 44 44 #endif 45 45 46 #if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD) 47 bool selected { false }; 48 #endif 49 46 50 template<class Encoder> void encode(Encoder&) const; 47 51 template<class Decoder> static std::optional<ApplePayShippingMethod> decode(Decoder&); … … 57 61 #if ENABLE(APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE) 58 62 encoder << dateComponentsRange; 63 #endif 64 #if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD) 65 encoder << selected; 59 66 #endif 60 67 } … … 76 83 DECODE(dateComponentsRange, std::optional<ApplePayDateComponentsRange>) 77 84 #endif 85 #if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD) 86 DECODE(selected, bool) 87 #endif 78 88 79 89 #undef DECODE … … 87 97 WTFMove(*dateComponentsRange), 88 98 #endif 99 #if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD) 100 WTFMove(*selected), 101 #endif 89 102 } }; 90 103 } -
trunk/Source/WebCore/Modules/applepay/ApplePayShippingMethod.idl
r278630 r285521 35 35 36 36 [Conditional=APPLE_PAY_SHIPPING_METHOD_DATE_COMPONENTS_RANGE] ApplePayDateComponentsRange dateComponentsRange; 37 38 [Conditional=APPLE_PAY_SELECTED_SHIPPING_METHOD] boolean selected = false; 37 39 }; -
trunk/Source/WebCore/Modules/applepay/paymentrequest/ApplePayPaymentHandler.cpp
r285444 r285521 300 300 shippingOptions.reserveInitialCapacity(details.shippingOptions->size()); 301 301 for (auto& shippingOption : *details.shippingOptions) { 302 auto shippingMethod = convertAndValidate(shippingOption, currency); 303 if (shippingMethod.hasException()) 304 return shippingMethod.releaseException(); 305 shippingOptions.uncheckedAppend(shippingMethod.releaseReturnValue()); 302 auto shippingMethodOrException = convertAndValidate(shippingOption, currency); 303 if (shippingMethodOrException.hasException()) 304 return shippingMethodOrException.releaseException(); 305 306 auto shippingMethod = shippingMethodOrException.releaseReturnValue(); 307 308 #if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD) 309 if (shippingMethod.identifier == m_paymentRequest->shippingOption()) 310 shippingMethod.selected = true; 311 #endif 312 313 shippingOptions.uncheckedAppend(WTFMove(shippingMethod)); 306 314 } 307 315 } -
trunk/Source/WebCore/Modules/paymentrequest/PaymentRequest.cpp
r285444 r285521 219 219 return Exception { TypeError, "Shipping option IDs must be unique." }; 220 220 221 // FIXME: <rdar://problem/73464404> 221 #if ENABLE(PAYMENT_REQUEST_SELECTED_SHIPPING_OPTION) 222 if (shippingOption.selected) 223 selectedShippingOption = shippingOption.id; 224 UNUSED_PARAM(context); 225 UNUSED_VARIABLE(didLog); 226 #else 222 227 if (!selectedShippingOption) 223 228 selectedShippingOption = shippingOption.id; … … 226 231 didLog = true; 227 232 } 233 #endif 228 234 } 229 235 } else if (isUpdate == IsUpdate::No) -
trunk/Source/WebCore/PAL/ChangeLog
r285513 r285521 1 2021-11-09 Devin Rousso <drousso@apple.com> 2 3 REGRESSION(r271735): PaymentShippingOption.selected ignored 4 https://bugs.webkit.org/show_bug.cgi?id=221960 5 <rdar://problem/73464404> 6 7 Reviewed by Tim Horton. 8 9 Leverage new `PKShippingMethods` SPI to provide both the general list of `PKShippingMethod` 10 and the default selected `PKShippingMethods` when creating/updating a payment request. 11 12 * pal/cocoa/PassKitSoftLink.h: 13 * pal/cocoa/PassKitSoftLink.mm: 14 * pal/spi/cocoa/PassKitSPI.h: 15 1 16 2021-11-09 Commit Queue <commit-queue@webkit.org> 2 17 -
trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.h
r278630 r285521 61 61 #endif 62 62 63 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 64 SOFT_LINK_CLASS_FOR_HEADER(PAL, PKShippingMethods) 65 #endif 66 63 67 #if HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE) 64 68 SOFT_LINK_CLASS_FOR_HEADER(PAL, PKDateComponentsRange) -
trunk/Source/WebCore/PAL/pal/cocoa/PassKitSoftLink.mm
r278630 r285521 65 65 #endif 66 66 67 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 68 SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKShippingMethods, PAL_EXPORT) 69 #endif 70 67 71 #if HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE) 68 72 SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, PassKit, PKDateComponentsRange, PAL_EXPORT) -
trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h
r283431 r285521 72 72 #endif 73 73 74 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 75 #import <PassKitCore/PKShippingMethods.h> 76 #endif 77 74 78 #if HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE) 75 79 #import <PassKitCore/PKDateComponentsRange.h> … … 256 260 @property (nonatomic, copy) NSString *label; 257 261 @property (nonatomic, copy) NSDecimalNumber *amount; 262 @end 263 #endif 264 265 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 266 @interface PKShippingMethods : NSObject 267 - (instancetype)initWithMethods:(NSArray<PKShippingMethod *> *)methods defaultMethod:(nullable PKShippingMethod *)defaultMethod; 258 268 @end 259 269 #endif … … 305 315 #endif 306 316 317 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 318 @property (nonatomic, copy) PKShippingMethods *availableShippingMethods; 319 #endif 320 307 321 #if HAVE(PASSKIT_SHIPPING_CONTACT_EDITING_MODE) 308 322 @property (nonatomic, assign) PKShippingContactEditingMode shippingContactEditingMode; … … 460 474 @property (nonatomic, copy) NSArray<PKShippingMethod *> *shippingMethods; 461 475 #endif 476 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 477 @property (nonatomic, copy) PKShippingMethods *availableShippingMethods; 478 #endif 462 479 @end 463 480 464 481 @interface PKPaymentRequestPaymentMethodUpdate : PKPaymentRequestUpdate 465 - (instancetype)initWithErrors:(nullable NSArray<NSError *> *)errors paymentSummaryItems:(nonnull NSArray<PKPaymentSummaryItem *> *)summaryItems;466 482 @property (null_resettable, nonatomic, copy) NSArray<NSError *> *errors; 467 483 @end 468 484 469 485 @interface PKPaymentRequestShippingContactUpdate : PKPaymentRequestUpdate 470 - (instancetype)initWithErrors:(nullable NSArray<NSError *> *)errors paymentSummaryItems:(nonnull NSArray<PKPaymentSummaryItem *> *)summaryItems shippingMethods:(nonnull NSArray<PKShippingMethod *> *)shippingMethods;471 486 @property (nonatomic, copy) NSArray<PKShippingMethod *> *shippingMethods; 487 @property (nonatomic, copy, null_resettable) NSArray<NSError *> *errors; 472 488 @end 473 489 … … 477 493 #if HAVE(PASSKIT_COUPON_CODE) 478 494 @interface PKPaymentRequestCouponCodeUpdate : PKPaymentRequestUpdate 479 - (instancetype)initWithErrors:(nullable NSArray<NSError *> *)errors paymentSummaryItems:(NSArray<PKPaymentSummaryItem *> *)paymentSummaryItems shippingMethods:(NSArray<PKShippingMethod *> *)shippingMethods;495 @property (nonatomic, copy, null_resettable) NSArray<NSError *> *errors; 480 496 @end 481 497 #endif -
trunk/Source/WebKit/ChangeLog
r285520 r285521 1 2021-11-09 Devin Rousso <drousso@apple.com> 2 3 REGRESSION(r271735): PaymentShippingOption.selected ignored 4 https://bugs.webkit.org/show_bug.cgi?id=221960 5 <rdar://problem/73464404> 6 7 Reviewed by Tim Horton. 8 9 Leverage new `PKShippingMethods` SPI to provide both the general list of `PKShippingMethod` 10 and the default selected `PKShippingMethods` when creating/updating a payment request. 11 12 * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h: 13 * Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm: 14 (WebKit::toPKShippingMethods): Added. 15 (WebKit::WebPaymentCoordinatorProxy::platformPaymentRequest): 16 Add new helper to generate the `PKShippingMethods` from WebCore objects. 17 18 * Platform/cocoa/PaymentAuthorizationPresenter.mm: 19 (WebKit::PaymentAuthorizationPresenter::completePaymentMethodSelection): 20 (WebKit::PaymentAuthorizationPresenter::completeShippingContactSelection): 21 (WebKit::PaymentAuthorizationPresenter::completeShippingMethodSelection): 22 (WebKit::PaymentAuthorizationPresenter::completeCouponCodeChange): 23 (WebKit::toPKShippingMethods): Deleted. 24 25 * Platform/cocoa/WKPaymentAuthorizationDelegate.mm: 26 (-[WKPaymentAuthorizationDelegate completePaymentMethodSelection:]): 27 (-[WKPaymentAuthorizationDelegate completeShippingContactSelection:]): 28 (-[WKPaymentAuthorizationDelegate completeShippingMethodSelection:]): 29 (-[WKPaymentAuthorizationDelegate completeCouponCodeChange:]): 30 (-[WKPaymentAuthorizationDelegate _initWithRequest:presenter:]): 31 (toShippingMethod): 32 (-[WKPaymentAuthorizationDelegate _didSelectShippingMethod:completion:]): 33 (-[WKPaymentAuthorizationDelegate summaryItems]): Deleted. 34 (-[WKPaymentAuthorizationDelegate shippingMethods]): Deleted. 35 Drive-by: Delete unused methods. 36 1 37 2021-11-09 Sihui Liu <sihui_liu@apple.com> 2 38 -
trunk/Source/WebKit/Platform/cocoa/PaymentAuthorizationPresenter.mm
r282464 r285521 196 196 } 197 197 198 static RetainPtr<NSArray> toPKShippingMethods(const Vector<WebCore::ApplePayShippingMethod>& shippingMethods)199 {200 return createNSArray(shippingMethods, [] (auto& method) {201 return toPKShippingMethod(method);202 });203 }204 205 198 void PaymentAuthorizationPresenter::completeMerchantValidation(const WebCore::PaymentMerchantSession& merchantSession) 206 199 { … … 224 217 #if HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS) 225 218 [paymentMethodUpdate setErrors:toNSErrors(WTFMove(update->errors)).get()]; 226 [paymentMethodUpdate setShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods)).get()]; 219 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 220 [paymentMethodUpdate setAvailableShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods))]; 221 #else 222 [paymentMethodUpdate setShippingMethods:createNSArray(WTFMove(update->newShippingMethods), [] (auto& method) { 223 return toPKShippingMethod(method); 224 }).get()]; 225 #endif 227 226 #endif 228 227 #if HAVE(PASSKIT_INSTALLMENTS) && ENABLE(APPLE_PAY_INSTALLMENTS) … … 249 248 } 250 249 251 auto shippingContactUpdate = adoptNS([PAL::allocPKPaymentRequestShippingContactUpdateInstance() initWithErrors:toNSErrors(WTFMove(update->errors)).get() 252 paymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems)) 253 shippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods)).get()]); 250 auto shippingContactUpdate = adoptNS([PAL::allocPKPaymentRequestShippingContactUpdateInstance() initWithPaymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems))]); 251 [shippingContactUpdate setErrors:toNSErrors(WTFMove(update->errors)).get()]; 252 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 253 [shippingContactUpdate setAvailableShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods))]; 254 #else 255 [shippingContactUpdate setShippingMethods:createNSArray(WTFMove(update->newShippingMethods), [] (auto& method) { 256 return toPKShippingMethod(method); 257 }).get()]; 258 #endif 254 259 merge(shippingContactUpdate.get(), *update); 255 260 [platformDelegate() completeShippingContactSelection:shippingContactUpdate.get()]; … … 265 270 266 271 auto shippingMethodUpdate = adoptNS([PAL::allocPKPaymentRequestShippingMethodUpdateInstance() initWithPaymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems))]); 267 #if HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS) 268 [shippingMethodUpdate setShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods)).get()]; 272 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 273 [shippingMethodUpdate setAvailableShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods))]; 274 #elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS) 275 [shippingMethodUpdate setShippingMethods:createNSArray(WTFMove(update->newShippingMethods), [] (auto& method) { 276 return toPKShippingMethod(method); 277 }).get()]; 269 278 #endif 270 279 merge(shippingMethodUpdate.get(), *update); … … 282 291 } 283 292 284 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()]); 293 auto couponCodeUpdate = adoptNS([PAL::allocPKPaymentRequestCouponCodeUpdateInstance() initWithPaymentSummaryItems:WebCore::platformSummaryItems(WTFMove(update->newTotal), WTFMove(update->newLineItems))]); 294 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 295 [couponCodeUpdate setAvailableShippingMethods:toPKShippingMethods(WTFMove(update->newShippingMethods))]; 296 #else 297 [couponCodeUpdate setShippingMethods:createNSArray(WTFMove(update->newShippingMethods), [] (auto& method) { 298 return toPKShippingMethod(method); 299 }).get()]; 300 #endif 285 301 merge(couponCodeUpdate.get(), *update); 286 302 [platformDelegate() completeCouponCodeChange:couponCodeUpdate.get()]; -
trunk/Source/WebKit/Platform/cocoa/WKPaymentAuthorizationDelegate.mm
r284142 r285521 36 36 @implementation WKPaymentAuthorizationDelegate { 37 37 RetainPtr<NSArray<PKPaymentSummaryItem *>> _summaryItems; 38 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 39 RetainPtr<PKShippingMethods> _availableShippingMethods; 40 #else 38 41 RetainPtr<NSArray<PKShippingMethod *>> _shippingMethods; 42 #endif 39 43 RetainPtr<NSError> _sessionError; 40 44 WebKit::DidAuthorizePaymentCompletion _didAuthorizePaymentCompletion; … … 48 52 } 49 53 50 - (NSArray<PKPaymentSummaryItem *> *)summaryItems51 {52 return _summaryItems.get();53 }54 55 - (NSArray<PKShippingMethod *> *)shippingMethods56 {57 return _shippingMethods.get();58 }59 60 54 - (void)completeMerchantValidation:(PKPaymentMerchantSession *)session error:(NSError *)error 61 55 { … … 65 59 - (void)completePaymentMethodSelection:(PKPaymentRequestPaymentMethodUpdate *)paymentMethodUpdate 66 60 { 67 auto update = paymentMethodUpdate ? retainPtr(paymentMethodUpdate) : adoptNS([PAL::allocPKPaymentRequestPaymentMethodUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]); 68 _summaryItems = adoptNS([[update paymentSummaryItems] copy]); 61 RetainPtr update = paymentMethodUpdate; 62 if (update) { 63 _summaryItems = adoptNS([[update paymentSummaryItems] copy]); 64 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 65 _availableShippingMethods = adoptNS([[update availableShippingMethods] copy]); 66 #elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS) 67 _shippingMethods = adoptNS([[update shippingMethods] copy]); 68 #endif 69 } else { 70 update = adoptNS([PAL::allocPKPaymentRequestPaymentMethodUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]); 71 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 72 [update setAvailableShippingMethods:_availableShippingMethods.get()]; 73 #elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS) 74 [update setShippingMethods:_shippingMethods.get()]; 75 #endif 76 } 77 69 78 std::exchange(_didSelectPaymentMethodCompletion, nil)(update.get()); 70 79 } … … 77 86 - (void)completeShippingContactSelection:(PKPaymentRequestShippingContactUpdate *)shippingContactUpdate 78 87 { 79 auto update = shippingContactUpdate ? retainPtr(shippingContactUpdate) : adoptNS([PAL::allocPKPaymentRequestShippingContactUpdateInstance() initWithErrors:@[] paymentSummaryItems:_summaryItems.get() shippingMethods:_shippingMethods.get()]); 80 _summaryItems = adoptNS([[update paymentSummaryItems] copy]); 81 _shippingMethods = adoptNS([[update shippingMethods] copy]); 88 RetainPtr update = shippingContactUpdate; 89 if (update) { 90 _summaryItems = adoptNS([[update paymentSummaryItems] copy]); 91 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 92 _availableShippingMethods = adoptNS([[update availableShippingMethods] copy]); 93 #else 94 _shippingMethods = adoptNS([[update shippingMethods] copy]); 95 #endif 96 } else { 97 update = adoptNS([PAL::allocPKPaymentRequestShippingContactUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]); 98 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 99 [update setAvailableShippingMethods:_availableShippingMethods.get()]; 100 #else 101 [update setShippingMethods:_shippingMethods.get()]; 102 #endif 103 } 104 82 105 std::exchange(_didSelectShippingContactCompletion, nil)(update.get()); 83 106 } … … 85 108 - (void)completeShippingMethodSelection:(PKPaymentRequestShippingMethodUpdate *)shippingMethodUpdate 86 109 { 87 auto update = shippingMethodUpdate ? retainPtr(shippingMethodUpdate) : adoptNS([PAL::allocPKPaymentRequestShippingMethodUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]); 88 _summaryItems = adoptNS([[update paymentSummaryItems] copy]); 110 RetainPtr update = shippingMethodUpdate; 111 if (update) { 112 _summaryItems = adoptNS([[update paymentSummaryItems] copy]); 113 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 114 _availableShippingMethods = adoptNS([[update availableShippingMethods] copy]); 115 #elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS) 116 _shippingMethods = adoptNS([[update shippingMethods] copy]); 117 #endif 118 } else { 119 update = adoptNS([PAL::allocPKPaymentRequestShippingMethodUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]); 120 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 121 [update setAvailableShippingMethods:_availableShippingMethods.get()]; 122 #elif HAVE(PASSKIT_UPDATE_SHIPPING_METHODS_WHEN_CHANGING_SUMMARY_ITEMS) 123 [update setShippingMethods:_shippingMethods.get()]; 124 #endif 125 } 126 89 127 std::exchange(_didSelectShippingMethodCompletion, nil)(update.get()); 90 128 } … … 94 132 - (void)completeCouponCodeChange:(PKPaymentRequestCouponCodeUpdate *)couponCodeUpdate 95 133 { 96 PKPaymentRequestCouponCodeUpdate *update = couponCodeUpdate ?: adoptNS([PAL::allocPKPaymentRequestCouponCodeUpdateInstance() initWithErrors:@[] paymentSummaryItems:_summaryItems.get() shippingMethods:_shippingMethods.get()]).autorelease(); 97 _summaryItems = adoptNS([update.paymentSummaryItems copy]); 98 _shippingMethods = adoptNS([update.shippingMethods copy]); 99 std::exchange(_didChangeCouponCodeCompletion, nil)(update); 134 RetainPtr update = couponCodeUpdate; 135 if (update) { 136 _summaryItems = adoptNS([[update paymentSummaryItems] copy]); 137 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 138 _availableShippingMethods = adoptNS([[update availableShippingMethods] copy]); 139 #else 140 _shippingMethods = adoptNS([[update shippingMethods] copy]); 141 #endif 142 } else { 143 update = adoptNS([PAL::allocPKPaymentRequestCouponCodeUpdateInstance() initWithPaymentSummaryItems:_summaryItems.get()]); 144 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 145 [update setAvailableShippingMethods:_availableShippingMethods.get()]; 146 #else 147 [update setShippingMethods:_shippingMethods.get()]; 148 #endif 149 } 150 151 std::exchange(_didChangeCouponCodeCompletion, nil)(update.get()); 100 152 } 101 153 … … 119 171 _presenter = presenter; 120 172 _request = request; 173 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 174 _availableShippingMethods = request.availableShippingMethods; 175 #else 121 176 _shippingMethods = request.shippingMethods; 177 #endif 122 178 _summaryItems = request.paymentSummaryItems; 123 179 return self; … … 215 271 #endif // HAVE(PASSKIT_SHIPPING_METHOD_DATE_COMPONENTS_RANGE) 216 272 217 static WebCore::ApplePayShippingMethod toShippingMethod(PKShippingMethod *shippingMethod )273 static WebCore::ApplePayShippingMethod toShippingMethod(PKShippingMethod *shippingMethod, bool selected) 218 274 { 219 275 ASSERT(shippingMethod); … … 228 284 result.dateComponentsRange = toDateComponentsRange(shippingMethod.dateComponentsRange); 229 285 #endif 286 #if ENABLE(APPLE_PAY_SELECTED_SHIPPING_METHOD) 287 result.selected = selected; 288 #else 289 UNUSED_PARAM(selected); 290 #endif 230 291 return result; 231 292 } … … 240 301 return [self completeShippingMethodSelection:nil]; 241 302 242 presenter->client().presenterDidSelectShippingMethod(*presenter, toShippingMethod(shippingMethod ));303 presenter->client().presenterDidSelectShippingMethod(*presenter, toShippingMethod(shippingMethod, true)); 243 304 } 244 305 -
trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.h
r273143 r285521 29 29 30 30 OBJC_CLASS PKShippingMethod; 31 OBJC_CLASS PKShippingMethods; 31 32 32 33 namespace WebCore { … … 40 41 NSDecimalNumber *toDecimalNumber(const String& amount); 41 42 PKShippingMethod *toPKShippingMethod(const WebCore::ApplePayShippingMethod&); 43 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 44 PKShippingMethods *toPKShippingMethods(const Vector<WebCore::ApplePayShippingMethod>&); 45 #endif 42 46 43 47 } // namespace WebKit -
trunk/Source/WebKit/Shared/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm
r283431 r285521 202 202 } 203 203 204 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 205 206 PKShippingMethods *toPKShippingMethods(const Vector<WebCore::ApplePayShippingMethod>& webShippingMethods) 207 { 208 RetainPtr<PKShippingMethod> defaultMethod; 209 auto methods = createNSArray(webShippingMethods, [&defaultMethod] (const auto& webShippingMethod) { 210 auto pkShippingMethod = toPKShippingMethod(webShippingMethod); 211 if (webShippingMethod.selected) 212 defaultMethod = pkShippingMethod; 213 return pkShippingMethod; 214 }); 215 return [PAL::allocPKShippingMethodsInstance() initWithMethods:methods.get() defaultMethod:defaultMethod.get()]; 216 } 217 218 #endif // HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 219 204 220 #if HAVE(PASSKIT_SHIPPING_CONTACT_EDITING_MODE) 205 221 … … 268 284 [result setShippingType:toPKShippingType(paymentRequest.shippingType())]; 269 285 286 #if HAVE(PASSKIT_DEFAULT_SHIPPING_METHOD) 287 [result setAvailableShippingMethods:toPKShippingMethods(paymentRequest.shippingMethods())]; 288 #else 270 289 [result setShippingMethods:createNSArray(paymentRequest.shippingMethods(), [] (auto& method) { 271 290 return toPKShippingMethod(method); 272 291 }).get()]; 292 #endif 273 293 274 294 [result setPaymentSummaryItems:WebCore::platformSummaryItems(paymentRequest.total(), paymentRequest.lineItems())];
Note:
See TracChangeset
for help on using the changeset viewer.