Skip to content
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

[iOS 16] 'Insert text from camera' action should not appear in the edit menu when a range is selected #2708

Merged
merged 1 commit into from Jul 25, 2022

Conversation

whsieh
Copy link
Member

@whsieh whsieh commented Jul 25, 2022

c106e6e

[iOS 16] 'Insert text from camera' action should not appear in the edit menu when a range is selected
https://bugs.webkit.org/show_bug.cgi?id=243171

Reviewed by Devin Rousso.

This is another platform behavior (similar to the one fixed in `252764@main`) that broke due to the
new edit menu in iOS 16. The "Insert from camera" action (which shows up as a Live Text button in
the edit menu) was intended to only show up when the selection is collapsed and editable; however,
WebKit diverges from this platform behavior, since our logic for special-casing the edit menu is
based around checking whether the `sender` in `canPerformActionForWebView:withSender:` is a
`UIMenuController`, which is not the case when the iOS 16+ edit menu is enabled.

To fix this, check the newly introduced `_isPreparingEditMenu` flag instead. Changes tested by
augmenting an existing API test: `WebKit.CaptureTextFromCamera`

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView canPerformActionForWebView:withSender:]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:

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

@whsieh whsieh requested a review from cdumez as a code owner July 25, 2022 19:04
@whsieh whsieh self-assigned this Jul 25, 2022
@whsieh whsieh added Platform Portability improvements and other general platform improvements not driven directly by site bugs. WebKit Nightly Build labels Jul 25, 2022
@whsieh
Copy link
Member Author

whsieh commented Jul 25, 2022

Thanks for the review!

@whsieh whsieh added the merge-queue Applied to send a pull request to merge-queue label Jul 25, 2022
…it menu when a range is selected

https://bugs.webkit.org/show_bug.cgi?id=243171

Reviewed by Devin Rousso.

This is another platform behavior (similar to the one fixed in `252764@main`) that broke due to the
new edit menu in iOS 16. The "Insert from camera" action (which shows up as a Live Text button in
the edit menu) was intended to only show up when the selection is collapsed and editable; however,
WebKit diverges from this platform behavior, since our logic for special-casing the edit menu is
based around checking whether the `sender` in `canPerformActionForWebView:withSender:` is a
`UIMenuController`, which is not the case when the iOS 16+ edit menu is enabled.

To fix this, check the newly introduced `_isPreparingEditMenu` flag instead. Changes tested by
augmenting an existing API test: `WebKit.CaptureTextFromCamera`

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView canPerformActionForWebView:withSender:]):
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKContentViewEditingActions.mm:

Canonical link: https://commits.webkit.org/252805@main
@webkit-commit-queue
Copy link
Collaborator

Committed 252805@main (c106e6e): https://commits.webkit.org/252805@main

Reviewed commits have been landed. Closing PR #2708 and removing active labels.

@webkit-early-warning-system webkit-early-warning-system merged commit c106e6e into WebKit:main Jul 25, 2022
@webkit-commit-queue webkit-commit-queue removed the merge-queue Applied to send a pull request to merge-queue label Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Platform Portability improvements and other general platform improvements not driven directly by site bugs.
Projects
None yet
4 participants