Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 63bfab4cff442ccc4552bc35e27e4c287e286549
      
https://github.com/WebKit/WebKit/commit/63bfab4cff442ccc4552bc35e27e4c287e286549
  Author: Wenson Hsieh <[email protected]>
  Date:   2023-11-03 (Fri, 03 Nov 2023)

  Changed paths:
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/html/HTMLInputElement.h
    M Source/WebKit/Platform/spi/ios/UIKitSPI.h
    M Source/WebKit/Shared/FocusedElementInformation.h
    M Source/WebKit/Shared/FocusedElementInformation.serialization.in
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/TestRunnerShared/spi/UIKitSPIForTesting.h
    M Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm

  Log Message:
  -----------
  [iOS] Keyboard should not learn autocorrections after revealing password in 
Gmail login flow
https://bugs.webkit.org/show_bug.cgi?id=260864
rdar://111393742

Reviewed by Aditya Keerthi.

When focusing and editing secure inputs (i.e. input type="password"), we set 
`isSecureTextEntry` on
`UITextInputTraits` to `YES`, which disables autocorrection learning when the 
user types in this
field, suppresses the keyboard in screen recordings, and more.

However, some webpages (e.g. Gmail login) offer the ability to reveal the 
password as plain text as
a convenience to the user — this typically works by changing the input type 
from `"password"` to
just `"text"`. This currently causes all of the secure text entry behaviors to 
be disabled, which
includes disabling correction learning; this is undesirable, since the password 
may be offered as an
autocorrection candidate when editing in other plain text fields in the future, 
in non-secure
contexts.

Because the user opted to reveal the input, it doesn't really make sense to 
treat the input as fully
secure (for instance, there's no reason to suppress keyboard visibility in 
screen recordings if the
password text itself is fully visible). However, we need to (at least) prevent 
the keyboard from
learning suggestions when typing in this field. To achieve this, we add a flag 
on `HTMLInputElement`
to remember whether it was ever a password field; if so, we set the 
`-learnsCorrections` property on
text input traits to `NO`.

Test: 
AutocorrectionTests.DoNotLearnCorrectionsAfterChangingInputTypeFromPassword

* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::runPostTypeUpdateTasks):

Set `m_hasEverBeenPasswordField` here.

* Source/WebCore/html/HTMLInputElement.h:
(WebCore::HTMLInputElement::hasEverBeenPasswordField const):
* Source/WebKit/Platform/spi/ios/UIKitSPI.h:
* Source/WebKit/Shared/FocusedElementInformation.h:
* Source/WebKit/Shared/FocusedElementInformation.serialization.in:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _updateTextInputTraits:]):

Consult `hasEverBeenPasswordField` on the focused element information, and 
disable learning from
corrections if it's set.

* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:

Propagate `hasEverBeenPasswordField` state to the UI process when focusing an 
input element.

(WebKit::WebPage::focusedElementInformation):
* Tools/TestWebKitAPI/Tests/ios/AutocorrectionTestsIOS.mm:

Add an API test to exercise the change.

* Tools/TestWebKitAPI/ios/UIKitSPI.h:

Originally-landed-as: 265870.476@safari-7616-branch (5cfdf9b1cbac). 
rdar://117808918
Canonical link: https://commits.webkit.org/270184@main


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to