Title: [179001] branches/safari-600.1.4.15-branch/Source/WebKit2

Diff

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/ChangeLog	2015-01-23 10:04:56 UTC (rev 179001)
@@ -1,5 +1,61 @@
 2015-01-22  David Kilzer  <ddkil...@apple.com>
 
+        Merge r174885.
+
+    2014-10-16  Andy Estes  <aes...@apple.com>
+
+        [iOS] Capture WKActionSheetAssistant's interaction with WKContentView in a @protocol
+        https://bugs.webkit.org/show_bug.cgi?id=137792
+
+        Reviewed by Tim Horton.
+
+        WKPDFView would like to use WKActionSheetAssistant to show an action sheet when long-pressing a link, but it
+        can't so long as WKActionSheetAssistant is tightly coupled to WKContentView. Resolve this by factoring
+        WKActionSheetAssistant's interaction with WKContentView into a new protocol called
+        WKActionSheetAssistantDelegate and having WKContentView conform to this protocol.
+
+        * UIProcess/API/Cocoa/_WKElementAction.mm:
+        (+[_WKElementAction elementActionWithTitle:actionHandler:]): Changed instances of WKContentView * to id <WKActionSheetAssistantDelegate>.
+        (+[_WKElementAction elementActionWithType:customTitle:]): Ditto.
+        (-[_WKElementAction _runActionWithElementInfo:delegate:]): Ditto.
+        (copyElement): Deleted.
+        (saveImage): Deleted.
+        (-[_WKElementAction _runActionWithElementInfo:view:]): Deleted.
+        * UIProcess/API/Cocoa/_WKElementActionInternal.h:
+        * UIProcess/ios/WKActionSheet.h:
+        * UIProcess/ios/WKActionSheet.mm:
+        (-[WKActionSheet init]): Renamed from initWithView: since WKActionSheet no longer needs to know about a view.
+        (-[WKActionSheet _didRotateAndLayout]): Called -[WKActionSheetDelegate updatePositionInformation].
+        (-[WKActionSheet initWithView:]): Deleted.
+        * UIProcess/ios/WKActionSheetAssistant.h:
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        (-[WKActionSheetAssistant delegate]): Added a getter for the delegate property.
+        (-[WKActionSheetAssistant setDelegate:]): Added a setter for the delegate property.
+        (-[WKActionSheetAssistant initWithView:]): Changed argument type from WKContentView * to UIView *.
+        (-[WKActionSheetAssistant initialPresentationRectInHostViewForSheet]): Returned CGRectZero if there is no delegate.
+        Otherwise, retrieved positionInformation from the delegate.
+        (-[WKActionSheetAssistant presentationRectInHostViewForSheet]): Ditto.
+        (-[WKActionSheetAssistant updatePositionInformation]): Called -[WKActionSheetAssistantDelegate updatePositionInformation].
+        (-[WKActionSheetAssistant _createSheetWithElementActions:showLinkTitle:]): Returned early if there is no delegate.
+        Otherwise, retrieved positionInformation from the delegate.
+        (-[WKActionSheetAssistant showImageSheet]): Ditto.
+        (-[WKActionSheetAssistant showLinkSheet]): Ditto.
+        (-[WKActionSheetAssistant showDataDetectorsSheet]): Ditto.
+        (-[WKActionSheetAssistant cleanupSheet]):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView setupInteraction]): Installed self as WKActionSheetAssistant's delegate.
+        (-[WKContentView updatePositionInformation]): Renamed from _updatePositionInformation.
+        (-[WKContentView performAction:]): Renamed from _performAction:.
+        (-[WKContentView openElementAtLocation:]): Called _attemptClickAtLocation:.
+        (-[WKContentView actionsForElement:defaultActions:]): Called API::UIClient::actionsForElement().
+        (-[WKContentView startInteractionWithElement:]): Called WebPageProxy::startInteractionWithElementAtPosition().
+        (-[WKContentView stopInteraction]): Called WebPageProxy::stopInteraction().
+        (-[WKContentView _updatePositionInformation]): Deleted.
+        (-[WKContentView _performAction:]): Deleted.
+
+2015-01-22  David Kilzer  <ddkil...@apple.com>
+
         Merge r174286.
 
     2014-10-03  Andy Estes  <aes...@apple.com>

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm	2015-01-23 10:04:56 UTC (rev 179001)
@@ -31,6 +31,7 @@
 #if PLATFORM(IOS)
 
 #import "GestureTypes.h"
+#import "WKActionSheetAssistant.h"
 #import "WKContentViewInteraction.h"
 #import "_WKActivatedElementInfoInternal.h"
 #import <SafariServices/SSReadingList.h>
@@ -42,7 +43,7 @@
 SOFT_LINK_FRAMEWORK(SafariServices);
 SOFT_LINK_CLASS(SafariServices, SSReadingList);
 
-typedef void (^WKElementActionHandlerInternal)(WKContentView *, _WKActivatedElementInfo *);
+typedef void (^WKElementActionHandlerInternal)(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *);
 
 @implementation _WKElementAction  {
     RetainPtr<NSString> _title;
@@ -71,20 +72,10 @@
 
 + (instancetype)elementActionWithTitle:(NSString *)title actionHandler:(WKElementActionHandler)handler
 {
-    return [[[self alloc] _initWithTitle:title actionHandler:^(WKContentView *view, _WKActivatedElementInfo *actionInfo) { handler(actionInfo); }
+    return [[[self alloc] _initWithTitle:title actionHandler:^(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *actionInfo) { handler(actionInfo); }
        type:_WKElementActionTypeCustom] autorelease];
 }
 
-static void copyElement(WKContentView *view)
-{
-    [view _performAction:WebKit::SheetAction::Copy];
-}
-
-static void saveImage(WKContentView *view)
-{
-    [view _performAction:WebKit::SheetAction::SaveImage];
-}
-
 static void addToReadingList(NSURL *targetURL, NSString *title)
 {
     if (!title || [title length] == 0)
@@ -100,25 +91,25 @@
     switch (type) {
     case _WKElementActionTypeCopy:
         title = WEB_UI_STRING_KEY("Copy", "Copy ActionSheet Link", "Title for Copy Link or Image action button");
-        handler = ^(WKContentView *view, _WKActivatedElementInfo *actionInfo) {
-            copyElement(view);
+        handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
+            [delegate performAction:WebKit::SheetAction::Copy];
         };
         break;
     case _WKElementActionTypeOpen:
         title = WEB_UI_STRING_KEY("Open", "Open ActionSheet Link", "Title for Open Link action button");
-        handler = ^(WKContentView *view, _WKActivatedElementInfo *actionInfo) {
-            [view _attemptClickAtLocation:actionInfo._interactionLocation];
+        handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
+            [delegate openElementAtLocation:actionInfo._interactionLocation];
         };
         break;
     case _WKElementActionTypeSaveImage:
         title = WEB_UI_STRING_KEY("Save Image", "Save Image", "Title for Save Image action button");
-        handler = ^(WKContentView *view, _WKActivatedElementInfo *actionInfo) {
-            saveImage(view);
+        handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
+            [delegate performAction:WebKit::SheetAction::SaveImage];
         };
         break;
     case _WKElementActionTypeAddToReadingList:
         title = WEB_UI_STRING("Add to Reading List", "Title for Add to Reading List action button");
-        handler = ^(WKContentView *view, _WKActivatedElementInfo *actionInfo) {
+        handler = ^(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *actionInfo) {
             addToReadingList(actionInfo.URL, actionInfo.title);
         };
         break;
@@ -140,9 +131,9 @@
     return _title.get();
 }
 
-- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info view:(WKContentView *)view
+- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info delegate:(id <WKActionSheetAssistantDelegate>)delegate
 {
-    _actionHandler(view, info);
+    _actionHandler(delegate, info);
 }
 
 @end

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h	2015-01-23 10:04:56 UTC (rev 179001)
@@ -30,10 +30,11 @@
 #if PLATFORM(IOS)
 
 @class WKContentView;
+@protocol WKActionSheetAssistantDelegate;
 
 @interface _WKElementAction ()
 
-- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info view:(WKContentView *)view;
+- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info delegate:(id <WKActionSheetAssistantDelegate>)delegate;
 
 @end
 

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheet.h (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheet.h	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheet.h	2015-01-23 10:04:56 UTC (rev 179001)
@@ -35,7 +35,6 @@
 
 @property (nonatomic, assign) id <WKActionSheetDelegate> sheetDelegate;
 @property (nonatomic) UIPopoverArrowDirection arrowDirections;
-- (id)initWithView:(WKContentView *)view;
 - (void)doneWithSheet;
 - (BOOL)presentSheet;
 - (BOOL)presentSheetFromRect:(CGRect)presentationRect;
@@ -47,6 +46,7 @@
 - (UIView *)hostViewForSheet;
 - (CGRect)initialPresentationRectInHostViewForSheet;
 - (CGRect)presentationRectInHostViewForSheet;
+- (void)updatePositionInformation;
 @end
 
 #endif // PLATFORM(IOS)

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheet.mm (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheet.mm	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheet.mm	2015-01-23 10:04:56 UTC (rev 179001)
@@ -28,13 +28,12 @@
 
 #if PLATFORM(IOS)
 
-#import "WKContentViewInteraction.h"
 #import <UIKit/UIAlertController_Private.h>
 #import <UIKit/UIWindow_Private.h>
+#import <wtf/RetainPtr.h>
 
 @implementation WKActionSheet {
     id <WKActionSheetDelegate> _sheetDelegate;
-    WKContentView *_view;
     UIPopoverArrowDirection _arrowDirections;
     BOOL _isRotating;
     BOOL _readyToPresentAfterRotation;
@@ -43,14 +42,13 @@
     RetainPtr<id <UIPopoverPresentationControllerDelegate>> _popoverPresentationControllerDelegateWhileRotating;
 }
 
-- (id)initWithView:(WKContentView *)view
+- (id)init
 {
     self = [super init];
     if (!self)
         return nil;
 
     _arrowDirections = UIPopoverArrowDirectionAny;
-    _view = view;
 
     if (UI_USER_INTERFACE_IDIOM() != UIUserInterfaceIdiomPhone) {
         // Only iPads support popovers that rotate. UIActionSheets actually block rotation on iPhone/iPod Touch
@@ -213,7 +211,7 @@
 {
     _isRotating = NO;
     _readyToPresentAfterRotation = YES;
-    [_view _updatePositionInformation];
+    [_sheetDelegate updatePositionInformation];
     [self updateSheetPosition];
 }
 

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h	2015-01-23 10:04:56 UTC (rev 179001)
@@ -25,23 +25,34 @@
 
 #if PLATFORM(IOS)
 
+#import "GestureTypes.h"
 #import "WKActionSheet.h"
-
 #import <DataDetectorsUI/DDDetectionController.h>
 #import <UIKit/UIPopoverController.h>
-#import <WebKit/WKDeclarationSpecifiers.h>
 #import <wtf/RetainPtr.h>
 
-@protocol WKActionSheetDelegate;
-@class WKContentView;
-
 namespace WebKit {
 class WebPageProxy;
+struct InteractionInformationAtPosition;
 }
 
+@protocol WKActionSheetDelegate;
+@class _WKActivatedElementInfo;
+
+@protocol WKActionSheetAssistantDelegate
+@required
+@property (nonatomic, readonly) const WebKit::InteractionInformationAtPosition& positionInformation;
+- (void)updatePositionInformation;
+- (void)performAction:(WebKit::SheetAction)action;
+- (void)openElementAtLocation:(CGPoint)location;
+- (RetainPtr<NSArray>)actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions;
+- (void)startInteractionWithElement:(_WKActivatedElementInfo *)element;
+- (void)stopInteraction;
+@end
+
 @interface WKActionSheetAssistant : NSObject <WKActionSheetDelegate, DDDetectionControllerInteractionDelegate>
-
-- (id)initWithView:(WKContentView *)view;
+@property (nonatomic, weak) id <WKActionSheetAssistantDelegate> delegate;
+- (id)initWithView:(UIView *)view;
 - (void)showLinkSheet;
 - (void)showImageSheet;
 - (void)showDataDetectorsSheet;

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm	2015-01-23 10:04:56 UTC (rev 179001)
@@ -31,6 +31,7 @@
 #import "APIUIClient.h"
 #import "WKActionSheet.h"
 #import "WKContentViewInteraction.h"
+#import "WeakObjCPtr.h"
 #import "WebPageProxy.h"
 #import "_WKActivatedElementInfoInternal.h"
 #import "_WKElementActionInternal.h"
@@ -65,13 +66,24 @@
 using namespace WebKit;
 
 @implementation WKActionSheetAssistant {
+    WeakObjCPtr<id <WKActionSheetAssistantDelegate>> _delegate;
     RetainPtr<WKActionSheet> _interactionSheet;
     RetainPtr<_WKActivatedElementInfo> _elementInfo;
-    WKContentView *_view;
+    UIView *_view;
 }
 
-- (id)initWithView:(WKContentView *)view
+- (id <WKActionSheetAssistantDelegate>)delegate
 {
+    return _delegate.getAutoreleased();
+}
+
+- (void)setDelegate:(id <WKActionSheetAssistantDelegate>)delegate
+{
+    _delegate = delegate;
+}
+
+- (id)initWithView:(UIView *)view
+{
     _view = view;
     return self;
 }
@@ -121,22 +133,26 @@
 - (CGRect)initialPresentationRectInHostViewForSheet
 {
     UIView *view = [self superviewForSheet];
-    if (!view)
+    auto delegate = _delegate.get();
+    if (!view || !delegate)
         return CGRectZero;
 
-    return [self _presentationRectForSheetGivenPoint:_view.positionInformation.point inHostView:view];
+    return [self _presentationRectForSheetGivenPoint:[delegate positionInformation].point inHostView:view];
 
 }
 
 - (CGRect)presentationRectInHostViewForSheet
 {
     UIView *view = [self superviewForSheet];
-    if (!view)
+    auto delegate = _delegate.get();
+    if (!view || !delegate)
         return CGRectZero;
 
-    CGRect boundingRect = _view.positionInformation.bounds;
-    CGPoint fromPoint = _view.positionInformation.point;
+    const auto& positionInformation = [delegate positionInformation];
 
+    CGRect boundingRect = positionInformation.bounds;
+    CGPoint fromPoint = positionInformation.point;
+
     // FIXME: We must adjust our presentation point to take into account a change in document scale.
 
     // Test to see if we are still within the target node as it may have moved after rotation.
@@ -146,6 +162,11 @@
     return [self _presentationRectForSheetGivenPoint:fromPoint inHostView:view];
 }
 
+- (void)updatePositionInformation
+{
+    [_delegate.get() updatePositionInformation];
+}
+
 - (BOOL)presentSheet
 {
     // Calculate the presentation rect just before showing.
@@ -167,13 +188,18 @@
 - (void)_createSheetWithElementActions:(NSArray *)actions showLinkTitle:(BOOL)showLinkTitle
 {
     ASSERT(!_interactionSheet);
+    auto delegate = _delegate.get();
+    if (!delegate)
+        return;
 
-    NSURL *targetURL = [NSURL URLWithString:_view.positionInformation.url];
+    const auto& positionInformation = [delegate positionInformation];
+
+    NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
     NSString *urlScheme = [targetURL scheme];
     BOOL isJavaScriptURL = [urlScheme length] && [urlScheme caseInsensitiveCompare:@"_javascript_"] == NSOrderedSame;
     // FIXME: We should check if _javascript_ is enabled in the preferences.
 
-    _interactionSheet = adoptNS([[WKActionSheet alloc] initWithView:_view]);
+    _interactionSheet = adoptNS([[WKActionSheet alloc] init]);
     _interactionSheet.get().sheetDelegate = self;
     _interactionSheet.get().preferredStyle = UIAlertControllerStyleActionSheet;
 
@@ -187,7 +213,7 @@
             titleIsURL = YES;
         }
     } else
-        titleString = _view.positionInformation.title;
+        titleString = positionInformation.title;
 
     if ([titleString length]) {
         [_interactionSheet setTitle:titleString];
@@ -199,7 +225,7 @@
 
     for (_WKElementAction *action in actions) {
         [_interactionSheet _addActionWithTitle:[action title] style:UIAlertActionStyleDefault handler:^{
-            [action _runActionWithElementInfo:_elementInfo.get() view:_view];
+            [action _runActionWithElementInfo:_elementInfo.get() delegate:delegate.get()];
             [self cleanupSheet];
         } shouldDismissHandler:^{
             return (BOOL)(!action.dismissalHandler || action.dismissalHandler());
@@ -211,7 +237,7 @@
                                                         handler:^(UIAlertAction *action) {
                                                             [self cleanupSheet];
                                                         }]];
-    _view.page->startInteractionWithElementAtPosition(_view.positionInformation.point);
+    [delegate startInteractionWithElement:_elementInfo.get()];
 }
 
 - (void)showImageSheet
@@ -219,8 +245,12 @@
     ASSERT(!_interactionSheet);
     ASSERT(!_elementInfo);
 
-    const auto& positionInformation = _view.positionInformation;
+    auto delegate = _delegate.get();
+    if (!delegate)
+        return;
 
+    const auto& positionInformation = [delegate positionInformation];
+
     NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
     auto defaultActions = adoptNS([[NSMutableArray alloc] init]);
     if (!positionInformation.url.isEmpty())
@@ -235,7 +265,7 @@
     auto elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeImage
         URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
 
-    RetainPtr<NSArray> actions = _view.page->uiClient().actionsForElement(elementInfo.get(), WTF::move(defaultActions));
+    RetainPtr<NSArray> actions = [delegate actionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
 
     if (![actions count])
         return;
@@ -255,8 +285,12 @@
     ASSERT(!_interactionSheet);
     ASSERT(!_elementInfo);
 
-    const auto& positionInformation = _view.positionInformation;
+    auto delegate = _delegate.get();
+    if (!delegate)
+        return;
 
+    const auto& positionInformation = [delegate positionInformation];
+
     NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
     if (!targetURL)
         return;
@@ -271,7 +305,7 @@
     RetainPtr<_WKActivatedElementInfo> elementInfo = adoptNS([[_WKActivatedElementInfo alloc] _initWithType:_WKActivatedElementTypeLink
         URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
 
-    RetainPtr<NSArray> actions = _view.page->uiClient().actionsForElement(elementInfo.get(), WTF::move(defaultActions));
+    RetainPtr<NSArray> actions = [delegate actionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
 
     if (![actions count])
         return;
@@ -289,7 +323,12 @@
 - (void)showDataDetectorsSheet
 {
     ASSERT(!_interactionSheet);
-    NSURL *targetURL = [NSURL URLWithString:_view.positionInformation.url];
+
+    auto delegate = _delegate.get();
+    if (!delegate)
+        return;
+
+    NSURL *targetURL = [NSURL URLWithString:[delegate positionInformation].url];
     if (!targetURL)
         return;
 
@@ -327,7 +366,7 @@
 
 - (void)cleanupSheet
 {
-    _view.page->stopInteraction();
+    [_delegate.get() stopInteraction];
 
     [_interactionSheet doneWithSheet];
     [_interactionSheet setSheetDelegate:nil];

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2015-01-23 10:04:56 UTC (rev 179001)
@@ -30,10 +30,11 @@
 #import "AssistedNodeInformation.h"
 #import "GestureTypes.h"
 #import "InteractionInformationAtPosition.h"
-#import "WKSyntheticClickTapGestureRecognizer.h"
+#import "WKActionSheetAssistant.h"
 #import "WKAirPlayRoutePicker.h"
 #import "WKFileUploadPanel.h"
 #import "WKFormPeripheral.h"
+#import "WKSyntheticClickTapGestureRecognizer.h"
 #import <UIKit/UITextInput_Private.h>
 #import <UIKit/UIView.h>
 #import <UIKit/UIWKSelectionAssistant.h>
@@ -146,7 +147,7 @@
 
 @end
 
-@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate>
+@interface WKContentView (WKInteraction) <UIGestureRecognizerDelegate, UIWebTouchEventsGestureRecognizerDelegate, UITextInputPrivate, UIWebFormAccessoryDelegate, UIWKInteractionViewProtocol, WKFileUploadPanelDelegate, WKActionSheetAssistantDelegate>
 
 @property (nonatomic, readonly) CGPoint lastInteractionLocation;
 @property (nonatomic, readonly) BOOL isEditable;
@@ -171,8 +172,6 @@
 - (BOOL)_interpretKeyEvent:(WebIOSEvent *)theEvent isCharEvent:(BOOL)isCharEvent;
 - (void)_positionInformationDidChange:(const WebKit::InteractionInformationAtPosition&)info;
 - (void)_attemptClickAtLocation:(CGPoint)location;
-- (void)_updatePositionInformation;
-- (void)_performAction:(WebKit::SheetAction)action;
 - (void)_willStartScrollingOrZooming;
 - (void)_didScroll;
 - (void)_didEndScrollingOrZooming;

Modified: branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (179000 => 179001)


--- branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-01-23 10:04:52 UTC (rev 179000)
+++ branches/safari-600.1.4.15-branch/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2015-01-23 10:04:56 UTC (rev 179001)
@@ -28,6 +28,7 @@
 
 #if PLATFORM(IOS)
 
+#import "APIUIClient.h"
 #import "EditingRange.h"
 #import "NativeWebKeyboardEvent.h"
 #import "NativeWebTouchEvent.h"
@@ -277,6 +278,7 @@
     [self useSelectionAssistantWithMode:toUIWebSelectionMode([[_webView configuration] selectionGranularity])];
     
     _actionSheetAssistant = adoptNS([[WKActionSheetAssistant alloc] initWithView:self]);
+    [_actionSheetAssistant setDelegate:self];
     _smartMagnificationController = std::make_unique<SmartMagnificationController>(self);
 }
 
@@ -823,12 +825,6 @@
     }
 }
 
-- (void)_updatePositionInformation
-{
-    _hasValidPositionInformation = NO;
-    _page->requestPositionInformation(_positionInformation.point);
-}
-
 - (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer
 {
     CGPoint point = [gestureRecognizer locationInView:self];
@@ -1396,11 +1392,6 @@
     [_textSelectionAssistant hideTextStyleOptions];
 }
 
-- (void)_performAction:(SheetAction)action
-{
-    _page->performActionOnElement((uint32_t)action);
-}
-
 - (void)copy:(id)sender
 {
     _page->executeEditCommand(ASCIILiteral("copy"));
@@ -2724,6 +2715,39 @@
     return YES;
 }
 
+#pragma mark - Implementation of WKActionSheetAssistantDelegate.
+
+- (void)updatePositionInformation
+{
+    _hasValidPositionInformation = NO;
+    _page->requestPositionInformation(_positionInformation.point);
+}
+
+- (void)performAction:(WebKit::SheetAction)action
+{
+    _page->performActionOnElement((uint32_t)action);
+}
+
+- (void)openElementAtLocation:(CGPoint)location
+{
+    [self _attemptClickAtLocation:location];
+}
+
+- (RetainPtr<NSArray>)actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions
+{
+    return _page->uiClient().actionsForElement(element, WTF::move(defaultActions));
+}
+
+- (void)startInteractionWithElement:(_WKActivatedElementInfo *)element
+{
+    _page->startInteractionWithElementAtPosition(_positionInformation.point);
+}
+
+- (void)stopInteraction
+{
+    _page->stopInteraction();
+}
+
 @end
 
 // UITextRange, UITextPosition and UITextSelectionRect implementations for WK2
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to