Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 3330d607a01671f4588217c7fbd58fca43fdd98c
https://github.com/WebKit/WebKit/commit/3330d607a01671f4588217c7fbd58fca43fdd98c
Author: Richard Robinson <[email protected]>
Date: 2026-07-22 (Wed, 22 Jul 2026)
Changed paths:
M Source/WebKit/UIProcess/mac/WKAppKitGestureController.h
M Source/WebKit/UIProcess/mac/WKAppKitGestureController.mm
M Source/WebKit/UIProcess/mac/WKAppKitGestureController.swift
M Source/WebKit/UIProcess/mac/WebViewImpl.h
M Tools/TestWebKitAPI/Helpers/cocoa/ImageAnalysisTestingUtilities.swift
M Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKit Gesture
Tests/BasicAppKitGesturesTests.swift
Log Message:
-----------
[AppKit Gestures] Support Live Text interactions for images
https://bugs.webkit.org/show_bug.cgi?id=319700
rdar://182543552
Reviewed by Abrar Rahman Protyasha.
Clicking and dragging on an image should select the image's recognized text via
Live Text when it
contains any, and otherwise fall through to the existing drag / context-menu
behavior.
Implement this behavior using three new gesture recognizers:
1. A preflight NSPressGestureRecognizer (`_imageAnalysisGestureRecognizer`): a
short, stationary
long-press that, once it settles on an analyzable image, kicks off Vision image
analysis. It
recognizes simultaneously with everything, prevents nothing, and is always
allowed to begin.
2. `_imageAnalysisTextSelectionDeferringGestureRecognizer`: holds the
text-selection gestures over
an image until analysis resolves.
3. `_imageAnalysisDragAndContextMenuDeferringGestureRecognizer`: holds the
drag-press and
secondary-click (context menu) recognizers over an image until analysis
resolves.
Two deferrals are required because WKDeferringGestureRecognizer's
`endDeferralShouldPreventGestures`
applies a single boolean (recognized -> .ended / prevents, or failed -> allows)
to *every* gesture
it defers, whereas text selection and the drag / context-menu fallback must
resolve to opposite
outcomes: on "text found" we allow text selection and prevent the fallback
(Live Text wins), and
the reverse on "no text". iOS needs only one deferral because its drag /
context menu are UIKit
interactions gated by a ProceedWithTextSelectionInImage callback; macOS
drag-press and secondary-click
are independent NSGestureRecognizers on their own timers, so they must be
deferred to keep them
from firing before analysis resolves.
Test: Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKit Gesture
Tests/BasicAppKitGesturesTests.swift
* Source/WebKit/UIProcess/mac/WKAppKitGestureController.mm:
(isAnalyzableImageForLiveText):
(-[WKAppKitGestureController setUpGestureRecognizers]):
(-[WKAppKitGestureController setUpImageAnalysisGestureRecognizer]):
(-[WKAppKitGestureController
_makeImageAnalysisDeferringGestureRecognizerNamed:]):
(-[WKAppKitGestureController setUpImageAnalysisDeferringGestureRecognizer]):
(-[WKAppKitGestureController addGesturesToWebView]):
(-[WKAppKitGestureController enableGesturesIfNeeded]):
(-[WKAppKitGestureController ensureGesturesAreNotArchived]):
(-[WKAppKitGestureController enableImageAnalysisGestureIfNeeded]):
(-[WKAppKitGestureController imageAnalysisGestureRecognized:]):
(-[WKAppKitGestureController _resolveImageAnalysisDeferralsWithOutcome:]):
(-[WKAppKitGestureController
deferringGestureRecognizer:shouldDeferOtherGestureRecognizer:]):
(-[WKAppKitGestureController
deferringGestureRecognizer:shouldDeferGesturesForEventThatWillBeginAction:]):
(-[WKAppKitGestureController
gestureRecognizer:shouldRecognizeSimultaneouslyWithGestureRecognizer:]):
(-[WKAppKitGestureController gestureRecognizerShouldBegin:]):
(-[WKAppKitGestureController _gestureRecognizer:canPreventGestureRecognizer:]):
* Source/WebKit/UIProcess/mac/WebViewImpl.h:
* Tools/TestWebKitAPI/Helpers/cocoa/ImageAnalysisTestingUtilities.swift:
* Tools/TestWebKitAPI/Tests/WebKit/WebPage/AppKit Gesture
Tests/BasicAppKitGesturesTests.swift:
Canonical link: https://commits.webkit.org/317733@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications