Title: [223089] branches/safari-604-branch
Revision
223089
Author
[email protected]
Date
2017-10-09 17:07:42 -0700 (Mon, 09 Oct 2017)

Log Message

Cherry-pick r220718. rdar://problem/34771041

Modified Paths

Diff

Modified: branches/safari-604-branch/LayoutTests/ChangeLog (223088 => 223089)


--- branches/safari-604-branch/LayoutTests/ChangeLog	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/LayoutTests/ChangeLog	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,3 +1,22 @@
+2017-10-02  Jason Marcell  <[email protected]>
+
+        Cherry-pick r220718. rdar://problem/34771041
+
+    2017-08-14  Andy Estes  <[email protected]>
+
+            [Apple Pay] Add support for phonetic contact names
+            https://bugs.webkit.org/show_bug.cgi?id=175537
+            <rdar://problem/32002644>
+
+            Reviewed by Tim Horton.
+
+            * http/tests/ssl/applepay/ApplePayError-expected.txt:
+            * http/tests/ssl/applepay/ApplePayError.html:
+            * http/tests/ssl/applepay/ApplePaySession-expected.txt:
+            * http/tests/ssl/applepay/ApplePaySession.html:
+            * http/tests/ssl/applepay/ApplePaySessionV3-expected.txt:
+            * http/tests/ssl/applepay/ApplePaySessionV3.html:
+
 2017-10-04  Kocsen Chung  <[email protected]>
 
         Revert r222779. rdar://problem/34706688

Modified: branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePayError-expected.txt (223088 => 223089)


--- branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePayError-expected.txt	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePayError-expected.txt	2017-10-10 00:07:42 UTC (rev 223089)
@@ -27,10 +27,10 @@
 PASS new ApplePayError('addressUnserviceable') did not throw exception.
 
 SETUP: 
-PASS new ApplePayError('unknown', []) threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".
+PASS new ApplePayError('unknown', []) threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "phoneticName", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".
 
 SETUP: 
-PASS new ApplePayError('unknown', '') threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".
+PASS new ApplePayError('unknown', '') threw exception TypeError: Argument 2 ('contactField') to the ApplePayError constructor must be one of: "phoneNumber", "emailAddress", "name", "phoneticName", "postalAddress", "addressLines", "locality", "postalCode", "administrativeArea", "country", "countryCode".
 
 SETUP: 
 PASS new ApplePayError('unknown', 'phoneNumber') did not throw exception.
@@ -42,6 +42,9 @@
 PASS new ApplePayError('unknown', 'name') did not throw exception.
 
 SETUP: 
+PASS new ApplePayError('unknown', 'phoneticName') did not throw exception.
+
+SETUP: 
 PASS new ApplePayError('unknown', 'postalAddress') did not throw exception.
 
 SETUP: 

Modified: branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePayError.html (223088 => 223089)


--- branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePayError.html	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePayError.html	2017-10-10 00:07:42 UTC (rev 223089)
@@ -40,6 +40,7 @@
         logAndShouldNotThrow("", "new ApplePayError('unknown', 'phoneNumber')")
         logAndShouldNotThrow("", "new ApplePayError('unknown', 'emailAddress')")
         logAndShouldNotThrow("", "new ApplePayError('unknown', 'name')")
+        logAndShouldNotThrow("", "new ApplePayError('unknown', 'phoneticName')")
         logAndShouldNotThrow("", "new ApplePayError('unknown', 'postalAddress')")
         logAndShouldNotThrow("", "new ApplePayError('unknown', 'addressLines')")
         logAndShouldNotThrow("", "new ApplePayError('unknown', 'locality')")

Modified: branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt (223088 => 223089)


--- branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession-expected.txt	2017-10-10 00:07:42 UTC (rev 223089)
@@ -228,6 +228,9 @@
 SETUP: request = validRequest(); request.requiredBillingContactFields = ['invalid'];
 PASS new ApplePaySession(2, request) threw exception TypeError: Type error.
 
+SETUP: request = validRequest(); request.requiredBillingContactFields = ['phoneticName'];
+PASS new ApplePaySession(2, request) threw exception TypeError: "phoneticName" is not a valid contact field..
+
 SETUP: request = validRequest(); request.requiredBillingContactFields = ['email', 'name', 'phone', 'postalAddress'];
 PASS new ApplePaySession(2, request) did not throw exception.
 
@@ -286,6 +289,9 @@
 SETUP: request = validRequest(); request.requiredShippingContactFields = ['invalid'];
 PASS new ApplePaySession(2, request) threw exception TypeError: Type error.
 
+SETUP: request = validRequest(); request.requiredShippingContactFields = ['phoneticName'];
+PASS new ApplePaySession(2, request) threw exception TypeError: "phoneticName" is not a valid contact field..
+
 SETUP: request = validRequest(); request.requiredShippingContactFields = ['email', 'name', 'phone', 'postalAddress'];
 PASS new ApplePaySession(2, request) did not throw exception.
 

Modified: branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html (223088 => 223089)


--- branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySession.html	2017-10-10 00:07:42 UTC (rev 223089)
@@ -134,6 +134,7 @@
     logAndShouldThrow("request = validRequest(); request.requiredBillingContactFields = [undefined];", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.requiredBillingContactFields = [{}];", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.requiredBillingContactFields = ['invalid'];", "new ApplePaySession(2, request)")
+    logAndShouldThrow("request = validRequest(); request.requiredBillingContactFields = ['phoneticName'];", "new ApplePaySession(2, request)")
     logAndShouldNotThrow("request = validRequest(); request.requiredBillingContactFields = ['email', 'name', 'phone', 'postalAddress'];", "new ApplePaySession(2, request)")
     // FIXME: Should duplicate contactFields be allowed?
     logAndShouldNotThrow("request = validRequest(); request.requiredBillingContactFields = ['email', 'email'];", "new ApplePaySession(2, request)")
@@ -159,6 +160,7 @@
     logAndShouldThrow("request = validRequest(); request.requiredShippingContactFields = [undefined];", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.requiredShippingContactFields = [{}];", "new ApplePaySession(2, request)")
     logAndShouldThrow("request = validRequest(); request.requiredShippingContactFields = ['invalid'];", "new ApplePaySession(2, request)")
+    logAndShouldThrow("request = validRequest(); request.requiredShippingContactFields = ['phoneticName'];", "new ApplePaySession(2, request)")
     logAndShouldNotThrow("request = validRequest(); request.requiredShippingContactFields = ['email', 'name', 'phone', 'postalAddress'];", "new ApplePaySession(2, request)")
     // FIXME: Should duplicate contactFields be allowed?
     logAndShouldNotThrow("request = validRequest(); request.requiredShippingContactFields = ['email', 'email'];", "new ApplePaySession(2, request)")

Modified: branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt (223088 => 223089)


--- branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3-expected.txt	2017-10-10 00:07:42 UTC (rev 223089)
@@ -43,7 +43,13 @@
 SETUP: request = validRequest(); request.supportedCountries = ['US', 'US'];
 PASS new ApplePaySession(3, request) did not throw exception.
 
+SETUP: request = validRequest(); request.requiredBillingContactFields = ['phoneticName'];
+PASS new ApplePaySession(3, request) did not throw exception.
 
+SETUP: request = validRequest(); request.requiredShippingContactFields = ['phoneticName'];
+PASS new ApplePaySession(3, request) did not throw exception.
+
+
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html (223088 => 223089)


--- branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/LayoutTests/http/tests/ssl/applepay/ApplePaySessionV3.html	2017-10-10 00:07:42 UTC (rev 223089)
@@ -56,6 +56,8 @@
     logAndShouldNotThrow("request = validRequest(); request.supportedCountries = [];", "new ApplePaySession(3, request)");
     logAndShouldNotThrow("request = validRequest(); request.supportedCountries = ['US'];", "new ApplePaySession(3, request)");
     logAndShouldNotThrow("request = validRequest(); request.supportedCountries = ['US', 'US'];", "new ApplePaySession(3, request)");
+    logAndShouldNotThrow("request = validRequest(); request.requiredBillingContactFields = ['phoneticName'];", "new ApplePaySession(3, request)")
+    logAndShouldNotThrow("request = validRequest(); request.requiredShippingContactFields = ['phoneticName'];", "new ApplePaySession(3, request)")
     debug("");
 
     document.querySelector("button").remove();

Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/ChangeLog	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,35 @@
 2017-10-02  Jason Marcell  <[email protected]>
 
+        Cherry-pick r220718. rdar://problem/34771041
+
+    2017-08-14  Andy Estes  <[email protected]>
+
+            [Apple Pay] Add support for phonetic contact names
+            https://bugs.webkit.org/show_bug.cgi?id=175537
+            <rdar://problem/32002644>
+
+            Reviewed by Tim Horton.
+
+            * Modules/applepay/ApplePayError.idl: Defined "phoneticName" in ApplePayErrorContactField.
+            * Modules/applepay/ApplePayPaymentContact.h: Defined phoneticGivenName and phoneticFamilyName
+            in ApplePayPaymentContact.
+            * Modules/applepay/ApplePayPaymentContact.idl: Ditto.
+            * Modules/applepay/ApplePayPaymentRequest.h: Defined PhoneticName in
+            ApplePayPaymentRequest::ContactField.
+            * Modules/applepay/ApplePayPaymentRequest.idl: Defined "phoneticName" in ApplePayContactField.
+            * Modules/applepay/ApplePaySession.cpp:
+            (WebCore::convertAndValidate): Added a version parameter. Added code to convert
+            ContactField::PhoneticName, throwing an exception if version is less than 3.
+            * Modules/applepay/PaymentContact.h: Added a version parameter to fromApplePayPaymentContact().
+            * Modules/applepay/PaymentRequest.h: Defined phoneticName in PaymentRequest::ContactFields
+            and defined PhoneticName in PaymentError::ContactField.
+            * Modules/applepay/cocoa/PaymentContactCocoa.mm:
+            (WebCore::convert): Added a version parameter. Set a phoneticRepresentation on the
+            PKContact's name if there are non-empty phonetic names and version is 3 or greater.
+            (WebCore::PaymentContact::fromApplePayPaymentContact): Passed version to convert().
+
+2017-10-02  Jason Marcell  <[email protected]>
+
         Cherry-pick r220496. rdar://problem/34770816
 
     2017-08-09  Jeremy Jones  <[email protected]>

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayError.idl (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayError.idl	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayError.idl	2017-10-10 00:07:42 UTC (rev 223089)
@@ -38,6 +38,7 @@
     "phoneNumber",
     "emailAddress",
     "name",
+    "phoneticName",
     "postalAddress",
     "addressLines",
     "locality",

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentContact.h (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentContact.h	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentContact.h	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -38,6 +38,8 @@
     String emailAddress;
     String givenName;
     String familyName;
+    String phoneticGivenName;
+    String phoneticFamilyName;
     std::optional<Vector<String>> addressLines;
     String locality;
     String postalCode;

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentContact.idl (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentContact.idl	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentContact.idl	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -31,6 +31,8 @@
     DOMString emailAddress;
     DOMString givenName;
     DOMString familyName;
+    [Conditional=APPLE_PAY_SESSION_V3] DOMString phoneticGivenName;
+    [Conditional=APPLE_PAY_SESSION_V3] DOMString phoneticFamilyName;
     sequence<DOMString> addressLines;
     DOMString locality;
     DOMString postalCode;

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.h	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -36,7 +36,7 @@
 
 struct ApplePayPaymentRequest {
     enum class MerchantCapability { Supports3DS, SupportsEMV, SupportsCredit, SupportsDebit };
-    enum class ContactField { Email, Name, Phone, PostalAddress };
+    enum class ContactField { Email, Name, PhoneticName, Phone, PostalAddress };
 
     using ShippingType = PaymentRequest::ShippingType;
 

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePayPaymentRequest.idl	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -37,6 +37,7 @@
 ] enum ApplePayContactField {
     "email",
     "name",
+    "phoneticName",
     "phone",
     "postalAddress"
 };

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/ApplePaySession.cpp	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -257,7 +257,7 @@
     return WTFMove(supportedNetworks);
 }
 
-static ExceptionOr<PaymentRequest::ContactFields> convertAndValidate(Vector<ApplePayPaymentRequest::ContactField>&& contactFields)
+static ExceptionOr<PaymentRequest::ContactFields> convertAndValidate(unsigned version, Vector<ApplePayPaymentRequest::ContactField>&& contactFields)
 {
     PaymentRequest::ContactFields result;
 
@@ -269,6 +269,11 @@
         case ApplePayPaymentRequest::ContactField::Name:
             result.name = true;
             break;
+        case ApplePayPaymentRequest::ContactField::PhoneticName:
+            if (version < 3)
+                return Exception { TypeError, "\"phoneticName\" is not a valid contact field." };
+            result.phoneticName = true;
+            break;
         case ApplePayPaymentRequest::ContactField::Phone:
             result.phone = true;
             break;
@@ -339,7 +344,7 @@
     result.setSupportedNetworks(supportedNetworks.releaseReturnValue());
 
     if (paymentRequest.requiredBillingContactFields) {
-        auto requiredBillingContactFields = convertAndValidate(WTFMove(*paymentRequest.requiredBillingContactFields));
+        auto requiredBillingContactFields = convertAndValidate(version, WTFMove(*paymentRequest.requiredBillingContactFields));
         if (requiredBillingContactFields.hasException())
             return requiredBillingContactFields.releaseException();
         result.setRequiredBillingContactFields(requiredBillingContactFields.releaseReturnValue());
@@ -346,10 +351,10 @@
     }
 
     if (paymentRequest.billingContact)
-        result.setBillingContact(PaymentContact::fromApplePayPaymentContact(paymentRequest.billingContact.value()));
+        result.setBillingContact(PaymentContact::fromApplePayPaymentContact(version, paymentRequest.billingContact.value()));
 
     if (paymentRequest.requiredShippingContactFields) {
-        auto requiredShippingContactFields = convertAndValidate(WTFMove(*paymentRequest.requiredShippingContactFields));
+        auto requiredShippingContactFields = convertAndValidate(version, WTFMove(*paymentRequest.requiredShippingContactFields));
         if (requiredShippingContactFields.hasException())
             return requiredShippingContactFields.releaseException();
         result.setRequiredShippingContactFields(requiredShippingContactFields.releaseReturnValue());
@@ -356,7 +361,7 @@
     }
 
     if (paymentRequest.shippingContact)
-        result.setShippingContact(PaymentContact::fromApplePayPaymentContact(paymentRequest.shippingContact.value()));
+        result.setShippingContact(PaymentContact::fromApplePayPaymentContact(version, paymentRequest.shippingContact.value()));
 
     result.setShippingType(paymentRequest.shippingType);
 

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/PaymentContact.h (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/PaymentContact.h	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/PaymentContact.h	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -44,7 +44,7 @@
     {
     }
 
-    static PaymentContact fromApplePayPaymentContact(const ApplePayPaymentContact&);
+    static PaymentContact fromApplePayPaymentContact(unsigned version, const ApplePayPaymentContact&);
     ApplePayPaymentContact toApplePayPaymentContact() const;
 
     PKContact *pkContact() const { return m_pkContact.get(); }

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/PaymentRequest.h (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/PaymentRequest.h	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/PaymentRequest.h	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2015, 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2015-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -53,6 +53,7 @@
         bool phone { false };
         bool email { false };
         bool name { false };
+        bool phoneticName { false };
     };
 
     const ContactFields& requiredBillingContactFields() const { return m_requiredBillingContactFields; }
@@ -166,6 +167,7 @@
         PhoneNumber,
         EmailAddress,
         Name,
+        PhoneticName,
         PostalAddress,
         AddressLines,
         Locality,

Modified: branches/safari-604-branch/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm (223088 => 223089)


--- branches/safari-604-branch/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -48,14 +48,36 @@
 
 namespace WebCore {
 
-static RetainPtr<PKContact> convert(const ApplePayPaymentContact& contact)
+static RetainPtr<PKContact> convert(unsigned version, const ApplePayPaymentContact& contact)
 {
     auto result = adoptNS([allocPKContactInstance() init]);
 
-    if (!contact.familyName.isEmpty() || !contact.givenName.isEmpty()) {
+    NSString *familyName = nil;
+    NSString *phoneticFamilyName = nil;
+    if (!contact.familyName.isEmpty()) {
+        familyName = contact.familyName;
+        if (version >= 3 && !contact.phoneticFamilyName.isEmpty())
+            phoneticFamilyName = contact.phoneticFamilyName;
+    }
+
+    NSString *givenName = nil;
+    NSString *phoneticGivenName = nil;
+    if (!contact.givenName.isEmpty()) {
+        givenName = contact.givenName;
+        if (version >= 3 && !contact.phoneticGivenName.isEmpty())
+            phoneticGivenName = contact.phoneticGivenName;
+    }
+
+    if (familyName || givenName) {
         auto name = adoptNS([[NSPersonNameComponents alloc] init]);
-        [name setFamilyName:contact.familyName];
-        [name setGivenName:contact.givenName];
+        [name setFamilyName:familyName];
+        [name setGivenName:givenName];
+        if (phoneticFamilyName || phoneticGivenName) {
+            auto phoneticName = adoptNS([[NSPersonNameComponents alloc] init]);
+            [phoneticName setFamilyName:phoneticFamilyName];
+            [phoneticName setGivenName:phoneticGivenName];
+            [name setPhoneticRepresentation:phoneticName.get()];
+        }
         [result setName:name.get()];
     }
 
@@ -74,7 +96,7 @@
             if (i != contact.addressLines->size() - 1)
                 builder.append('\n');
         }
-        
+
         // FIXME: StringBuilder should hava a toNSString() function to avoid the extra String allocation.
         [address setStreet:builder.toString()];
 
@@ -101,36 +123,35 @@
 
     ApplePayPaymentContact result;
 
-    if (contact.phoneNumber)
-        result.phoneNumber = contact.phoneNumber.stringValue;
-    if (contact.emailAddress)
-        result.emailAddress = contact.emailAddress;
-    if (contact.name.givenName)
-        result.givenName = contact.name.givenName;
-    if (contact.name.familyName)
-        result.familyName = contact.name.familyName;
-    if (contact.postalAddress.street.length) {
+    result.phoneNumber = contact.phoneNumber.stringValue;
+    result.emailAddress = contact.emailAddress;
+
+    NSPersonNameComponents *name = contact.name;
+    result.givenName = name.givenName;
+    result.familyName = name.familyName;
+
+    NSPersonNameComponents *phoneticName = name.phoneticRepresentation;
+    result.phoneticGivenName = phoneticName.givenName;
+    result.phoneticFamilyName = phoneticName.familyName;
+
+    CNPostalAddress *postalAddress = contact.postalAddress;
+    if (postalAddress.street.length) {
         Vector<String> addressLines;
-        String(contact.postalAddress.street).split("\n", addressLines);
+        String(postalAddress.street).split("\n", addressLines);
         result.addressLines = WTFMove(addressLines);
     }
-    if (contact.postalAddress.city)
-        result.locality = contact.postalAddress.city;
-    if (contact.postalAddress.postalCode)
-        result.postalCode = contact.postalAddress.postalCode;
-    if (contact.postalAddress.state)
-        result.administrativeArea = contact.postalAddress.state;
-    if (contact.postalAddress.country)
-        result.country = contact.postalAddress.country;
-    if (contact.postalAddress.ISOCountryCode)
-        result.countryCode = contact.postalAddress.ISOCountryCode;
+    result.locality = postalAddress.city;
+    result.postalCode = postalAddress.postalCode;
+    result.administrativeArea = postalAddress.state;
+    result.country = postalAddress.country;
+    result.countryCode = postalAddress.ISOCountryCode;
 
     return result;
 }
 
-PaymentContact PaymentContact::fromApplePayPaymentContact(const ApplePayPaymentContact& contact)
+PaymentContact PaymentContact::fromApplePayPaymentContact(unsigned version, const ApplePayPaymentContact& contact)
 {
-    return PaymentContact(convert(contact).get());
+    return PaymentContact(convert(version, contact).get());
 }
 
 ApplePayPaymentContact PaymentContact::toApplePayPaymentContact() const

Modified: branches/safari-604-branch/Source/WebKit/ChangeLog (223088 => 223089)


--- branches/safari-604-branch/Source/WebKit/ChangeLog	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebKit/ChangeLog	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,23 @@
 2017-10-02  Jason Marcell  <[email protected]>
 
+        Cherry-pick r220718. rdar://problem/34771041
+
+    2017-08-14  Andy Estes  <[email protected]>
+
+            [Apple Pay] Add support for phonetic contact names
+            https://bugs.webkit.org/show_bug.cgi?id=175537
+            <rdar://problem/32002644>
+
+            Reviewed by Tim Horton.
+
+            * UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm: Soft-linked PKContactFieldPhoneticName.
+            (WebKit::toPKContactFields): Added code to append PKContactFieldPhoneticName to result if
+            contactFields.phoneticName is true.
+            (WebKit::toNSError): Specified PKContactFieldPhoneticName as the contact field for
+            PaymentError::ContactField::PhoneticName.
+
+2017-10-02  Jason Marcell  <[email protected]>
+
         Cherry-pick r220496. rdar://problem/34770816
 
     2017-08-09  Jeremy Jones  <[email protected]>

Modified: branches/safari-604-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm (223088 => 223089)


--- branches/safari-604-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2017-10-10 00:07:36 UTC (rev 223088)
+++ branches/safari-604-branch/Source/WebKit/UIProcess/ApplePay/cocoa/WebPaymentCoordinatorProxyCocoa.mm	2017-10-10 00:07:42 UTC (rev 223089)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2016-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -76,6 +76,7 @@
 SOFT_LINK_CONSTANT(PassKit, PKContactFieldEmailAddress, NSString *);
 SOFT_LINK_CONSTANT(PassKit, PKContactFieldPhoneNumber, NSString *);
 SOFT_LINK_CONSTANT(PassKit, PKContactFieldName, NSString *);
+SOFT_LINK_CONSTANT(PassKit, PKContactFieldPhoneticName, NSString *);
 SOFT_LINK_CONSTANT(PassKit, PKPaymentErrorContactFieldUserInfoKey, NSString *);
 SOFT_LINK_CONSTANT(PassKit, PKPaymentErrorPostalAddressUserInfoKey, NSString *);
 #endif
@@ -361,6 +362,8 @@
         result.append(getPKContactFieldEmailAddress());
     if (contactFields.name)
         result.append(getPKContactFieldName());
+    if (contactFields.phoneticName)
+        result.append(getPKContactFieldPhoneticName());
 
     return adoptNS([[NSSet alloc] initWithObjects:result.data() count:result.size()]);
 }
@@ -635,6 +638,10 @@
             pkContactField = getPKContactFieldName();
             break;
 
+        case WebCore::PaymentError::ContactField::PhoneticName:
+            pkContactField = getPKContactFieldPhoneticName();
+            break;
+
         case WebCore::PaymentError::ContactField::PostalAddress:
             pkContactField = getPKContactFieldPostalAddress();
             break;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to