iOS file upload panel menu items need icons
authorjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2015 02:24:55 +0000 (02:24 +0000)
committerjhoneycutt@apple.com <jhoneycutt@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 27 Mar 2015 02:24:55 +0000 (02:24 +0000)
<https://bugs.webkit.org/show_bug.cgi?id=143042>
<rdar://problem/20178678>

Reviewed by Andy Estes.

* Platform/spi/ios/UIKitSPI.h:
Declare new SPI methods _UIImageGetWebKitTakePhotoOrVideoIcon and
_UIImageGetWebKitPhotoLibraryIcon().

* UIProcess/ios/forms/WKFileUploadPanel.mm:
(photoLibraryIcon):
(cameraIcon):
If UIKit SPI exists, use it. Otherwise, return nil.

(-[WKFileUploadPanel _showDocumentPickerMenu]):
Use icons.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Platform/spi/ios/UIKitSPI.h
Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.mm

index fc7300d..bcd6825 100644 (file)
@@ -1,3 +1,23 @@
+2015-03-25  Jon Honeycutt  <jhoneycutt@apple.com>
+
+        iOS file upload panel menu items need icons
+        <https://bugs.webkit.org/show_bug.cgi?id=143042>
+        <rdar://problem/20178678>
+
+        Reviewed by Andy Estes.
+
+        * Platform/spi/ios/UIKitSPI.h:
+        Declare new SPI methods _UIImageGetWebKitTakePhotoOrVideoIcon and
+        _UIImageGetWebKitPhotoLibraryIcon().
+
+        * UIProcess/ios/forms/WKFileUploadPanel.mm:
+        (photoLibraryIcon):
+        (cameraIcon):
+        If UIKit SPI exists, use it. Otherwise, return nil.
+
+        (-[WKFileUploadPanel _showDocumentPickerMenu]):
+        Use icons.
+
 2015-03-26  Enrica Casucci  <enrica@apple.com>
 
         OS X build fix after r182037.
index 787a377..a874a79 100644 (file)
@@ -37,6 +37,7 @@
 #import <UIKit/UIGestureRecognizer_Private.h>
 #import <UIKit/UIImagePickerController_Private.h>
 #import <UIKit/UIImage_Private.h>
+#import <UIKit/UIInterface_Private.h>
 #import <UIKit/UIKeyboardImpl.h>
 #import <UIKit/UIKeyboardIntl.h>
 #import <UIKit/UIKeyboard_Private.h>
@@ -699,6 +700,9 @@ BOOL _UIApplicationUsesLegacyUI(void);
 
 void UIImageDataWriteToSavedPhotosAlbum(NSData *imageData, id completionTarget, SEL completionSelector, void *contextInfo);
 
+UIImage* _UIImageGetWebKitPhotoLibraryIcon(void);
+UIImage* _UIImageGetWebKitTakePhotoOrVideoIcon(void);
+
 extern const float UIWebViewGrowsAndShrinksToFitHeight;
 extern const float UIWebViewScalesToFitScale;
 extern const float UIWebViewStandardViewportWidth;
index 9984b0e..f8787bb 100644 (file)
@@ -57,6 +57,28 @@ SOFT_LINK_FRAMEWORK(CoreMedia);
 SOFT_LINK_CONSTANT(CoreMedia, kCMTimeZero, CMTime);
 #define kCMTimeZero getkCMTimeZero()
 
+#pragma mark - Document picker icons
+
+static inline UIImage *photoLibraryIcon()
+{
+    // FIXME: Remove when a new SDK is available. <rdar://problem/20150072>
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000 && defined(HAVE_WEBKIT_DOC_PICKER_ICONS)
+    return _UIImageGetWebKitPhotoLibraryIcon();
+#else
+    return nil;
+#endif
+}
+
+static inline UIImage *cameraIcon()
+{
+    // FIXME: Remove when a new SDK is available. <rdar://problem/20150072>
+#if __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000 && defined(HAVE_WEBKIT_DOC_PICKER_ICONS)
+    return _UIImageGetWebKitTakePhotoOrVideoIcon();
+#else
+    return nil;
+#endif
+}
+
 #pragma mark - Icon generation
 
 static CGRect squareCropRectForSize(CGSize size)
@@ -491,13 +513,12 @@ static NSArray *UTIsForMIMETypes(NSArray *mimeTypes)
     [_documentMenuController initWithDocumentTypes:[self _documentPickerMenuMediaTypes] inMode:UIDocumentPickerModeImport];
     [_documentMenuController setDelegate:self];
 
-    // FIXME: Need icons for Camera and Photo Library options.
-    [_documentMenuController addOptionWithTitle:[self _photoLibraryButtonLabel] image:nil order:UIDocumentMenuOrderFirst handler:^{
+    [_documentMenuController addOptionWithTitle:[self _photoLibraryButtonLabel] image:photoLibraryIcon() order:UIDocumentMenuOrderFirst handler:^{
         [self _showPhotoPickerWithSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
     }];
 
     if (NSString *cameraString = [self _cameraButtonLabel]) {
-        [_documentMenuController addOptionWithTitle:cameraString image:nil order:UIDocumentMenuOrderFirst handler:^{
+        [_documentMenuController addOptionWithTitle:cameraString image:cameraIcon() order:UIDocumentMenuOrderFirst handler:^{
             _usingCamera = YES;
             [self _showPhotoPickerWithSourceType:UIImagePickerControllerSourceTypeCamera];
         }];