Title: [265465] branches/safari-610.1.25.10-branch
Revision
265465
Author
[email protected]
Date
2020-08-10 16:47:43 -0700 (Mon, 10 Aug 2020)

Log Message

Cherry-pick r265238. rdar://problem/66645891

    Allow -accessoryDone to blur the focused element on iPad when AutoFilling strong passwords
    https://bugs.webkit.org/show_bug.cgi?id=215105
    <rdar://problem/65143984>

    Reviewed by Tim Horton.

    Source/WebKit:

    `-accessoryDone` is now used to dismiss the strong password AutoFill keyboard after choosing a password on iOS,
    due to how it hides the keyboard without causing the content view to resign first responder; being stuck in a
    state where the content view is not first responder causes several issues when choosing strong passwords on iOS,
    such as keyboard shortcuts no longer working.

    On iPad, to ensure that `-accessoryDone` actually dismisses the keyboard, we need to additionally teach
    `-endEditingAndUpdateFocusAppearanceWithReason:` (when given `EndEditingReasonAccessoryDone`) to allow the
    focused element to blur when dismissing the strong password input view.

    Test: KeyboardInputTests.TestWebViewAccessoryDoneDuringStrongPasswordAssistance

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

    Refactor this logic into a local helper lambda with early returns, instead of using a single if statement.

    Tools:

    Add an API test that exercises the behavior change when run on iPad simulator.

    * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
    * TestWebKitAPI/ios/UIKitSPI.h:

    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265238 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Modified Paths

Diff

Modified: branches/safari-610.1.25.10-branch/Source/WebKit/ChangeLog (265464 => 265465)


--- branches/safari-610.1.25.10-branch/Source/WebKit/ChangeLog	2020-08-10 23:47:40 UTC (rev 265464)
+++ branches/safari-610.1.25.10-branch/Source/WebKit/ChangeLog	2020-08-10 23:47:43 UTC (rev 265465)
@@ -1,5 +1,67 @@
 2020-08-10  Alan Coon  <[email protected]>
 
+        Cherry-pick r265238. rdar://problem/66645891
+
+    Allow -accessoryDone to blur the focused element on iPad when AutoFilling strong passwords
+    https://bugs.webkit.org/show_bug.cgi?id=215105
+    <rdar://problem/65143984>
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebKit:
+    
+    `-accessoryDone` is now used to dismiss the strong password AutoFill keyboard after choosing a password on iOS,
+    due to how it hides the keyboard without causing the content view to resign first responder; being stuck in a
+    state where the content view is not first responder causes several issues when choosing strong passwords on iOS,
+    such as keyboard shortcuts no longer working.
+    
+    On iPad, to ensure that `-accessoryDone` actually dismisses the keyboard, we need to additionally teach
+    `-endEditingAndUpdateFocusAppearanceWithReason:` (when given `EndEditingReasonAccessoryDone`) to allow the
+    focused element to blur when dismissing the strong password input view.
+    
+    Test: KeyboardInputTests.TestWebViewAccessoryDoneDuringStrongPasswordAssistance
+    
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
+    
+    Refactor this logic into a local helper lambda with early returns, instead of using a single if statement.
+    
+    Tools:
+    
+    Add an API test that exercises the behavior change when run on iPad simulator.
+    
+    * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
+    * TestWebKitAPI/ios/UIKitSPI.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-03  Wenson Hsieh  <[email protected]>
+
+            Allow -accessoryDone to blur the focused element on iPad when AutoFilling strong passwords
+            https://bugs.webkit.org/show_bug.cgi?id=215105
+            <rdar://problem/65143984>
+
+            Reviewed by Tim Horton.
+
+            `-accessoryDone` is now used to dismiss the strong password AutoFill keyboard after choosing a password on iOS,
+            due to how it hides the keyboard without causing the content view to resign first responder; being stuck in a
+            state where the content view is not first responder causes several issues when choosing strong passwords on iOS,
+            such as keyboard shortcuts no longer working.
+
+            On iPad, to ensure that `-accessoryDone` actually dismisses the keyboard, we need to additionally teach
+            `-endEditingAndUpdateFocusAppearanceWithReason:` (when given `EndEditingReasonAccessoryDone`) to allow the
+            focused element to blur when dismissing the strong password input view.
+
+            Test: KeyboardInputTests.TestWebViewAccessoryDoneDuringStrongPasswordAssistance
+
+            * UIProcess/ios/WKContentViewInteraction.mm:
+            (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
+
+            Refactor this logic into a local helper lambda with early returns, instead of using a single if statement.
+
+2020-08-10  Alan Coon  <[email protected]>
+
         Cherry-pick r265230. rdar://problem/66643993
 
     Null check parentProcessConnection when creating a NetworkDataTaskCocoa

Modified: branches/safari-610.1.25.10-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (265464 => 265465)


--- branches/safari-610.1.25.10-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-08-10 23:47:40 UTC (rev 265464)
+++ branches/safari-610.1.25.10-branch/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2020-08-10 23:47:43 UTC (rev 265465)
@@ -1388,7 +1388,26 @@
     if (!self.webView._retainingActiveFocusedState) {
         // We need to complete the editing operation before we blur the element.
         [self _endEditing];
-        if ((reason == EndEditingReasonAccessoryDone && !WebKit::currentUserInterfaceIdiomIsPad()) || _keyboardDidRequestDismissal || self._shouldUseLegacySelectPopoverDismissalBehavior) {
+
+        auto shouldBlurFocusedElement = [&] {
+            if (_keyboardDidRequestDismissal)
+                return true;
+
+            if (self._shouldUseLegacySelectPopoverDismissalBehavior)
+                return true;
+
+            if (reason == EndEditingReasonAccessoryDone) {
+                if (_focusRequiresStrongPasswordAssistance)
+                    return true;
+
+                if (!WebKit::currentUserInterfaceIdiomIsPad())
+                    return true;
+            }
+
+            return false;
+        };
+
+        if (shouldBlurFocusedElement()) {
             _page->blurFocusedElement();
             // Don't wait for WebPageProxy::blurFocusedElement() to round-trip back to us to hide the keyboard
             // because we know that the user explicitly requested us to do so.

Modified: branches/safari-610.1.25.10-branch/Tools/ChangeLog (265464 => 265465)


--- branches/safari-610.1.25.10-branch/Tools/ChangeLog	2020-08-10 23:47:40 UTC (rev 265464)
+++ branches/safari-610.1.25.10-branch/Tools/ChangeLog	2020-08-10 23:47:43 UTC (rev 265465)
@@ -1,5 +1,56 @@
 2020-08-10  Alan Coon  <[email protected]>
 
+        Cherry-pick r265238. rdar://problem/66645891
+
+    Allow -accessoryDone to blur the focused element on iPad when AutoFilling strong passwords
+    https://bugs.webkit.org/show_bug.cgi?id=215105
+    <rdar://problem/65143984>
+    
+    Reviewed by Tim Horton.
+    
+    Source/WebKit:
+    
+    `-accessoryDone` is now used to dismiss the strong password AutoFill keyboard after choosing a password on iOS,
+    due to how it hides the keyboard without causing the content view to resign first responder; being stuck in a
+    state where the content view is not first responder causes several issues when choosing strong passwords on iOS,
+    such as keyboard shortcuts no longer working.
+    
+    On iPad, to ensure that `-accessoryDone` actually dismisses the keyboard, we need to additionally teach
+    `-endEditingAndUpdateFocusAppearanceWithReason:` (when given `EndEditingReasonAccessoryDone`) to allow the
+    focused element to blur when dismissing the strong password input view.
+    
+    Test: KeyboardInputTests.TestWebViewAccessoryDoneDuringStrongPasswordAssistance
+    
+    * UIProcess/ios/WKContentViewInteraction.mm:
+    (-[WKContentView endEditingAndUpdateFocusAppearanceWithReason:]):
+    
+    Refactor this logic into a local helper lambda with early returns, instead of using a single if statement.
+    
+    Tools:
+    
+    Add an API test that exercises the behavior change when run on iPad simulator.
+    
+    * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
+    * TestWebKitAPI/ios/UIKitSPI.h:
+    
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@265238 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2020-08-03  Wenson Hsieh  <[email protected]>
+
+            Allow -accessoryDone to blur the focused element on iPad when AutoFilling strong passwords
+            https://bugs.webkit.org/show_bug.cgi?id=215105
+            <rdar://problem/65143984>
+
+            Reviewed by Tim Horton.
+
+            Add an API test that exercises the behavior change when run on iPad simulator.
+
+            * TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:
+            * TestWebKitAPI/ios/UIKitSPI.h:
+
+2020-08-10  Alan Coon  <[email protected]>
+
         Cherry-pick r265188. rdar://problem/66643973
 
     Table data is incorrectly translated in some articles on en.wikipedia.org

Modified: branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm (265464 => 265465)


--- branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2020-08-10 23:47:40 UTC (rev 265464)
+++ branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm	2020-08-10 23:47:43 UTC (rev 265465)
@@ -691,6 +691,29 @@
     EXPECT_TRUE([[actual allValues] containsObject:expected]);
 }
 
+TEST(KeyboardInputTests, TestWebViewAccessoryDoneDuringStrongPasswordAssistance)
+{
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
+    auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);
+
+    [inputDelegate setFocusStartsInputSessionPolicyHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
+        return _WKFocusStartsInputSessionPolicyAllow;
+    }];
+
+    [inputDelegate setFocusRequiresStrongPasswordAssistanceHandler:[&] (WKWebView *, id <_WKFocusedElementInfo>) {
+        return YES;
+    }];
+
+    [webView _setInputDelegate:inputDelegate.get()];
+
+    [webView synchronouslyLoadHTMLString:@"<input type='password' id='input'>"];
+    [webView evaluateJavaScriptAndWaitForInputSessionToChange:@"document.getElementById('input').focus()"];
+    EXPECT_WK_STREQ("INPUT", [webView stringByEvaluatingJavaScript:@"document.activeElement.tagName"]);
+    [(id <UIWebFormAccessoryDelegate>)[webView textInputContentView] accessoryDone];
+    EXPECT_WK_STREQ("BODY", [webView stringByEvaluatingJavaScript:@"document.activeElement.tagName"]);
+    EXPECT_TRUE([webView _contentViewIsFirstResponder]);
+}
+
 TEST(KeyboardInputTests, SupportsImagePaste)
 {
     auto inputDelegate = adoptNS([[TestInputDelegate alloc] init]);

Modified: branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h (265464 => 265465)


--- branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h	2020-08-10 23:47:40 UTC (rev 265464)
+++ branches/safari-610.1.25.10-branch/Tools/TestWebKitAPI/ios/UIKitSPI.h	2020-08-10 23:47:43 UTC (rev 265465)
@@ -171,6 +171,10 @@
 @interface UIWKAutocorrectionContext : NSObject
 @end
 
+@protocol UIWebFormAccessoryDelegate
+- (void)accessoryDone;
+@end
+
 @protocol UIWKInteractionViewProtocol
 - (void)pasteWithCompletionHandler:(void (^)(void))completionHandler;
 - (void)requestAutocorrectionRectsForString:(NSString *)input withCompletionHandler:(void (^)(UIWKAutocorrectionRects *rectsForInput))completionHandler;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to