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] Refactor some logic around tap gesture handling when VKCImageAnalysisInteraction is active #994

Merged
merged 0 commits into from May 25, 2022

Conversation

whsieh
Copy link
Member

@whsieh whsieh commented May 24, 2022

555e4e3

[iOS] Refactor some logic around tap gesture handling when VKCImageAnalysisInteraction is active
https://bugs.webkit.org/show_bug.cgi?id=240891
rdar://93808100

Reviewed by Aditya Keerthi.

Currently, when handling a single tap in WKContentView, we check whether or not the tap occurred
over the Live Text button in the `VKCImageAnalysisInteraction`; if so, we manually toggle Live Text
interaction highlight state. This special treatment exists (instead of simply relying on the
UIButton's tap gesture) because `WKContentView` already has its own synthetic click gesture which
conflicts with the UIButton's tap gesture; without this logic, taps on the analysis button would be
completely ignored.

While this works for the Live Text button, it doesn't work for other actionable buttons in the image
analysis interaction. To address this, we install a `UIButtonConfigurationUpdateHandler` on the
image analysis interaction just to collect the set of `UIButton`s that are owned by the interaction.
When tapping on the content view, if we hit one of these VisionKitCore-owned buttons, then invoke
the button action on its behalf.

* Source/WebKit/UIProcess/ios/WKContentViewInteraction.h:
* Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _singleTapIdentified:]):

Also, pull this VisionKit interception logic out into a new helper method below, named
`-_handleTapOverImageAnalysisInteractionButton:`. This returns whether or not the tap was handled by
VisionKit (in which case we avoid treating this as a synthetic click on the page).

(-[WKContentView _handleTapOverImageAnalysisInteractionButton:]):
(-[WKContentView installImageAnalysisInteraction:]):
(-[WKContentView uninstallImageAnalysisInteraction]):

Canonical link: https://commits.webkit.org/250968@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294815 268f45cc-cd09-0410-ab3c-d52691b4dbfc

@whsieh whsieh self-assigned this May 24, 2022
@whsieh whsieh added Platform Portability improvements and other general platform improvements not driven directly by site bugs. WebKit Nightly Build labels May 24, 2022
@whsieh whsieh added the merge-queue Applied to send a pull request to merge-queue label May 25, 2022
@whsieh
Copy link
Member Author

whsieh commented May 25, 2022

Thanks for the review!

@webkit-early-warning-system
Copy link
Collaborator

Committed r294815 (250968@main): https://commits.webkit.org/250968@main

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

@webkit-early-warning-system webkit-early-warning-system removed the merge-queue Applied to send a pull request to merge-queue label May 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
3 participants