Title: [211897] trunk/Source/WebKit2
Revision
211897
Author
m...@apple.com
Date
2017-02-08 13:34:40 -0800 (Wed, 08 Feb 2017)

Log 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.

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (211896 => 211897)


--- trunk/Source/WebKit2/ChangeLog	2017-02-08 21:21:45 UTC (rev 211896)
+++ trunk/Source/WebKit2/ChangeLog	2017-02-08 21:34:40 UTC (rev 211897)
@@ -1,3 +1,26 @@
+2017-02-08  Dan Bernstein  <m...@apple.com>
+
+        [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.
+
 2017-02-08  Antti Koivisto  <an...@apple.com>
 
         Allow speculative redirects

Modified: trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm (211896 => 211897)


--- trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-02-08 21:21:45 UTC (rev 211896)
+++ trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm	2017-02-08 21:34:40 UTC (rev 211897)
@@ -1045,6 +1045,52 @@
     return [super resignFirstResponder];
 }
 
+#define FOR_EACH_WKCONTENTVIEW_ACTION(M) \
+    M(_addShortcut) \
+    M(_arrowKey) \
+    M(_define) \
+    M(_lookup) \
+    M(_promptForReplace) \
+    M(_reanalyze) \
+    M(_share) \
+    M(_showTextStyleOptions) \
+    M(_transliterateChinese) \
+    M(copy) \
+    M(cut) \
+    M(paste) \
+    M(replace) \
+    M(select) \
+    M(selectAll) \
+    M(toggleBoldface) \
+    M(toggleItalics) \
+    M(toggleUnderline) \
+
+#define FORWARD_ACTION_TO_WKCONTENTVIEW(_action) \
+    - (void)_action:(id)sender \
+    { \
+        if (self.usesStandardContentView) \
+            [_contentView _action:sender]; \
+    }
+
+FOR_EACH_WKCONTENTVIEW_ACTION(FORWARD_ACTION_TO_WKCONTENTVIEW)
+
+#undef FORWARD_ACTION_TO_WKCONTENTVIEW
+
+- (BOOL)canPerformAction:(SEL)action withSender:(id)sender
+{
+    #define FORWARD_CANPERFORMACTION_TO_WKCONTENTVIEW(_action) \
+        if (action == @selector(_action:)) \
+            return self.usesStandardContentView && [_contentView canPerformActionForWebView:action withSender:sender];
+
+    FOR_EACH_WKCONTENTVIEW_ACTION(FORWARD_CANPERFORMACTION_TO_WKCONTENTVIEW)
+
+    #undef FORWARD_CANPERFORMACTION_TO_WKCONTENTVIEW
+
+    return [super canPerformAction:action withSender:sender];
+}
+
+#undef FOR_EACH_WKCONTENTVIEW_ACTION
+
 static inline CGFloat floorToDevicePixel(CGFloat input, float deviceScaleFactor)
 {
     return CGFloor(input * deviceScaleFactor) / deviceScaleFactor;

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h (211896 => 211897)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-02-08 21:21:45 UTC (rev 211896)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h	2017-02-08 21:34:40 UTC (rev 211897)
@@ -217,7 +217,16 @@
 - (BOOL)canBecomeFirstResponderForWebView;
 - (BOOL)becomeFirstResponderForWebView;
 - (BOOL)resignFirstResponderForWebView;
+- (BOOL)canPerformActionForWebView:(SEL)action withSender:(id)sender;
 
+- (void)_addShortcut:(id)sender;
+- (void)_arrowKey:(id)sender;
+- (void)_define:(id)sender;
+- (void)_lookup:(id)sender;
+- (void)_reanalyze:(id)sender;
+- (void)_share:(id)sender;
+- (void)_showTextStyleOptions:(id)sender;
+
 #if ENABLE(TOUCH_EVENTS)
 - (void)_webTouchEvent:(const WebKit::NativeWebTouchEvent&)touchEvent preventsNativeGestures:(BOOL)preventsDefault;
 #endif

Modified: trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm (211896 => 211897)


--- trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-02-08 21:21:45 UTC (rev 211896)
+++ trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm	2017-02-08 21:34:40 UTC (rev 211897)
@@ -1995,6 +1995,11 @@
 
 - (BOOL)canPerformAction:(SEL)action withSender:(id)sender
 {
+    return NO;
+}
+
+- (BOOL)canPerformActionForWebView:(SEL)action withSender:(id)sender
+{
     BOOL hasWebSelection = _webSelectionAssistant && !CGRectIsEmpty(_webSelectionAssistant.get().selectionFrame);
 
     if (action == @selector(_arrowKey:))
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to