Title: [233436] trunk/Source/WebCore
- Revision
- 233436
- Author
- [email protected]
- Date
- 2018-07-02 14:52:18 -0700 (Mon, 02 Jul 2018)
Log Message
Enable copy paste on iOS apps for Mac
https://bugs.webkit.org/show_bug.cgi?id=187194
<rdar://problem/41451148>
Reviewed by Darin Adler.
Difficult to test this platform.
UIKit doesn't support itemProviders for iOS apps for Mac, so we need to revert to the
older way of setting a dictionary of objects and keys for items. Not everything is
availble in this form, and we haven't cleaned up our itemProvider code yet, so we
need to case some things out for now. Hopefully in the future, this will be implmented
and can just work as expected, but for now, this is the best workaround.
* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::registerItemToPasteboard):
(WebCore::PlatformPasteboard::write):
(WebCore::PlatformPasteboard::readURL):
* platform/ios/WebItemProviderPasteboard.h:
* platform/ios/WebItemProviderPasteboard.mm:
(-[WebItemProviderRegistrationInfoList itemProvider]):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (233435 => 233436)
--- trunk/Source/WebCore/ChangeLog 2018-07-02 21:49:49 UTC (rev 233435)
+++ trunk/Source/WebCore/ChangeLog 2018-07-02 21:52:18 UTC (rev 233436)
@@ -1,3 +1,27 @@
+2018-07-02 Megan Gardner <[email protected]>
+
+ Enable copy paste on iOS apps for Mac
+ https://bugs.webkit.org/show_bug.cgi?id=187194
+ <rdar://problem/41451148>
+
+ Reviewed by Darin Adler.
+
+ Difficult to test this platform.
+
+ UIKit doesn't support itemProviders for iOS apps for Mac, so we need to revert to the
+ older way of setting a dictionary of objects and keys for items. Not everything is
+ availble in this form, and we haven't cleaned up our itemProvider code yet, so we
+ need to case some things out for now. Hopefully in the future, this will be implmented
+ and can just work as expected, but for now, this is the best workaround.
+
+ * platform/ios/PlatformPasteboardIOS.mm:
+ (WebCore::registerItemToPasteboard):
+ (WebCore::PlatformPasteboard::write):
+ (WebCore::PlatformPasteboard::readURL):
+ * platform/ios/WebItemProviderPasteboard.h:
+ * platform/ios/WebItemProviderPasteboard.mm:
+ (-[WebItemProviderRegistrationInfoList itemProvider]):
+
2018-07-02 Eric Carlson <[email protected]>
Video sometimes flickers when playing to AppleTV
Modified: trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm (233435 => 233436)
--- trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm 2018-07-02 21:49:49 UTC (rev 233435)
+++ trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm 2018-07-02 21:52:18 UTC (rev 233436)
@@ -45,7 +45,8 @@
#import <wtf/SoftLinking.h>
#import <wtf/text/StringHash.h>
-#define PASTEBOARD_SUPPORTS_ITEM_PROVIDERS (PLATFORM(IOS) && !(PLATFORM(WATCHOS) || PLATFORM(APPLETV) || ENABLE(MINIMAL_SIMULATOR)))
+#define PASTEBOARD_SUPPORTS_ITEM_PROVIDERS (PLATFORM(IOS) && !(PLATFORM(WATCHOS) || PLATFORM(APPLETV)))
+#define NSURL_SUPPORTS_TITLE (!ENABLE(MINIMAL_SIMULATOR))
SOFT_LINK_FRAMEWORK(UIKit)
SOFT_LINK_CLASS(UIKit, UIImage)
@@ -288,6 +289,14 @@
static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *representationsToRegister, id <AbstractPasteboard> pasteboard)
{
+#if ENABLE(MINIMAL_SIMULATOR)
+ auto itemDictionary = adoptNS([[NSMutableDictionary alloc] init]);
+ [representationsToRegister enumerateItems:[itemDictionary] (id <WebItemProviderRegistrar> item, NSUInteger) {
+ if ([item respondsToSelector:@selector(typeIdentifierForClient)] && [item respondsToSelector:@selector(dataForClient)])
+ [itemDictionary setObject:item.dataForClient forKey:item.typeIdentifierForClient];
+ }];
+ [pasteboard setItems:@[ itemDictionary.get() ]];
+#else
if (UIItemProvider *itemProvider = representationsToRegister.itemProvider)
[pasteboard setItemProviders:@[ itemProvider ]];
else
@@ -295,6 +304,8 @@
if ([pasteboard respondsToSelector:@selector(stageRegistrationList:)])
[pasteboard stageRegistrationList:representationsToRegister];
+#endif
+
}
static void addRepresentationsForPlainText(WebItemProviderRegistrationInfoList *itemsToRegister, const String& plainText)
@@ -386,7 +397,9 @@
// the URL (i.e. the anchor's href attribute) to be a higher fidelity representation.
auto& pasteboardURL = pasteboardImage.url;
if (NSURL *nsURL = pasteboardURL.url) {
+#if NSURL_SUPPORTS_TITLE
nsURL._title = pasteboardURL.title.isEmpty() ? userVisibleString(pasteboardURL.url) : (NSString *)pasteboardURL.title;
+#endif
[representationsToRegister addRepresentingObject:nsURL];
}
@@ -416,8 +429,10 @@
[representationsToRegister setPreferredPresentationStyle:WebPreferredPresentationStyleInline];
if (NSURL *nsURL = url.url) {
+#if NSURL_SUPPORTS_TITLE
if (!url.title.isEmpty())
nsURL._title = url.title;
+#endif
[representationsToRegister addRepresentingObject:nsURL];
[representationsToRegister addRepresentingObject:(NSString *)url.url.string()];
}
@@ -658,7 +673,7 @@
if (!allowReadingURLAtIndex(url, index))
return { };
-#if PASTEBOARD_SUPPORTS_ITEM_PROVIDERS
+#if PASTEBOARD_SUPPORTS_ITEM_PROVIDERS && NSURL_SUPPORTS_TITLE
title = [url _title];
#else
UNUSED_PARAM(title);
Modified: trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h (233435 => 233436)
--- trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h 2018-07-02 21:49:49 UTC (rev 233435)
+++ trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.h 2018-07-02 21:52:18 UTC (rev 233436)
@@ -27,6 +27,17 @@
#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+// UIItemProviders are not implemented for iOS apps for Mac, because they were depricated last year.
+// We need to switch over to NSItemProviders everywhere. This should just be a temporary fix.
+#if defined(TARGET_OS_IOSMAC) && TARGET_OS_IOSMAC
+
+#define UIItemProvider NSItemProvider
+#define UIItemProviderReading NSItemProviderReading
+#define UIItemProviderWriting NSItemProviderWriting
+#define UIItemProviderRepresentationOptionsVisibilityAll NSItemProviderRepresentationVisibilityAll
+
+#endif
+
@class UIItemProvider;
@protocol UIItemProviderWriting;
Modified: trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm (233435 => 233436)
--- trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm 2018-07-02 21:49:49 UTC (rev 233435)
+++ trunk/Source/WebCore/platform/ios/WebItemProviderPasteboard.mm 2018-07-02 21:52:18 UTC (rev 233436)
@@ -26,7 +26,7 @@
#include "config.h"
#import "WebItemProviderPasteboard.h"
-#if ENABLE(DATA_INTERACTION)
+#if ENABLE(DATA_INTERACTION) || ENABLE(MINIMAL_SIMULATOR)
#import <Foundation/NSItemProvider.h>
#import <Foundation/NSProgress.h>
@@ -256,6 +256,7 @@
block([self itemAtIndex:index], index);
}
+#if !ENABLE(MINIMAL_SIMULATOR)
static UIPreferredPresentationStyle uiPreferredPresentationStyle(WebPreferredPresentationStyle style)
{
switch (style) {
@@ -270,6 +271,7 @@
return UIPreferredPresentationStyleUnspecified;
}
}
+#endif
- (UIItemProvider *)itemProvider
{
@@ -279,10 +281,14 @@
auto itemProvider = adoptNS([allocUIItemProviderInstance() init]);
for (id <WebItemProviderRegistrar> representation in _representations.get())
[representation registerItemProvider:itemProvider.get()];
+ [itemProvider setSuggestedName:self.suggestedName];
+ // UIItemProviders are not implemented for iOS apps for Mac, because they were depricated last year.
+ // We need to switch over to NSItemProviders everywhere. This should just be a temporary fix.
+#if !ENABLE(MINIMAL_SIMULATOR)
[itemProvider setPreferredPresentationSize:self.preferredPresentationSize];
- [itemProvider setSuggestedName:self.suggestedName];
[itemProvider setPreferredPresentationStyle:uiPreferredPresentationStyle(self.preferredPresentationStyle)];
[itemProvider setTeamData:self.teamData];
+#endif
return itemProvider.autorelease();
}
@@ -832,4 +838,4 @@
@end
-#endif // ENABLE(DATA_INTERACTION)
+#endif // ENABLE(DATA_INTERACTION) || ENABLE(MINIMAL_SIMULATOR)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes