Title: [279423] trunk
Revision
279423
Author
[email protected]
Date
2021-06-30 11:26:44 -0700 (Wed, 30 Jun 2021)

Log Message

[iOS] [Live Text] "Text from Camera" should not be shown in callout bar when selecting text
https://bugs.webkit.org/show_bug.cgi?id=227535
rdar://79936981

Reviewed by Devin Rousso.

Source/WebKit:

Match new system behavior in rdar://79758142 by not showing the "Text from Camera" item in the callout bar when
the selection is a (non-collapsed) range.

Test: WebKit.CaptureTextFromCamera

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView canPerformActionForWebView:withSender:]):

Tools:

Add an API test to exercise the change. See WebKit ChangeLog for more detail.

* TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:
(canPerformActionWithSender):
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (279422 => 279423)


--- trunk/Source/WebKit/ChangeLog	2021-06-30 18:14:17 UTC (rev 279422)
+++ trunk/Source/WebKit/ChangeLog	2021-06-30 18:26:44 UTC (rev 279423)
@@ -1,3 +1,19 @@
+2021-06-30  Wenson Hsieh  <[email protected]>
+
+        [iOS] [Live Text] "Text from Camera" should not be shown in callout bar when selecting text
+        https://bugs.webkit.org/show_bug.cgi?id=227535
+        rdar://79936981
+
+        Reviewed by Devin Rousso.
+
+        Match new system behavior in rdar://79758142 by not showing the "Text from Camera" item in the callout bar when
+        the selection is a (non-collapsed) range.
+
+        Test: WebKit.CaptureTextFromCamera
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView canPerformActionForWebView:withSender:]):
+
 2021-06-30  Antoine Quint  <[email protected]>
 
         [Model] [iOS] Add support for displaying <model> in fullscreen

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (279422 => 279423)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-06-30 18:14:17 UTC (rev 279422)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-06-30 18:26:44 UTC (rev 279423)
@@ -3881,7 +3881,7 @@
     }
 
 #if ENABLE(IMAGE_ANALYSIS)
-    if (action == @selector(captureTextFromCamera:) && !editorState.isContentEditable)
+    if (action == @selector(captureTextFromCamera:) && (!editorState.isContentEditable || editorState.selectionIsRange))
         return NO;
 #endif
 

Modified: trunk/Tools/ChangeLog (279422 => 279423)


--- trunk/Tools/ChangeLog	2021-06-30 18:14:17 UTC (rev 279422)
+++ trunk/Tools/ChangeLog	2021-06-30 18:26:44 UTC (rev 279423)
@@ -1,3 +1,17 @@
+2021-06-30  Wenson Hsieh  <[email protected]>
+
+        [iOS] [Live Text] "Text from Camera" should not be shown in callout bar when selecting text
+        https://bugs.webkit.org/show_bug.cgi?id=227535
+        rdar://79936981
+
+        Reviewed by Devin Rousso.
+
+        Add an API test to exercise the change. See WebKit ChangeLog for more detail.
+
+        * TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:
+        (canPerformActionWithSender):
+        (TEST):
+
 2021-06-30  Zhifei Fang  <[email protected]>
 
         [webkit.css] make the active tab more obvious

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm (279422 => 279423)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm	2021-06-30 18:14:17 UTC (rev 279422)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm	2021-06-30 18:26:44 UTC (rev 279423)
@@ -27,6 +27,7 @@
 
 #if PLATFORM(IOS_FAMILY)
 
+#import "InstanceMethodSwizzler.h"
 #import "PlatformUtilities.h"
 #import "Test.h"
 #import "TestNavigationDelegate.h"
@@ -73,8 +74,10 @@
     [webView waitForNextPresentationUpdate];
 }
 
-#if ENABLE(IMAGE_ANALYSIS) && ENABLE(APP_HIGHLIGHTS)
+#if ENABLE(IMAGE_ANALYSIS)
 
+#if ENABLE(APP_HIGHLIGHTS)
+
 TEST(WebKit, AppHighlightsInImageOverlays)
 {
     auto configuration = retainPtr([WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"WebProcessPlugInWithInternals" configureJSCForTesting:YES]);
@@ -99,6 +102,39 @@
     EXPECT_EQ([contentView targetForAction:createHighlightForNewQuickNoteWithRangeSelector withSender:nil], contentView);
 }
 
-#endif // ENABLE(IMAGE_ANALYSIS) && ENABLE(APP_HIGHLIGHTS)
+#endif // ENABLE(APP_HIGHLIGHTS)
 
+static BOOL gCanPerformActionWithSenderResult = NO;
+static BOOL canPerformActionWithSender(id /* instance */, SEL, SEL /* action */, id /* sender */)
+{
+    return gCanPerformActionWithSenderResult;
+}
+
+TEST(WebKit, CaptureTextFromCamera)
+{
+    gCanPerformActionWithSenderResult = YES;
+    InstanceMethodSwizzler swizzler { UIResponder.class, @selector(canPerformAction:withSender:), reinterpret_cast<IMP>(canPerformActionWithSender) };
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+    auto contentView = [webView textInputContentView];
+
+    [webView synchronouslyLoadHTMLString:@"<input value='foo' autofocus>"];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_EQ([webView targetForAction:@selector(captureTextFromCamera:) withSender:nil], contentView);
+    EXPECT_TRUE([webView canPerformAction:@selector(captureTextFromCamera:) withSender:nil]);
+
+    [webView selectAll:nil];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE([webView canPerformAction:@selector(captureTextFromCamera:) withSender:nil]);
+
+    [webView collapseToEnd];
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE([webView canPerformAction:@selector(captureTextFromCamera:) withSender:nil]);
+
+    gCanPerformActionWithSenderResult = NO;
+    EXPECT_FALSE([webView canPerformAction:@selector(captureTextFromCamera:) withSender:nil]);
+}
+
+#endif // ENABLE(IMAGE_ANALYSIS)
+
 #endif // PLATFORM(IOS_FAMILY)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to