Changeset 220883 in webkit


Ignore:
Timestamp:
Aug 17, 2017 3:20:02 PM (7 years ago)
Author:
Wenson Hsieh
Message:

Fix the build on other platforms after r220865
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:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r220876 r220883  
     12017-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
    1202017-08-17  Michael Catanzaro  <mcatanzaro@igalia.com>
    221
  • trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm

    r220865 r220883  
    176176static NSString *webIOSPastePboardType = @"iOS rich content paste pasteboard type";
    177177
    178 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
     178#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     179
     180static 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
    179194
    180195static RetainPtr<NSDictionary> richTextRepresentationsForPasteboardWebContent(const PasteboardWebContent& content)
     
    200215}
    201216
    202 #else
    203 
    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 
    217217#endif
    218218
     
    253253void PlatformPasteboard::write(const PasteboardWebContent& content)
    254254{
    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
    256284    RetainPtr<NSMutableDictionary> representations = adoptNS([[NSMutableDictionary alloc] init]);
    257285    [representations addEntriesFromDictionary:richTextRepresentationsForPasteboardWebContent(content).autorelease()];
     
    267295    ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
    268296    [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
    269 #else
    270     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());
    297297#endif
    298298}
     
    300300void PlatformPasteboard::write(const PasteboardImage& pasteboardImage)
    301301{
    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
    314303    auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
    315304
     
    340329
    341330    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];
    361337    }
    362338
     
    364340    ASSERT([m_pasteboard isKindOfClass:getUIPasteboardClass()]);
    365341    [(UIPasteboard *)m_pasteboard setItems:@[representations.get()]];
    366 #else
     342#endif
     343}
     344
     345void PlatformPasteboard::write(const String& pasteboardType, const String& text)
     346{
     347#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
    367348    auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
    368349
     
    377358
    378359    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()]];
    379379#endif
    380380}
     
    382382void PlatformPasteboard::write(const PasteboardURL& url)
    383383{
    384 #if __IPHONE_OS_VERSION_MAX_ALLOWED < 110000
    385     write(kUTTypeURL, url.url.string());
    386 #else
     384#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
    387385    auto representationsToRegister = adoptNS([[WebItemProviderRegistrationInfoList alloc] init]);
    388386
     
    394392
    395393    registerItemToPasteboard(representationsToRegister.get(), m_pasteboard.get());
     394#else
     395    write(kUTTypeURL, url.url.string());
    396396#endif
    397397}
  • trunk/Tools/ChangeLog

    r220870 r220883  
     12017-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
    1132017-08-17  Andreas Kling  <akling@apple.com>
    214
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r220869 r220883  
    2626#if PLATFORM(IOS)
    2727
    28 #if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000
     28#if USE(APPLE_INTERNAL_SDK) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000
    2929
    3030#import <UIKit/UIApplication_Private.h>
Note: See TracChangeset for help on using the changeset viewer.