Changeset 233436 in webkit
- Timestamp:
- Jul 2, 2018 2:52:18 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r233435 r233436 1 2018-07-02 Megan Gardner <megan_gardner@apple.com> 2 3 Enable copy paste on iOS apps for Mac 4 https://bugs.webkit.org/show_bug.cgi?id=187194 5 <rdar://problem/41451148> 6 7 Reviewed by Darin Adler. 8 9 Difficult to test this platform. 10 11 UIKit doesn't support itemProviders for iOS apps for Mac, so we need to revert to the 12 older way of setting a dictionary of objects and keys for items. Not everything is 13 availble in this form, and we haven't cleaned up our itemProvider code yet, so we 14 need to case some things out for now. Hopefully in the future, this will be implmented 15 and can just work as expected, but for now, this is the best workaround. 16 17 * platform/ios/PlatformPasteboardIOS.mm: 18 (WebCore::registerItemToPasteboard): 19 (WebCore::PlatformPasteboard::write): 20 (WebCore::PlatformPasteboard::readURL): 21 * platform/ios/WebItemProviderPasteboard.h: 22 * platform/ios/WebItemProviderPasteboard.mm: 23 (-[WebItemProviderRegistrationInfoList itemProvider]): 24 1 25 2018-07-02 Eric Carlson <eric.carlson@apple.com> 2 26 -
trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
r233339 r233436 46 46 #import <wtf/text/StringHash.h> 47 47 48 #define PASTEBOARD_SUPPORTS_ITEM_PROVIDERS (PLATFORM(IOS) && !(PLATFORM(WATCHOS) || PLATFORM(APPLETV) || ENABLE(MINIMAL_SIMULATOR))) 48 #define PASTEBOARD_SUPPORTS_ITEM_PROVIDERS (PLATFORM(IOS) && !(PLATFORM(WATCHOS) || PLATFORM(APPLETV))) 49 #define NSURL_SUPPORTS_TITLE (!ENABLE(MINIMAL_SIMULATOR)) 49 50 50 51 SOFT_LINK_FRAMEWORK(UIKit) … … 289 290 static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *representationsToRegister, id <AbstractPasteboard> pasteboard) 290 291 { 292 #if ENABLE(MINIMAL_SIMULATOR) 293 auto itemDictionary = adoptNS([[NSMutableDictionary alloc] init]); 294 [representationsToRegister enumerateItems:[itemDictionary] (id <WebItemProviderRegistrar> item, NSUInteger) { 295 if ([item respondsToSelector:@selector(typeIdentifierForClient)] && [item respondsToSelector:@selector(dataForClient)]) 296 [itemDictionary setObject:item.dataForClient forKey:item.typeIdentifierForClient]; 297 }]; 298 [pasteboard setItems:@[ itemDictionary.get() ]]; 299 #else 291 300 if (UIItemProvider *itemProvider = representationsToRegister.itemProvider) 292 301 [pasteboard setItemProviders:@[ itemProvider ]]; … … 296 305 if ([pasteboard respondsToSelector:@selector(stageRegistrationList:)]) 297 306 [pasteboard stageRegistrationList:representationsToRegister]; 307 #endif 308 298 309 } 299 310 … … 387 398 auto& pasteboardURL = pasteboardImage.url; 388 399 if (NSURL *nsURL = pasteboardURL.url) { 400 #if NSURL_SUPPORTS_TITLE 389 401 nsURL._title = pasteboardURL.title.isEmpty() ? userVisibleString(pasteboardURL.url) : (NSString *)pasteboardURL.title; 402 #endif 390 403 [representationsToRegister addRepresentingObject:nsURL]; 391 404 } … … 417 430 418 431 if (NSURL *nsURL = url.url) { 432 #if NSURL_SUPPORTS_TITLE 419 433 if (!url.title.isEmpty()) 420 434 nsURL._title = url.title; 435 #endif 421 436 [representationsToRegister addRepresentingObject:nsURL]; 422 437 [representationsToRegister addRepresentingObject:(NSString *)url.url.string()]; … … 659 674 return { }; 660 675 661 #if PASTEBOARD_SUPPORTS_ITEM_PROVIDERS 676 #if PASTEBOARD_SUPPORTS_ITEM_PROVIDERS && NSURL_SUPPORTS_TITLE 662 677 title = [url _title]; 663 678 #else -
trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h
r226779 r233436 27 27 28 28 #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000 29 30 // UIItemProviders are not implemented for iOS apps for Mac, because they were depricated last year. 31 // We need to switch over to NSItemProviders everywhere. This should just be a temporary fix. 32 #if defined(TARGET_OS_IOSMAC) && TARGET_OS_IOSMAC 33 34 #define UIItemProvider NSItemProvider 35 #define UIItemProviderReading NSItemProviderReading 36 #define UIItemProviderWriting NSItemProviderWriting 37 #define UIItemProviderRepresentationOptionsVisibilityAll NSItemProviderRepresentationVisibilityAll 38 39 #endif 29 40 30 41 @class UIItemProvider; -
trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm
r232512 r233436 27 27 #import "WebItemProviderPasteboard.h" 28 28 29 #if ENABLE(DATA_INTERACTION) 29 #if ENABLE(DATA_INTERACTION) || ENABLE(MINIMAL_SIMULATOR) 30 30 31 31 #import <Foundation/NSItemProvider.h> … … 257 257 } 258 258 259 #if !ENABLE(MINIMAL_SIMULATOR) 259 260 static UIPreferredPresentationStyle uiPreferredPresentationStyle(WebPreferredPresentationStyle style) 260 261 { … … 271 272 } 272 273 } 274 #endif 273 275 274 276 - (UIItemProvider *)itemProvider … … 280 282 for (id <WebItemProviderRegistrar> representation in _representations.get()) 281 283 [representation registerItemProvider:itemProvider.get()]; 284 [itemProvider setSuggestedName:self.suggestedName]; 285 // UIItemProviders are not implemented for iOS apps for Mac, because they were depricated last year. 286 // We need to switch over to NSItemProviders everywhere. This should just be a temporary fix. 287 #if !ENABLE(MINIMAL_SIMULATOR) 282 288 [itemProvider setPreferredPresentationSize:self.preferredPresentationSize]; 283 [itemProvider setSuggestedName:self.suggestedName];284 289 [itemProvider setPreferredPresentationStyle:uiPreferredPresentationStyle(self.preferredPresentationStyle)]; 285 290 [itemProvider setTeamData:self.teamData]; 291 #endif 286 292 return itemProvider.autorelease(); 287 293 } … … 833 839 @end 834 840 835 #endif // ENABLE(DATA_INTERACTION) 841 #endif // ENABLE(DATA_INTERACTION) || ENABLE(MINIMAL_SIMULATOR)
Note: See TracChangeset
for help on using the changeset viewer.