Changeset 168180 in webkit


Ignore:
Timestamp:
May 2, 2014 12:28:30 PM (10 years ago)
Author:
Joseph Pecoraro
Message:

[iOS] WebKit2 File Upload Support
https://bugs.webkit.org/show_bug.cgi?id=132024

Reviewed by Enrica Casucci.

Source/WebCore:

  • English.lproj/Localizable.strings:

New localized strings for <input type="file"> on iOS.

Source/WebKit2:

  • Configurations/WebKit2.xcconfig:

Include MobileCoreServices on iOS for kUTTypeImage/kUTTypeMovie.

  • WebKit2.xcodeproj/project.pbxproj:

Add new files.

  • UIProcess/WebOpenPanelResultListenerProxy.h:
  • UIProcess/WebOpenPanelResultListenerProxy.cpp:

(WebKit::filePathsFromFileURLs):
(WebKit::WebOpenPanelResultListenerProxy::chooseFiles):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::runOpenPanel):
(WebKit::WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon):

  • WebProcess/WebPage/WebOpenPanelResultListener.h:
  • WebProcess/WebPage/WebOpenPanelResultListener.cpp:

(WebKit::WebOpenPanelResultListener::didChooseFilesWithDisplayStringAndIcon):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
Message forwarding for choosing files and providing a display string and icon,
leading down to the existing WebCore FileChooser method.

  • UIProcess/PageClient.h:
  • UIProcess/ios/PageClientImplIOS.h:
  • UIProcess/ios/PageClientImplIOS.mm:

(WebKit::PageClientImpl::handleRunOpenPanel):
Add a default handler for file open panel on iOS.
Forwards to the content view.

  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView lastInteractionLocation]):
(-[WKContentView _webTouchEventsRecognized:]):
(-[WKContentView _highlightLongPressRecognized:]):
(-[WKContentView _longPressRecognized:]):
(-[WKContentView _singleTapRecognized:]):
(-[WKContentView _doubleTapRecognized:]):
(-[WKContentView _twoFingerDoubleTapRecognized:]):
Keep track of the last interaction location. This matches previous behavior
of showing the file upload popover where the user tapped, to handle
cases where the <input> is hidden.

(-[WKContentView _showRunOpenPanel:resultListener:]):
(-[WKContentView fileUploadPanelDidDismiss:]):
Handle showing the cleaning up after the file upload panel.

  • UIProcess/ios/forms/WKFileUploadPanel.h:
  • UIProcess/ios/forms/WKFileUploadPanel.mm: Added.

(squareCropRectForSize):
(squareImage):
(thumbnailSizedImageForImage):
(-[_WKFileUploadItem isVideo]):
(-[_WKFileUploadItem fileURL]):
(-[_WKFileUploadItem displayImage]):
(-[_WKImageFileUploadItem initWithFilePath:originalImage:]):
(-[_WKImageFileUploadItem isVideo]):
(-[_WKImageFileUploadItem fileURL]):
(-[_WKImageFileUploadItem displayImage]):
(-[_WKVideoFileUploadItem initWithFilePath:mediaURL:]):
(-[_WKVideoFileUploadItem isVideo]):
(-[_WKVideoFileUploadItem fileURL]):
(-[_WKVideoFileUploadItem displayImage]):
Helper class for each image picker selection. Knows how to get
a file URL and thumbnail display image for the item.

(-[WKFileUploadPanel initWithView:]):
(-[WKFileUploadPanel dealloc]):
(-[WKFileUploadPanel _dispatchDidDismiss]):
(-[WKFileUploadPanel _cancel]):
(-[WKFileUploadPanel _chooseFiles:displayString:iconImage:]):
Lifetime of the upload panel requires that either cancel or choose
must happen as we go through the file picking process.

(-[WKFileUploadPanel presentWithParameters:WebKit::resultListener:WebKit::]):
(-[WKFileUploadPanel dismiss]):
API to show or dismiss the panel.

(-[WKFileUploadPanel _dismissDisplayAnimated:]):
Helper to clean up the UI as it progresses or completes no matter the device idiom.

(-[WKFileUploadPanel _presentPopoverWithContentViewController:animated:]):
(-[WKFileUploadPanel _presentFullscreenViewController:animated:]):
UI presentation for the appropriate idiom.

(-[WKFileUploadPanel _mediaTypesForPickerSourceType:]):
(-[WKFileUploadPanel _showMediaSourceSelectionSheet]):
(-[WKFileUploadPanel _showPhotoPickerWithSourceType:]):
Showing the action sheet or image picker.

(-[WKFileUploadPanel popoverControllerDidDismissPopover:]):
(-[WKFileUploadPanel _willMultipleSelectionDelegateBeCalled]):
(-[WKFileUploadPanel imagePickerController:didFinishPickingMediaWithInfo:]):
(-[WKFileUploadPanel imagePickerController:didFinishPickingMultipleMediaWithInfo:]):
(-[WKFileUploadPanel imagePickerControllerDidCancel:]):
Action sheet or image picker handlers.

(-[WKFileUploadPanel _processMediaInfoDictionaries:successBlock:failureBlock:]):
(-[WKFileUploadPanel _processMediaInfoDictionaries:atIndex:processedResults:processedImageCount:processedVideoCount:successBlock:failureBlock:]):
(-[WKFileUploadPanel _uploadItemFromMediaInfo:successBlock:failureBlock:]):
(-[WKFileUploadPanel _displayStringForPhotos:videos:]):
Processing selections from the image picker to FileUploadItems.

Location:
trunk/Source
Files:
1 added
20 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r168171 r168180  
     12014-05-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        [iOS] WebKit2 File Upload Support
     4        https://bugs.webkit.org/show_bug.cgi?id=132024
     5
     6        Reviewed by Enrica Casucci.
     7
     8        * English.lproj/Localizable.strings:
     9        New localized strings for <input type="file"> on iOS.
     10
    1112014-05-02  Chris Fleizach  <cfleizach@apple.com>
    212
  • trunk/Source/WebCore/English.lproj/Localizable.strings

    r166175 r168180  
     1/* File Upload multiple photos label */
     2"# Photos (file upload on page label for multiple photos)" = "%@ Photos";
     3
     4/* File Upload images and videos label */
     5"# Photos and # Videos (file upload on page label for image and videos)" = "%@ and %@";
     6
     7/* File Upload multiple videos label */
     8"# Videos (file upload on page label for multiple videos)" = "%@ Videos";
     9
    110/* accessibility help text for media controller time value >= 1 day */
    211"%1$d days %2$d hours %3$d minutes %4$d seconds" = "%1$d days %2$d hours %3$d minutes %4$d seconds";
     
    5665"1 Item" = "1 Item";
    5766
     67/* File Upload single photo label */
     68"1 Photo (file upload on page label for one photo)" = "1 Photo";
     69
     70/* File Upload single video label */
     71"1 Video (file upload on page label for one video)" = "1 Video";
     72
    5873/* Menu item title for KEYGEN pop-up menu */
    5974"1024 (Medium Grade)" = "1024 (Medium Grade)";
     
    95110"Bold (Undo action name)" = "Bold";
    96111
     112/* File Upload alert sheet button string to cancel */
     113"Cancel (file upload action sheet)" = "Cancel";
     114
    97115/* Title for Cancel button label in button bar */
    98116"Cancel button label in button bar" = "Cancel";
     
    380398"Pause" = "Pause";
    381399
     400/* File Upload alert sheet button string for choosing an existing media item from the Photo Library */
     401"Photo Library (file upload action sheet)" = "Photo Library";
     402
    382403/* Media Play context menu item */
    383404"Play" = "Play";
     
    527548"Superscript (Undo action name)" = "Superscript";
    528549
     550/* File Upload alert sheet camera button string for taking only photos */
     551"Take Photo (file upload action sheet)" = "Take Photo";
     552
     553/* File Upload alert sheet camera button string for taking photos or videos */
     554"Take Photo or Video (file upload action sheet)" = "Take Photo or Video";
     555
     556/* File Upload alert sheet camera button string for taking only videos */
     557"Take Video (file upload action sheet)" = "Take Video";
     558
    529559/* Text Replacement context menu item */
    530560"Text Replacement" = "Text Replacement";
  • trunk/Source/WebKit2/ChangeLog

    r168175 r168180  
     12014-05-02  Joseph Pecoraro  <pecoraro@apple.com>
     2
     3        [iOS] WebKit2 File Upload Support
     4        https://bugs.webkit.org/show_bug.cgi?id=132024
     5
     6        Reviewed by Enrica Casucci.
     7
     8        * Configurations/WebKit2.xcconfig:
     9        Include MobileCoreServices on iOS for kUTTypeImage/kUTTypeMovie.
     10
     11        * WebKit2.xcodeproj/project.pbxproj:
     12        Add new files.
     13
     14        * UIProcess/WebOpenPanelResultListenerProxy.h:
     15        * UIProcess/WebOpenPanelResultListenerProxy.cpp:
     16        (WebKit::filePathsFromFileURLs):
     17        (WebKit::WebOpenPanelResultListenerProxy::chooseFiles):
     18        * UIProcess/WebPageProxy.h:
     19        * UIProcess/WebPageProxy.cpp:
     20        (WebKit::WebPageProxy::runOpenPanel):
     21        (WebKit::WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
     22        * WebProcess/WebPage/WebOpenPanelResultListener.h:
     23        * WebProcess/WebPage/WebOpenPanelResultListener.cpp:
     24        (WebKit::WebOpenPanelResultListener::didChooseFilesWithDisplayStringAndIcon):
     25        * WebProcess/WebPage/WebPage.h:
     26        * WebProcess/WebPage/WebPage.messages.in:
     27        * WebProcess/WebPage/WebPage.cpp:
     28        (WebKit::WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon):
     29        Message forwarding for choosing files and providing a display string and icon,
     30        leading down to the existing WebCore FileChooser method.
     31
     32        * UIProcess/PageClient.h:
     33        * UIProcess/ios/PageClientImplIOS.h:
     34        * UIProcess/ios/PageClientImplIOS.mm:
     35        (WebKit::PageClientImpl::handleRunOpenPanel):
     36        Add a default handler for file open panel on iOS.
     37        Forwards to the content view.
     38
     39        * UIProcess/ios/WKContentViewInteraction.h:
     40        * UIProcess/ios/WKContentViewInteraction.mm:
     41        (-[WKContentView lastInteractionLocation]):
     42        (-[WKContentView _webTouchEventsRecognized:]):
     43        (-[WKContentView _highlightLongPressRecognized:]):
     44        (-[WKContentView _longPressRecognized:]):
     45        (-[WKContentView _singleTapRecognized:]):
     46        (-[WKContentView _doubleTapRecognized:]):
     47        (-[WKContentView _twoFingerDoubleTapRecognized:]):
     48        Keep track of the last interaction location. This matches previous behavior
     49        of showing the file upload popover where the user tapped, to handle
     50        cases where the <input> is hidden.
     51
     52        (-[WKContentView _showRunOpenPanel:resultListener:]):
     53        (-[WKContentView fileUploadPanelDidDismiss:]):
     54        Handle showing the cleaning up after the file upload panel.
     55
     56        * UIProcess/ios/forms/WKFileUploadPanel.h:
     57        * UIProcess/ios/forms/WKFileUploadPanel.mm: Added.
     58        (squareCropRectForSize):
     59        (squareImage):
     60        (thumbnailSizedImageForImage):
     61        (-[_WKFileUploadItem isVideo]):
     62        (-[_WKFileUploadItem fileURL]):
     63        (-[_WKFileUploadItem displayImage]):
     64        (-[_WKImageFileUploadItem initWithFilePath:originalImage:]):
     65        (-[_WKImageFileUploadItem isVideo]):
     66        (-[_WKImageFileUploadItem fileURL]):
     67        (-[_WKImageFileUploadItem displayImage]):
     68        (-[_WKVideoFileUploadItem initWithFilePath:mediaURL:]):
     69        (-[_WKVideoFileUploadItem isVideo]):
     70        (-[_WKVideoFileUploadItem fileURL]):
     71        (-[_WKVideoFileUploadItem displayImage]):
     72        Helper class for each image picker selection. Knows how to get
     73        a file URL and thumbnail display image for the item.
     74
     75        (-[WKFileUploadPanel initWithView:]):
     76        (-[WKFileUploadPanel dealloc]):
     77        (-[WKFileUploadPanel _dispatchDidDismiss]):
     78        (-[WKFileUploadPanel _cancel]):
     79        (-[WKFileUploadPanel _chooseFiles:displayString:iconImage:]):
     80        Lifetime of the upload panel requires that either cancel or choose
     81        must happen as we go through the file picking process.
     82
     83        (-[WKFileUploadPanel presentWithParameters:WebKit::resultListener:WebKit::]):
     84        (-[WKFileUploadPanel dismiss]):
     85        API to show or dismiss the panel.
     86
     87        (-[WKFileUploadPanel _dismissDisplayAnimated:]):
     88        Helper to clean up the UI as it progresses or completes no matter the device idiom.
     89
     90        (-[WKFileUploadPanel _presentPopoverWithContentViewController:animated:]):
     91        (-[WKFileUploadPanel _presentFullscreenViewController:animated:]):
     92        UI presentation for the appropriate idiom.
     93
     94        (-[WKFileUploadPanel _mediaTypesForPickerSourceType:]):
     95        (-[WKFileUploadPanel _showMediaSourceSelectionSheet]):
     96        (-[WKFileUploadPanel _showPhotoPickerWithSourceType:]):
     97        Showing the action sheet or image picker.
     98
     99        (-[WKFileUploadPanel popoverControllerDidDismissPopover:]):
     100        (-[WKFileUploadPanel _willMultipleSelectionDelegateBeCalled]):
     101        (-[WKFileUploadPanel imagePickerController:didFinishPickingMediaWithInfo:]):
     102        (-[WKFileUploadPanel imagePickerController:didFinishPickingMultipleMediaWithInfo:]):
     103        (-[WKFileUploadPanel imagePickerControllerDidCancel:]):
     104        Action sheet or image picker handlers.
     105
     106        (-[WKFileUploadPanel _processMediaInfoDictionaries:successBlock:failureBlock:]):
     107        (-[WKFileUploadPanel _processMediaInfoDictionaries:atIndex:processedResults:processedImageCount:processedVideoCount:successBlock:failureBlock:]):
     108        (-[WKFileUploadPanel _uploadItemFromMediaInfo:successBlock:failureBlock:]):
     109        (-[WKFileUploadPanel _displayStringForPhotos:videos:]):
     110        Processing selections from the image picker to FileUploadItems.
     111
    11122014-05-01  Simon Fraser  <simon.fraser@apple.com>
    2113
  • trunk/Source/WebKit2/Configurations/WebKit2.xcconfig

    r167946 r168180  
    2020// OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2121// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    22 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     22// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2323
    2424#include "BaseTarget.xcconfig"
     
    3131
    3232FRAMEWORK_AND_LIBRARY_LDFLAGS = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_$(PLATFORM_NAME));
    33 FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator = -lobjc -framework AssertionServices -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CorePDF -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework UIKit -framework OpenGLES -framework MobileAsset -framework WebKit -lMobileGestalt -lassertion_extension;
     33FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator = -lobjc -framework AssertionServices -framework CFNetwork -framework CoreFoundation -framework CoreGraphics -framework CorePDF -framework CoreText -framework Foundation -framework GraphicsServices -framework ImageIO -framework UIKit -framework OpenGLES -framework MobileAsset -framework MobileCoreServices -framework WebKit -lMobileGestalt -lassertion_extension;
    3434FRAMEWORK_AND_LIBRARY_LDFLAGS_iphoneos = $(FRAMEWORK_AND_LIBRARY_LDFLAGS_iphonesimulator) -framework IOSurface;
    3535FRAMEWORK_AND_LIBRARY_LDFLAGS_macosx = -framework ApplicationServices -framework Carbon -framework Cocoa -framework CoreServices -framework IOKit -framework CoreAudio -framework IOSurface -framework OpenGL;
  • trunk/Source/WebKit2/Shared/WebOpenPanelParameters.h

    r163958 r168180  
    4444    ~WebOpenPanelParameters();
    4545
    46     bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; } 
     46    bool allowMultipleFiles() const { return m_settings.allowsMultipleFiles; }
    4747    PassRefPtr<API::Array> acceptMIMETypes() const;
    4848    PassRefPtr<API::Array> selectedFileNames() const;
  • trunk/Source/WebKit2/UIProcess/PageClient.h

    r167774 r168180  
    151151    virtual void handleDownloadRequest(DownloadProxy*) = 0;
    152152
     153    virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) { return false; }
     154
    153155#if PLATFORM(EFL)
    154156    virtual void didChangeContentSize(const WebCore::IntSize&) = 0;
  • trunk/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.cpp

    r160969 r168180  
    2828
    2929#include "APIArray.h"
     30#include "APIString.h"
    3031#include "WebPageProxy.h"
    3132#include <WebCore/URL.h>
     
    4546}
    4647
     48static Vector<String> filePathsFromFileURLs(const API::Array& fileURLs)
     49{
     50    Vector<String> filePaths;
     51
     52    size_t size = fileURLs.size();
     53    filePaths.reserveInitialCapacity(size);
     54
     55    for (size_t i = 0; i < size; ++i) {
     56        API::URL* apiURL = fileURLs.at<API::URL>(i);
     57        if (apiURL)
     58            filePaths.uncheckedAppend(URL(URL(), apiURL->string()).fileSystemPath());
     59    }
     60
     61    return filePaths;
     62}
     63
     64#if PLATFORM(IOS)
     65void WebOpenPanelResultListenerProxy::chooseFiles(API::Array* fileURLsArray, API::String* displayString, const API::Data* iconImageData)
     66{
     67    if (!m_page)
     68        return;
     69
     70    m_page->didChooseFilesForOpenPanelWithDisplayStringAndIcon(filePathsFromFileURLs(*fileURLsArray), displayString ? displayString->string() : String(), iconImageData);
     71}
     72#endif
     73
    4774void WebOpenPanelResultListenerProxy::chooseFiles(API::Array* fileURLsArray)
    4875{
     
    5077        return;
    5178
    52     size_t size = fileURLsArray->size();
    53 
    54     Vector<String> filePaths;
    55     filePaths.reserveInitialCapacity(size);
    56 
    57     for (size_t i = 0; i < size; ++i) {
    58         API::URL* apiURL = fileURLsArray->at<API::URL>(i);
    59         if (apiURL) {
    60             URL url(URL(), apiURL->string());
    61             filePaths.uncheckedAppend(url.fileSystemPath());
    62         }
    63     }
    64 
    65     m_page->didChooseFilesForOpenPanel(filePaths);
     79    m_page->didChooseFilesForOpenPanel(filePathsFromFileURLs(*fileURLsArray));
    6680}
    6781
  • trunk/Source/WebKit2/UIProcess/WebOpenPanelResultListenerProxy.h

    r160384 r168180  
    3333namespace API {
    3434class Array;
     35class Data;
     36class String;
    3537}
    3638
     
    4850    virtual ~WebOpenPanelResultListenerProxy();
    4951
     52#if PLATFORM(IOS)
     53    void chooseFiles(API::Array*, API::String* displayString, const API::Data* iconImageData);
     54#endif
    5055    void chooseFiles(API::Array*);
    5156    void cancel();
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp

    r168118 r168180  
    30843084    m_process->responsivenessTimer()->stop();
    30853085
    3086     if (!m_uiClient->runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
    3087         didCancelForOpenPanel();
     3086    if (!m_uiClient->runOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get())) {
     3087        if (!m_pageClient.handleRunOpenPanel(this, frame, parameters.get(), m_openPanelResultListener.get()))
     3088            didCancelForOpenPanel();
     3089    }
    30883090}
    30893091
     
    35923594}
    35933595#endif // ENABLE(CONTEXT_MENUS)
     3596
     3597#if PLATFORM(IOS)
     3598void WebPageProxy::didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>& fileURLs, const String& displayString, const API::Data* iconData)
     3599{
     3600    if (!isValid())
     3601        return;
     3602
     3603    m_process->send(Messages::WebPage::DidChooseFilesForOpenPanelWithDisplayStringAndIcon(fileURLs, displayString, iconData ? iconData->dataReference() : IPC::DataReference()), m_pageID);
     3604
     3605    m_openPanelResultListener->invalidate();
     3606    m_openPanelResultListener = nullptr;
     3607}
     3608#endif
    35943609
    35953610void WebPageProxy::didChooseFilesForOpenPanel(const Vector<String>& fileURLs)
  • trunk/Source/WebKit2/UIProcess/WebPageProxy.h

    r168118 r168180  
    947947
    948948    // Called by the WebOpenPanelResultListenerProxy.
     949#if PLATFORM(IOS)
     950    void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const API::Data* iconData);
     951#endif
    949952    void didChooseFilesForOpenPanel(const Vector<String>&);
    950953    void didCancelForOpenPanel();
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.h

    r168038 r168180  
    121121    virtual void showPlaybackTargetPicker(bool hasVideo, const WebCore::IntRect& elementRect) override;
    122122
     123    virtual bool handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters*, WebOpenPanelResultListenerProxy*) override;
     124
    123125#if ENABLE(INSPECTOR)
    124126    virtual void showInspectorIndication() override;
  • trunk/Source/WebKit2/UIProcess/ios/PageClientImplIOS.mm

    r168069 r168180  
    415415}
    416416
     417bool PageClientImpl::handleRunOpenPanel(WebPageProxy*, WebFrameProxy*, WebOpenPanelParameters* parameters, WebOpenPanelResultListenerProxy* listener)
     418{
     419    [m_contentView _showRunOpenPanel:parameters resultListener:listener];
     420    return true;
     421}
     422
    417423#if ENABLE(INSPECTOR)
    418424void PageClientImpl::showInspectorIndication()
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r168117 r168180  
    3232#import "InteractionInformationAtPosition.h"
    3333#import "WKAirPlayRoutePicker.h"
     34#import "WKFileUploadPanel.h"
    3435#import "WKFormPeripheral.h"
    3536#import <UIKit/UITextInput_Private.h>
     
    5253class NativeWebTouchEvent;
    5354class SmartMagnificationController;
     55class WebOpenPanelParameters;
     56class WebOpenPanelResultListenerProxy;
    5457class WebPageProxy;
    5558}
    5659
    57 @class _UIWebHighlightLongPressGestureRecognizer;
    58 @class _UIHighlightView;
    59 @class WebIOSEvent;
    6060@class WKActionSheetAssistant;
    6161@class WKFormInputSession;
     62@class WebIOSEvent;
     63@class _UIHighlightView;
     64@class _UIWebHighlightLongPressGestureRecognizer;
    6265
    6366typedef void (^UIWKAutocorrectionCompletionHandler)(UIWKAutocorrectionRects *rectsForInput);
     
    99102    RetainPtr<WKAirPlayRoutePicker> _airPlayRoutePicker;
    100103    RetainPtr<WKFormInputSession> _formInputSession;
     104    RetainPtr<WKFileUploadPanel> _fileUploadPanel;
    101105
    102106    std::unique_ptr<WebKit::SmartMagnificationController> _smartMagnificationController;
     
    111115    RetainPtr<NSObject<WKFormPeripheral>> _inputPeripheral;
    112116
     117    CGPoint _lastInteractionLocation;
     118
    113119    BOOL _isEditable;
    114120    BOOL _showingTextStyleOptions;
     
    121127@end
    122128
    123 @interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol>
     129@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate>
    124130
     131@property (nonatomic, readonly) CGPoint lastInteractionLocation;
    125132@property (nonatomic, readonly) BOOL isEditable;
    126133@property (nonatomic, readonly) const WebKit::InteractionInformationAtPosition& positionInformation;
     
    149156- (void)_didUpdateBlockSelectionWithTouch:(WebKit::SelectionTouch)touch withFlags:(WebKit::SelectionFlags)flags growThreshold:(CGFloat)growThreshold shrinkThreshold:(CGFloat)shrinkThreshold;
    150157- (void)_showPlaybackTargetPicker:(BOOL)hasVideo fromRect:(const WebCore::IntRect&)elementRect;
     158- (void)_showRunOpenPanel:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
    151159- (void)accessoryDone;
    152160- (Vector<WebKit::WKOptionItem>&) assistedNodeSelectOptions;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r168142 r168180  
    3333#import "NativeWebTouchEvent.h"
    3434#import "SmartMagnificationController.h"
     35#import "WKActionSheetAssistant.h"
     36#import "WKFormInputControl.h"
     37#import "WKFormSelectControl.h"
     38#import "WKWebViewPrivate.h"
    3539#import "WebEvent.h"
    3640#import "WebIOSEventFactory.h"
    3741#import "WebPageMessages.h"
    3842#import "WebProcessProxy.h"
    39 #import "WKActionSheetAssistant.h"
    40 #import "WKFormInputControl.h"
    41 #import "WKFormSelectControl.h"
    42 #import "WKWebViewPrivate.h"
    4343#import "_WKFormDelegate.h"
    4444#import "_WKFormInputSession.h"
    4545#import <DataDetectorsUI/DDDetectionController.h>
    4646#import <TextInput/TI_NSStringExtras.h>
    47 #import <UIKit/_UIHighlightView.h>
    48 #import <UIKit/_UIWebHighlightLongPressGestureRecognizer.h>
    4947#import <UIKit/UIFont_Private.h>
    5048#import <UIKit/UIGestureRecognizer_Private.h>
     
    5553#import <UIKit/UITextInteractionAssistant_Private.h>
    5654#import <UIKit/UIWebDocumentView.h> // FIXME: should not include this header.
     55#import <UIKit/_UIHighlightView.h>
     56#import <UIKit/_UIWebHighlightLongPressGestureRecognizer.h>
    5757#import <WebCore/Color.h>
    5858#import <WebCore/FloatQuad.h>
     
    241241    [_highlightLongPressGestureRecognizer setDelegate:nil];
    242242    [_longPressGestureRecognizer setDelegate:nil];
     243
     244    if (_fileUploadPanel) {
     245        [_fileUploadPanel setDelegate:nil];
     246        [_fileUploadPanel dismiss];
     247    }
    243248}
    244249
     
    256261{
    257262    return _inputDelegate;
     263}
     264
     265- (CGPoint)lastInteractionLocation
     266{
     267    return _lastInteractionLocation;
    258268}
    259269
     
    288298    if (nativeWebTouchEvent.type() == WebKit::WebEvent::TouchStart)
    289299        _canSendTouchEventsAsynchronously = NO;
     300
     301    _lastInteractionLocation = gestureRecognizer.locationInWindow;
    290302
    291303    if (_canSendTouchEventsAsynchronously)
     
    670682    ASSERT(gestureRecognizer == _highlightLongPressGestureRecognizer);
    671683
     684    _lastInteractionLocation = gestureRecognizer.startPoint;
     685
    672686    switch ([gestureRecognizer state]) {
    673687    case UIGestureRecognizerStateBegan:
     
    691705    ASSERT(gestureRecognizer == _longPressGestureRecognizer);
    692706
     707    _lastInteractionLocation = gestureRecognizer.startPoint;
     708
    693709    if ([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
    694710        SEL action = [self _actionForLongPress];
     
    707723    [_webSelectionAssistant clearSelection];
    708724
    709     [self _attemptClickAtLocation:[gestureRecognizer location]];
     725    _lastInteractionLocation = gestureRecognizer.location;
     726
     727    [self _attemptClickAtLocation:gestureRecognizer.location];
    710728}
    711729
    712730- (void)_doubleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer
    713731{
     732    _lastInteractionLocation = gestureRecognizer.location;
     733
    714734    _smartMagnificationController->handleSmartMagnificationGesture(gestureRecognizer.location);
    715735}
     
    717737- (void)_twoFingerDoubleTapRecognized:(UITapGestureRecognizer *)gestureRecognizer
    718738{
     739    _lastInteractionLocation = gestureRecognizer.location;
     740
    719741    _smartMagnificationController->handleResetMagnificationGesture(gestureRecognizer.location);
    720742}
     
    20892111}
    20902112
     2113- (void)_showRunOpenPanel:(WebOpenPanelParameters*)parameters resultListener:(WebOpenPanelResultListenerProxy*)listener
     2114{
     2115    ASSERT(!_fileUploadPanel);
     2116    if (_fileUploadPanel)
     2117        return;
     2118
     2119    _fileUploadPanel = adoptNS([[WKFileUploadPanel alloc] initWithView:self]);
     2120    [_fileUploadPanel setDelegate:self];
     2121    [_fileUploadPanel presentWithParameters:parameters resultListener:listener];
     2122}
     2123
     2124- (void)fileUploadPanelDidDismiss:(WKFileUploadPanel *)fileUploadPanel
     2125{
     2126    ASSERT(_fileUploadPanel.get() == fileUploadPanel);
     2127
     2128    [_fileUploadPanel setDelegate:nil];
     2129    [_fileUploadPanel release];
     2130    _fileUploadPanel = nil;
     2131}
     2132
    20912133#pragma mark - Implementation of UIWebTouchEventsGestureRecognizerDelegate.
    20922134
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKFileUploadPanel.h

    r168179 r168180  
    11/*
    2  * Copyright (C) 2010 Apple Inc. All rights reserved.
     2 * Copyright (C) 2014 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 #include "config.h"
    27 #include "WebOpenPanelResultListener.h"
     26#if PLATFORM(IOS)
     27
     28#import <UIKit/UIViewController.h>
     29
     30@class WKContentView;
     31@protocol WKFileUploadPanelDelegate;
    2832
    2933namespace WebKit {
    30 
    31 PassRefPtr<WebOpenPanelResultListener> WebOpenPanelResultListener::create(WebPage* page, PassRefPtr<WebCore::FileChooser> fileChooser)
    32 {
    33     return adoptRef(new WebOpenPanelResultListener(page, fileChooser));
     34class WebOpenPanelParameters;
     35class WebOpenPanelResultListenerProxy;
    3436}
    3537
    36 WebOpenPanelResultListener::WebOpenPanelResultListener(WebPage* page, PassRefPtr<WebCore::FileChooser> fileChooser)
    37     : m_page(page)
    38     , m_fileChooser(fileChooser)
    39 {
    40 }
     38@interface WKFileUploadPanel : UIViewController
     39@property (nonatomic, assign) id <WKFileUploadPanelDelegate> delegate;
     40- (instancetype)initWithView:(WKContentView *)view;
     41- (void)presentWithParameters:(WebKit::WebOpenPanelParameters*)parameters resultListener:(WebKit::WebOpenPanelResultListenerProxy*)listener;
     42- (void)dismiss;
     43@end
    4144
    42 WebOpenPanelResultListener::~WebOpenPanelResultListener()
    43 {
    44 }
     45@protocol WKFileUploadPanelDelegate <NSObject>
     46@optional
     47- (void)fileUploadPanelDidDismiss:(WKFileUploadPanel *)fileUploadPanel;
     48@end
    4549
    46 void WebOpenPanelResultListener::didChooseFiles(const Vector<String>& files)
    47 {
    48     m_fileChooser->chooseFiles(files);
    49 }
    50 
    51 } // namespace WebKit
     50#endif // PLATFORM(IOS)
  • trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj

    r168085 r168180  
    10401040                A1DF631218E0B7C8003A3E2A /* DownloadClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */; };
    10411041                A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1DF631118E0B7C8003A3E2A /* DownloadClient.h */; };
     1042                A58B6F0818FCA733008CBA53 /* WKFileUploadPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = A58B6F0618FCA733008CBA53 /* WKFileUploadPanel.h */; };
     1043                A58B6F0918FCA733008CBA53 /* WKFileUploadPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = A58B6F0718FCA733008CBA53 /* WKFileUploadPanel.mm */; };
    10421044                A5EFD38C16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h in Headers */ = {isa = PBXBuildFile; fileRef = A5EFD38B16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h */; settings = {ATTRIBUTES = (Private, ); }; };
    10431045                A7D792D61767CB6E00881CBE /* ActivityAssertion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7D792D51767CB6E00881CBE /* ActivityAssertion.cpp */; };
     
    29232925                A1EDD2DC1884B9B500BBFE98 /* SecItemShim.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SecItemShim.xcconfig; sourceTree = "<group>"; };
    29242926                A1EDD2DD1884B9E300BBFE98 /* WebProcessShim.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = WebProcessShim.xcconfig; sourceTree = "<group>"; };
     2927                A58B6F0618FCA733008CBA53 /* WKFileUploadPanel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WKFileUploadPanel.h; path = ios/forms/WKFileUploadPanel.h; sourceTree = "<group>"; };
     2928                A58B6F0718FCA733008CBA53 /* WKFileUploadPanel.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFileUploadPanel.mm; path = ios/forms/WKFileUploadPanel.mm; sourceTree = "<group>"; };
    29252929                A5EFD38B16B0E88C00B2F0E8 /* WKPageVisibilityTypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKPageVisibilityTypes.h; sourceTree = "<group>"; };
    29262930                A72D5D7F1236CBA800A88B15 /* WebSerializedScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSerializedScriptValue.h; sourceTree = "<group>"; };
     
    65276531                                C5FA1ED118E1062200B3F402 /* WKAirPlayRoutePicker.h */,
    65286532                                C5FA1ED218E1062200B3F402 /* WKAirPlayRoutePicker.mm */,
     6533                                A58B6F0618FCA733008CBA53 /* WKFileUploadPanel.h */,
     6534                                A58B6F0718FCA733008CBA53 /* WKFileUploadPanel.mm */,
    65296535                                C54256AF18BEC18B00DE4179 /* WKFormInputControl.h */,
    65306536                                C54256B018BEC18B00DE4179 /* WKFormInputControl.mm */,
     
    67406746                                373D122D18A4B6EB0066D9CC /* WKWebProcessPlugInFramePrivate.h in Headers */,
    67416747                                1AD25E96167AB08100EA9BCD /* DownloadProxyMap.h in Headers */,
     6748                                A58B6F0818FCA733008CBA53 /* WKFileUploadPanel.h in Headers */,
    67426749                                1AB7D61A1288B9D900CFD08C /* DownloadProxyMessages.h in Headers */,
    67436750                                C517388112DF8F4F00EE3F47 /* DragControllerAction.h in Headers */,
     
    84598466                                868160D0187645570021E79D /* WindowServerConnection.mm in Sources */,
    84608467                                3F87B9BD158940120090FF62 /* WebColorChooser.cpp in Sources */,
     8468                                A58B6F0918FCA733008CBA53 /* WKFileUploadPanel.mm in Sources */,
    84618469                                F036978815F4BF0500C3A80E /* WebColorPicker.cpp in Sources */,
    84628470                                BC4A628F147312BE006C681A /* WebConnection.cpp in Sources */,
  • trunk/Source/WebKit2/WebProcess/WebPage/WebOpenPanelResultListener.cpp

    r95901 r168180  
    2727#include "WebOpenPanelResultListener.h"
    2828
     29#include <WebCore/Icon.h>
     30
    2931namespace WebKit {
    3032
     
    4951}
    5052
     53#if PLATFORM(IOS)
     54void WebOpenPanelResultListener::didChooseFilesWithDisplayStringAndIcon(const Vector<String>& files, const String& displayString, WebCore::Icon* displayIcon)
     55{
     56    m_fileChooser->chooseMediaFiles(files, displayString, displayIcon);
     57}
     58#endif
     59
    5160} // namespace WebKit
  • trunk/Source/WebKit2/WebProcess/WebPage/WebOpenPanelResultListener.h

    r95901 r168180  
    3030#include <WebCore/FileChooser.h>
    3131
     32namespace WebCore {
     33class Icon;
     34}
     35
    3236namespace WebKit {
    3337
     
    4145    void disconnectFromPage() { m_page = 0; }
    4246    void didChooseFiles(const Vector<String>&);
     47#if PLATFORM(IOS)
     48    void didChooseFilesWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, WebCore::Icon*);
     49#endif
    4350
    4451private:
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp

    r168085 r168180  
    186186#if PLATFORM(IOS)
    187187#include "WebVideoFullscreenManager.h"
     188#include <CoreGraphics/CoreGraphics.h>
     189#include <WebCore/Icon.h>
    188190#endif
    189191
     
    30513053}
    30523054
     3055#if PLATFORM(IOS)
     3056void WebPage::didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>& files, const String& displayString, const IPC::DataReference& iconData)
     3057{
     3058    if (!m_activeOpenPanelResultListener)
     3059        return;
     3060
     3061    RefPtr<Icon> icon;
     3062    if (!iconData.isEmpty()) {
     3063        RetainPtr<CFDataRef> dataRef = adoptCF(CFDataCreate(nullptr, iconData.data(), iconData.size()));
     3064        RetainPtr<CGDataProviderRef> imageProviderRef = adoptCF(CGDataProviderCreateWithCFData(dataRef.get()));
     3065        RetainPtr<CGImageRef> imageRef = adoptCF(CGImageCreateWithJPEGDataProvider(imageProviderRef.get(), nullptr, true, kCGRenderingIntentDefault));
     3066        icon = Icon::createIconForImage(imageRef.get());
     3067    }
     3068
     3069    m_activeOpenPanelResultListener->didChooseFilesWithDisplayStringAndIcon(files, displayString, icon.get());
     3070    m_activeOpenPanelResultListener = nullptr;
     3071}
     3072#endif
     3073
    30533074void WebPage::didChooseFilesForOpenPanel(const Vector<String>& files)
    30543075{
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h

    r167974 r168180  
    960960#endif
    961961
     962#if PLATFORM(IOS)
     963    void didChooseFilesForOpenPanelWithDisplayStringAndIcon(const Vector<String>&, const String& displayString, const IPC::DataReference& iconData);
     964#endif
    962965    void didChooseFilesForOpenPanel(const Vector<String>&);
    963966    void didCancelForOpenPanel();
  • trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in

    r167974 r168180  
    226226
    227227    # Open panel.
     228#if PLATFORM(IOS)
     229    DidChooseFilesForOpenPanelWithDisplayStringAndIcon(Vector<String> fileURLs, String displayString, IPC::DataReference iconData)
     230#endif
    228231    DidChooseFilesForOpenPanel(Vector<String> fileURLs)
    229232    DidCancelForOpenPanel()
Note: See TracChangeset for help on using the changeset viewer.