-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop overriding -[UITextInputPrivate supportsImagePaste]
on WKContentView
#20712
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EWS run on previous version of this PR (hash 6e75484) |
EWS run on current version of this PR (hash f0e6539) |
hortont424
approved these changes
Nov 19, 2023
Thanks for the review! |
aprotyas
approved these changes
Nov 19, 2023
β¦entView` 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
f0e6539
to
c152bf5
Compare
Committed 270947@main (c152bf5): https://commits.webkit.org/270947@main Reviewed commits have been landed. Closing PR #20712 and removing active labels. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
c152bf5
f0e6539