Changeset 246531 in webkit


Ignore:
Timestamp:
Jun 17, 2019 7:33:50 PM (5 years ago)
Author:
timothy_horton@apple.com
Message:

Expose DataDetectors context generation on WKContentViewInteraction
https://bugs.webkit.org/show_bug.cgi?id=198950
<rdar://problem/51116021>

Reviewed by Andy Estes.

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

(-[WKActionSheetAssistant currentPositionInformation]):
(-[WKActionSheetAssistant showDataDetectorsSheet]):

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

(-[WKContentView dataDetectionContextForPositionInformation:]):
(-[WKContentView dataDetectionContextForActionSheetAssistant:]):
For use by other clients, add -dataDetectionContextForPositionInformation:
and make -dataDetectionContextForActionSheetAssistant: use it.
Also, pull the code to augment the context with surrounding text out of
from WKActionSheetAssistant.

Location:
trunk/Source/WebKit
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246530 r246531  
     12019-06-17  Tim Horton  <timothy_horton@apple.com>
     2
     3        Expose DataDetectors context generation on WKContentViewInteraction
     4        https://bugs.webkit.org/show_bug.cgi?id=198950
     5        <rdar://problem/51116021>
     6
     7        Reviewed by Andy Estes.
     8
     9        * UIProcess/ios/WKActionSheetAssistant.h:
     10        * UIProcess/ios/WKActionSheetAssistant.mm:
     11        (-[WKActionSheetAssistant currentPositionInformation]):
     12        (-[WKActionSheetAssistant showDataDetectorsSheet]):
     13        * UIProcess/ios/WKContentViewInteraction.h:
     14        * UIProcess/ios/WKContentViewInteraction.mm:
     15        (-[WKContentView dataDetectionContextForPositionInformation:]):
     16        (-[WKContentView dataDetectionContextForActionSheetAssistant:]):
     17        For use by other clients, add -dataDetectionContextForPositionInformation:
     18        and make -dataDetectionContextForActionSheetAssistant: use it.
     19        Also, pull the code to augment the context with surrounding text out of
     20        from WKActionSheetAssistant.
     21
    1222019-06-17  Sihui Liu  <sihui_liu@apple.com>
    223
  • trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.h

    r246224 r246531  
    8383- (void)interactionDidStartWithPositionInformation:(const WebKit::InteractionInformationAtPosition&)information;
    8484- (NSArray *)currentAvailableActionTitles;
     85- (Optional<WebKit::InteractionInformationAtPosition>)currentPositionInformation;
    8586@end
    8687
  • trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm

    r246224 r246531  
    326326}
    327327
     328- (Optional<WebKit::InteractionInformationAtPosition>)currentPositionInformation
     329{
     330    return _positionInformation;
     331}
     332
    328333- (void)_createSheetWithElementActions:(NSArray *)actions defaultTitle:(NSString *)defaultTitle showLinkTitle:(BOOL)showLinkTitle
    329334{
     
    647652    NSDictionary *context = nil;
    648653    NSString *textAtSelection = nil;
    649     RetainPtr<NSMutableDictionary> extendedContext;
    650654
    651655    if ([_delegate respondsToSelector:@selector(dataDetectionContextForActionSheetAssistant:)])
     
    653657    if ([_delegate respondsToSelector:@selector(selectedTextForActionSheetAssistant:)])
    654658        textAtSelection = [_delegate selectedTextForActionSheetAssistant:self];
    655     if (!_positionInformation->textBefore.isEmpty() || !_positionInformation->textAfter.isEmpty()) {
    656         extendedContext = adoptNS([@{
    657             getkDataDetectorsLeadingText() : _positionInformation->textBefore,
    658             getkDataDetectorsTrailingText() : _positionInformation->textAfter,
    659         } mutableCopy]);
    660        
    661         if (context)
    662             [extendedContext addEntriesFromDictionary:context];
    663         context = extendedContext.get();
    664     }
    665659
    666660    if ([controller respondsToSelector:@selector(shouldImmediatelyLaunchDefaultActionForURL:)] && [controller shouldImmediatelyLaunchDefaultActionForURL:targetURL]) {
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h

    r246347 r246531  
    471471- (WKFormInputSession *)_formInputSession;
    472472- (void)_didChangeWebViewEditability;
     473- (NSDictionary *)dataDetectionContextForPositionInformation:(WebKit::InteractionInformationAtPosition)positionInformation;
    473474
    474475- (void)willFinishIgnoringCalloutBarFadeAfterPerformingAction;
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r246425 r246531  
    61406140}
    61416141
    6142 - (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant
    6143 {
    6144     NSDictionary *context = nil;
     6142- (NSDictionary *)dataDetectionContextForPositionInformation:(WebKit::InteractionInformationAtPosition)positionInformation
     6143{
     6144    RetainPtr<NSMutableDictionary> context;
    61456145    id <WKUIDelegatePrivate> uiDelegate = static_cast<id <WKUIDelegatePrivate>>([_webView UIDelegate]);
    61466146    if ([uiDelegate respondsToSelector:@selector(_dataDetectionContextForWebView:)])
    6147         context = [uiDelegate _dataDetectionContextForWebView:_webView];
    6148     return context;
     6147        context = adoptNS([[uiDelegate _dataDetectionContextForWebView:_webView] mutableCopy]);
     6148   
     6149    if (!context)
     6150        context = adoptNS([[NSMutableDictionary alloc] init]);
     6151   
     6152    if (!positionInformation.textBefore.isEmpty())
     6153        context.get()[getkDataDetectorsLeadingText()] = positionInformation.textBefore;
     6154    if (!positionInformation.textAfter.isEmpty())
     6155        context.get()[getkDataDetectorsTrailingText()] = positionInformation.textAfter;
     6156   
     6157    return context.autorelease();
     6158}
     6159
     6160- (NSDictionary *)dataDetectionContextForActionSheetAssistant:(WKActionSheetAssistant *)assistant
     6161{
     6162    return [self dataDetectionContextForPositionInformation:assistant.currentPositionInformation.valueOr(_positionInformation)];
    61496163}
    61506164
Note: See TracChangeset for help on using the changeset viewer.