Changeset 242908 in webkit
- Timestamp:
- Mar 13, 2019 2:18:34 PM (5 years ago)
- Location:
- trunk/Source
- Files:
-
- 2 deleted
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r242906 r242908 1 2019-03-13 Timothy Hatcher <timothy@apple.com> 2 3 Consolidate ArgumentCodersMac and ArgumentCodersCocoa. 4 https://bugs.webkit.org/show_bug.cgi?id=195636 5 rdar://problem/45055697 6 7 Reviewed by Ryosuke Niwa. 8 9 * editing/DictionaryPopupInfo.h: 10 (WebCore::DictionaryPopupInfo::encodingRequiresPlatformData const): Added. 11 * editing/FontAttributes.h: 12 (WebCore::FontAttributes::encodingRequiresPlatformData const): Added. 13 1 14 2019-03-13 Chris Dumez <cdumez@apple.com> 2 15 -
trunk/Source/WebCore/editing/DictionaryPopupInfo.h
r208646 r242908 41 41 RetainPtr<NSDictionary> options; 42 42 RetainPtr<NSAttributedString> attributedString; 43 44 bool encodingRequiresPlatformData() const { return true; } 45 #else 46 bool encodingRequiresPlatformData() const { return false; } 43 47 #endif 44 48 }; -
trunk/Source/WebCore/editing/FontAttributes.h
r239427 r242908 80 80 81 81 #if PLATFORM(COCOA) 82 bool encodingRequiresPlatformData() const { return true; } 83 82 84 WEBCORE_EXPORT RetainPtr<NSDictionary> createDictionary() const; 85 #else 86 bool encodingRequiresPlatformData() const { return false; } 83 87 #endif 84 88 -
trunk/Source/WebKit/ChangeLog
r242905 r242908 1 2019-03-13 Timothy Hatcher <timothy@apple.com> 2 3 Consolidate ArgumentCodersMac and ArgumentCodersCocoa. 4 https://bugs.webkit.org/show_bug.cgi?id=195636 5 rdar://problem/45055697 6 7 Reviewed by Ryosuke Niwa. 8 9 Merge the two similar encoders and decoders. This avoids issues where 10 one encoder could be used and the other decoder, which caused a crash. 11 It also stops handling NSAttributedString specifically and just uses 12 the NSSecureCoding path to handle more complex attributes. 13 14 Some WebCore encoders code needed to move to platform files, since 15 ArgumentCodersCocoa.h requires an ObjectiveC++ implementation to work. 16 17 * Shared/Cocoa/ArgumentCodersCocoa.h: 18 (IPC::encode): 19 (IPC::decode): 20 (IPC::ArgumentCoder<RetainPtr<T>>::encode): 21 (IPC::ArgumentCoder<RetainPtr<T>>::decode): 22 * Shared/Cocoa/ArgumentCodersCocoa.mm: 23 (IPC::typeFromObject): 24 (IPC::isSerializableFont): 25 (IPC::isSerializableValue): 26 (IPC::encodeObject): 27 (IPC::decodeObject): 28 * Shared/Cocoa/LoadParametersCocoa.mm: 29 * Shared/Cocoa/WebCoreArgumentCodersCocoa.mm: 30 (IPC::ArgumentCoder<WebCore::DictionaryPopupInfo>::encodePlatformData): 31 (IPC::ArgumentCoder<WebCore::DictionaryPopupInfo>::decodePlatformData): 32 (IPC::ArgumentCoder<WebCore::FontAttributes>::encodePlatformData): 33 (IPC::ArgumentCoder<WebCore::FontAttributes>::decodePlatformData): 34 * Shared/WebCoreArgumentCoders.cpp: 35 (IPC::ArgumentCoder<DictionaryPopupInfo>::encode): 36 (IPC::ArgumentCoder<DictionaryPopupInfo>::decode): 37 (IPC::ArgumentCoder<FontAttributes>::encode): 38 (IPC::ArgumentCoder<FontAttributes>::decode): 39 * Shared/WebCoreArgumentCoders.h: 40 * Shared/mac/ArgumentCodersMac.h: Removed. 41 * Shared/mac/ArgumentCodersMac.mm: Removed. 42 * Shared/mac/AttributedString.mm: 43 (WebKit::AttributedString::encode const): 44 * Shared/mac/ObjCObjectGraph.mm: 45 * SourcesCocoa.txt: 46 * WebKit.xcodeproj/project.pbxproj: 47 1 48 2019-03-13 Chris Dumez <cdumez@apple.com> 2 49 -
trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.h
r239427 r242908 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018, 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 32 32 namespace IPC { 33 33 34 void encodeObject(Encoder&, id <NSSecureCoding>);35 Optional<RetainPtr<id <NSSecureCoding>>> decodeObject(Decoder&, NSArray<Class> *allowedClasses);34 void encodeObject(Encoder&, id); 35 Optional<RetainPtr<id>> decodeObject(Decoder&, NSArray<Class> *allowedClasses); 36 36 37 template<typename T> Optional<RetainPtr<T>> decode(Decoder&, Class allowedClass); 38 template<typename T> Optional<RetainPtr<T>> decode(Decoder&, NSArray<Class> *allowedClasses = @[ [T class] ]); 37 template<typename T> using IsObjCObject = std::enable_if_t<std::is_convertible<T *, id>::value, T *>; 39 38 40 template<typename T> 41 Optional<RetainPtr<T>> decode(Decoder& decoder, Class allowedClass) 42 { 43 return decode<T>(decoder, @[ allowedClass ]); 44 } 39 template<typename T, typename = IsObjCObject<T>> void encode(Encoder&, T *); 40 template<typename T, typename = IsObjCObject<T>> bool decode(Decoder&, RetainPtr<T>&, NSArray<Class> *allowedClasses = @[ [T class] ]); 41 template<typename T, typename = IsObjCObject<T>> Optional<RetainPtr<T>> decode(Decoder&, NSArray<Class> *allowedClasses = @[ [T class] ]); 45 42 46 43 #ifndef NDEBUG … … 57 54 #endif 58 55 59 template<typename T> 56 template<typename T, typename> 57 void encode(Encoder& encoder, T *object) 58 { 59 encodeObject(encoder, object); 60 } 61 62 template<typename T, typename> 63 bool decode(Decoder& decoder, RetainPtr<T>& result, NSArray<Class> *allowedClasses) 64 { 65 auto object = decodeObject(decoder, allowedClasses); 66 if (!object) 67 return false; 68 result = *object; 69 ASSERT(!*object || isObjectClassAllowed((*object).get(), allowedClasses)); 70 return true; 71 } 72 73 template<typename T, typename> 60 74 Optional<RetainPtr<T>> decode(Decoder& decoder, NSArray<Class> *allowedClasses) 61 75 { … … 63 77 if (!result) 64 78 return WTF::nullopt; 65 66 if (!*result) 67 return { nullptr }; 68 69 id object = result->leakRef(); 70 ASSERT(isObjectClassAllowed(object, allowedClasses)); 71 return { adoptNS(static_cast<T *>(object)) }; 79 ASSERT(!*result || isObjectClassAllowed((*result).get(), allowedClasses)); 80 return { *result }; 72 81 } 73 82 74 template<typename T> using ConformsToSecureCoding = std::is_convertible<T *, id <NSSecureCoding>>;75 76 83 template<typename T> struct ArgumentCoder<T *> { 77 template<typename U = T, std::enable_if_t<ConformsToSecureCoding<U>::value>* = nullptr>84 template<typename U = T, typename = IsObjCObject<U>> 78 85 static void encode(Encoder& encoder, U *object) 79 86 { … … 83 90 84 91 template<typename T> struct ArgumentCoder<RetainPtr<T>> { 85 template <typename U = T, std::enable_if_t<ConformsToSecureCoding<U>::value>* = nullptr>92 template<typename U = T, typename = IsObjCObject<U>> 86 93 static void encode(Encoder& encoder, const RetainPtr<U>& object) 87 94 { … … 89 96 } 90 97 91 template <typename U = T, std::enable_if_t<ConformsToSecureCoding<U>::value>* = nullptr>98 template<typename U = T, typename = IsObjCObject<U>> 92 99 static Optional<RetainPtr<U>> decode(Decoder& decoder) 93 100 { -
trunk/Source/WebKit/Shared/Cocoa/ArgumentCodersCocoa.mm
r239427 r242908 1 1 /* 2 * Copyright (C) 2018 Apple Inc. All rights reserved.2 * Copyright (C) 2018, 2019 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 30 30 31 31 #import "ArgumentCodersCF.h" 32 #import <CoreText/CTFont.h> 33 #import <CoreText/CTFontDescriptor.h> 32 34 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> 35 #import <wtf/HashSet.h> 36 37 #if USE(APPKIT) 38 #import <WebCore/ColorMac.h> 39 #endif 40 41 #if USE(APPKIT) 42 #define PlatformFont NSFont 43 #define PlatformFontDescriptor NSFontDescriptor 44 #else 45 #define PlatformFont UIFont 46 #define PlatformFontDescriptor UIFontDescriptor 47 #endif 33 48 34 49 namespace IPC { 35 36 void encodeObject(Encoder& encoder, id <NSSecureCoding> object) 50 using namespace WebCore; 51 52 #pragma mark - Types 53 54 enum class NSType { 55 Array, 56 #if USE(APPKIT) 57 Color, 58 #endif 59 Data, 60 Date, 61 Dictionary, 62 Font, 63 Number, 64 SecureCoding, 65 String, 66 URL, 67 Unknown, 68 }; 69 70 #pragma mark - Helpers 71 72 static NSType typeFromObject(id object) 73 { 74 ASSERT(object); 75 76 // Specific classes handled. 77 if ([object isKindOfClass:[NSArray class]]) 78 return NSType::Array; 79 #if USE(APPKIT) 80 if ([object isKindOfClass:[NSColor class]]) 81 return NSType::Color; 82 #endif 83 if ([object isKindOfClass:[NSData class]]) 84 return NSType::Data; 85 if ([object isKindOfClass:[NSDate class]]) 86 return NSType::Date; 87 if ([object isKindOfClass:[NSDictionary class]]) 88 return NSType::Dictionary; 89 if ([object isKindOfClass:[PlatformFont class]]) 90 return NSType::Font; 91 if ([object isKindOfClass:[NSNumber class]]) 92 return NSType::Number; 93 if ([object isKindOfClass:[NSString class]]) 94 return NSType::String; 95 if ([object isKindOfClass:[NSURL class]]) 96 return NSType::URL; 97 98 // Check NSSecureCoding after the specific cases since 99 // most of the classes above conform to NSSecureCoding, 100 // and we want our special case coders for them instead. 101 if ([object conformsToProtocol:@protocol(NSSecureCoding)]) 102 return NSType::SecureCoding; 103 104 ASSERT_NOT_REACHED(); 105 return NSType::Unknown; 106 } 107 108 static inline bool isSerializableFont(CTFontRef font) 109 { 110 return adoptCF(CTFontCopyAttribute(font, kCTFontURLAttribute)); 111 } 112 113 static inline bool isSerializableValue(id value) 114 { 115 if ([value isKindOfClass:[PlatformFont class]]) 116 return isSerializableFont((__bridge CTFontRef)value); 117 return typeFromObject(value) != NSType::Unknown; 118 } 119 120 #pragma mark - NSArray 121 122 static void encodeArrayInternal(Encoder& encoder, NSArray *array) 123 { 124 // Even though NSArray is toll free bridged with CFArrayRef, values may not be, 125 // so we should stay within this file's code. 126 127 if (!array.count) { 128 encoder << static_cast<uint64_t>(0); 129 return; 130 } 131 132 HashSet<NSUInteger> invalidIndicies; 133 for (NSUInteger i = 0; i < array.count; ++i) { 134 id value = array[i]; 135 136 // Ignore values we don't support. 137 ASSERT(isSerializableValue(value)); 138 if (!isSerializableValue(value)) 139 invalidIndicies.add(i); 140 } 141 142 encoder << static_cast<uint64_t>(array.count - invalidIndicies.size()); 143 144 for (NSUInteger i = 0; i < array.count; ++i) { 145 if (invalidIndicies.contains(i)) 146 continue; 147 encodeObject(encoder, array[i]); 148 } 149 } 150 151 static Optional<RetainPtr<id>> decodeArrayInternal(Decoder& decoder) 152 { 153 uint64_t size; 154 if (!decoder.decode(size)) 155 return WTF::nullopt; 156 157 RetainPtr<NSMutableArray> array = adoptNS([[NSMutableArray alloc] initWithCapacity:size]); 158 for (uint64_t i = 0; i < size; ++i) { 159 auto value = decodeObject(decoder, nil); 160 if (!value) 161 return WTF::nullopt; 162 [array addObject:value.value().get()]; 163 } 164 165 return { array }; 166 } 167 168 #pragma mark - NSColor 169 170 #if USE(APPKIT) 171 static inline void encodeColorInternal(Encoder& encoder, NSColor *color) 172 { 173 encoder << colorFromNSColor(color); 174 } 175 176 static inline Optional<RetainPtr<id>> decodeColorInternal(Decoder& decoder) 177 { 178 Color color; 179 if (!decoder.decode(color)) 180 return WTF::nullopt; 181 return { nsColor(color) }; 182 } 183 #endif 184 185 #pragma mark - NSData 186 187 static inline void encodeDataInternal(Encoder& encoder, NSData *data) 188 { 189 encode(encoder, (__bridge CFDataRef)data); 190 } 191 192 static inline Optional<RetainPtr<id>> decodeDataInternal(Decoder& decoder) 193 { 194 RetainPtr<CFDataRef> data; 195 if (!decode(decoder, data)) 196 return WTF::nullopt; 197 return { adoptNS((NSData *)data.leakRef()) }; 198 } 199 200 #pragma mark - NSDate 201 202 static inline void encodeDateInternal(Encoder& encoder, NSDate *date) 203 { 204 encode(encoder, (__bridge CFDateRef)date); 205 } 206 207 static inline Optional<RetainPtr<id>> decodeDateInternal(Decoder& decoder) 208 { 209 RetainPtr<CFDateRef> date; 210 if (!decode(decoder, date)) 211 return WTF::nullopt; 212 return { adoptNS((NSDate *)date.leakRef()) }; 213 } 214 215 #pragma mark - NSDictionary 216 217 static void encodeDictionaryInternal(Encoder& encoder, NSDictionary *dictionary) 218 { 219 // Even though NSDictionary is toll free bridged with CFDictionaryRef, keys/values may not be, 220 // so we should stay within this file's code. 221 222 if (!dictionary.count) { 223 encoder << static_cast<uint64_t>(0); 224 return; 225 } 226 227 HashSet<id> invalidKeys; 228 for (id key in dictionary) { 229 id value = dictionary[key]; 230 ASSERT(value); 231 232 // Ignore values we don't support. 233 ASSERT(isSerializableValue(key)); 234 ASSERT(isSerializableValue(value)); 235 if (!isSerializableValue(key) || !isSerializableValue(value)) 236 invalidKeys.add(key); 237 } 238 239 encoder << static_cast<uint64_t>(dictionary.count - invalidKeys.size()); 240 241 for (id key in dictionary) { 242 if (invalidKeys.contains(key)) 243 continue; 244 encodeObject(encoder, key); 245 encodeObject(encoder, dictionary[key]); 246 } 247 } 248 249 static Optional<RetainPtr<id>> decodeDictionaryInternal(Decoder& decoder) 250 { 251 uint64_t size; 252 if (!decoder.decode(size)) 253 return WTF::nullopt; 254 255 RetainPtr<NSMutableDictionary> dictionary = adoptNS([[NSMutableDictionary alloc] initWithCapacity:size]); 256 for (uint64_t i = 0; i < size; ++i) { 257 auto key = decodeObject(decoder, nil); 258 if (!key) 259 return WTF::nullopt; 260 261 auto value = decodeObject(decoder, nil); 262 if (!value) 263 return WTF::nullopt; 264 265 [dictionary setObject:value.value().get() forKey:key.value().get()]; 266 } 267 268 return { dictionary }; 269 } 270 271 #pragma mark - NSFont / UIFont 272 273 static inline void encodeFontInternal(Encoder& encoder, PlatformFont *font) 274 { 275 encode(encoder, font.fontDescriptor.fontAttributes); 276 } 277 278 static Optional<RetainPtr<id>> decodeFontInternal(Decoder& decoder) 279 { 280 RetainPtr<NSDictionary> fontAttributes; 281 if (!decode(decoder, fontAttributes)) 282 return WTF::nullopt; 283 284 PlatformFontDescriptor *fontDescriptor = [PlatformFontDescriptor fontDescriptorWithFontAttributes:fontAttributes.get()]; 285 return { [PlatformFont fontWithDescriptor:fontDescriptor size:0] }; 286 } 287 288 #pragma mark - NSNumber 289 290 static inline void encodeNumberInternal(Encoder& encoder, NSNumber *number) 291 { 292 encode(encoder, (__bridge CFNumberRef)number); 293 } 294 295 static inline Optional<RetainPtr<id>> decodeNumberInternal(Decoder& decoder) 296 { 297 RetainPtr<CFNumberRef> number; 298 if (!decode(decoder, number)) 299 return WTF::nullopt; 300 return { adoptNS((NSNumber *)number.leakRef()) }; 301 } 302 303 #pragma mark - id <NSSecureCoding> 304 305 static void encodeSecureCodingInternal(Encoder& encoder, id <NSObject, NSSecureCoding> object) 37 306 { 38 307 auto archiver = secureArchiver(); … … 40 309 [archiver finishEncoding]; 41 310 42 IPC::encode(encoder, (__bridge CFDataRef)[archiver encodedData]); 43 } 44 45 Optional<RetainPtr<id <NSSecureCoding>>> decodeObject(Decoder& decoder, NSArray<Class> *allowedClasses) 46 { 311 encode(encoder, (__bridge CFDataRef)[archiver encodedData]); 312 } 313 314 static Optional<RetainPtr<id>> decodeSecureCodingInternal(Decoder& decoder, NSArray<Class> *allowedClasses) 315 { 316 ASSERT(allowedClasses && allowedClasses.count); 317 if (!allowedClasses || !allowedClasses.count) 318 return WTF::nullopt; 319 47 320 RetainPtr<CFDataRef> data; 48 321 if (!decode(decoder, data)) … … 62 335 } 63 336 337 #pragma mark - NSString 338 339 static inline void encodeStringInternal(Encoder& encoder, NSString *string) 340 { 341 encode(encoder, (__bridge CFStringRef)string); 342 } 343 344 static inline Optional<RetainPtr<id>> decodeStringInternal(Decoder& decoder) 345 { 346 RetainPtr<CFStringRef> string; 347 if (!decode(decoder, string)) 348 return WTF::nullopt; 349 return { adoptNS((NSString *)string.leakRef()) }; 350 } 351 352 #pragma mark - NSURL 353 354 static inline void encodeURLInternal(Encoder& encoder, NSURL *URL) 355 { 356 encode(encoder, (__bridge CFURLRef)URL); 357 } 358 359 static inline Optional<RetainPtr<id>> decodeURLInternal(Decoder& decoder) 360 { 361 RetainPtr<CFURLRef> URL; 362 if (!decode(decoder, URL)) 363 return WTF::nullopt; 364 return { adoptNS((NSURL *)URL.leakRef()) }; 365 } 366 367 #pragma mark - Entry Point Encoder / Decoder 368 369 void encodeObject(Encoder& encoder, id object) 370 { 371 encoder << static_cast<bool>(!object); 372 if (!object) 373 return; 374 375 NSType type = typeFromObject(object); 376 encoder << type; 377 378 switch (type) { 379 case NSType::Array: 380 encodeArrayInternal(encoder, static_cast<NSArray *>(object)); 381 return; 382 #if USE(APPKIT) 383 case NSType::Color: 384 encodeColorInternal(encoder, static_cast<NSColor *>(object)); 385 return; 386 #endif 387 case NSType::Dictionary: 388 encodeDictionaryInternal(encoder, static_cast<NSDictionary *>(object)); 389 return; 390 case NSType::Font: 391 encodeFontInternal(encoder, static_cast<PlatformFont *>(object)); 392 return; 393 case NSType::Number: 394 encodeNumberInternal(encoder, static_cast<NSNumber *>(object)); 395 return; 396 case NSType::SecureCoding: 397 encodeSecureCodingInternal(encoder, static_cast<id <NSObject, NSSecureCoding>>(object)); 398 return; 399 case NSType::String: 400 encodeStringInternal(encoder, static_cast<NSString *>(object)); 401 return; 402 case NSType::Date: 403 encodeDateInternal(encoder, static_cast<NSDate *>(object)); 404 return; 405 case NSType::Data: 406 encodeDataInternal(encoder, static_cast<NSData *>(object)); 407 return; 408 case NSType::URL: 409 encodeURLInternal(encoder, static_cast<NSURL *>(object)); 410 return; 411 case NSType::Unknown: 412 break; 413 } 414 415 ASSERT_NOT_REACHED(); 416 } 417 418 Optional<RetainPtr<id>> decodeObject(Decoder& decoder, NSArray<Class> *allowedClasses) 419 { 420 bool isNull; 421 if (!decoder.decode(isNull)) 422 return WTF::nullopt; 423 if (isNull) 424 return { nullptr }; 425 426 NSType type; 427 if (!decoder.decodeEnum(type)) 428 return WTF::nullopt; 429 430 switch (type) { 431 case NSType::Array: 432 return decodeArrayInternal(decoder); 433 #if USE(APPKIT) 434 case NSType::Color: 435 return decodeColorInternal(decoder); 436 #endif 437 case NSType::Dictionary: 438 return decodeDictionaryInternal(decoder); 439 #if USE(APPKIT) 440 case NSType::Font: 441 return decodeFontInternal(decoder); 442 #else 443 case NSType::Font: 444 return decodeFontInternal(decoder); 445 #endif 446 case NSType::Number: 447 return decodeNumberInternal(decoder); 448 case NSType::SecureCoding: 449 return decodeSecureCodingInternal(decoder, allowedClasses); 450 case NSType::String: 451 return decodeStringInternal(decoder); 452 case NSType::Date: 453 return decodeDateInternal(decoder); 454 case NSType::Data: 455 return decodeDataInternal(decoder); 456 case NSType::URL: 457 return decodeURLInternal(decoder); 458 case NSType::Unknown: 459 break; 460 } 461 462 ASSERT_NOT_REACHED(); 463 return WTF::nullopt; 464 } 465 64 466 } // namespace IPC 65 467 468 namespace WTF { 469 template<> struct EnumTraits<IPC::NSType> { 470 using values = EnumValues< 471 IPC::NSType, 472 IPC::NSType::Array, 473 #if USE(APPKIT) 474 IPC::NSType::Color, 475 #endif 476 IPC::NSType::Data, 477 IPC::NSType::Date, 478 IPC::NSType::Dictionary, 479 IPC::NSType::Font, 480 IPC::NSType::Number, 481 IPC::NSType::SecureCoding, 482 IPC::NSType::String, 483 IPC::NSType::URL, 484 IPC::NSType::Unknown 485 >; 486 }; 487 } // namespace WTF 488 66 489 #endif // PLATFORM(COCOA) -
trunk/Source/WebKit/Shared/Cocoa/LoadParametersCocoa.mm
r204668 r242908 29 29 #if PLATFORM(COCOA) 30 30 31 #include "ArgumentCoders Mac.h"31 #include "ArgumentCodersCocoa.h" 32 32 #include "WebCoreArgumentCoders.h" 33 33 -
trunk/Source/WebKit/Shared/Cocoa/WebCoreArgumentCodersCocoa.mm
r239427 r242908 27 27 #import "WebCoreArgumentCoders.h" 28 28 29 #import "ArgumentCodersCocoa.h" 30 #import <WebCore/DictionaryPopupInfo.h> 31 #import <WebCore/FontAttributes.h> 32 29 33 #if ENABLE(APPLE_PAY) 30 34 31 #import "ArgumentCodersCocoa.h"32 35 #import "DataReference.h" 33 36 #import <WebCore/PaymentAuthorizationStatus.h> … … 35 38 #import <pal/spi/cocoa/NSKeyedArchiverSPI.h> 36 39 40 #endif 41 37 42 namespace IPC { 38 43 using namespace WebCore; 44 45 #if ENABLE(APPLE_PAY) 39 46 40 47 void ArgumentCoder<WebCore::Payment>::encode(Encoder& encoder, const WebCore::Payment& payment) … … 409 416 } 410 417 411 } 412 #endif 418 #endif // ENABLE(APPLEPAY) 419 420 void ArgumentCoder<WebCore::DictionaryPopupInfo>::encodePlatformData(Encoder& encoder, const WebCore::DictionaryPopupInfo& info) 421 { 422 encoder << info.options << info.attributedString; 423 } 424 425 bool ArgumentCoder<WebCore::DictionaryPopupInfo>::decodePlatformData(Decoder& decoder, WebCore::DictionaryPopupInfo& result) 426 { 427 if (!IPC::decode(decoder, result.options)) 428 return false; 429 if (!IPC::decode(decoder, result.attributedString)) 430 return false; 431 return true; 432 } 433 434 void ArgumentCoder<WebCore::FontAttributes>::encodePlatformData(Encoder& encoder, const WebCore::FontAttributes& attributes) 435 { 436 encoder << attributes.font; 437 } 438 439 Optional<FontAttributes> ArgumentCoder<WebCore::FontAttributes>::decodePlatformData(Decoder& decoder, WebCore::FontAttributes& attributes) 440 { 441 if (!IPC::decode(decoder, attributes.font)) 442 return WTF::nullopt; 443 return attributes; 444 } 445 446 } // namespace IPC -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.cpp
r242155 r242908 91 91 #if PLATFORM(COCOA) 92 92 #include "ArgumentCodersCF.h" 93 #include "ArgumentCodersMac.h"94 93 #endif 95 94 … … 2600 2599 encoder << info.textIndicator; 2601 2600 2602 #if PLATFORM(COCOA) 2603 bool hadOptions = info.options; 2604 encoder << hadOptions; 2605 if (hadOptions) 2606 IPC::encode(encoder, info.options.get()); 2607 2608 bool hadAttributedString = info.attributedString; 2609 encoder << hadAttributedString; 2610 if (hadAttributedString) 2611 IPC::encode(encoder, info.attributedString.get()); 2612 #endif 2601 if (info.encodingRequiresPlatformData()) { 2602 encoder << true; 2603 encodePlatformData(encoder, info); 2604 return; 2605 } 2606 2607 encoder << false; 2613 2608 } 2614 2609 … … 2624 2619 result.textIndicator = WTFMove(*textIndicator); 2625 2620 2626 #if PLATFORM(COCOA) 2627 bool hadOptions; 2628 if (!decoder.decode(hadOptions)) 2629 return false; 2630 if (hadOptions) { 2631 if (!IPC::decode(decoder, result.options)) 2632 return false; 2633 } else 2634 result.options = nullptr; 2635 2636 bool hadAttributedString; 2637 if (!decoder.decode(hadAttributedString)) 2638 return false; 2639 if (hadAttributedString) { 2640 if (!IPC::decode(decoder, result.attributedString)) 2641 return false; 2642 } else 2643 result.attributedString = nullptr; 2644 #endif 2621 bool hasPlatformData; 2622 if (!decoder.decode(hasPlatformData)) 2623 return false; 2624 if (hasPlatformData) 2625 return decodePlatformData(decoder, result); 2645 2626 return true; 2646 2627 } … … 3046 3027 encoder.encodeEnum(attributes.horizontalAlignment); 3047 3028 encoder.encodeEnum(attributes.subscriptOrSuperscript); 3048 #if PLATFORM(COCOA) 3049 bool hasFont = attributes.font;3050 encoder << hasFont;3051 if (hasFont)3052 IPC::encode(encoder, attributes.font.get());3053 #endif 3029 3030 if (attributes.encodingRequiresPlatformData()) { 3031 encoder << true; 3032 encodePlatformData(encoder, attributes); 3033 return; 3034 } 3054 3035 } 3055 3036 … … 3082 3063 return WTF::nullopt; 3083 3064 3084 #if PLATFORM(COCOA) 3085 bool hasFont = false; 3086 if (!decoder.decode(hasFont)) 3087 return WTF::nullopt; 3088 3089 if (hasFont && !IPC::decode(decoder, attributes.font)) 3090 return WTF::nullopt; 3091 #endif 3065 bool hasPlatformData; 3066 if (!decoder.decode(hasPlatformData)) 3067 return WTF::nullopt; 3068 if (hasPlatformData) 3069 return decodePlatformData(decoder, attributes); 3092 3070 3093 3071 return attributes; -
trunk/Source/WebKit/Shared/WebCoreArgumentCoders.h
r240579 r242908 583 583 static void encode(Encoder&, const WebCore::DictionaryPopupInfo&); 584 584 static bool decode(Decoder&, WebCore::DictionaryPopupInfo&); 585 static void encodePlatformData(Encoder&, const WebCore::DictionaryPopupInfo&); 586 static bool decodePlatformData(Decoder&, WebCore::DictionaryPopupInfo&); 585 587 }; 586 588 … … 745 747 static void encode(Encoder&, const WebCore::FontAttributes&); 746 748 static Optional<WebCore::FontAttributes> decode(Decoder&); 749 static void encodePlatformData(Encoder&, const WebCore::FontAttributes&); 750 static Optional<WebCore::FontAttributes> decodePlatformData(Decoder&, WebCore::FontAttributes&); 747 751 }; 748 752 -
trunk/Source/WebKit/Shared/curl/WebCoreArgumentCodersCurl.cpp
r239550 r242908 30 30 #include <WebCore/CertificateInfo.h> 31 31 #include <WebCore/CurlProxySettings.h> 32 #include <WebCore/DictionaryPopupInfo.h> 33 #include <WebCore/FontAttributes.h> 32 34 #include <WebCore/ProtectionSpace.h> 33 35 #include <WebCore/ResourceError.h> … … 211 213 } 212 214 213 } 215 void ArgumentCoder<FontAttributes>::encodePlatformData(Encoder&, const FontAttributes&) 216 { 217 ASSERT_NOT_REACHED(); 218 } 219 220 Optional<FontAttributes> ArgumentCoder<FontAttributes>::decodePlatformData(Decoder&, FontAttributes&) 221 { 222 ASSERT_NOT_REACHED(); 223 return WTF::nullopt; 224 } 225 226 void ArgumentCoder<DictionaryPopupInfo>::encodePlatformData(Encoder&, const DictionaryPopupInfo&) 227 { 228 ASSERT_NOT_REACHED(); 229 } 230 231 bool ArgumentCoder<DictionaryPopupInfo>::decodePlatformData(Decoder&, DictionaryPopupInfo&) 232 { 233 ASSERT_NOT_REACHED(); 234 return false; 235 } 236 237 } -
trunk/Source/WebKit/Shared/mac/AttributedString.mm
r242285 r242908 28 28 29 29 #import "ArgumentCodersCocoa.h" 30 #import " ArgumentCodersMac.h"31 #import <Foundation/Foundation.h>30 #import "Decoder.h" 31 #import "Encoder.h" 32 32 33 33 namespace IPC { … … 35 35 void ArgumentCoder<WebKit::AttributedString>::encode(Encoder& encoder, const WebKit::AttributedString& attributedString) 36 36 { 37 encoder << static_cast<bool>(!attributedString.string); 38 if (!attributedString.string) 39 return; 40 IPC::encode(encoder, attributedString.string.get()); 37 encoder << attributedString.string; 41 38 } 42 39 43 40 Optional<WebKit::AttributedString> ArgumentCoder<WebKit::AttributedString>::decode(Decoder& decoder) 44 41 { 45 bool isNull;46 if (! decoder.decode(isNull))42 RetainPtr<NSAttributedString> attributedString; 43 if (!IPC::decode(decoder, attributedString)) 47 44 return WTF::nullopt; 48 if (isNull)49 return WebKit::AttributedString { };50 51 RetainPtr<NSAttributedString> attributedString;52 IPC::decode(decoder, attributedString);53 if (!attributedString)54 return WTF::nullopt;55 56 45 return WebKit::AttributedString { attributedString.get() }; 57 46 } -
trunk/Source/WebKit/Shared/mac/ObjCObjectGraph.mm
r242339 r242908 27 27 #import "ObjCObjectGraph.h" 28 28 29 #import "ArgumentCoders Mac.h"29 #import "ArgumentCodersCocoa.h" 30 30 #import "Decoder.h" 31 31 #import "Encoder.h" -
trunk/Source/WebKit/Shared/soup/WebCoreArgumentCodersSoup.cpp
r237415 r242908 31 31 32 32 #include <WebCore/CertificateInfo.h> 33 #include <WebCore/DictionaryPopupInfo.h> 34 #include <WebCore/FontAttributes.h> 33 35 #include <WebCore/ResourceError.h> 34 36 #include <WebCore/ResourceRequest.h> … … 228 230 } 229 231 230 } 231 232 void ArgumentCoder<FontAttributes>::encodePlatformData(Encoder&, const FontAttributes&) 233 { 234 ASSERT_NOT_REACHED(); 235 } 236 237 Optional<FontAttributes> ArgumentCoder<FontAttributes>::decodePlatformData(Decoder&, FontAttributes&) 238 { 239 ASSERT_NOT_REACHED(); 240 return WTF::nullopt; 241 } 242 243 void ArgumentCoder<DictionaryPopupInfo>::encodePlatformData(Encoder&, const DictionaryPopupInfo&) 244 { 245 ASSERT_NOT_REACHED(); 246 } 247 248 bool ArgumentCoder<DictionaryPopupInfo>::decodePlatformData(Decoder&, DictionaryPopupInfo&) 249 { 250 ASSERT_NOT_REACHED(); 251 return false; 252 } 253 254 } 255 -
trunk/Source/WebKit/SourcesCocoa.txt
r242764 r242908 175 175 Shared/ios/WebTouchEventIOS.cpp 176 176 177 Shared/mac/ArgumentCodersMac.mm178 177 Shared/mac/AttributedString.mm 179 178 Shared/mac/AuxiliaryProcessMac.mm -
trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj
r242891 r242908 1599 1599 E170876C16D6CA6900F99226 /* BlobRegistryProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = E170876A16D6CA6900F99226 /* BlobRegistryProxy.h */; }; 1600 1600 E179088F169BAA6A006904C7 /* SecItemShim.h in Headers */ = {isa = PBXBuildFile; fileRef = E18E6948169B77C8009B6670 /* SecItemShim.h */; }; 1601 E179FD9C134D38060015B883 /* ArgumentCodersMac.h in Headers */ = {isa = PBXBuildFile; fileRef = E179FD9B134D38060015B883 /* ArgumentCodersMac.h */; };1602 1601 E17AE2C316B9C63A001C42F1 /* com.apple.WebKit.NetworkProcess.sb in Resources */ = {isa = PBXBuildFile; fileRef = E17AE2C216B9C63A001C42F1 /* com.apple.WebKit.NetworkProcess.sb */; }; 1603 1602 E18E690C169B563F009B6670 /* SecItemShimProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = E18E690A169B563F009B6670 /* SecItemShimProxy.h */; }; … … 4472 4471 E170876A16D6CA6900F99226 /* BlobRegistryProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = BlobRegistryProxy.h; path = WebProcess/FileAPI/BlobRegistryProxy.h; sourceTree = "<group>"; }; 4473 4472 E1798C7716E6818800240139 /* NetworkBlobRegistry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = NetworkBlobRegistry.cpp; sourceTree = "<group>"; }; 4474 E179FD9B134D38060015B883 /* ArgumentCodersMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ArgumentCodersMac.h; sourceTree = "<group>"; };4475 E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ArgumentCodersMac.mm; sourceTree = "<group>"; };4476 4473 E17AE2C116B9C139001C42F1 /* com.apple.WebKit.NetworkProcess.sb.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = com.apple.WebKit.NetworkProcess.sb.in; sourceTree = "<group>"; }; 4477 4474 E17AE2C216B9C63A001C42F1 /* com.apple.WebKit.NetworkProcess.sb */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = com.apple.WebKit.NetworkProcess.sb; path = DerivedSources/WebKit2/com.apple.WebKit.NetworkProcess.sb; sourceTree = BUILT_PRODUCTS_DIR; }; … … 7861 7858 isa = PBXGroup; 7862 7859 children = ( 7863 E179FD9B134D38060015B883 /* ArgumentCodersMac.h */,7864 E179FD9E134D38250015B883 /* ArgumentCodersMac.mm */,7865 7860 E1A31731134CEA6C007C9A4F /* AttributedString.h */, 7866 7861 E1A31734134CEA80007C9A4F /* AttributedString.mm */, … … 9061 9056 1AAF0C4A12B16334008E49E2 /* ArgumentCodersCF.h in Headers */, 9062 9057 A175C44A21AA3171000037D0 /* ArgumentCodersCocoa.h in Headers */, 9063 E179FD9C134D38060015B883 /* ArgumentCodersMac.h in Headers */,9064 9058 CE1A0BD21A48E6C60054EF74 /* AssertionServicesSPI.h in Headers */, 9065 9059 515E7728183DD6F60007203F /* AsyncRequest.h in Headers */,
Note: See TracChangeset
for help on using the changeset viewer.