Fix the build on other platforms after r220865
authorwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Aug 2017 22:20:02 +0000 (22:20 +0000)
committerwenson_hsieh@apple.com <wenson_hsieh@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Aug 2017 22:20:02 +0000 (22:20 +0000)
https://bugs.webkit.org/show_bug.cgi?id=175683

Reviewed by Tim Horton.

Source/WebCore:

Instead of special casing iOS 10 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED < 110000, revert to special
casing iOS 11 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000. This is because other targets that are
neither iOS 10 nor 11 will fail the "before iOS 11" compile-time check, and subsequently assume that item
providers exist. To fix this, flip the compiler-time checks and the order of codeblocks in the
PlatformPasteboard::write methods.

There is no change in behavior.

* platform/ios/PlatformPasteboardIOS.mm:
(WebCore::registerItemToPasteboard):
(WebCore::PlatformPasteboard::write):

Tools:

Check __IPHONE_OS_VERSION_MAX_ALLOWED instead of __IPHONE_OS_VERSION_MIN_REQUIRED in an SPI header. SPI
availability is determined by SDK version rather than deployment version.

* TestWebKitAPI/ios/UIKitSPI.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@220883 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
Tools/ChangeLog
Tools/TestWebKitAPI/ios/UIKitSPI.h

index 67960c7..03eb938 100644 (file)
@@ -1,3 +1,22 @@
+2017-08-17  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Fix the build on other platforms after r220865
+        https://bugs.webkit.org/show_bug.cgi?id=175683
+
+        Reviewed by Tim Horton.
+
+        Instead of special casing iOS 10 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED < 110000, revert to special
+        casing iOS 11 behavior with __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000. This is because other targets that are
+        neither iOS 10 nor 11 will fail the "before iOS 11" compile-time check, and subsequently assume that item
+        providers exist. To fix this, flip the compiler-time checks and the order of codeblocks in the
+        PlatformPasteboard::write methods.
+
+        There is no change in behavior.
+
+        * platform/ios/PlatformPasteboardIOS.mm:
+        (WebCore::registerItemToPasteboard):
+        (WebCore::PlatformPasteboard::write):
+
 2017-08-17  Michael Catanzaro  <mcatanzaro@igalia.com>
 
         -Wreturn-type warnings in CryptoKey.cpp and SubtleCrypto.cpp
index 936701a..25bfb7a 100644 (file)
@@ -175,7 +175,22 @@ String PlatformPasteboard::uniqueName()
 
 static NSString *webIOSPastePboardType = @"iOS rich content paste pasteboard type";
 
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+
+static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *representationsToRegister, id <AbstractPasteboard> pasteboard)
+{
+    UIItemProvider *itemProvider = [representationsToRegister itemProvider];
+    if (!itemProvider) {
+        [pasteboard setItemProviders:@[ ]];
+        return;
+    }
+
+    [pasteboard setItemProviders:@[ itemProvider ]];
+    if ([pasteboard respondsToSelector:@selector(setRegistrationInfoLists:)])
+        [pasteboard setRegistrationInfoLists:@[ representationsToRegister ]];
+}
+
+#else
 
 static RetainPtr<NSDictionary> richTextRepresentationsForPasteboardWebContent(const PasteboardWebContent& content)
 {
@@ -199,21 +214,6 @@ static RetainPtr<NSDictionary> richTextRepresentationsForPasteboardWebContent(co
     return representations;
 }
 
-#else
-
-static void registerItemToPasteboard(WebItemProviderRegistrationInfoList *representationsToRegister, id <AbstractPasteboard> pasteboard)
-{
-    UIItemProvider *itemProvider = [representationsToRegister itemProvider];
-    if (!itemProvider) {
-        [pasteboard setItemProviders:@[ ]];
-        return;
-    }
-
-    [pasteboard setItemProviders:@[ itemProvider ]];
-    if ([pasteboard respondsToSelector:@selector(setRegistrationInfoLists:)])
-        [pasteboard setRegistrationInfoLists:@[ representationsToRegister ]];
-}
-
 #endif
 
 #if ENABLE(DATA_INTERACTION)
@@ -252,21 +252,7 @@ bool PlatformPasteboard::allowReadingURLAtIndex(const URL&, int) const
 
 void PlatformPasteboard::write(const PasteboardWebContent& content)
 {
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
-    RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
-    [representations addEntriesFromDictionary:richTextRepresentationsForPasteboardWebContent(content).autorelease()];
-
-    NSString *textAsString = content.dataInStringFormat;
-    [representations setValue:[textAsString dataUsingEncoding:NSUTF8StringEncoding] forKey:(NSString *)kUTTypeUTF8PlainText];
-    [representations setValue:[textAsString dataUsingEncoding:NSUTF16StringEncoding] forKey:(NSString *)kUTTypeUTF16PlainText];
-    // FIXME: We vend "public.text" here for backwards compatibility with pre-iOS 11 apps. In the future, we should stop vending this UTI,
-    // and instead set data for concrete plain text types. See <https://bugs.webkit.org/show_bug.cgi?id=173317>.
-    [representations setValue:textAsString forKey:(NSString *)kUTTypeText];
-
-    // Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.
-    ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
-    [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
-#else
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
 
     [representationsToRegister addData:[webIOSPastePboardType dataUsingEncoding:NSUTF8StringEncoding] forType:webIOSPastePboardType];
@@ -294,23 +280,26 @@ void PlatformPasteboard::write(const PasteboardWebContent& content)
         addRepresentationsForPlainText(representationsToRegister.get(), content.dataInStringFormat);
 
     registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
-#endif
-}
-
-void PlatformPasteboard::write(const PasteboardImage& pasteboardImage)
-{
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
+#else
     RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
-    if (!pasteboardImage.resourceMIMEType.isNull()) {
-        [representations setObject:pasteboardImage.resourceData->createNSData().get() forKey:pasteboardImage.resourceMIMEType];
-        if (!pasteboardImage.url.url.isNull())
-            [representations setObject:(NSURL *)pasteboardImage.url.url forKey:(NSString *)kUTTypeURL];
-    }
+    [representations addEntriesFromDictionary:richTextRepresentationsForPasteboardWebContent(content).autorelease()];
+
+    NSString *textAsString = content.dataInStringFormat;
+    [representations setValue:[textAsString dataUsingEncoding:NSUTF8StringEncoding] forKey:(NSString *)kUTTypeUTF8PlainText];
+    [representations setValue:[textAsString dataUsingEncoding:NSUTF16StringEncoding] forKey:(NSString *)kUTTypeUTF16PlainText];
+    // FIXME: We vend "public.text" here for backwards compatibility with pre-iOS 11 apps. In the future, we should stop vending this UTI,
+    // and instead set data for concrete plain text types. See <https://bugs.webkit.org/show_bug.cgi?id=173317>.
+    [representations setValue:textAsString forKey:(NSString *)kUTTypeText];
 
     // Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.
     ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
     [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
-#else
+#endif
+}
+
+void PlatformPasteboard::write(const PasteboardImage& pasteboardImage)
+{
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
 
     auto& types = pasteboardImage.clientTypes;
@@ -339,12 +328,36 @@ void PlatformPasteboard::write(const PasteboardImage& pasteboardImage)
     }
 
     registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
+#else
+    RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
+    if (!pasteboardImage.resourceMIMEType.isNull()) {
+        [representations setObject:pasteboardImage.resourceData->createNSData().get() forKey:pasteboardImage.resourceMIMEType];
+        if (!pasteboardImage.url.url.isNull())
+            [representations setObject:(NSURL *)pasteboardImage.url.url forKey:(NSString *)kUTTypeURL];
+    }
+
+    // Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.
+    ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
+    [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
 #endif
 }
 
 void PlatformPasteboard::write(const String& pasteboardType, const String& text)
 {
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+    auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
+
+    NSString *pasteboardTypeAsNSString = pasteboardType;
+    if (!text.isEmpty() && pasteboardTypeAsNSString.length) {
+        auto pasteboardTypeAsCFString = (CFStringRef)pasteboardTypeAsNSString;
+        if (UTTypeConformsTo(pasteboardTypeAsCFString, kUTTypeURL) || UTTypeConformsTo(pasteboardTypeAsCFString, kUTTypeText))
+            addRepresentationsForPlainText(representationsToRegister.get(), text);
+        else
+            [representationsToRegister addData:[pasteboardTypeAsNSString dataUsingEncoding:NSUTF8StringEncoding] forType:pasteboardType];
+    }
+
+    registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
+#else
     RetainPtr<NSDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
 
     NSString *textAsString = text;
@@ -363,27 +376,12 @@ void PlatformPasteboard::write(const String& pasteboardType, const String& text)
     // Explicitly cast m_pasteboard to UIPasteboard * to work around rdar://problem/33383354.
     ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
     [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
-#else
-    auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
-
-    NSString *pasteboardTypeAsNSString = pasteboardType;
-    if (!text.isEmpty() && pasteboardTypeAsNSString.length) {
-        auto pasteboardTypeAsCFString = (CFStringRef)pasteboardTypeAsNSString;
-        if (UTTypeConformsTo(pasteboardTypeAsCFString, kUTTypeURL) || UTTypeConformsTo(pasteboardTypeAsCFString, kUTTypeText))
-            addRepresentationsForPlainText(representationsToRegister.get(), text);
-        else
-            [representationsToRegister addData:[pasteboardTypeAsNSString dataUsingEncoding:NSUTF8StringEncoding] forType:pasteboardType];
-    }
-
-    registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
 #endif
 }
 
 void PlatformPasteboard::write(const PasteboardURL& url)
 {
-#if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
-    write(kUTTypeURL, url.url.string());
-#else
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
 
     if (NSURL *nsURL = url.url) {
@@ -393,6 +391,8 @@ void PlatformPasteboard::write(const PasteboardURL& url)
     }
 
     registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
+#else
+    write(kUTTypeURL, url.url.string());
 #endif
 }
 
index 49f25a0..621a527 100644 (file)
@@ -1,3 +1,15 @@
+2017-08-17  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Fix the build on other platforms after r220865
+        https://bugs.webkit.org/show_bug.cgi?id=175683
+
+        Reviewed by Tim Horton.
+
+        Check __IPHONE_OS_VERSION_MAX_ALLOWED instead of __IPHONE_OS_VERSION_MIN_REQUIRED in an SPI header. SPI
+        availability is determined by SDK version rather than deployment version.
+
+        * TestWebKitAPI/ios/UIKitSPI.h:
+
 2017-08-17  Andreas Kling  <akling@apple.com>
 
         Disable CSS regions at compile time
index de6f952..9dcb223 100644 (file)
@@ -25,7 +25,7 @@
 
 #if PLATFORM(IOS)
 
-#if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
+#if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
 
 #import <UIKit/UIApplication_Private.h>