Changeset 220883 in webkit
- Timestamp:
- Aug 17, 2017 3:20:02 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r220876 r220883 1 2017-08-17 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Fix the build on other platforms after r220865 4 https://bugs.webkit.org/show_bug.cgi?id=175683 5 6 Reviewed by Tim Horton. 7 8 Instead of special casing iOS 10 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED < 110000, revert to special 9 casing iOS 11 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000. This is because other targets that are 10 neither iOS 10 nor 11 will fail the "before iOS 11" compile-time check, and subsequently assume that item 11 providers exist. To fix this, flip the compiler-time checks and the order of codeblocks in the 12 PlatformPasteboard::write methods. 13 14 There is no change in behavior. 15 16 * platform/ios/PlatformPasteboardIOS.mm: 17 (WebCore::registerItemToPasteboard): 18 (WebCore::PlatformPasteboard::write): 19 1 20 2017-08-17 Michael Catanzaro <mcatanzaro@igalia.com> 2 21 -
trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
r220865 r220883 176 176 static NSString *webIOSPastePboardType = @"iOS rich content paste pasteboard type"; 177 177 178 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000 178 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 179 180 static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *representationsToRegister, id <AbstractPasteboard> pasteboard) 181 { 182 UIItemProvider *itemProvider = [representationsToRegister itemProvider]; 183 if (!itemProvider) { 184 [pasteboard setItemProviders:@[ ]]; 185 return; 186 } 187 188 [pasteboard setItemProviders:@[ itemProvider ]]; 189 if ([pasteboard respondsToSelector:@selector(setRegistrationInfoLists:)]) 190 [pasteboard setRegistrationInfoLists:@[ representationsToRegister ]]; 191 } 192 193 #else 179 194 180 195 static RetainPtr<NSDictionary> richTextRepresentationsForPasteboardWebContent(const PasteboardWebContent& content) … … 200 215 } 201 216 202 #else203 204 static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *representationsToRegister, id <AbstractPasteboard> pasteboard)205 {206 UIItemProvider *itemProvider = [representationsToRegister itemProvider];207 if (!itemProvider) {208 [pasteboard setItemProviders:@[ ]];209 return;210 }211 212 [pasteboard setItemProviders:@[ itemProvider ]];213 if ([pasteboard respondsToSelector:@selector(setRegistrationInfoLists:)])214 [pasteboard setRegistrationInfoLists:@[ representationsToRegister ]];215 }216 217 217 #endif 218 218 … … 253 253 void PlatformPasteboard::write(const PasteboardWebContent& content) 254 254 { 255 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000 255 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 256 auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]); 257 258 [representationsToRegister addData:[webIOSPastePboardType dataUsingEncoding:NSUTF8StringEncoding] forType:webIOSPastePboardType]; 259 260 ASSERT(content.clientTypes.size() == content.clientData.size()); 261 for (size_t i = 0, size = content.clientTypes.size(); i < size; ++i) 262 [representationsToRegister addData:content.clientData[i]->createNSData().get() forType:content.clientTypes[i]]; 263 264 if (content.dataInWebArchiveFormat) 265 [representationsToRegister addData:content.dataInWebArchiveFormat->createNSData().get() forType:WebArchivePboardType]; 266 267 if (content.dataInAttributedStringFormat) { 268 NSAttributedString *attributedString = [NSKeyedUnarchiver unarchiveObjectWithData:content.dataInAttributedStringFormat->createNSData().get()]; 269 if (attributedString) 270 [representationsToRegister addRepresentingObject:attributedString]; 271 } 272 273 if (content.dataInRTFDFormat) 274 [representationsToRegister addData:content.dataInRTFDFormat->createNSData().get() forType:(NSString *)kUTTypeFlatRTFD]; 275 276 if (content.dataInRTFFormat) 277 [representationsToRegister addData:content.dataInRTFFormat->createNSData().get() forType:(NSString *)kUTTypeRTF]; 278 279 if (!content.dataInStringFormat.isEmpty()) 280 addRepresentationsForPlainText(representationsToRegister.get(), content.dataInStringFormat); 281 282 registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get()); 283 #else 256 284 RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]); 257 285 [representations addEntriesFromDictionary:richTextRepresentationsForPasteboardWebContent(content).autorelease()]; … … 267 295 ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]); 268 296 [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]]; 269 #else270 auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);271 272 [representationsToRegister addData:[webIOSPastePboardType dataUsingEncoding:NSUTF8StringEncoding] forType:webIOSPastePboardType];273 274 ASSERT(content.clientTypes.size() == content.clientData.size());275 for (size_t i = 0, size = content.clientTypes.size(); i < size; ++i)276 [representationsToRegister addData:content.clientData[i]->createNSData().get() forType:content.clientTypes[i]];277 278 if (content.dataInWebArchiveFormat)279 [representationsToRegister addData:content.dataInWebArchiveFormat->createNSData().get() forType:WebArchivePboardType];280 281 if (content.dataInAttributedStringFormat) {282 NSAttributedString *attributedString = [NSKeyedUnarchiver unarchiveObjectWithData:content.dataInAttributedStringFormat->createNSData().get()];283 if (attributedString)284 [representationsToRegister addRepresentingObject:attributedString];285 }286 287 if (content.dataInRTFDFormat)288 [representationsToRegister addData:content.dataInRTFDFormat->createNSData().get() forType:(NSString *)kUTTypeFlatRTFD];289 290 if (content.dataInRTFFormat)291 [representationsToRegister addData:content.dataInRTFFormat->createNSData().get() forType:(NSString *)kUTTypeRTF];292 293 if (!content.dataInStringFormat.isEmpty())294 addRepresentationsForPlainText(representationsToRegister.get(), content.dataInStringFormat);295 296 registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());297 297 #endif 298 298 } … … 300 300 void PlatformPasteboard::write(const PasteboardImage& pasteboardImage) 301 301 { 302 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000 303 RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]); 304 if (!pasteboardImage.resourceMIMEType.isNull()) { 305 [representations setObject:pasteboardImage.resourceData->createNSData().get() forKey:pasteboardImage.resourceMIMEType]; 306 if (!pasteboardImage.url.url.isNull()) 307 [representations setObject:(NSURL *)pasteboardImage.url.url forKey:(NSString *)kUTTypeURL]; 308 } 309 310 // Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354. 311 ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]); 312 [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]]; 313 #else 302 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 314 303 auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]); 315 304 … … 340 329 341 330 registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get()); 342 #endif 343 } 344 345 void PlatformPasteboard::write(const String& pasteboardType, const String& text) 346 { 347 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000 348 RetainPtr<NSDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]); 349 350 NSString *textAsString = text; 351 if (pasteboardType == String(kUTTypeURL)) { 352 [representations setValue:adoptNS([[NSURL alloc] initWithString:text]).get() forKey:pasteboardType]; 353 [representations setValue:textAsString forKey:(NSString *)kUTTypeText]; 354 } else if (!pasteboardType.isNull()) 355 [representations setValue:textAsString forKey:pasteboardType]; 356 357 auto cfPasteboardType = pasteboardType.createCFString(); 358 if (UTTypeConformsTo(cfPasteboardType.get(), kUTTypeText) || UTTypeConformsTo(cfPasteboardType.get(), kUTTypeURL)) { 359 [representations setValue:[textAsString dataUsingEncoding:NSUTF8StringEncoding] forKey:(NSString *)kUTTypeUTF8PlainText]; 360 [representations setValue:[textAsString dataUsingEncoding:NSUTF16StringEncoding] forKey:(NSString *)kUTTypeUTF16PlainText]; 331 #else 332 RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]); 333 if (!pasteboardImage.resourceMIMEType.isNull()) { 334 [representations setObject:pasteboardImage.resourceData->createNSData().get() forKey:pasteboardImage.resourceMIMEType]; 335 if (!pasteboardImage.url.url.isNull()) 336 [representations setObject:(NSURL *)pasteboardImage.url.url forKey:(NSString *)kUTTypeURL]; 361 337 } 362 338 … … 364 340 ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]); 365 341 [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]]; 366 #else 342 #endif 343 } 344 345 void PlatformPasteboard::write(const String& pasteboardType, const String& text) 346 { 347 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 367 348 auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]); 368 349 … … 377 358 378 359 registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get()); 360 #else 361 RetainPtr<NSDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]); 362 363 NSString *textAsString = text; 364 if (pasteboardType == String(kUTTypeURL)) { 365 [representations setValue:adoptNS([[NSURL alloc] initWithString:text]).get() forKey:pasteboardType]; 366 [representations setValue:textAsString forKey:(NSString *)kUTTypeText]; 367 } else if (!pasteboardType.isNull()) 368 [representations setValue:textAsString forKey:pasteboardType]; 369 370 auto cfPasteboardType = pasteboardType.createCFString(); 371 if (UTTypeConformsTo(cfPasteboardType.get(), kUTTypeText) || UTTypeConformsTo(cfPasteboardType.get(), kUTTypeURL)) { 372 [representations setValue:[textAsString dataUsingEncoding:NSUTF8StringEncoding] forKey:(NSString *)kUTTypeUTF8PlainText]; 373 [representations setValue:[textAsString dataUsingEncoding:NSUTF16StringEncoding] forKey:(NSString *)kUTTypeUTF16PlainText]; 374 } 375 376 // Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354. 377 ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]); 378 [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]]; 379 379 #endif 380 380 } … … 382 382 void PlatformPasteboard::write(const PasteboardURL& url) 383 383 { 384 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000 385 write(kUTTypeURL, url.url.string()); 386 #else 384 #if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 387 385 auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]); 388 386 … … 394 392 395 393 registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get()); 394 #else 395 write(kUTTypeURL, url.url.string()); 396 396 #endif 397 397 } -
trunk/Tools/ChangeLog
r220870 r220883 1 2017-08-17 Wenson Hsieh <wenson_hsieh@apple.com> 2 3 Fix the build on other platforms after r220865 4 https://bugs.webkit.org/show_bug.cgi?id=175683 5 6 Reviewed by Tim Horton. 7 8 Check __IPHONE_OS_VERSION_MAX_ALLOWED instead of __IPHONE_OS_VERSION_MIN_REQUIRED in an SPI header. SPI 9 availability is determined by SDK version rather than deployment version. 10 11 * TestWebKitAPI/ios/UIKitSPI.h: 12 1 13 2017-08-17 Andreas Kling <akling@apple.com> 2 14 -
trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h
r220869 r220883 26 26 #if PLATFORM(IOS) 27 27 28 #if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_M IN_REQUIRED >= 11000028 #if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 29 29 30 30 #import <UIKit/UIApplication_Private.h>
Note: See TracChangeset
for help on using the changeset viewer.