Changeset 175577 in webkit


Ignore:
Timestamp:
Nov 4, 2014 1:44:11 PM (9 years ago)
Author:
aestes@apple.com
Message:

[iOS] Include a WKActionSheetAssistant parameter in WKActionSheetAssistantDelegate methods
https://bugs.webkit.org/show_bug.cgi?id=137792

Reviewed by Dan Bernstein.

  • UIProcess/API/Cocoa/_WKElementAction.mm:

(+[_WKElementAction elementActionWithTitle:actionHandler:]):
(+[_WKElementAction elementActionWithType:customTitle:]):
(-[_WKElementAction _runActionWithElementInfo:forActionSheetAssistant:]):

  • UIProcess/API/Cocoa/_WKElementActionInternal.h:
  • UIProcess/ios/WKActionSheetAssistant.h:
  • UIProcess/ios/WKActionSheetAssistant.mm:

(-[WKActionSheetAssistant initialPresentationRectInHostViewForSheet]):
(-[WKActionSheetAssistant presentationRectInHostViewForSheet]):
(-[WKActionSheetAssistant updatePositionInformation]):
(-[WKActionSheetAssistant _createSheetWithElementActions:showLinkTitle:]):
(-[WKActionSheetAssistant showImageSheet]):
(-[WKActionSheetAssistant showLinkSheet]):
(-[WKActionSheetAssistant showDataDetectorsSheet]):
(-[WKActionSheetAssistant cleanupSheet]):

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView positionInformationForActionSheetAssistant:]):
(-[WKContentView updatePositionInformationForActionSheetAssistant:]):
(-[WKContentView actionSheetAssistant:performAction:]):
(-[WKContentView actionSheetAssistant:openElementAtLocation:]):
(-[WKContentView actionSheetAssistant:decideActionsForElement:defaultActions:]):
(-[WKContentView actionSheetAssistant:willStartInteractionWithElement:]):
(-[WKContentView actionSheetAssistantDidStopInteraction:]):

Location:
trunk/Source/WebKit2
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r175568 r175577  
     12014-11-04  Andy Estes  <aestes@apple.com>
     2
     3        [iOS] Include a WKActionSheetAssistant parameter in WKActionSheetAssistantDelegate methods
     4        https://bugs.webkit.org/show_bug.cgi?id=137792
     5
     6        Reviewed by Dan Bernstein.
     7
     8        * UIProcess/API/Cocoa/_WKElementAction.mm:
     9        (+[_WKElementAction elementActionWithTitle:actionHandler:]):
     10        (+[_WKElementAction elementActionWithType:customTitle:]):
     11        (-[_WKElementAction _runActionWithElementInfo:forActionSheetAssistant:]):
     12        * UIProcess/API/Cocoa/_WKElementActionInternal.h:
     13        * UIProcess/ios/WKActionSheetAssistant.h:
     14        * UIProcess/ios/WKActionSheetAssistant.mm:
     15        (-[WKActionSheetAssistant initialPresentationRectInHostViewForSheet]):
     16        (-[WKActionSheetAssistant presentationRectInHostViewForSheet]):
     17        (-[WKActionSheetAssistant updatePositionInformation]):
     18        (-[WKActionSheetAssistant _createSheetWithElementActions:showLinkTitle:]):
     19        (-[WKActionSheetAssistant showImageSheet]):
     20        (-[WKActionSheetAssistant showLinkSheet]):
     21        (-[WKActionSheetAssistant showDataDetectorsSheet]):
     22        (-[WKActionSheetAssistant cleanupSheet]):
     23        * UIProcess/ios/WKContentViewInteraction.mm:
     24        (-[WKContentView positionInformationForActionSheetAssistant:]):
     25        (-[WKContentView updatePositionInformationForActionSheetAssistant:]):
     26        (-[WKContentView actionSheetAssistant:performAction:]):
     27        (-[WKContentView actionSheetAssistant:openElementAtLocation:]):
     28        (-[WKContentView actionSheetAssistant:decideActionsForElement:defaultActions:]):
     29        (-[WKContentView actionSheetAssistant:willStartInteractionWithElement:]):
     30        (-[WKContentView actionSheetAssistantDidStopInteraction:]):
     31
    1322014-11-04  Csaba Osztrogonác  <ossy@webkit.org>
    233
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm

    r174885 r175577  
    4444SOFT_LINK_CLASS(SafariServices, SSReadingList);
    4545
    46 typedef void (^WKElementActionHandlerInternal)(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *);
     46typedef void (^WKElementActionHandlerInternal)(WKActionSheetAssistant *, _WKActivatedElementInfo *);
    4747
    4848@implementation _WKElementAction  {
     
    7373+ (instancetype)elementActionWithTitle:(NSString *)title actionHandler:(WKElementActionHandler)handler
    7474{
    75     return [[[self alloc] _initWithTitle:title actionHandler:^(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *actionInfo) { handler(actionInfo); }
     75    return [[[self alloc] _initWithTitle:title actionHandler:^(WKActionSheetAssistant *, _WKActivatedElementInfo *actionInfo) { handler(actionInfo); }
    7676       type:_WKElementActionTypeCustom] autorelease];
    7777}
     
    9292    case _WKElementActionTypeCopy:
    9393        title = WEB_UI_STRING_KEY("Copy", "Copy ActionSheet Link", "Title for Copy Link or Image action button");
    94         handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
    95             [delegate performAction:WebKit::SheetAction::Copy];
     94        handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
     95            [assistant.delegate actionSheetAssistant:assistant performAction:WebKit::SheetAction::Copy];
    9696        };
    9797        break;
    9898    case _WKElementActionTypeOpen:
    9999        title = WEB_UI_STRING_KEY("Open", "Open ActionSheet Link", "Title for Open Link action button");
    100         handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
    101             [delegate openElementAtLocation:actionInfo._interactionLocation];
     100        handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
     101            [assistant.delegate actionSheetAssistant:assistant openElementAtLocation:actionInfo._interactionLocation];
    102102        };
    103103        break;
    104104    case _WKElementActionTypeSaveImage:
    105105        title = WEB_UI_STRING_KEY("Save Image", "Save Image", "Title for Save Image action button");
    106         handler = ^(id <WKActionSheetAssistantDelegate> delegate, _WKActivatedElementInfo *actionInfo) {
    107             [delegate performAction:WebKit::SheetAction::SaveImage];
     106        handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
     107            [assistant.delegate actionSheetAssistant:assistant performAction:WebKit::SheetAction::SaveImage];
    108108        };
    109109        break;
    110110    case _WKElementActionTypeAddToReadingList:
    111111        title = WEB_UI_STRING("Add to Reading List", "Title for Add to Reading List action button");
    112         handler = ^(id <WKActionSheetAssistantDelegate>, _WKActivatedElementInfo *actionInfo) {
     112        handler = ^(WKActionSheetAssistant *, _WKActivatedElementInfo *actionInfo) {
    113113            addToReadingList(actionInfo.URL, actionInfo.title);
    114114        };
     
    132132}
    133133
    134 - (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info delegate:(id <WKActionSheetAssistantDelegate>)delegate
     134- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info forActionSheetAssistant:(WKActionSheetAssistant *)assistant
    135135{
    136     _actionHandler(delegate, info);
     136    _actionHandler(assistant, info);
    137137}
    138138
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementActionInternal.h

    r174885 r175577  
    3030#if PLATFORM(IOS)
    3131
     32@class WKActionSheetAssistant;
    3233@class WKContentView;
    33 @protocol WKActionSheetAssistantDelegate;
    3434
    3535@interface _WKElementAction ()
    3636
    37 - (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info delegate:(id <WKActionSheetAssistantDelegate>)delegate;
     37- (void)_runActionWithElementInfo:(_WKActivatedElementInfo *)info forActionSheetAssistant:(WKActionSheetAssistant *)assistant;
    3838
    3939@end
  • trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h

    r174885 r175577  
    3737}
    3838
     39@class WKActionSheetAssistant;
     40@class _WKActivatedElementInfo;
    3941@protocol WKActionSheetDelegate;
    40 @class _WKActivatedElementInfo;
    4142
    4243@protocol WKActionSheetAssistantDelegate
    4344@required
    44 @property (nonatomic, readonly) const WebKit::InteractionInformationAtPosition& positionInformation;
    45 - (void)updatePositionInformation;
    46 - (void)performAction:(WebKit::SheetAction)action;
    47 - (void)openElementAtLocation:(CGPoint)location;
    48 - (RetainPtr<NSArray>)actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions;
    49 - (void)startInteractionWithElement:(_WKActivatedElementInfo *)element;
    50 - (void)stopInteraction;
     45- (const WebKit::InteractionInformationAtPosition&)positionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
     46- (void)updatePositionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant;
     47- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant performAction:(WebKit::SheetAction)action;
     48- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant openElementAtLocation:(CGPoint)location;
     49- (RetainPtr<NSArray>)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions;
     50- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant willStartInteractionWithElement:(_WKActivatedElementInfo *)element;
     51- (void)actionSheetAssistantDidStopInteraction:(WKActionSheetAssistant *)assistant;
    5152@end
    5253
  • trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm

    r174885 r175577  
    138138        return CGRectZero;
    139139
    140     return [self _presentationRectForSheetGivenPoint:[delegate positionInformation].point inHostView:view];
    141 
     140    return [self _presentationRectForSheetGivenPoint:[delegate positionInformationForActionSheetAssistant:self].point inHostView:view];
    142141}
    143142
     
    149148        return CGRectZero;
    150149
    151     const auto& positionInformation = [delegate positionInformation];
     150    const auto& positionInformation = [delegate positionInformationForActionSheetAssistant:self];
    152151
    153152    CGRect boundingRect = positionInformation.bounds;
     
    165164- (void)updatePositionInformation
    166165{
    167     [_delegate.get() updatePositionInformation];
     166    [_delegate.get() updatePositionInformationForActionSheetAssistant:self];
    168167}
    169168
     
    193192        return;
    194193
    195     const auto& positionInformation = [delegate positionInformation];
     194    const auto& positionInformation = [delegate positionInformationForActionSheetAssistant:self];
    196195
    197196    NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
     
    226225    for (_WKElementAction *action in actions) {
    227226        [_interactionSheet _addActionWithTitle:[action title] style:UIAlertActionStyleDefault handler:^{
    228             [action _runActionWithElementInfo:_elementInfo.get() delegate:delegate.get()];
     227            [action _runActionWithElementInfo:_elementInfo.get() forActionSheetAssistant:self];
    229228            [self cleanupSheet];
    230229        } shouldDismissHandler:^{
     
    238237                                                            [self cleanupSheet];
    239238                                                        }]];
    240     [delegate startInteractionWithElement:_elementInfo.get()];
     239    [delegate actionSheetAssistant:self willStartInteractionWithElement:_elementInfo.get()];
    241240}
    242241
     
    250249        return;
    251250
    252     const auto& positionInformation = [delegate positionInformation];
     251    const auto& positionInformation = [delegate positionInformationForActionSheetAssistant:self];
    253252
    254253    NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
     
    266265        URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
    267266
    268     RetainPtr<NSArray> actions = [delegate actionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
     267    RetainPtr<NSArray> actions = [delegate actionSheetAssistant:self decideActionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
    269268
    270269    if (![actions count])
     
    290289        return;
    291290
    292     const auto& positionInformation = [delegate positionInformation];
     291    const auto& positionInformation = [delegate positionInformationForActionSheetAssistant:self];
    293292
    294293    NSURL *targetURL = [NSURL URLWithString:positionInformation.url];
     
    306305        URL:targetURL location:positionInformation.point title:positionInformation.title rect:positionInformation.bounds image:positionInformation.image.get()]);
    307306
    308     RetainPtr<NSArray> actions = [delegate actionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
     307    RetainPtr<NSArray> actions = [delegate actionSheetAssistant:self decideActionsForElement:elementInfo.get() defaultActions:WTF::move(defaultActions)];
    309308
    310309    if (![actions count])
     
    329328        return;
    330329
    331     NSURL *targetURL = [NSURL URLWithString:[delegate positionInformation].url];
     330    NSURL *targetURL = [NSURL URLWithString:[delegate positionInformationForActionSheetAssistant:self].url];
    332331    if (!targetURL)
    333332        return;
     
    367366- (void)cleanupSheet
    368367{
    369     [_delegate.get() stopInteraction];
     368    [_delegate.get() actionSheetAssistantDidStopInteraction:self];
    370369
    371370    [_interactionSheet doneWithSheet];
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r174885 r175577  
    26892689#pragma mark - Implementation of WKActionSheetAssistantDelegate.
    26902690
    2691 - (void)updatePositionInformation
     2691- (const WebKit::InteractionInformationAtPosition&)positionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant
     2692{
     2693    return _positionInformation;
     2694}
     2695
     2696- (void)updatePositionInformationForActionSheetAssistant:(WKActionSheetAssistant *)assistant
    26922697{
    26932698    _hasValidPositionInformation = NO;
     
    26952700}
    26962701
    2697 - (void)performAction:(WebKit::SheetAction)action
     2702- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant performAction:(WebKit::SheetAction)action
    26982703{
    26992704    _page->performActionOnElement((uint32_t)action);
    27002705}
    27012706
    2702 - (void)openElementAtLocation:(CGPoint)location
     2707- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant openElementAtLocation:(CGPoint)location
    27032708{
    27042709    [self _attemptClickAtLocation:location];
    27052710}
    27062711
    2707 - (RetainPtr<NSArray>)actionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions
     2712- (RetainPtr<NSArray>)actionSheetAssistant:(WKActionSheetAssistant *)assistant decideActionsForElement:(_WKActivatedElementInfo *)element defaultActions:(RetainPtr<NSArray>)defaultActions
    27082713{
    27092714    return _page->uiClient().actionsForElement(element, WTF::move(defaultActions));
    27102715}
    27112716
    2712 - (void)startInteractionWithElement:(_WKActivatedElementInfo *)element
     2717- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant willStartInteractionWithElement:(_WKActivatedElementInfo *)element
    27132718{
    27142719    _page->startInteractionWithElementAtPosition(_positionInformation.point);
    27152720}
    27162721
    2717 - (void)stopInteraction
     2722- (void)actionSheetAssistantDidStopInteraction:(WKActionSheetAssistant *)assistant
    27182723{
    27192724    _page->stopInteraction();
Note: See TracChangeset for help on using the changeset viewer.