Skip to content

Commit b298686

Browse files
Matthew BenedictMatthew Benedict
authored andcommitted
Compile iOS 13
1 parent 3b2d162 commit b298686

File tree

8 files changed

+146
-28
lines changed

8 files changed

+146
-28
lines changed

Source/CyberCore/platform/ios/PasteboardIOS.mm

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,15 @@ static void readURLAlongsideAttachmentIfNecessary(PasteboardWebContentReader& re
304304

305305
static bool shouldTreatAsAttachmentByDefault(const String& typeIdentifier)
306306
{
307-
auto type = [UTType typeWithIdentifier:typeIdentifier];
308-
return [type conformsToType:UTTypeVCard] || [type conformsToType:UTTypePDF];
307+
if (@available(iOS 14.0, *)) {
308+
auto type = [UTType typeWithIdentifier:typeIdentifier];
309+
return [type conformsToType:UTTypeVCard] || [type conformsToType:UTTypePDF];
310+
} else {
311+
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
312+
CFStringRef type = (__bridge CFStringRef)typeIdentifier.utf8().data();
313+
return UTTypeConformsTo(type, kUTTypeVCard) || UTTypeConformsTo(type, kUTTypePDF);
314+
ALLOW_DEPRECATED_DECLARATIONS_END
315+
}
309316
}
310317

311318
static bool prefersAttachmentRepresentation(const PasteboardItemInfo& info)

Source/CyberKit/Shared/API/Cocoa/_WKHitTestResult.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
#import <CyberKit/WKFoundation.h>
2727

28-
#if TARGET_OS_OSX || TARGET_OS_IOS
28+
#if TARGET_OS_OSX || (TARGET_OS_IOS && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130400)
2929

3030
#import <Foundation/Foundation.h>
3131

Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionCocoa.mm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@
5959
SOFT_LINK(CoreSVG, CGSVGDocumentRelease, void, (CGSVGDocumentRef document), (document))
6060
#endif
6161

62+
#if !HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
63+
#import <MobileCoreServices/MobileCoreServices.h>
64+
#endif
65+
6266
namespace CyberKit {
6367

6468
static NSString * const manifestVersionManifestKey = @"manifest_version";
@@ -747,10 +751,20 @@ static _WKWebExtensionError toAPI(WebExtension::Error error)
747751

748752
NSURL *imageURL = resourceFileURLForPath(imagePath);
749753

754+
#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
750755
UTType *imageType;
751756
[imageURL getResourceValue:&imageType forKey:NSURLContentTypeKey error:nil];
752757

753758
if ([imageType.identifier isEqualToString:UTTypeSVG.identifier]) {
759+
#else
760+
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
761+
static CFStringRef kUTTagClassFilenameExtension;
762+
static CFStringRef kUTTypeSVG;
763+
CFStringRef fileExtension = (__bridge CFStringRef)((NSURL *)imageURL).pathExtension;
764+
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, nullptr);
765+
if (UTTypeConformsTo(UTI, kUTTypeSVG)) {
766+
ALLOW_DEPRECATED_DECLARATIONS_END
767+
#endif
754768
#if PLATFORM(MAC)
755769
#if USE(NSIMAGE_FOR_SVG_SUPPORT)
756770
return [[NSImage alloc] initWithData:imageData];

Source/CyberKit/UIProcess/Extensions/Cocoa/WebExtensionURLSchemeHandlerCocoa.mm

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@
4141
#import <UniformTypeIdentifiers/UTType.h>
4242
#import <wtf/BlockPtr.h>
4343

44+
#if !HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
45+
#import <MobileCoreServices/MobileCoreServices.h>
46+
#endif
47+
4448
namespace CyberKit {
4549

4650
class WebPageProxy;
@@ -91,7 +95,19 @@
9195
return;
9296
}
9397

94-
NSString *mimeType = [UTType typeWithFilenameExtension:((NSURL *)requestURL).pathExtension].preferredMIMEType;
98+
NSString *mimeType;
99+
#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
100+
mimeType = [UTType typeWithFilenameExtension:((NSURL *)requestURL).pathExtension].preferredMIMEType;
101+
#else
102+
ALLOW_DEPRECATED_DECLARATIONS_BEGIN
103+
static CFStringRef kUTTagClassFilenameExtension;
104+
static CFStringRef kUTTagClassMIMEType;
105+
CFStringRef fileExtension = (__bridge CFStringRef)((NSURL *)requestURL).pathExtension;
106+
CFStringRef UTI = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, fileExtension, nullptr);
107+
mimeType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass(UTI, kUTTagClassMIMEType);
108+
CFRelease(UTI);
109+
ALLOW_DEPRECATED_DECLARATIONS_END
110+
#endif
95111
if (!mimeType)
96112
mimeType = @"application/octet-stream";
97113

Source/CyberKit/UIProcess/ios/WKContentViewInteraction.mm

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5357,7 +5357,9 @@ - (void)updateFocusedElementValueAsColor:(UIColor *)value
53575357

53585358
_page->setFocusedElementValue(_focusedElementInformation.elementContext, valueAsString);
53595359
_focusedElementInformation.value = valueAsString;
5360+
#if ENABLE(INPUT_TYPE_COLOR)
53605361
_focusedElementInformation.colorValue = color;
5362+
#endif
53615363
}
53625364

53635365
- (void)updateFocusedElementSelectedIndex:(uint32_t)index allowsMultipleSelection:(bool)allowsMultipleSelection
@@ -10902,7 +10904,7 @@ - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)cont
1090210904
{
1090310905
ASSERT(controller == _visualSearchPreviewController);
1090410906
ASSERT(!index);
10905-
auto item = adoptNS([PAL::allocQLItemInstance() initWithDataProvider:self contentType:UTTypeTIFF.identifier previewTitle:_visualSearchPreviewTitle.get()]);
10907+
auto item = adoptNS([PAL::allocQLItemInstance() initWithDataProvider:self contentType:@"public.tiff" previewTitle:_visualSearchPreviewTitle.get()]);
1090610908
if ([item respondsToSelector:@selector(setPreviewOptions:)]) {
1090710909
auto previewOptions = adoptNS([[NSMutableDictionary alloc] initWithCapacity:2]);
1090810910
if (_visualSearchPreviewImageURL)
@@ -10920,7 +10922,7 @@ - (NSInteger)numberOfPreviewItemsInPreviewController:(QLPreviewController *)cont
1092010922
- (NSData *)provideDataForItem:(QLItem *)item
1092110923
{
1092210924
ASSERT(_visualSearchPreviewImage);
10923-
return CyberKit::transcode([_visualSearchPreviewImage CGImage], (__bridge CFStringRef)UTTypeTIFF.identifier).autorelease();
10925+
return CyberKit::transcode([_visualSearchPreviewImage CGImage], (__bridge CFStringRef)@"public.tiff").autorelease();
1092410926
}
1092510927

1092610928
#pragma mark - WKActionSheetAssistantDelegate
@@ -11686,8 +11688,10 @@ - (BOOL)selectFormAccessoryHasCheckedItemAtRow:(long)rowIndex
1168611688

1168711689
- (void)setSelectedColorForColorPicker:(UIColor *)color
1168811690
{
11691+
#if ENABLE(INPUT_TYPE_COLOR)
1168911692
if ([_inputPeripheral isKindOfClass:[WKFormColorControl class]])
1169011693
[(WKFormColorControl *)_inputPeripheral selectColor:color];
11694+
#endif
1169111695
}
1169211696

1169311697
- (NSString *)textContentTypeForTesting

Source/CyberKit/UIProcess/ios/forms/WKFileUploadPanel.mm

Lines changed: 95 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,10 @@
7474
#endif
7575
#endif
7676

77+
#if !HAVE(UNIFORM_TYPE_IDENTIFERS_FRAMEWORK)
78+
#import <MobileCoreServices/MobileCoreServices.h>
79+
#endif
80+
7781
enum class WKFileUploadPanelImagePickerType : uint8_t {
7882
Image = 1 << 0,
7983
Video = 1 << 1,
@@ -98,14 +102,18 @@ static bool setContainsUTIThatConformsTo(NSSet<NSString *> *typeIdentifiers, UTT
98102
}
99103
#endif
100104

101-
/*static bool setContainsUTIThatConformsTo(NSSet<NSString *> *typeIdentifiers, CFStringRef conformToUTI)
105+
static bool setContainsUTIThatConformsTo(NSSet<NSString *> *typeIdentifiers, NSString* conformToUTI)
102106
{
107+
#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
108+
return setContainsUTIThatConformsTo(typeIdentifiers, [UTType typeWithIdentifier:conformToUTI]);
109+
#else
103110
for (NSString *uti in typeIdentifiers) {
104-
if ([UTTypeConformance conforms:(__bridge CFStringRef)uti :conformToUTI])
111+
if (UTTypeConformsTo((__bridge CFStringRef)uti, (__bridge CFStringRef)conformToUTI))
105112
return true;
106113
}
107114
return false;
108-
}*/
115+
#endif
116+
}
109117

110118
#if HAVE(PHOTOS_UI)
111119

@@ -121,14 +129,18 @@ static bool setContainsUTIThatConformsTo(NSSet<NSString *> *typeIdentifiers, UTT
121129
}
122130
#endif
123131

124-
/*static NSString * firstUTIThatConformsTo(NSArray<NSString *> *typeIdentifiers, CFStringRef conformToUTI)
132+
static NSString * firstUTIThatConformsTo(NSArray<NSString *> *typeIdentifiers, NSString* conformToUTI)
125133
{
134+
#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
135+
return firstUTIThatConformsTo(typeIdentifiers, [UTType typeWithIdentifier:conformToUTI]);
136+
#else
126137
for (NSString *uti in typeIdentifiers) {
127-
if ([UTTypeConformance conforms:(__bridge CFStringRef)uti :conformToUTI])
138+
if (UTTypeConformsTo((__bridge CFStringRef)uti, (__bridge CFStringRef)conformToUTI))
128139
return uti;
129140
}
130141
return nil;
131-
}*/
142+
#endif
143+
}
132144

133145
#endif
134146

@@ -267,7 +279,20 @@ - (void)start
267279
_progressController = adoptNS([allocPUActivityProgressControllerInstance() init]);
268280
#endif
269281
[_progressController setTitle:WEB_UI_STRING_KEY("Preparing…", "Preparing (file upload)", "Title for file upload progress view")];
270-
[_progressController showAnimated:YES allowDelay:YES];
282+
#pragma clang diagnostic push
283+
#pragma clang diagnostic ignored "-Wundeclared-selector"
284+
SEL selector = @selector(showAnimated:allowDelay:);
285+
if ([_progressController respondsToSelector:selector]) {
286+
BOOL myBoolValue = YES;
287+
NSMethodSignature* signature = [[_progressController.get() class] instanceMethodSignatureForSelector:selector];
288+
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature];
289+
[invocation setTarget: _progressController.get()];
290+
[invocation setSelector: selector ];
291+
[invocation setArgument: &myBoolValue atIndex: 2];
292+
[invocation setArgument: &myBoolValue atIndex: 3];
293+
[invocation invoke];
294+
}
295+
#pragma clang diagnostic pop
271296

272297
[_progressController setCancellationHandler:makeBlockPtr([weakSelf = WeakObjCPtr<WKFileUploadMediaTranscoder>(self)] {
273298
auto strongSelf = weakSelf.get();
@@ -313,7 +338,14 @@ - (void)_processItemAtIndex:(NSUInteger)index
313338
return;
314339
}
315340

316-
NSString *fileName = [item.fileURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingPathExtension:UTTypeQuickTimeMovie.preferredFilenameExtension.uppercaseString];
341+
NSString* QTExtension;
342+
#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
343+
QTExtension = UTTypeQuickTimeMovie.preferredFilenameExtension;
344+
#else
345+
static CFStringRef kUTTagClassFilenameExtension;
346+
QTExtension = (NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)@"com.apple.quicktime-movie", kUTTagClassFilenameExtension);
347+
#endif
348+
NSString *fileName = [item.fileURL.lastPathComponent.stringByDeletingPathExtension stringByAppendingPathExtension:QTExtension.uppercaseString];
317349
NSString *filePath = [temporaryDirectory stringByAppendingPathComponent:fileName];
318350
NSURL *outputURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
319351

@@ -357,13 +389,32 @@ - (void)_finishedProcessing
357389
- (void)_dismissProgress
358390
{
359391
[_progressTimer invalidate];
360-
[_progressController hideAnimated:NO allowDelay:NO];
392+
#pragma clang diagnostic push
393+
#pragma clang diagnostic ignored "-Wundeclared-selector"
394+
SEL selector = @selector(hideAnimated:allowDelay:);
395+
if ([_progressController respondsToSelector:selector]) {
396+
BOOL myBoolValue = NO;
397+
NSMethodSignature* signature = [[_progressController.get() class] instanceMethodSignatureForSelector:selector];
398+
NSInvocation* invocation = [NSInvocation invocationWithMethodSignature: signature];
399+
[invocation setTarget: _progressController.get()];
400+
[invocation setSelector: selector ];
401+
[invocation setArgument: &myBoolValue atIndex: 2];
402+
[invocation setArgument: &myBoolValue atIndex: 3];
403+
[invocation invoke];
404+
}
405+
#pragma clang diagnostic pop
361406
}
362407

363408
- (void)_updateProgress:(NSTimer *)timer
364409
{
365410
auto currentSessionProgress = [_exportSession progress];
366-
[_progressController setFractionCompleted:(currentSessionProgress + _processedVideoCount) / _videoCount];
411+
#pragma clang diagnostic push
412+
#pragma clang diagnostic ignored "-Wundeclared-selector"
413+
SEL selector = @selector(setFractionCompleted:);
414+
if ([_progressController respondsToSelector:selector]) {
415+
[_progressController performSelector:selector withObject:@((currentSessionProgress + _processedVideoCount) / _videoCount)];
416+
}
417+
#pragma clang diagnostic pop
367418
}
368419

369420
- (NSString *)_temporaryDirectoryCreateIfNecessary
@@ -534,9 +585,9 @@ - (void)presentWithParameters:(API::OpenPanelParameters*)parameters resultListen
534585
if (![_acceptedUTIs count])
535586
_allowedImagePickerTypes.add({ WKFileUploadPanelImagePickerType::Image, WKFileUploadPanelImagePickerType::Video });
536587
else {
537-
if (setContainsUTIThatConformsTo(_acceptedUTIs.get(), UTTypeImage))
588+
if (setContainsUTIThatConformsTo(_acceptedUTIs.get(), @"public.image"))
538589
_allowedImagePickerTypes.add({ WKFileUploadPanelImagePickerType::Image });
539-
if (setContainsUTIThatConformsTo(_acceptedUTIs.get(), UTTypeMovie))
590+
if (setContainsUTIThatConformsTo(_acceptedUTIs.get(), @"public.movie"))
540591
_allowedImagePickerTypes.add({ WKFileUploadPanelImagePickerType::Video });
541592
}
542593

@@ -623,17 +674,25 @@ - (void)_dismissDisplayAnimated:(BOOL)animated
623674
return [NSSet set];
624675

625676
if ([mimeType caseInsensitiveCompare:@"image/*"] == NSOrderedSame)
626-
[mediaTypes addObject:UTTypeImage.identifier];
677+
[mediaTypes addObject:@"public.image"];
627678
else if ([mimeType caseInsensitiveCompare:@"video/*"] == NSOrderedSame)
628-
[mediaTypes addObject:UTTypeMovie.identifier];
679+
[mediaTypes addObject:@"public.movie"];
629680
else if ([mimeType caseInsensitiveCompare:@"audio/*"] == NSOrderedSame)
630681
// UIImagePickerController doesn't allow audio-only recording, so show the video
631682
// recorder for "audio/*".
632-
[mediaTypes addObject:UTTypeMovie.identifier];
683+
[mediaTypes addObject:@"public.movie"];
633684
else {
685+
#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
634686
auto uti = [UTType typeWithMIMEType:mimeType];
635687
if (uti)
636688
[mediaTypes addObject:uti.identifier];
689+
#else
690+
static CFStringRef kUTTagClassMIMEType;
691+
NSString *uti = (NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassMIMEType,
692+
(__bridge CFStringRef)mimeType, nullptr);
693+
if (uti)
694+
[mediaTypes addObject:uti];
695+
#endif
637696
}
638697
}
639698
return mediaTypes;
@@ -649,6 +708,7 @@ - (void)_dismissDisplayAnimated:(BOOL)animated
649708
if ([acceptedMediaTypeUTIs containsObject:availableMediaTypeUTI])
650709
[mediaTypes addObject:availableMediaTypeUTI];
651710
else {
711+
#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
652712
UTType *availableMediaType = [UTType typeWithIdentifier:availableMediaTypeUTI];
653713
for (NSString *acceptedMediaTypeUTI in acceptedMediaTypeUTIs) {
654714
UTType *acceptedMediaType = [UTType typeWithIdentifier:acceptedMediaTypeUTI];
@@ -657,6 +717,15 @@ - (void)_dismissDisplayAnimated:(BOOL)animated
657717
break;
658718
}
659719
}
720+
#else
721+
for (NSString *acceptedMediaTypeUTI in acceptedMediaTypeUTIs) {
722+
if (UTTypeConformsTo((__bridge CFStringRef)acceptedMediaTypeUTI,
723+
(__bridge CFStringRef)availableMediaTypeUTI)) {
724+
[mediaTypes addObject:availableMediaTypeUTI];
725+
break;
726+
}
727+
}
728+
#endif
660729
}
661730
}
662731

@@ -814,7 +883,7 @@ - (void)repositionContextMenuIfNeeded
814883
- (void)showFilePickerMenu
815884
{
816885
NSArray *mediaTypes = [_acceptedUTIs allObjects];
817-
NSArray *documentTypes = mediaTypes.count ? mediaTypes : @[ UTTypeItem.identifier ];
886+
NSArray *documentTypes = mediaTypes.count ? mediaTypes : @[ @"public.item" ];
818887

819888
_uploadFileManager = adoptNS([[NSFileManager alloc] init]);
820889
_uploadFileCoordinator = adoptNS([[NSFileCoordinator alloc] init]);
@@ -1212,10 +1281,17 @@ - (void)_uploadItemForJPEGRepresentationOfImage:(UIImage *)image successBlock:(v
12121281
- (void)_uploadItemFromMediaInfo:(NSDictionary *)info successBlock:(void (^)(_WKFileUploadItem *))successBlock failureBlock:(void (^)(void))failureBlock
12131282
{
12141283
NSString *mediaTypeUTI = [info objectForKey:UIImagePickerControllerMediaType];
1284+
#if HAVE(UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK)
12151285
UTType *mediaType = [UTType typeWithIdentifier:mediaTypeUTI];
1286+
auto isMovie = [mediaType conformsToType:UTTypeMovie];
1287+
auto isImage = [mediaType conformsToType:UTTypeImage];
1288+
#else
1289+
auto isMovie = UTTypeConformsTo((__bridge CFStringRef)mediaTypeUTI, (__bridge CFStringRef)@"public.movie");
1290+
auto isImage = UTTypeConformsTo((__bridge CFStringRef)mediaTypeUTI, (__bridge CFStringRef)@"public.image");
1291+
#endif
12161292

12171293
// For videos from the existing library or camera, the media URL will give us a file path.
1218-
if ([mediaType conformsToType:UTTypeMovie]) {
1294+
if (isMovie) {
12191295
NSURL *mediaURL = [info objectForKey:UIImagePickerControllerMediaURL];
12201296
if (![mediaURL isFileURL]) {
12211297
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
12281304
return;
12291305
}
12301306

1231-
if (![mediaType conformsToType:UTTypeImage]) {
1232-
LOG_ERROR("WKFileUploadPanel: Unexpected media type. Expected image or video, got: %@", mediaType);
1307+
if (!isImage) {
1308+
LOG_ERROR("WKFileUploadPanel: Unexpected media type. Expected image or video, got: %@", mediaTypeUTI);
12331309
ASSERT_NOT_REACHED();
12341310
failureBlock();
12351311
return;

Source/WTF/wtf/PlatformEnable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@
281281
#define ENABLE_GEOLOCATION 0
282282
#endif
283283

284-
#if !defined(ENABLE_INPUT_TYPE_COLOR)
284+
#if !defined(ENABLE_INPUT_TYPE_COLOR) && (!PLATFORM(IOS) || __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
285285
#define ENABLE_INPUT_TYPE_COLOR 1
286286
#endif
287287

Source/WTF/wtf/PlatformHave.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,7 @@
10801080
#define HAVE_AVSAMPLEBUFFERVIDEOOUTPUT 1
10811081
#endif
10821082

1083-
#if PLATFORM(IOS)
1083+
#if PLATFORM(IOS) && (!PLATFORM(IOS) || __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
10841084
#define HAVE_PHOTOS_UI 1
10851085
// FIXME (102246762): Remove this have (and make it true everywhere) when possible.
10861086
#if __has_include(<PhotosUICore/PXActivityProgressController.h>)
@@ -1143,7 +1143,8 @@
11431143
#define HAVE_UNIFIED_SPEECHSYNTHESIS_FIX_FOR_81465164 1
11441144
#endif
11451145

1146-
#if PLATFORM(COCOA)
1146+
#if PLATFORM(COCOA) \
1147+
&& (!PLATFORM(IOS) || __IPHONE_OS_VERSION_MIN_REQUIRED >= 140000)
11471148
#define HAVE_UNIFORM_TYPE_IDENTIFIERS_FRAMEWORK 1
11481149
#endif
11491150

0 commit comments

Comments
 (0)