Changeset 191805 in webkit


Ignore:
Timestamp:
Oct 30, 2015 12:38:40 PM (9 years ago)
Author:
Beth Dakin
Message:

Tapping and holding a link should have a share option
https://bugs.webkit.org/show_bug.cgi?id=150693
-and corresponding-
rdar://problem/21319702

Reviewed by Tim Horton.

Source/WebCore:

  • English.lproj/Localizable.strings:

Source/WebKit2:

New _WKElementActionType called _WKElementActionTypeShare.

  • UIProcess/API/Cocoa/_WKElementAction.h:
  • UIProcess/API/Cocoa/_WKElementAction.mm:

(+[_WKElementAction _elementActionWithType:customTitle:assistant:]):

_WKElementActionTypeShare is part of the default actions for links.

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

(-[WKActionSheetAssistant defaultActionsForLinkSheet:]):

Handle the sharing part!

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView actionSheetAssistant:shareElementWithURL:rect:]):

To support this in PDF, PDF need to create a _webSelectionAssistant.

  • UIProcess/ios/WKPDFView.mm:

(-[WKPDFView web_initWithFrame:webView:]):
(-[WKPDFView actionSheetAssistant:openElementAtLocation:]):
(-[WKPDFView actionSheetAssistant:shareElementWithURL:rect:]):
(-[WKPDFView actionSheetAssistant:shouldIncludeAppLinkActionsForElement:]):

Location:
trunk/Source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r191804 r191805  
     12015-10-30  Beth Dakin  <bdakin@apple.com>
     2
     3        Tapping and holding a link should have a share option
     4        https://bugs.webkit.org/show_bug.cgi?id=150693
     5        -and corresponding-
     6        rdar://problem/21319702
     7
     8        Reviewed by Tim Horton.
     9
     10        * English.lproj/Localizable.strings:
     11
    1122015-10-30  Joseph Pecoraro  <pecoraro@apple.com>
    213
  • trunk/Source/WebCore/English.lproj/Localizable.strings

    r190611 r191805  
    497497"Set Writing Direction (Undo action name)" = "Set Writing Direction";
    498498
     499/* Title for Share action button */
     500"Share…" = "Share…";
     501
    499502/* Show colors context menu item */
    500503"Show Colors" = "Show Colors";
  • trunk/Source/WebKit2/ChangeLog

    r191802 r191805  
     12015-10-30  Beth Dakin  <bdakin@apple.com>
     2
     3        Tapping and holding a link should have a share option
     4        https://bugs.webkit.org/show_bug.cgi?id=150693
     5        -and corresponding-
     6        rdar://problem/21319702
     7
     8        Reviewed by Tim Horton.
     9
     10        New _WKElementActionType called _WKElementActionTypeShare.
     11        * UIProcess/API/Cocoa/_WKElementAction.h:
     12        * UIProcess/API/Cocoa/_WKElementAction.mm:
     13        (+[_WKElementAction _elementActionWithType:customTitle:assistant:]):
     14
     15        _WKElementActionTypeShare is part of the default actions for links.
     16        * UIProcess/ios/WKActionSheetAssistant.h:
     17        * UIProcess/ios/WKActionSheetAssistant.mm:
     18        (-[WKActionSheetAssistant defaultActionsForLinkSheet:]):
     19
     20        Handle the sharing part!
     21        * UIProcess/ios/WKContentViewInteraction.mm:
     22        (-[WKContentView actionSheetAssistant:shareElementWithURL:rect:]):
     23
     24        To support this in PDF, PDF need to create a _webSelectionAssistant.
     25        * UIProcess/ios/WKPDFView.mm:
     26        (-[WKPDFView web_initWithFrame:webView:]):
     27        (-[WKPDFView actionSheetAssistant:openElementAtLocation:]):
     28        (-[WKPDFView actionSheetAssistant:shareElementWithURL:rect:]):
     29        (-[WKPDFView actionSheetAssistant:shouldIncludeAppLinkActionsForElement:]):
     30
    1312015-10-30  Tim Horton  <timothy_horton@apple.com>
    232
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.h

    r189547 r191805  
    4444    _WKElementActionTypeOpenInDefaultBrowser WK_ENUM_AVAILABLE(NA, 9_0),
    4545    _WKElementActionTypeOpenInExternalApplication WK_ENUM_AVAILABLE(NA, 9_0),
     46    _WKElementActionTypeShare WK_ENUM_AVAILABLE(NA, WK_IOS_TBA),
    4647#endif
    4748} WK_ENUM_AVAILABLE(10_10, 8_0);
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/_WKElementAction.mm

    r186718 r191805  
    128128        break;
    129129#endif
     130    case _WKElementActionTypeShare:
     131        title = WEB_UI_STRING("Share…", "Title for Share action button");
     132        handler = ^(WKActionSheetAssistant *assistant, _WKActivatedElementInfo *actionInfo) {
     133            [assistant.delegate actionSheetAssistant:assistant shareElementWithURL:actionInfo.URL rect:actionInfo.boundingRect];
     134        };
     135        break;
    130136    default:
    131137        [NSException raise:NSInvalidArgumentException format:@"There is no standard web element action of type %ld.", (long)type];
  • trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.h

    r188349 r191805  
    4646- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant performAction:(WebKit::SheetAction)action;
    4747- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant openElementAtLocation:(CGPoint)location;
     48- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant shareElementWithURL:(NSURL *)url rect:(CGRect)boundingRect;
    4849#if HAVE(APP_LINKS)
    4950- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element;
  • trunk/Source/WebKit2/UIProcess/ios/WKActionSheetAssistant.mm

    r188349 r191805  
    344344        [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeAddToReadingList assistant:self]];
    345345#endif
    346     if (![[targetURL scheme] length] || [[targetURL scheme] caseInsensitiveCompare:@"javascript"] != NSOrderedSame)
     346    if (![[targetURL scheme] length] || [[targetURL scheme] caseInsensitiveCompare:@"javascript"] != NSOrderedSame) {
    347347        [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeCopy assistant:self]];
     348        [defaultActions addObject:[_WKElementAction _elementActionWithType:_WKElementActionTypeShare assistant:self]];
     349    }
    348350
    349351    return defaultActions;
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r191644 r191805  
    33713371}
    33723372
     3373- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant shareElementWithURL:(NSURL *)url rect:(CGRect)boundingRect
     3374{
     3375    if (_textSelectionAssistant)
     3376        [_textSelectionAssistant showShareSheetFor:url.absoluteString fromRect:boundingRect];
     3377    else if (_webSelectionAssistant)
     3378        [_webSelectionAssistant showShareSheetFor:url.absoluteString fromRect:boundingRect];
     3379}
     3380
    33733381#if HAVE(APP_LINKS)
    33743382- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element
  • trunk/Source/WebKit2/UIProcess/ios/WKPDFView.mm

    r186719 r191805  
    106106
    107107    dispatch_queue_t _findQueue;
     108
     109    RetainPtr<UIWKSelectionAssistant> _webSelectionAssistant;
    108110}
    109111
     
    719721}
    720722
     723- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant shareElementWithURL:(NSURL *)url rect:(CGRect)boundingRect
     724{
     725    _webSelectionAssistant = adoptNS([[UIWKSelectionAssistant alloc] initWithView:self]);
     726    [_webSelectionAssistant showShareSheetFor:url.absoluteString fromRect:boundingRect];
     727    _webSelectionAssistant = nil;
     728}
     729
    721730#if HAVE(APP_LINKS)
    722731- (BOOL)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeAppLinkActionsForElement:(_WKActivatedElementInfo *)element
Note: See TracChangeset for help on using the changeset viewer.