Changeset 238515 in webkit
- Timestamp:
- Nov 26, 2018 1:13:47 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 1 added
- 20 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r238513 r238515 1 2018-11-26 Andy Estes <aestes@apple.com> 2 3 [Cocoa] Make it easier to encode NSObjects 4 https://bugs.webkit.org/show_bug.cgi?id=191948 5 6 Reviewed by Dean Jackson. 7 8 * Modules/applepay/Payment.h: Changed the PKPayment * constructor to take a 9 RetainPtr<PKPayment>&& instead. 10 * Modules/applepay/PaymentContact.h: Ditto for PKContact. 11 * Modules/applepay/PaymentMerchantSession.h: Ditto for PKPaymentMerchantSession. 12 * Modules/applepay/PaymentMethod.h: Ditto for PKPaymentMethod. 13 * Modules/applepay/cocoa/PaymentCocoa.mm: 14 (WebCore::Payment::Payment): Moved definition out-of-line. 15 (WebCore::Payment::pkPayment const): Ditto. 16 * Modules/applepay/cocoa/PaymentContactCocoa.mm: 17 (WebCore::PaymentContact::PaymentContact): Ditto. 18 (WebCore::PaymentContact::pkContact const): Ditto. 19 * Modules/applepay/cocoa/PaymentMethodCocoa.mm: 20 (WebCore::PaymentMethod::PaymentMethod): Ditto. 21 (WebCore::PaymentMethod::pkPaymentMethod const): Ditto. 22 1 23 2018-11-26 Daniel Bates <dabates@apple.com> 2 24 -
trunk/Source/WebCore/Modules/applepay/Payment.h
r226098 r238515 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 38 38 class WEBCORE_EXPORT Payment { 39 39 public: 40 Payment() = default; 41 42 explicit Payment(PKPayment *pkPayment) 43 : m_pkPayment(pkPayment) 44 { 45 } 46 47 virtual ~Payment() = default; 40 Payment(); 41 explicit Payment(RetainPtr<PKPayment>&&); 42 virtual ~Payment(); 48 43 49 44 virtual ApplePayPayment toApplePayPayment(unsigned version) const; 50 45 51 PKPayment *pkPayment() const { return m_pkPayment.get(); }46 PKPayment *pkPayment() const; 52 47 53 48 private: -
trunk/Source/WebCore/Modules/applepay/PaymentContact.h
r226098 r238515 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 39 39 class WEBCORE_EXPORT PaymentContact { 40 40 public: 41 PaymentContact() = default; 42 explicit PaymentContact(PKContact *pkContact) 43 : m_pkContact(pkContact) 44 { 45 } 46 virtual ~PaymentContact() = default; 41 PaymentContact(); 42 explicit PaymentContact(RetainPtr<PKContact>&&); 43 virtual ~PaymentContact(); 47 44 48 45 static PaymentContact fromApplePayPaymentContact(unsigned version, const ApplePayPaymentContact&); 49 46 virtual ApplePayPaymentContact toApplePayPaymentContact(unsigned version) const; 50 47 51 PKContact *pkContact() const { return m_pkContact.get(); }48 PKContact *pkContact() const; 52 49 53 50 private: -
trunk/Source/WebCore/Modules/applepay/PaymentMerchantSession.h
r223794 r238515 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 43 43 public: 44 44 PaymentMerchantSession() = default; 45 explicit PaymentMerchantSession( PKPaymentMerchantSession *pkPaymentMerchantSession)46 : m_pkPaymentMerchantSession (pkPaymentMerchantSession)45 explicit PaymentMerchantSession(RetainPtr<PKPaymentMerchantSession>&& pkPaymentMerchantSession) 46 : m_pkPaymentMerchantSession { WTFMove(pkPaymentMerchantSession) } 47 47 { 48 48 } -
trunk/Source/WebCore/Modules/applepay/PaymentMethod.h
r223945 r238515 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 38 38 class WEBCORE_EXPORT PaymentMethod { 39 39 public: 40 PaymentMethod() = default; 41 virtual ~PaymentMethod() = default; 42 43 explicit PaymentMethod(PKPaymentMethod *pkPaymentMethod) 44 : m_pkPaymentMethod(pkPaymentMethod) 45 { 46 } 40 PaymentMethod(); 41 explicit PaymentMethod(RetainPtr<PKPaymentMethod>&&); 42 virtual ~PaymentMethod(); 47 43 48 44 virtual ApplePayPaymentMethod toApplePayPaymentMethod() const; 49 45 50 PKPaymentMethod *pkPaymentMethod() const { return m_pkPaymentMethod.get(); }46 PKPaymentMethod *pkPaymentMethod() const; 51 47 52 48 private: -
trunk/Source/WebCore/Modules/applepay/cocoa/PaymentCocoa.mm
r226098 r238515 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 67 67 return result; 68 68 } 69 70 Payment::Payment() = default; 71 72 Payment::Payment(RetainPtr<PKPayment>&& pkPayment) 73 : m_pkPayment { WTFMove(pkPayment) } 74 { 75 } 76 77 Payment::~Payment() = default; 69 78 70 79 ApplePayPayment Payment::toApplePayPayment(unsigned version) const … … 73 82 } 74 83 84 PKPayment *Payment::pkPayment() const 85 { 86 return m_pkPayment.get(); 87 } 88 75 89 } 76 90 -
trunk/Source/WebCore/Modules/applepay/cocoa/PaymentContactCocoa.mm
r238434 r238515 209 209 } 210 210 211 PaymentContact::PaymentContact() = default; 212 213 PaymentContact::PaymentContact(RetainPtr<PKContact>&& pkContact) 214 : m_pkContact { WTFMove(pkContact) } 215 { 216 } 217 218 PaymentContact::~PaymentContact() = default; 219 211 220 PaymentContact PaymentContact::fromApplePayPaymentContact(unsigned version, const ApplePayPaymentContact& contact) 212 221 { … … 219 228 } 220 229 221 } 222 223 #endif 230 PKContact *PaymentContact::pkContact() const 231 { 232 return m_pkContact.get(); 233 } 234 235 } 236 237 #endif -
trunk/Source/WebCore/Modules/applepay/cocoa/PaymentMethodCocoa.mm
r225849 r238515 1 1 /* 2 * Copyright (C) 2016 Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 102 102 } 103 103 104 PaymentMethod::PaymentMethod() = default; 105 106 PaymentMethod::PaymentMethod(RetainPtr<PKPaymentMethod>&& pkPaymentMethod) 107 : m_pkPaymentMethod { WTFMove(pkPaymentMethod) } 108 { 109 } 110 111 PaymentMethod::~PaymentMethod() = default; 112 104 113 ApplePayPaymentMethod PaymentMethod::toApplePayPaymentMethod() const 105 114 { … … 107 116 } 108 117 118 PKPaymentMethod *PaymentMethod::pkPaymentMethod() const 119 { 120 return m_pkPaymentMethod.get(); 121 } 122 109 123 } 110 124 -
trunk/Source/WebCore/PAL/ChangeLog
r238470 r238515 1 2018-11-26 Andy Estes <aestes@apple.com> 2 3 [Cocoa] Make it easier to encode NSObjects 4 https://bugs.webkit.org/show_bug.cgi?id=191948 5 6 Reviewed by Dean Jackson. 7 8 * pal/spi/cocoa/PassKitSPI.h: Declared some classes that secretly conform to NSSecureCoding. 9 1 10 2018-11-24 Andy Estes <aestes@apple.com> 2 11 -
trunk/Source/WebCore/PAL/pal/spi/cocoa/PassKitSPI.h
r238434 r238515 328 328 NS_ASSUME_NONNULL_BEGIN 329 329 330 @interface PKContact () <NSSecureCoding> 331 @end 332 330 333 @interface PKPassLibrary () 331 334 - (void)openPaymentSetupForMerchantIdentifier:(NSString *)identifier domain:(NSString *)domain completion:(void(^)(BOOL success))completion; 335 @end 336 337 @interface PKPayment () <NSSecureCoding> 338 @end 339 340 @interface PKPaymentMethod () <NSSecureCoding> 332 341 @end 333 342 -
trunk/Source/WebKit/ChangeLog
r238507 r238515 1 2018-11-26 Andy Estes <aestes@apple.com> 2 3 [Cocoa] Make it easier to encode NSObjects 4 https://bugs.webkit.org/show_bug.cgi?id=191948 5 6 Reviewed by Dean Jackson. 7 8 It should be easier to encode objects that conform to NSSecureCoding for WebKit IPC. Right 9 now, several argument coders duplicate the logic for encoding and decoding objects using 10 NSKeyedArchiver and NSKeyedUnarchiver. 11 12 This patch adds encodeObject() and decodeObject() primitives for encoding and decoding using 13 Foundation keyed archiving. It then partially specializes ArgumentCoder for raw pointers and 14 RetainPtrs whose pointee conforms to NSSecureCoding to call these new primitives. 15 16 This allows us to use Encoder::operator<< to encode raw pointers or RetainPtrs and use 17 Decoder::operator>> to decode to an optional RetainPtr. By default, IPC::decode infers the 18 allowed class for decoding by calling `[T class]`. We can also specify the allowed classes 19 explicitly for containers and classes that are loaded at runtime. 20 21 * Shared/Cocoa/ArgumentCodersCocoa.h: Added. 22 * Shared/Cocoa/ArgumentCodersCocoa.mm: Added. 23 * Shared/Cocoa/DataDetectionResult.mm: 24 (WebKit::DataDetectionResult::encode const): Removed custom encoding code and used ArgumentCodersCocoa instead. 25 (WebKit::DataDetectionResult::decode): Ditto. 26 * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: 27 (IPC::ArgumentCoder<WebCore::Payment>::encode): Ditto. 28 (IPC::ArgumentCoder<WebCore::Payment>::decode): Ditto. 29 (IPC::ArgumentCoder<WebCore::PaymentAuthorizationResult>::decode): Ditto. 30 (IPC::ArgumentCoder<WebCore::PaymentContact>::encode): Ditto. 31 (IPC::ArgumentCoder<WebCore::PaymentContact>::decode): Ditto. 32 (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::encode): Ditto. 33 (IPC::ArgumentCoder<WebCore::PaymentMerchantSession>::decode): Ditto. 34 (IPC::ArgumentCoder<WebCore::PaymentMethod>::encode): Ditto. 35 (IPC::ArgumentCoder<WebCore::PaymentMethod>::decode): Ditto. 36 (IPC::ArgumentCoder<ApplePaySessionPaymentRequest>::decode): Ditto. 37 * Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm: 38 (WebKit::RemoteLayerTreeTransaction::description const): Added some needed namespaces due to unified source shuffling. 39 * Shared/WebCoreArgumentCoders.h: Modernized several decoders. 40 * Shared/ios/InteractionInformationAtPosition.mm: 41 (WebKit::InteractionInformationAtPosition::encode const): Removed custom encoding code and used ArgumentCodersCocoa instead. 42 (WebKit::InteractionInformationAtPosition::decode): Ditto. 43 * Shared/mac/WebCoreArgumentCodersMac.mm: 44 (IPC::ArgumentCoder<WebCore::ProtectionSpace>::encodePlatformData): Ditto. 45 (IPC::ArgumentCoder<WebCore::ProtectionSpace>::decodePlatformData): Ditto. 46 (IPC::ArgumentCoder<WebCore::Credential>::encodePlatformData): Ditto. 47 (IPC::ArgumentCoder<WebCore::Credential>::decodePlatformData): Ditto. 48 (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData): Ditto. 49 (IPC::ArgumentCoder<WebCore::MediaPlaybackTargetContext>::decodePlatformData): Ditto. 50 (IPC::deviceContextKey): Deleted. 51 * Shared/mac/WebHitTestResultData.mm: 52 (WebKit::WebHitTestResultData::platformEncode const): Ditto. 53 (WebKit::WebHitTestResultData::platformDecode): Ditto. 54 * SourcesCocoa.txt: Added ArgumentCodersCocoa.mm. 55 * WebKit.xcodeproj/project.pbxproj: Ditto. 56 1 57 2018-11-26 Wenson Hsieh <wenson_hsieh@apple.com> 2 58 -
trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm
r238514 r238515 1 1 /* 2 * Copyright (C) 201 4-2017Apple Inc. All rights reserved.2 * Copyright (C) 2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 25 25 26 26 #import "config.h" 27 #import "DataDetectionResult.h" 27 #import "ArgumentCodersCocoa.h" 28 29 #if PLATFORM(COCOA) 28 30 29 31 #import "ArgumentCodersCF.h" 30 #import "WebCoreArgumentCoders.h"31 #import <pal/spi/cocoa/DataDetectorsCoreSPI.h>32 32 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> 33 #import <wtf/SoftLinking.h>34 33 35 SOFT_LINK_PRIVATE_FRAMEWORK(DataDetectorsCore) 36 SOFT_LINK_CLASS(DataDetectorsCore, DDScannerResult) 34 namespace IPC { 37 35 38 namespace WebKit { 39 40 #if ENABLE(DATA_DETECTION) 41 42 void DataDetectionResult::encode(IPC::Encoder& encoder) const 36 void encodeObject(Encoder& encoder, id <NSSecureCoding> object) 43 37 { 44 38 auto archiver = secureArchiver(); 45 [archiver encodeObject:results.get() forKey:@"dataDetectorResults"]; 46 IPC::encode(encoder, (__bridge CFDataRef)archiver.get().encodedData); 39 [archiver encodeObject:object forKey:NSKeyedArchiveRootObjectKey]; 40 [archiver finishEncoding]; 41 42 IPC::encode(encoder, (__bridge CFDataRef)[archiver encodedData]); 47 43 } 48 44 49 std::optional< DataDetectionResult> DataDetectionResult::decode(IPC::Decoder& decoder)45 std::optional<RetainPtr<id <NSSecureCoding>>> decodeObject(Decoder& decoder, NSArray<Class> *allowedClasses) 50 46 { 51 47 RetainPtr<CFDataRef> data; 52 if (! IPC::decode(decoder, data))48 if (!decode(decoder, data)) 53 49 return std::nullopt; 54 50 55 DataDetectionResult result;56 51 auto unarchiver = secureUnarchiverFromData((__bridge NSData *)data.get()); 57 52 @try { 58 result.results = [unarchiver decodeObjectOfClasses:[NSSet setWithArray:@[ [NSArray class], getDDScannerResultClass()] ] forKey:@"dataDetectorResults"]; 53 id result = [unarchiver decodeObjectOfClasses:[NSSet setWithArray:allowedClasses] forKey:NSKeyedArchiveRootObjectKey]; 54 ASSERT(!result || [result conformsToProtocol:@protocol(NSSecureCoding)]); 55 return { result }; 59 56 } @catch (NSException *exception) { 60 LOG_ERROR("Failed to decode NSArray of DDScanResult: %@", exception);57 LOG_ERROR("Failed to decode object of classes %@: %@", allowedClasses, exception); 61 58 return std::nullopt; 59 } @finally { 60 [unarchiver finishDecoding]; 62 61 } 63 64 [unarchiver finishDecoding];65 return { WTFMove(result) };66 62 } 67 #endif68 63 69 } 64 } // namespace IPC 65 66 #endif // PLATFORM(COCOA) -
trunk/Source/WebKit/Shared/Cocoa/DataDetectionResult.mm
r238471 r238515 1 1 /* 2 * Copyright (C) 2014-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #import "DataDetectionResult.h" 28 28 29 #import "ArgumentCodersC F.h"29 #import "ArgumentCodersCocoa.h" 30 30 #import "WebCoreArgumentCoders.h" 31 31 #import <pal/spi/cocoa/DataDetectorsCoreSPI.h> … … 42 42 void DataDetectionResult::encode(IPC::Encoder& encoder) const 43 43 { 44 auto archiver = secureArchiver(); 45 [archiver encodeObject:results.get() forKey:@"dataDetectorResults"]; 46 IPC::encode(encoder, (__bridge CFDataRef)archiver.get().encodedData); 44 encoder << results; 47 45 } 48 46 49 47 std::optional<DataDetectionResult> DataDetectionResult::decode(IPC::Decoder& decoder) 50 48 { 51 RetainPtr<CFDataRef> data;52 if (! IPC::decode(decoder, data))49 auto results = IPC::decode<NSArray>(decoder, @[ [NSArray class], getDDScannerResultClass() ]); 50 if (!results) 53 51 return std::nullopt; 54 52 55 53 DataDetectionResult result; 56 auto unarchiver = secureUnarchiverFromData((__bridge NSData *)data.get()); 57 @try { 58 result.results = [unarchiver decodeObjectOfClasses:[NSSet setWithArray:@[ [NSArray class], getDDScannerResultClass()] ] forKey:@"dataDetectorResults"]; 59 } @catch (NSException *exception) { 60 LOG_ERROR("Failed to decode NSArray of DDScanResult: %@", exception); 61 return std::nullopt; 62 } 63 64 [unarchiver finishDecoding]; 54 result.results = WTFMove(*results); 65 55 return { WTFMove(result) }; 66 56 } -
trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
r238470 r238515 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 29 29 #if ENABLE(APPLE_PAY) 30 30 31 #import "ArgumentCodersCocoa.h" 31 32 #import "DataReference.h" 32 33 #import <WebCore/PaymentAuthorizationStatus.h> … … 39 40 void ArgumentCoder<WebCore::Payment>::encode(Encoder& encoder, const WebCore::Payment& payment) 40 41 { 41 auto archiver = secureArchiver(); 42 [archiver encodeObject:payment.pkPayment() forKey:NSKeyedArchiveRootObjectKey]; 43 [archiver finishEncoding]; 44 45 auto data = archiver.get().encodedData; 46 encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]); 47 } 48 49 bool ArgumentCoder<WebCore::Payment>::decode(Decoder& decoder, WebCore::Payment& payment) 50 { 51 IPC::DataReference dataReference; 52 if (!decoder.decode(dataReference)) 53 return false; 54 55 auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]); 56 auto unarchiver = secureUnarchiverFromData(data.get()); 57 @try { 58 PKPayment *pkPayment = [unarchiver decodeObjectOfClass:PAL::getPKPaymentClass() forKey:NSKeyedArchiveRootObjectKey]; 59 payment = Payment(pkPayment); 60 } @catch (NSException *exception) { 61 LOG_ERROR("Failed to decode PKPayment: %@", exception); 62 return false; 63 } 64 65 [unarchiver finishDecoding]; 66 return true; 42 encoder << payment.pkPayment(); 43 } 44 45 std::optional<WebCore::Payment> ArgumentCoder<WebCore::Payment>::decode(Decoder& decoder) 46 { 47 auto payment = IPC::decode<PKPayment>(decoder, PAL::getPKPaymentClass()); 48 if (!payment) 49 return std::nullopt; 50 51 return Payment { WTFMove(*payment) }; 67 52 } 68 53 … … 84 69 if (!errors) 85 70 return std::nullopt; 86 71 87 72 return {{ WTFMove(*status), WTFMove(*errors) }}; 88 73 } … … 90 75 void ArgumentCoder<WebCore::PaymentContact>::encode(Encoder& encoder, const WebCore::PaymentContact& paymentContact) 91 76 { 92 auto archiver = secureArchiver(); 93 [archiver encodeObject:paymentContact.pkContact() forKey:NSKeyedArchiveRootObjectKey]; 94 [archiver finishEncoding]; 95 96 auto data = archiver.get().encodedData; 97 encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]); 98 } 99 100 bool ArgumentCoder<WebCore::PaymentContact>::decode(Decoder& decoder, WebCore::PaymentContact& paymentContact) 101 { 102 IPC::DataReference dataReference; 103 if (!decoder.decode(dataReference)) 104 return false; 105 106 auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]); 107 auto unarchiver = secureUnarchiverFromData(data.get()); 108 @try { 109 PKContact *pkContact = [unarchiver decodeObjectOfClass:PAL::getPKContactClass() forKey:NSKeyedArchiveRootObjectKey]; 110 paymentContact = PaymentContact(pkContact); 111 } @catch (NSException *exception) { 112 LOG_ERROR("Failed to decode PKContact: %@", exception); 113 return false; 114 } 115 116 [unarchiver finishDecoding]; 117 return true; 77 encoder << paymentContact.pkContact(); 78 } 79 80 std::optional<WebCore::PaymentContact> ArgumentCoder<WebCore::PaymentContact>::decode(Decoder& decoder) 81 { 82 auto contact = IPC::decode<PKContact>(decoder, PAL::getPKContactClass()); 83 if (!contact) 84 return std::nullopt; 85 86 return WebCore::PaymentContact { WTFMove(*contact) }; 118 87 } 119 88 … … 147 116 void ArgumentCoder<WebCore::PaymentMerchantSession>::encode(Encoder& encoder, const WebCore::PaymentMerchantSession& paymentMerchantSession) 148 117 { 149 auto archiver = secureArchiver(); 150 [archiver encodeObject:paymentMerchantSession.pkPaymentMerchantSession() forKey:NSKeyedArchiveRootObjectKey]; 151 [archiver finishEncoding]; 152 153 auto data = archiver.get().encodedData; 154 encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]); 155 } 156 157 bool ArgumentCoder<WebCore::PaymentMerchantSession>::decode(Decoder& decoder, WebCore::PaymentMerchantSession& paymentMerchantSession) 158 { 159 IPC::DataReference dataReference; 160 if (!decoder.decode(dataReference)) 161 return false; 162 163 auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]); 164 auto unarchiver = secureUnarchiverFromData(data.get()); 165 @try { 166 PKPaymentMerchantSession *pkPaymentMerchantSession = [unarchiver decodeObjectOfClass:PAL::getPKPaymentMerchantSessionClass() forKey:NSKeyedArchiveRootObjectKey]; 167 paymentMerchantSession = PaymentMerchantSession(pkPaymentMerchantSession); 168 } @catch (NSException *exception) { 169 LOG_ERROR("Failed to decode PKPaymentMerchantSession: %@", exception); 170 return false; 171 } 172 173 [unarchiver finishDecoding]; 174 return true; 118 encoder << paymentMerchantSession.pkPaymentMerchantSession(); 119 } 120 121 std::optional<WebCore::PaymentMerchantSession> ArgumentCoder<WebCore::PaymentMerchantSession>::decode(Decoder& decoder) 122 { 123 auto paymentMerchantSession = IPC::decode<PKPaymentMerchantSession>(decoder, PAL::getPKPaymentMerchantSessionClass()); 124 if (!paymentMerchantSession) 125 return std::nullopt; 126 127 return WebCore::PaymentMerchantSession { WTFMove(*paymentMerchantSession) }; 175 128 } 176 129 177 130 void ArgumentCoder<WebCore::PaymentMethod>::encode(Encoder& encoder, const WebCore::PaymentMethod& paymentMethod) 178 131 { 179 auto archiver = secureArchiver(); 180 [archiver encodeObject:paymentMethod.pkPaymentMethod() forKey:NSKeyedArchiveRootObjectKey]; 181 [archiver finishEncoding]; 182 183 auto data = archiver.get().encodedData; 184 encoder << DataReference(static_cast<const uint8_t*>([data bytes]), [data length]); 185 } 186 187 bool ArgumentCoder<WebCore::PaymentMethod>::decode(Decoder& decoder, WebCore::PaymentMethod& paymentMethod) 188 { 189 IPC::DataReference dataReference; 190 if (!decoder.decode(dataReference)) 191 return false; 192 193 auto data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<void*>(static_cast<const void*>(dataReference.data())) length:dataReference.size() freeWhenDone:NO]); 194 auto unarchiver = secureUnarchiverFromData(data.get()); 195 @try { 196 PKPaymentMethod *pkPaymentMethod = [unarchiver decodeObjectOfClass:PAL::getPKPaymentMethodClass() forKey:NSKeyedArchiveRootObjectKey]; 197 paymentMethod = PaymentMethod(pkPaymentMethod); 198 } @catch (NSException *exception) { 199 LOG_ERROR("Failed to decode PKPayment: %@", exception); 200 return false; 201 } 202 203 [unarchiver finishDecoding]; 204 return true; 132 encoder << paymentMethod.pkPaymentMethod(); 133 } 134 135 std::optional<WebCore::PaymentMethod> ArgumentCoder<WebCore::PaymentMethod>::decode(Decoder& decoder) 136 { 137 auto paymentMethod = IPC::decode<PKPaymentMethod>(decoder, PAL::getPKPaymentMethodClass()); 138 if (!paymentMethod) 139 return std::nullopt; 140 141 return PaymentMethod { WTFMove(*paymentMethod) }; 205 142 } 206 143 … … 255 192 request.setRequiredBillingContactFields(requiredBillingContactFields); 256 193 257 PaymentContact billingContact; 258 if (!decoder.decode(billingContact)) 259 return false; 260 request.setBillingContact(billingContact); 194 std::optional<PaymentContact> billingContact; 195 decoder >> billingContact; 196 if (!billingContact) 197 return false; 198 request.setBillingContact(*billingContact); 261 199 262 200 ApplePaySessionPaymentRequest::ContactFields requiredShippingContactFields; … … 265 203 request.setRequiredShippingContactFields(requiredShippingContactFields); 266 204 267 PaymentContact shippingContact; 268 if (!decoder.decode(shippingContact)) 269 return false; 270 request.setShippingContact(shippingContact); 205 std::optional<PaymentContact> shippingContact; 206 decoder >> shippingContact; 207 if (!shippingContact) 208 return false; 209 request.setShippingContact(*shippingContact); 271 210 272 211 ApplePaySessionPaymentRequest::MerchantCapabilities merchantCapabilities; -
trunk/Source/WebKit/Shared/RemoteLayerTree/RemoteLayerTreeTransaction.mm
r238108 r238515 1 1 /* 2 * Copyright (C) 2012 Apple Inc. All rights reserved.2 * Copyright (C) 2012-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 921 921 ts << createdLayer.type <<" " << createdLayer.layerID; 922 922 switch (createdLayer.type) { 923 case PlatformCALayer::LayerTypeAVPlayerLayer:923 case WebCore::PlatformCALayer::LayerTypeAVPlayerLayer: 924 924 ts << " (context-id " << createdLayer.hostingContextID << ")"; 925 925 break; 926 case PlatformCALayer::LayerTypeContentsProvidedLayer:926 case WebCore::PlatformCALayer::LayerTypeContentsProvidedLayer: 927 927 ts << " (context-id " << createdLayer.hostingContextID << ")"; 928 928 break; 929 case PlatformCALayer::LayerTypeCustom:929 case WebCore::PlatformCALayer::LayerTypeCustom: 930 930 ts << " (context-id " << createdLayer.hostingContextID << ")"; 931 931 break; … … 939 939 940 940 if (!m_destroyedLayerIDs.isEmpty()) 941 ts.dumpProperty<Vector< GraphicsLayer::PlatformLayerID>>("destroyed-layers", m_destroyedLayerIDs);941 ts.dumpProperty<Vector<WebCore::GraphicsLayer::PlatformLayerID>>("destroyed-layers", m_destroyedLayerIDs); 942 942 943 943 if (m_editorState) { -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h
r238384 r238515 602 602 template<> struct ArgumentCoder<WebCore::Payment> { 603 603 static void encode(Encoder&, const WebCore::Payment&); 604 static bool decode(Decoder&, WebCore::Payment&);604 static std::optional<WebCore::Payment> decode(Decoder&); 605 605 }; 606 606 … … 612 612 template<> struct ArgumentCoder<WebCore::PaymentContact> { 613 613 static void encode(Encoder&, const WebCore::PaymentContact&); 614 static bool decode(Decoder&, WebCore::PaymentContact&);614 static std::optional<WebCore::PaymentContact> decode(Decoder&); 615 615 }; 616 616 … … 622 622 template<> struct ArgumentCoder<WebCore::PaymentMerchantSession> { 623 623 static void encode(Encoder&, const WebCore::PaymentMerchantSession&); 624 static bool decode(Decoder&, WebCore::PaymentMerchantSession&);624 static std::optional<WebCore::PaymentMerchantSession> decode(Decoder&); 625 625 }; 626 626 627 627 template<> struct ArgumentCoder<WebCore::PaymentMethod> { 628 628 static void encode(Encoder&, const WebCore::PaymentMethod&); 629 static bool decode(Decoder&, WebCore::PaymentMethod&);629 static std::optional<WebCore::PaymentMethod> decode(Decoder&); 630 630 }; 631 631 -
trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm
r237266 r238515 1 1 /* 2 * Copyright (C) 2014-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2014-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 27 27 #import "InteractionInformationAtPosition.h" 28 28 29 #import "ArgumentCodersC F.h"29 #import "ArgumentCodersCocoa.h" 30 30 #import "WebCoreArgumentCoders.h" 31 31 #import <pal/spi/cocoa/DataDetectorsCoreSPI.h> … … 77 77 if (isDataDetectorLink) { 78 78 encoder << dataDetectorIdentifier; 79 auto archiver = secureArchiver(); 80 [archiver encodeObject:dataDetectorResults.get() forKey:@"dataDetectorResults"]; 81 82 IPC::encode(encoder, reinterpret_cast<CFDataRef>(archiver.get().encodedData)); 79 encoder << dataDetectorResults; 83 80 } 84 81 #endif … … 174 171 if (!decoder.decode(result.dataDetectorIdentifier)) 175 172 return false; 176 RetainPtr<CFDataRef> data; 177 if (!IPC::decode(decoder, data)) 173 174 auto dataDetectorResults = IPC::decode<NSArray>(decoder, @[ [NSArray class], getDDScannerResultClass() ]); 175 if (!dataDetectorResults) 178 176 return false; 179 180 auto unarchiver = secureUnarchiverFromData((NSData *)data.get()); 181 @try { 182 result.dataDetectorResults = [unarchiver decodeObjectOfClasses:[NSSet setWithArray:@[ [NSArray class], getDDScannerResultClass()] ] forKey:@"dataDetectorResults"]; 183 } @catch (NSException *exception) { 184 LOG_ERROR("Failed to decode NSArray of DDScanResult: %@", exception); 185 return false; 186 } 187 188 [unarchiver finishDecoding]; 177 178 result.dataDetectorResults = WTFMove(*dataDetectorResults); 189 179 } 190 180 #endif -
trunk/Source/WebKit/Shared/mac/WebCoreArgumentCodersMac.mm
r235006 r238515 29 29 30 30 #import "ArgumentCodersCF.h" 31 #import "ArgumentCodersCocoa.h" 31 32 #import "DataReference.h" 32 33 #import <WebCore/CertificateInfo.h> … … 432 433 void ArgumentCoder<WebCore::ProtectionSpace>::encodePlatformData(Encoder& encoder, const WebCore::ProtectionSpace& space) 433 434 { 434 auto archiver = secureArchiver(); 435 [archiver encodeObject:space.nsSpace() forKey:@"protectionSpace"]; 436 IPC::encode(encoder, (__bridge CFDataRef)archiver.get().encodedData); 435 encoder << space.nsSpace(); 437 436 } 438 437 439 438 bool ArgumentCoder<WebCore::ProtectionSpace>::decodePlatformData(Decoder& decoder, WebCore::ProtectionSpace& space) 440 439 { 441 RetainPtr<CFDataRef> data; 442 if (!IPC::decode(decoder, data)) 443 return false; 444 445 auto unarchiver = secureUnarchiverFromData((__bridge NSData *)data.get()); 446 @try { 447 if (RetainPtr<NSURLProtectionSpace> nsSpace = [unarchiver decodeObjectOfClass:[NSURLProtectionSpace class] forKey:@"protectionSpace"]) 448 space = WebCore::ProtectionSpace(nsSpace.get()); 449 } @catch (NSException *exception) { 450 LOG_ERROR("Failed to decode NSURLProtectionSpace: %@", exception); 451 } 452 453 [unarchiver finishDecoding]; 440 auto platformData = IPC::decode<NSURLProtectionSpace>(decoder); 441 if (!platformData) 442 return false; 443 444 space = WebCore::ProtectionSpace { platformData->get() }; 454 445 return true; 455 446 } … … 475 466 476 467 encoder << false; 477 478 auto archiver = secureArchiver(); 479 [archiver encodeObject:nsCredential forKey:@"credential"]; 480 IPC::encode(encoder, (__bridge CFDataRef)archiver.get().encodedData); 468 encoder << nsCredential; 481 469 } 482 470 … … 510 498 } 511 499 512 RetainPtr<CFDataRef> data; 513 if (!IPC::decode(decoder, data)) 514 return false; 515 516 auto unarchiver = secureUnarchiverFromData((__bridge NSData *)data.get()); 517 @try { 518 if (RetainPtr<NSURLCredential> nsCredential = [unarchiver decodeObjectOfClass:[NSURLCredential class] forKey:@"credential"]) 519 credential = WebCore::Credential(nsCredential.get()); 520 } @catch (NSException *exception) { 521 LOG_ERROR("Failed to decode NSURLCredential: %@", exception); 522 } 523 524 [unarchiver finishDecoding]; 500 auto nsCredential = IPC::decode<NSURLCredential>(decoder); 501 if (!nsCredential) 502 return false; 503 504 credential = WebCore::Credential { nsCredential->get() }; 525 505 return true; 526 506 } … … 599 579 #if ENABLE(WIRELESS_PLAYBACK_TARGET) 600 580 601 static NSString *deviceContextKey()602 {603 static NSString * const key = @"deviceContext";604 return key;605 }606 607 581 void ArgumentCoder<WebCore::MediaPlaybackTargetContext>::encodePlatformData(Encoder& encoder, const WebCore::MediaPlaybackTargetContext& target) 608 582 { 609 auto archiver = secureArchiver();610 611 583 if ([getAVOutputContextClass() conformsToProtocol:@protocol(NSSecureCoding)]) 612 [archiver encodeObject:target.avOutputContext() forKey:deviceContextKey()]; 613 614 IPC::encode(encoder, (__bridge CFDataRef)archiver.get().encodedData); 584 encoder << target.avOutputContext(); 615 585 } 616 586 … … 620 590 return false; 621 591 622 RetainPtr<CFDataRef> data; 623 if (!IPC::decode(decoder, data)) 624 return false; 625 626 auto unarchiver = secureUnarchiverFromData((__bridge NSData *)data.get()); 627 628 AVOutputContext *context = nil; 629 @try { 630 context = [unarchiver decodeObjectOfClass:getAVOutputContextClass() forKey:deviceContextKey()]; 631 } @catch (NSException *exception) { 632 LOG_ERROR("The target picker being decoded is not an AVOutputContext."); 633 return false; 634 } 635 636 target = WebCore::MediaPlaybackTargetContext(context); 637 638 [unarchiver finishDecoding]; 592 auto context = IPC::decode<AVOutputContext>(decoder, getAVOutputContextClass()); 593 if (!context) 594 return false; 595 596 target = WebCore::MediaPlaybackTargetContext { context->get() }; 639 597 return true; 640 598 } -
trunk/Source/WebKit/Shared/mac/WebHitTestResultData.mm
r232520 r238515 1 1 /* 2 * Copyright (C) 2015-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2015-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 46 46 return; 47 47 48 auto archiver = secureArchiver(); 49 [archiver encodeObject:detectedDataActionContext.get() forKey:@"actionContext"]; 50 51 IPC::encode(encoder, (__bridge CFDataRef)archiver.get().encodedData); 48 encoder << detectedDataActionContext; 52 49 53 50 encoder << detectedDataBoundingBox; … … 70 67 ASSERT(DataDetectorsLibrary()); 71 68 72 RetainPtr<CFDataRef> data;73 if (! IPC::decode(decoder, data))69 auto detectedDataActionContext = IPC::decode<DDActionContext>(decoder, getDDActionContextClass()); 70 if (!detectedDataActionContext) 74 71 return false; 75 72 76 auto unarchiver = secureUnarchiverFromData((__bridge NSData *)data.get()); 77 @try { 78 hitTestResultData.detectedDataActionContext = [unarchiver decodeObjectOfClass:getDDActionContextClass() forKey:@"actionContext"]; 79 } @catch (NSException *exception) { 80 LOG_ERROR("Failed to decode DDActionContext: %@", exception); 81 return false; 82 } 83 84 [unarchiver finishDecoding]; 73 hitTestResultData.detectedDataActionContext = WTFMove(*detectedDataActionContext); 85 74 86 75 if (!decoder.decode(hitTestResultData.detectedDataBoundingBox)) -
trunk/Source/WebKit/SourcesCocoa.txt
r238468 r238515 123 123 Shared/Cocoa/APIDataCocoa.mm 124 124 Shared/Cocoa/APIObject.mm 125 Shared/Cocoa/ArgumentCodersCocoa.mm 125 126 Shared/Cocoa/ChildProcessCocoa.mm 126 127 Shared/Cocoa/CompletionHandlerCallChecker.mm -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r238468 r238515 1266 1266 A13DC682207AA6B20066EF72 /* WKApplicationStateTrackingView.h in Headers */ = {isa = PBXBuildFile; fileRef = A13DC680207AA6B20066EF72 /* WKApplicationStateTrackingView.h */; }; 1267 1267 A15EEDE61E301CEE000069B0 /* WKPasswordView.h in Headers */ = {isa = PBXBuildFile; fileRef = A15EEDE41E301CEE000069B0 /* WKPasswordView.h */; }; 1268 A175C44A21AA3171000037D0 /* ArgumentCodersCocoa.h in Headers */ = {isa = PBXBuildFile; fileRef = A175C44921AA3170000037D0 /* ArgumentCodersCocoa.h */; }; 1268 1269 A182D5B51BE6BD250087A7CC /* AccessibilityIOS.h in Headers */ = {isa = PBXBuildFile; fileRef = A182D5B31BE6BD250087A7CC /* AccessibilityIOS.h */; }; 1269 1270 A19DD3C01D07D16800AC823B /* _WKWebViewPrintFormatterInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A19DD3BF1D07D16800AC823B /* _WKWebViewPrintFormatterInternal.h */; }; … … 3820 3821 A15EEDE31E301CEE000069B0 /* WKPasswordView.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKPasswordView.mm; path = ios/WKPasswordView.mm; sourceTree = "<group>"; }; 3821 3822 A15EEDE41E301CEE000069B0 /* WKPasswordView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKPasswordView.h; path = ios/WKPasswordView.h; sourceTree = "<group>"; }; 3823 A175C44921AA3170000037D0 /* ArgumentCodersCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArgumentCodersCocoa.h; sourceTree = "<group>"; }; 3824 A175C44B21AA331B000037D0 /* ArgumentCodersCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ArgumentCodersCocoa.mm; sourceTree = "<group>"; }; 3822 3825 A182D5B21BE6BD250087A7CC /* AccessibilityIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AccessibilityIOS.mm; sourceTree = "<group>"; }; 3823 3826 A182D5B31BE6BD250087A7CC /* AccessibilityIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AccessibilityIOS.h; sourceTree = "<group>"; }; … … 6171 6174 1A1EF1971A1D5B420023200A /* APIDataCocoa.mm */, 6172 6175 378E1A3B181ED6FF0031007A /* APIObject.mm */, 6176 A175C44921AA3170000037D0 /* ArgumentCodersCocoa.h */, 6177 A175C44B21AA331B000037D0 /* ArgumentCodersCocoa.mm */, 6173 6178 1A698F171E4910220064E881 /* ChildProcessCocoa.mm */, 6174 6179 37BEC4DF19491486008B4286 /* CompletionHandlerCallChecker.h */, … … 8876 8881 7A8A9D581EF119B0009801AE /* APIInjectedBundleClient.h in Headers */, 8877 8882 377512311DF0DEE2008A351C /* APIInjectedBundleEditorClient.h in Headers */, 8878 E4E57F6B21A83B1200345F3C /* RemoteLayerTreeNode.h in Headers */,8879 8883 3769079E18F340A2001DFF04 /* APIInjectedBundleFormClient.h in Headers */, 8880 8884 7A3ACE1B1EEEF79B00A864A4 /* APIInjectedBundlePageLoaderClient.h in Headers */, … … 8917 8921 1AEFD2F711D1807B008219D3 /* ArgumentCoders.h in Headers */, 8918 8922 1AAF0C4A12B16334008E49E2 /* ArgumentCodersCF.h in Headers */, 8923 A175C44A21AA3171000037D0 /* ArgumentCodersCocoa.h in Headers */, 8919 8924 E179FD9C134D38060015B883 /* ArgumentCodersMac.h in Headers */, 8920 8925 CE1A0BD21A48E6C60054EF74 /* AssertionServicesSPI.h in Headers */, … … 9218 9223 0FF24A2E1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessages.h in Headers */, 9219 9224 1AA3D75C1651B44F008713D0 /* RemoteLayerTreeHost.h in Headers */, 9225 E4E57F6B21A83B1200345F3C /* RemoteLayerTreeNode.h in Headers */, 9220 9226 2DDE0AFA18298CC900F97EAA /* RemoteLayerTreePropertyApplier.h in Headers */, 9221 9227 0FF264A01A1FF9CC001FE759 /* RemoteLayerTreeScrollingPerformanceData.h in Headers */,
Note: See TracChangeset
for help on using the changeset viewer.