diff --git a/Source/CyberCore/platform/ios/PasteboardIOS.mm b/Source/CyberCore/platform/ios/PasteboardIOS.mm index dc246acf76b64..a1d36253db92e 100644 --- a/Source/CyberCore/platform/ios/PasteboardIOS.mm +++ b/Source/CyberCore/platform/ios/PasteboardIOS.mm @@ -304,8 +304,15 @@ static void readURLAlongsideAttachmentIfNecessary(PasteboardWebContentReader& re static bool shouldTreatAsAttachmentByDefault(const String& typeIdentifier) { - auto type = [UTType typeWithIdentifier:typeIdentifier]; - return [type conformsToType:UTTypeVCard] || [type conformsToType:UTTypePDF]; + if (@available(iOS 14.0, *)) { + auto type = [UTType typeWithIdentifier:typeIdentifier]; + return [type conformsToType:UTTypeVCard] || [type conformsToType:UTTypePDF]; + } else { +ALLOW_DEPRECATED_DECLARATIONS_BEGIN + CFStringRef type = (__bridge CFStringRef)typeIdentifier.utf8().data(); + return UTTypeConformsTo(type, kUTTypeVCard) || UTTypeConformsTo(type, kUTTypePDF); +ALLOW_DEPRECATED_DECLARATIONS_END + } } static bool prefersAttachmentRepresentation(const PasteboardItemInfo& info) diff --git a/Source/CyberKit/Shared/API/Cocoa/_WKHitTestResult.h b/Source/CyberKit/Shared/API/Cocoa/_WKHitTestResult.h index 8dc274e48635f..041d1c7a0efbd 100644 --- a/Source/CyberKit/Shared/API/Cocoa/_WKHitTestResult.h +++ b/Source/CyberKit/Shared/API/Cocoa/_WKHitTestResult.h @@ -25,7 +25,7 @@ #import -#if TARGET_OS_OSX || TARGET_OS_IOS +#if TARGET_OS_OSX || (TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130400) #import diff --git a/Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm b/Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm index aea9a709db03f..1e357ac305629 100644 --- a/Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm +++ b/Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm @@ -59,6 +59,10 @@ SOFT_LINK(CoreSVG, CGSVGDocumentRelease, void, (CGSVGDocumentRef document), (document)) #endif +#if !HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) +#import +#endif + namespace CyberKit { static NSString * const manifestVersionManifestKey = @"manifest_version"; @@ -747,10 +751,20 @@ static _WKWebExtensionError toAPI(WebExtension::Error error) NSURL *imageURL = resourceFileURLForPath(imagePath); +#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) UTType *imageType; [imageURL getResourceValue:&imageType forKey:NSURLContentTypeKey error:nil]; if ([imageType.identifier isEqualToString:UTTypeSVG.identifier]) { +#else +ALLOW_DEPRECATED_DECLARATIONS_BEGIN + static CFStringRef kUTTagClassFilenameExtension; + static CFStringRef kUTTypeSVG; + CFStringRef fileExtension = (__bridge CFStringRef)((NSURL *)imageURL).pathExtension; + CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, nullptr); + if (UTTypeConformsTo(UTI, kUTTypeSVG)) { +ALLOW_DEPRECATED_DECLARATIONS_END +#endif #if PLATFORM(MAC) #if USE(NSIMAGE_FOR_SVG_SUPPORT) return [[NSImage alloc] initWithData:imageData]; diff --git a/Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionURLSchemeHandlerCocoa.mm b/Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionURLSchemeHandlerCocoa.mm index b15c18f174dea..480dfb1c229d6 100644 --- a/Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionURLSchemeHandlerCocoa.mm +++ b/Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionURLSchemeHandlerCocoa.mm @@ -41,6 +41,10 @@ #import #import +#if !HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) +#import +#endif + namespace CyberKit { class WebPageProxy; @@ -91,7 +95,19 @@ return; } - NSString *mimeType = [UTType typeWithFilenameExtension:((NSURL *)requestURL).pathExtension].preferredMIMEType; + NSString *mimeType; +#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) + mimeType = [UTType typeWithFilenameExtension:((NSURL *)requestURL).pathExtension].preferredMIMEType; +#else +ALLOW_DEPRECATED_DECLARATIONS_BEGIN + static CFStringRef kUTTagClassFilenameExtension; + static CFStringRef kUTTagClassMIMEType; + CFStringRef fileExtension = (__bridge CFStringRef)((NSURL *)requestURL).pathExtension; + CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, nullptr); + mimeType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType); + CFRelease(UTI); +ALLOW_DEPRECATED_DECLARATIONS_END +#endif if (!mimeType) mimeType = @"application/octet-stream"; diff --git a/Source/CyberKit/UIProcess/ios/WKContentViewInteraction.mm b/Source/CyberKit/UIProcess/ios/WKContentViewInteraction.mm index d9ec576f52dc2..38d774b25da29 100644 --- a/Source/CyberKit/UIProcess/ios/WKContentViewInteraction.mm +++ b/Source/CyberKit/UIProcess/ios/WKContentViewInteraction.mm @@ -5357,7 +5357,9 @@ - (void)updateFocusedElementValueAsColor:(UIColor *)value _page->setFocusedElementValue(_focusedElementInformation.elementContext, valueAsString); _focusedElementInformation.value = valueAsString; +#if ENABLE(INPUT_TYPE_COLOR) _focusedElementInformation.colorValue = color; +#endif } - (void)updateFocusedElementSelectedIndex:(uint32_t)index allowsMultipleSelection:(bool)allowsMultipleSelection @@ -10902,7 +10904,7 @@ - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)cont { ASSERT(controller == _visualSearchPreviewController); ASSERT(!index); - auto item = adoptNS([PAL::allocQLItemInstance() initWithDataProvider:self contentType:UTTypeTIFF.identifier previewTitle:_visualSearchPreviewTitle.get()]); + auto item = adoptNS([PAL::allocQLItemInstance() initWithDataProvider:self contentType:@"public.tiff" previewTitle:_visualSearchPreviewTitle.get()]); if ([item respondsToSelector:@selector(setPreviewOptions:)]) { auto previewOptions = adoptNS([[NSMutableDictionary alloc] initWithCapacity:2]); if (_visualSearchPreviewImageURL) @@ -10920,7 +10922,7 @@ - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)cont - (NSData *)provideDataForItem:(QLItem *)item { ASSERT(_visualSearchPreviewImage); - return CyberKit::transcode([_visualSearchPreviewImage CGImage], (__bridge CFStringRef)UTTypeTIFF.identifier).autorelease(); + return CyberKit::transcode([_visualSearchPreviewImage CGImage], (__bridge CFStringRef)@"public.tiff").autorelease(); } #pragma mark - WKActionSheetAssistantDelegate @@ -11686,8 +11688,10 @@ - (BOOL)selectFormAccessoryHasCheckedItemAtRow:(long)rowIndex - (void)setSelectedColorForColorPicker:(UIColor *)color { +#if ENABLE(INPUT_TYPE_COLOR) if ([_inputPeripheral isKindOfClass:[WKFormColorControl class]]) [(WKFormColorControl *)_inputPeripheral selectColor:color]; +#endif } - (NSString *)textContentTypeForTesting diff --git a/Source/CyberKit/UIProcess/ios/forms/WKFileUploadPanel.mm b/Source/CyberKit/UIProcess/ios/forms/WKFileUploadPanel.mm index 8905776d59a8a..10c5f0d548cca 100644 --- a/Source/CyberKit/UIProcess/ios/forms/WKFileUploadPanel.mm +++ b/Source/CyberKit/UIProcess/ios/forms/WKFileUploadPanel.mm @@ -74,6 +74,10 @@ #endif #endif +#if !HAVE(UNIFORM_TYPE_IDENTIFERS_FRAMEWORK) +#import +#endif + enum class WKFileUploadPanelImagePickerType : uint8_t { Image = 1 << 0, Video = 1 << 1, @@ -98,14 +102,18 @@ static bool setContainsUTIThatConformsTo(NSSet *typeIdentifiers, UTT } #endif -/*static bool setContainsUTIThatConformsTo(NSSet *typeIdentifiers, CFStringRef conformToUTI) +static bool setContainsUTIThatConformsTo(NSSet *typeIdentifiers, NSString* conformToUTI) { +#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) + return setContainsUTIThatConformsTo(typeIdentifiers, [UTType typeWithIdentifier:conformToUTI]); +#else for (NSString *uti in typeIdentifiers) { - if ([UTTypeConformance conforms:(__bridge CFStringRef)uti :conformToUTI]) + if (UTTypeConformsTo((__bridge CFStringRef)uti, (__bridge CFStringRef)conformToUTI)) return true; } return false; -}*/ +#endif +} #if HAVE(PHOTOS_UI) @@ -121,14 +129,18 @@ static bool setContainsUTIThatConformsTo(NSSet *typeIdentifiers, UTT } #endif -/*static NSString * firstUTIThatConformsTo(NSArray *typeIdentifiers, CFStringRef conformToUTI) +static NSString * firstUTIThatConformsTo(NSArray *typeIdentifiers, NSString* conformToUTI) { +#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) + return firstUTIThatConformsTo(typeIdentifiers, [UTType typeWithIdentifier:conformToUTI]); +#else for (NSString *uti in typeIdentifiers) { - if ([UTTypeConformance conforms:(__bridge CFStringRef)uti :conformToUTI]) + if (UTTypeConformsTo((__bridge CFStringRef)uti, (__bridge CFStringRef)conformToUTI)) return uti; } return nil; -}*/ +#endif +} #endif @@ -267,7 +279,20 @@ - (void)start _progressController = adoptNS([allocPUActivityProgressControllerInstance() init]); #endif [_progressController setTitle:WEB_UI_STRING_KEY("Preparing…", "Preparing (file upload)", "Title for file upload progress view")]; - [_progressController showAnimated:YES allowDelay:YES]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundeclared-selector" + SEL selector = @selector(showAnimated:allowDelay:); + if ([_progressController respondsToSelector:selector]) { + BOOL myBoolValue = YES; + NSMethodSignature* signature = [[_progressController.get() class] instanceMethodSignatureForSelector:selector]; + NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature]; + [invocation setTarget: _progressController.get()]; + [invocation setSelector: selector ]; + [invocation setArgument: &myBoolValue atIndex: 2]; + [invocation setArgument: &myBoolValue atIndex: 3]; + [invocation invoke]; + } +#pragma clang diagnostic pop [_progressController setCancellationHandler:makeBlockPtr([weakSelf = WeakObjCPtr(self)] { auto strongSelf = weakSelf.get(); @@ -313,7 +338,14 @@ - (void)_processItemAtIndex:(NSUInteger)index return; } - NSString *fileName = [item.fileURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingPathExtension:UTTypeQuickTimeMovie.preferredFilenameExtension.uppercaseString]; + NSString* QTExtension; +#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) + QTExtension = UTTypeQuickTimeMovie.preferredFilenameExtension; +#else + static CFStringRef kUTTagClassFilenameExtension; + QTExtension = (NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)@"com.apple.quicktime-movie", kUTTagClassFilenameExtension); +#endif + NSString *fileName = [item.fileURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingPathExtension:QTExtension.uppercaseString]; NSString *filePath = [temporaryDirectory stringByAppendingPathComponent:fileName]; NSURL *outputURL = [NSURL fileURLWithPath:filePath isDirectory:NO]; @@ -357,13 +389,32 @@ - (void)_finishedProcessing - (void)_dismissProgress { [_progressTimer invalidate]; - [_progressController hideAnimated:NO allowDelay:NO]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundeclared-selector" + SEL selector = @selector(hideAnimated:allowDelay:); + if ([_progressController respondsToSelector:selector]) { + BOOL myBoolValue = NO; + NSMethodSignature* signature = [[_progressController.get() class] instanceMethodSignatureForSelector:selector]; + NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature]; + [invocation setTarget: _progressController.get()]; + [invocation setSelector: selector ]; + [invocation setArgument: &myBoolValue atIndex: 2]; + [invocation setArgument: &myBoolValue atIndex: 3]; + [invocation invoke]; + } +#pragma clang diagnostic pop } - (void)_updateProgress:(NSTimer *)timer { auto currentSessionProgress = [_exportSession progress]; - [_progressController setFractionCompleted:(currentSessionProgress + _processedVideoCount) / _videoCount]; +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wundeclared-selector" + SEL selector = @selector(setFractionCompleted:); + if ([_progressController respondsToSelector:selector]) { + [_progressController performSelector:selector withObject:@((currentSessionProgress + _processedVideoCount) / _videoCount)]; + } +#pragma clang diagnostic pop } - (NSString *)_temporaryDirectoryCreateIfNecessary @@ -534,9 +585,9 @@ - (void)presentWithParameters:(API::OpenPanelParameters*)parameters resultListen if (![_acceptedUTIs count]) _allowedImagePickerTypes.add({ WKFileUploadPanelImagePickerType::Image, WKFileUploadPanelImagePickerType::Video }); else { - if (setContainsUTIThatConformsTo(_acceptedUTIs.get(), UTTypeImage)) + if (setContainsUTIThatConformsTo(_acceptedUTIs.get(), @"public.image")) _allowedImagePickerTypes.add({ WKFileUploadPanelImagePickerType::Image }); - if (setContainsUTIThatConformsTo(_acceptedUTIs.get(), UTTypeMovie)) + if (setContainsUTIThatConformsTo(_acceptedUTIs.get(), @"public.movie")) _allowedImagePickerTypes.add({ WKFileUploadPanelImagePickerType::Video }); } @@ -623,17 +674,25 @@ - (void)_dismissDisplayAnimated:(BOOL)animated return [NSSet set]; if ([mimeType caseInsensitiveCompare:@"image/*"] == NSOrderedSame) - [mediaTypes addObject:UTTypeImage.identifier]; + [mediaTypes addObject:@"public.image"]; else if ([mimeType caseInsensitiveCompare:@"video/*"] == NSOrderedSame) - [mediaTypes addObject:UTTypeMovie.identifier]; + [mediaTypes addObject:@"public.movie"]; else if ([mimeType caseInsensitiveCompare:@"audio/*"] == NSOrderedSame) // UIImagePickerController doesn't allow audio-only recording, so show the video // recorder for "audio/*". - [mediaTypes addObject:UTTypeMovie.identifier]; + [mediaTypes addObject:@"public.movie"]; else { +#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) auto uti = [UTType typeWithMIMEType:mimeType]; if (uti) [mediaTypes addObject:uti.identifier]; +#else + static CFStringRef kUTTagClassMIMEType; + NSString *uti = (NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType, + (__bridge CFStringRef)mimeType, nullptr); + if (uti) + [mediaTypes addObject:uti]; +#endif } } return mediaTypes; @@ -649,6 +708,7 @@ - (void)_dismissDisplayAnimated:(BOOL)animated if ([acceptedMediaTypeUTIs containsObject:availableMediaTypeUTI]) [mediaTypes addObject:availableMediaTypeUTI]; else { +#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) UTType *availableMediaType = [UTType typeWithIdentifier:availableMediaTypeUTI]; for (NSString *acceptedMediaTypeUTI in acceptedMediaTypeUTIs) { UTType *acceptedMediaType = [UTType typeWithIdentifier:acceptedMediaTypeUTI]; @@ -657,6 +717,15 @@ - (void)_dismissDisplayAnimated:(BOOL)animated break; } } +#else + for (NSString *acceptedMediaTypeUTI in acceptedMediaTypeUTIs) { + if (UTTypeConformsTo((__bridge CFStringRef)acceptedMediaTypeUTI, + (__bridge CFStringRef)availableMediaTypeUTI)) { + [mediaTypes addObject:availableMediaTypeUTI]; + break; + } + } +#endif } } @@ -814,7 +883,7 @@ - (void)repositionContextMenuIfNeeded - (void)showFilePickerMenu { NSArray *mediaTypes = [_acceptedUTIs allObjects]; - NSArray *documentTypes = mediaTypes.count ? mediaTypes : @[ UTTypeItem.identifier ]; + NSArray *documentTypes = mediaTypes.count ? mediaTypes : @[ @"public.item" ]; _uploadFileManager = adoptNS([[NSFileManager alloc] init]); _uploadFileCoordinator = adoptNS([[NSFileCoordinator alloc] init]); @@ -1212,10 +1281,17 @@ - (void)_uploadItemForJPEGRepresentationOfImage:(UIImage *)image successBlock:(v - (void)_uploadItemFromMediaInfo:(NSDictionary *)info successBlock:(void (^)(_WKFileUploadItem *))successBlock failureBlock:(void (^)(void))failureBlock { NSString *mediaTypeUTI = [info objectForKey:UIImagePickerControllerMediaType]; +#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK) UTType *mediaType = [UTType typeWithIdentifier:mediaTypeUTI]; + auto isMovie = [mediaType conformsToType:UTTypeMovie]; + auto isImage = [mediaType conformsToType:UTTypeImage]; +#else + auto isMovie = UTTypeConformsTo((__bridge CFStringRef)mediaTypeUTI, (__bridge CFStringRef)@"public.movie"); + auto isImage = UTTypeConformsTo((__bridge CFStringRef)mediaTypeUTI, (__bridge CFStringRef)@"public.image"); +#endif // For videos from the existing library or camera, the media URL will give us a file path. - if ([mediaType conformsToType:UTTypeMovie]) { + if (isMovie) { NSURL *mediaURL = [info objectForKey:UIImagePickerControllerMediaURL]; if (![mediaURL isFileURL]) { LOG_ERROR("WKFileUploadPanel: Expected media URL to be a file path, it was not"); @@ -1228,8 +1304,8 @@ - (void)_uploadItemFromMediaInfo:(NSDictionary *)info successBlock:(void (^)(_WK return; } - if (![mediaType conformsToType:UTTypeImage]) { - LOG_ERROR("WKFileUploadPanel: Unexpected media type. Expected image or video, got: %@", mediaType); + if (!isImage) { + LOG_ERROR("WKFileUploadPanel: Unexpected media type. Expected image or video, got: %@", mediaTypeUTI); ASSERT_NOT_REACHED(); failureBlock(); return; diff --git a/Source/WTF/wtf/PlatformEnable.h b/Source/WTF/wtf/PlatformEnable.h index f224ea73f913d..fea0f473fde1d 100644 --- a/Source/WTF/wtf/PlatformEnable.h +++ b/Source/WTF/wtf/PlatformEnable.h @@ -281,7 +281,7 @@ #define ENABLE_GEOLOCATION 0 #endif -#if !defined(ENABLE_INPUT_TYPE_COLOR) +#if !defined(ENABLE_INPUT_TYPE_COLOR) && (!PLATFORM(IOS) || __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000) #define ENABLE_INPUT_TYPE_COLOR 1 #endif diff --git a/Source/WTF/wtf/PlatformHave.h b/Source/WTF/wtf/PlatformHave.h index a54808969dbe9..964d2656b5362 100644 --- a/Source/WTF/wtf/PlatformHave.h +++ b/Source/WTF/wtf/PlatformHave.h @@ -1080,7 +1080,7 @@ #define HAVE_AVSAMPLEBUFFERVIDEOOUTPUT 1 #endif -#if PLATFORM(IOS) +#if PLATFORM(IOS) && (!PLATFORM(IOS) || __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000) #define HAVE_PHOTOS_UI 1 // FIXME (102246762): Remove this have (and make it true everywhere) when possible. #if __has_include() @@ -1143,7 +1143,8 @@ #define HAVE_UNIFIED_SPEECHSYNTHESIS_FIX_FOR_81465164 1 #endif -#if PLATFORM(COCOA) +#if PLATFORM(COCOA) \ + && (!PLATFORM(IOS) || __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000) #define HAVE_UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK 1 #endif