Title: [259078] trunk
Revision
259078
Author
dba...@webkit.org
Date
2020-03-26 14:10:09 -0700 (Thu, 26 Mar 2020)

Log Message

WebPage::selectPositionAtPoint() does not focus an element in a non-focused frame
https://bugs.webkit.org/show_bug.cgi?id=209559
<rdar://problem/60887055>

Reviewed by Wenson Hsieh.

Source/WebKit:

Call setFocusedFrameBeforeSelectingTextAtLocation() in WebPage::selectPositionAtPoint() to
update the focused frame before performing the selection. This way the target element will
be focused by the selection, if not already focused.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::selectPositionAtPoint):

Tools:

Add a test.

* TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm:
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (259077 => 259078)


--- trunk/Source/WebKit/ChangeLog	2020-03-26 20:59:03 UTC (rev 259077)
+++ trunk/Source/WebKit/ChangeLog	2020-03-26 21:10:09 UTC (rev 259078)
@@ -1,3 +1,18 @@
+2020-03-26  Daniel Bates  <daba...@apple.com>
+
+        WebPage::selectPositionAtPoint() does not focus an element in a non-focused frame
+        https://bugs.webkit.org/show_bug.cgi?id=209559
+        <rdar://problem/60887055>
+
+        Reviewed by Wenson Hsieh.
+
+        Call setFocusedFrameBeforeSelectingTextAtLocation() in WebPage::selectPositionAtPoint() to
+        update the focused frame before performing the selection. This way the target element will
+        be focused by the selection, if not already focused.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::selectPositionAtPoint):
+
 2020-03-26  Fujii Hironori  <hironori.fu...@sony.com>
 
         WebKitTestRunner should enable ResourceLoadStatistics also for non-Cocoa ports

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (259077 => 259078)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-03-26 20:59:03 UTC (rev 259077)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2020-03-26 21:10:09 UTC (rev 259078)
@@ -2058,6 +2058,8 @@
 {
     SetForScope<bool> userIsInteractingChange { m_userIsInteracting, true };
 
+    setFocusedFrameBeforeSelectingTextAtLocation(point);
+
     auto& frame = m_page->focusController().focusedOrMainFrame();
     VisiblePosition position = visiblePositionInFocusedNodeForPoint(frame, point, isInteractingWithFocusedElement);
     

Modified: trunk/Tools/ChangeLog (259077 => 259078)


--- trunk/Tools/ChangeLog	2020-03-26 20:59:03 UTC (rev 259077)
+++ trunk/Tools/ChangeLog	2020-03-26 21:10:09 UTC (rev 259078)
@@ -1,3 +1,16 @@
+2020-03-26  Daniel Bates  <daba...@apple.com>
+
+        WebPage::selectPositionAtPoint() does not focus an element in a non-focused frame
+        https://bugs.webkit.org/show_bug.cgi?id=209559
+        <rdar://problem/60887055>
+
+        Reviewed by Wenson Hsieh.
+
+        Add a test.
+
+        * TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm:
+        (TEST):
+
 2020-03-26  Fujii Hironori  <hironori.fu...@sony.com>
 
         WebKitTestRunner should enable ResourceLoadStatistics also for non-Cocoa ports

Modified: trunk/Tools/TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm (259077 => 259078)


--- trunk/Tools/TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm	2020-03-26 20:59:03 UTC (rev 259077)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/UIWKInteractionViewProtocol.mm	2020-03-26 21:10:09 UTC (rev 259078)
@@ -154,4 +154,25 @@
     TestWebKitAPI::Util::run(&didCallDecidePolicyForFocusedElement);
 }
 
+TEST(UIWKInteractionViewProtocol, SelectPositionAtPointInElementInNonFocusedFrame)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)]);
+    auto inputDelegate = adoptNS([TestInputDelegate new]);
+    [webView _setInputDelegate:inputDelegate.get()];
+
+    bool didStartInputSession = false;
+    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) {
+        didStartInputSession = true;
+        return _WKFocusStartsInputSessionPolicyAllow;
+    }];
+
+    [webView synchronouslyLoadHTMLString:@"<body style='margin: 0; padding: 0'><iframe height='100' width='100%' style='border: none; padding: 0; margin: 0' srcdoc='<body style=\"margin: 0; padding: 0\"><div contenteditable=\"true\" style=\"width: 200px; height: 200px\"></body>'></iframe></body>"];
+    EXPECT_WK_STREQ("BODY", [webView stringByEvaluatingJavaScript:@"document.querySelector('iframe').contentDocument.activeElement.tagName"]);
+
+    [webView becomeFirstResponder];
+    [webView selectPositionAtPoint:CGPointMake(0, 0)];
+    TestWebKitAPI::Util::run(&didStartInputSession);
+    EXPECT_WK_STREQ("DIV", [webView stringByEvaluatingJavaScript:@"document.querySelector('iframe').contentDocument.activeElement.tagName"]);
+}
+
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to