Changeset 211897 in webkit


Ignore:
Timestamp:
Feb 8, 2017, 1:34:40 PM (8 years ago)
Author:
mitz@apple.com
Message:

[iOS] WKWebView doesn’t have implementations of UIResponderStandardEditActions that can be overridden
https://bugs.webkit.org/show_bug.cgi?id=167974

Reviewed by Tim Horton.

  • UIProcess/API/Cocoa/WKWebView.mm: Gave each of the actions in FOR_EACH_WKCONTENTVIEW_ACTION an implementation that sends it to the WKContentView if we’re using one.

(-[WKWebView canPerformAction:withSender:]): Override and for each of the actions in

FOR_EACH_WKCONTENTVIEW_ACTION, forward to
-[WKContentView canPerformActionForWebView:withSender:] if we’re using a WKContentView,
otherwise returning NO.

  • UIProcess/ios/WKContentViewInteraction.h: Declared -canPerformActionForWebView:withSender: and several internal methods we override.
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView canPerformAction:withSender:]): Now returns NO so that the target for any

action is the WKWebView.

(-[WKContentView canPerformActionForWebView:withSender:]): Moved the logic previously in

-canPerformAction:withSender: to here.

Location:
trunk/Source/WebKit2
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r211894 r211897  
     12017-02-08  Dan Bernstein  <mitz@apple.com>
     2
     3        [iOS] WKWebView doesn’t have implementations of UIResponderStandardEditActions that can be overridden
     4        https://bugs.webkit.org/show_bug.cgi?id=167974
     5
     6        Reviewed by Tim Horton.
     7
     8        * UIProcess/API/Cocoa/WKWebView.mm:
     9          Gave each of the actions in FOR_EACH_WKCONTENTVIEW_ACTION an implementation that sends it
     10          to the WKContentView if we’re using one.
     11        (-[WKWebView canPerformAction:withSender:]): Override and for each of the actions in
     12          FOR_EACH_WKCONTENTVIEW_ACTION, forward to
     13          -[WKContentView canPerformActionForWebView:withSender:] if we’re using a WKContentView,
     14          otherwise returning NO.
     15
     16        * UIProcess/ios/WKContentViewInteraction.h: Declared -canPerformActionForWebView:withSender:
     17          and several internal methods we override.
     18        * UIProcess/ios/WKContentViewInteraction.mm:
     19        (-[WKContentView canPerformAction:withSender:]): Now returns NO so that the target for any
     20          action is the WKWebView.
     21        (-[WKContentView canPerformActionForWebView:withSender:]): Moved the logic previously in
     22          -canPerformAction:withSender: to here.
     23
    1242017-02-08  Antti Koivisto  <antti@apple.com>
    225
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r211891 r211897  
    10451045    return [super resignFirstResponder];
    10461046}
     1047
     1048#define FOR_EACH_WKCONTENTVIEW_ACTION(M) \
     1049    M(_addShortcut) \
     1050    M(_arrowKey) \
     1051    M(_define) \
     1052    M(_lookup) \
     1053    M(_promptForReplace) \
     1054    M(_reanalyze) \
     1055    M(_share) \
     1056    M(_showTextStyleOptions) \
     1057    M(_transliterateChinese) \
     1058    M(copy) \
     1059    M(cut) \
     1060    M(paste) \
     1061    M(replace) \
     1062    M(select) \
     1063    M(selectAll) \
     1064    M(toggleBoldface) \
     1065    M(toggleItalics) \
     1066    M(toggleUnderline) \
     1067
     1068#define FORWARD_ACTION_TO_WKCONTENTVIEW(_action) \
     1069    - (void)_action:(id)sender \
     1070    { \
     1071        if (self.usesStandardContentView) \
     1072            [_contentView _action:sender]; \
     1073    }
     1074
     1075FOR_EACH_WKCONTENTVIEW_ACTION(FORWARD_ACTION_TO_WKCONTENTVIEW)
     1076
     1077#undef FORWARD_ACTION_TO_WKCONTENTVIEW
     1078
     1079- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
     1080{
     1081    #define FORWARD_CANPERFORMACTION_TO_WKCONTENTVIEW(_action) \
     1082        if (action == @selector(_action:)) \
     1083            return self.usesStandardContentView && [_contentView canPerformActionForWebView:action withSender:sender];
     1084
     1085    FOR_EACH_WKCONTENTVIEW_ACTION(FORWARD_CANPERFORMACTION_TO_WKCONTENTVIEW)
     1086
     1087    #undef FORWARD_CANPERFORMACTION_TO_WKCONTENTVIEW
     1088
     1089    return [super canPerformAction:action withSender:sender];
     1090}
     1091
     1092#undef FOR_EACH_WKCONTENTVIEW_ACTION
    10471093
    10481094static inline CGFloat floorToDevicePixel(CGFloat input, float deviceScaleFactor)
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r211770 r211897  
    218218- (BOOL)becomeFirstResponderForWebView;
    219219- (BOOL)resignFirstResponderForWebView;
     220- (BOOL)canPerformActionForWebView:(SEL)action withSender:(id)sender;
     221
     222- (void)_addShortcut:(id)sender;
     223- (void)_arrowKey:(id)sender;
     224- (void)_define:(id)sender;
     225- (void)_lookup:(id)sender;
     226- (void)_reanalyze:(id)sender;
     227- (void)_share:(id)sender;
     228- (void)_showTextStyleOptions:(id)sender;
    220229
    221230#if ENABLE(TOUCH_EVENTS)
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r211770 r211897  
    19951995
    19961996- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
     1997{
     1998    return NO;
     1999}
     2000
     2001- (BOOL)canPerformActionForWebView:(SEL)action withSender:(id)sender
    19972002{
    19982003    BOOL hasWebSelection = _webSelectionAssistant && !CGRectIsEmpty(_webSelectionAssistant.get().selectionFrame);
Note: See TracChangeset for help on using the changeset viewer.