[webkit-changes] [WebKit/WebKit] 296ab2: Previously cleared text reappears when typing in K...

Wenson Hsieh noreply at github.com
Fri Dec 27 11:23:05 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 296ab29f51e372d0e00721ff34ad360ef75466b6
      https://github.com/WebKit/WebKit/commit/296ab29f51e372d0e00721ff34ad360ef75466b6
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2024-12-27 (Fri, 27 Dec 2024)

  Changed paths:
    A LayoutTests/editing/input/ios/invalidate-text-entry-context-when-clearing-text-area-expected.txt
    A LayoutTests/editing/input/ios/invalidate-text-entry-context-when-clearing-text-area.html
    M LayoutTests/resources/ui-helper.js
    M Source/WebCore/html/HTMLInputElement.cpp
    M Source/WebCore/html/HTMLTextAreaElement.cpp
    M Source/WebCore/page/ChromeClient.h
    M Source/WebKit/UIProcess/PageClient.h
    M Source/WebKit/UIProcess/WebPageProxy.h
    M Source/WebKit/UIProcess/WebPageProxy.messages.in
    M Source/WebKit/UIProcess/ios/PageClientImplIOS.h
    M Source/WebKit/UIProcess/ios/PageClientImplIOS.mm
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp
    M Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h
    M Source/WebKit/WebProcess/WebPage/WebPage.cpp
    M Source/WebKit/WebProcess/WebPage/WebPage.h
    M Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm
    M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
    M Tools/TestRunnerShared/spi/UIKitSPIForTesting.h
    M Tools/WebKitTestRunner/TestController.h
    M Tools/WebKitTestRunner/ios/TestControllerIOS.mm
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

  Log Message:
  -----------
  Previously cleared text reappears when typing in Korean after tapping ⨯ in Google search field
https://bugs.webkit.org/show_bug.cgi?id=285175
rdar://131897908

Reviewed by Richard Robinson.

When using Korean keyboards to search on Google (typing in a `textarea` element) on Google on iOS,
if you:

(1) Type some Korean text (stopping in the middle of a composed word).
(2) Tap the ⨯ button, which programmatically clears the text field.
(3) Continue typing on Korean.

...text that was previously typed and then cleared during (2) will reappear. This happens because
there's no mechanism to invalidate and update the keyboard's text entry context when text content
changes programmatically, so the stored input context ends up being reinserted.

To fix this, we add a heuristic to respond to programmatic changes in text content that cause the
value of focused text form controls to become empty, and `-invalidateTextEntryContextForTextInput:`
in the UI process. While we could potentially apply this treatment to *all* programmatic value
changes, this poses a more significant web compat and performance risk.

* LayoutTests/editing/input/ios/invalidate-text-entry-context-when-clearing-text-area-expected.txt: Added.
* LayoutTests/editing/input/ios/invalidate-text-entry-context-when-clearing-text-area.html: Added.

Add a layout test to exercise this change, by teaching the test runner to count the number of times
`-[_UIKeyboardStateManager updateForChangedSelection]` is invoked and verifying that clearing the
text in a `textarea` calls into this method.

* LayoutTests/resources/ui-helper.js:
(window.UIHelper.async keyboardUpdateForChangedSelectionCount):
(window.UIHelper):
* Source/WebCore/html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::setValue):

Call the new client hook below, when the value is set to the empty string from bindings.

* Source/WebCore/html/HTMLTextAreaElement.cpp:
(WebCore::HTMLTextAreaElement::setValueCommon):
* Source/WebCore/page/ChromeClient.h:
(WebCore::ChromeClient::didProgrammaticallyClearTextFormControl):

Add a client hook to notify `WebPage` when a text form control's text value is cleared.

* Source/WebKit/UIProcess/PageClient.h:
* Source/WebKit/UIProcess/WebPageProxy.h:
* Source/WebKit/UIProcess/WebPageProxy.messages.in:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.h:
* Source/WebKit/UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::didProgrammaticallyClearFocusedElement):
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _updateInputContextAfterBlurringAndRefocusingElement]):
(-[WKContentView _didProgrammaticallyClearFocusedElement:]):
(-[WKContentView _internalInvalidateTextEntryContext]):
* Source/WebKit/UIProcess/ios/WebPageProxyIOS.mm:
(WebKit::WebPageProxy::didProgrammaticallyClearFocusedElement):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::didProgrammaticallyClearTextFormControl):
* Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h:
* Source/WebKit/WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::contextForElement const):

Make this method const, so that we can pass in the form control element below.

* Source/WebKit/WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::didProgrammaticallyClearTextFormControl):
* Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::didProgrammaticallyClearTextFormControl):

Notify the UI process when the focused form control value is cleared. The IPC message is sent on the
next runloop, so that we'll still invalidate the text entry context in the case where a focused
element is blurred and immediately refocused.

* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::keyboardUpdateForChangedSelectionCount const):
* Tools/WebKitTestRunner/TestController.h:
* Tools/WebKitTestRunner/ios/TestControllerIOS.mm:
(-[NSObject swizzled_updateForChangedSelection]):
(WTR::TestController::platformInitialize):
(WTR::TestController::keyboardUpdateForChangedSelectionCount const):
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::keyboardUpdateForChangedSelectionCount const):

Add test infrastructure to keep track of the number of times `-updateForChangedSelection` is
invoked; also expose a new script controller hook to request this count from layout tests.

Canonical link: https://commits.webkit.org/288313@main



To unsubscribe from these emails, change your notification settings at https://github.com/WebKit/WebKit/settings/notifications


More information about the webkit-changes mailing list