[webkit-changes] [WebKit/WebKit] c152bf: Stop overriding `-[UITextInputPrivate supportsImag...

Wenson Hsieh noreply at github.com
Sat Nov 18 20:06:02 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: c152bf5e104d8b861c8871c1e715142049a393bc
      https://github.com/WebKit/WebKit/commit/c152bf5e104d8b861c8871c1e715142049a393bc
  Author: Wenson Hsieh <wenson_hsieh at apple.com>
  Date:   2023-11-18 (Sat, 18 Nov 2023)

  Changed paths:
    A LayoutTests/fast/forms/ios/focusing-text-field-does-not-increase-change-count-expected.txt
    A LayoutTests/fast/forms/ios/focusing-text-field-does-not-increase-change-count.html
    M LayoutTests/resources/ui-helper.js
    M Source/WTF/wtf/PlatformHave.h
    M Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm
    M Tools/DumpRenderTree/ios/UIScriptControllerIOS.h
    M Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm
    M Tools/DumpRenderTree/mac/UIScriptControllerMac.h
    M Tools/DumpRenderTree/mac/UIScriptControllerMac.mm
    M Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl
    M Tools/TestRunnerShared/UIScriptContext/UIScriptController.h
    M Tools/TestRunnerShared/spi/UIKitSPIForTesting.h
    M Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h
    M Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm
    M Tools/WebKitTestRunner/mac/UIScriptControllerMac.h
    M Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm

  Log Message:
  -----------
  Stop overriding `-[UITextInputPrivate supportsImagePaste]` on `WKContentView`
https://bugs.webkit.org/show_bug.cgi?id=265094
rdar://118430889

Reviewed by Tim Horton.

Stop implementing the SPI method `-supportsImagePaste`, which is used only to prevent UIKit from
bumping the `changeCount` from underneath us when showing the keyboard for a focused element by
short-circuiting the logic in `-[UIKeyboardImpl uncachedDelegateSupportsImagePaste]` (i.e. before
attempting to pin a 1x1 PNG image to the pasteboard, which is intended to check whether or not the
Emoji sticker section in the keyboard should be shown). If implemented on the responder, UIKit only
consults this SPI; since we currently make this return `YES` whenever the focused element is
"selectable" (i.e., contains editable/selectable text) and this delegate method is only consulted
when the keyboard is shown, this basically has the effect of always returning `YES` in the case of
WebKit.

To move off of this SPI, we can instead set a `UIPasteConfiguration` on the content view, which
achieves the same effect by allowing us to specify a list of uniform type identifiers that we can
support, for the purposes of paste handling. Note that the presence of a UTI in this list doesn't
necessarily mean that we'll unconditionally allow `@selector(paste:)` for that UTI, since UIKit
still consults our more granular logic in `-canPerformAction:withSender:` before showing any paste
UI. This only allows UIKit to short-circuit certain codepaths (such as the one above) when checking
whether or not to allow pastes, in the case where the paste configuration indicates that a type is
*not* supported. As such, it's safe to include more than we'd strictly allow in our
`UIPasteConfiguration`.

Test: fast/forms/ios/focusing-text-field-does-not-increase-change-count.html

* LayoutTests/fast/forms/ios/focusing-text-field-does-not-increase-change-count-expected.txt: Added.
* LayoutTests/fast/forms/ios/focusing-text-field-does-not-increase-change-count.html: Added.

Add a new layout test to exercise this change, by ensuring that the pasteboard's `changeCount` isn't
erroneously bumped when focusing any text field. This replaces the API test below, which is no
longer relevant since we no longer implement `-supportsImagePaste`.

* LayoutTests/resources/ui-helper.js:

Add a script controller hook to ask for the current pasteboard change count, and implement this hook
on all Cocoa platforms.

(window.UIHelper.async pasteboardChangeCount):
* Source/WTF/wtf/PlatformHave.h:

Add a compile-time flag to guard the availability of `UIPasteConfiguration`.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:

Refactor supported pasteboard types into a few helper functions, (some of) which are now used in
multiple places below.

(-[WKContentView setUpInteraction]):
(-[WKContentView cleanUpInteraction]):
(-[WKContentView supportedPasteboardTypesForCurrentSelection]):
(-[WKContentView canPerformActionForWebView:withSender:]):

Use the new helper functions above, and also refactor an existing "attachment element enabled" check
to consult `WebPreferences` instead of the `WKWebViewConfiguration` (the latter of which triggers an
unnecessary copy of the whole web view configuration object on the `WKWebView`).

(-[WKContentView _elementDidFocus:userIsInteracting:blurPreviousNode:activityStateChanges:userObject:]):
(-[WKContentView supportsImagePaste]): Deleted.

Remove this SPI method implementation.

* Tools/DumpRenderTree/ios/UIScriptControllerIOS.h:
* Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::pasteboardChangeCount const):
* Tools/DumpRenderTree/mac/UIScriptControllerMac.h:
* Tools/DumpRenderTree/mac/UIScriptControllerMac.mm:
(WTR::UIScriptControllerMac::pasteboardChangeCount const):
* Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
* Tools/TestRunnerShared/UIScriptContext/UIScriptController.h:
(WTR::UIScriptController::pasteboardChangeCount const):
* Tools/TestRunnerShared/spi/UIKitSPIForTesting.h:
* Tools/TestWebKitAPI/Tests/ios/KeyboardInputTestsIOS.mm:

Delete an existing API test, which has now been converted into a new layout test (see above).

* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.h:
* Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::UIScriptControllerIOS::pasteboardChangeCount const):
* Tools/WebKitTestRunner/mac/UIScriptControllerMac.h:
* Tools/WebKitTestRunner/mac/UIScriptControllerMac.mm:
(WTR::UIScriptControllerMac::pasteboardChangeCount const):

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




More information about the webkit-changes mailing list