Title: [285973] trunk/Source
Revision
285973
Author
wenson_hs...@apple.com
Date
2021-11-17 19:13:16 -0800 (Wed, 17 Nov 2021)

Log Message

[Live Text] Plumb an identifier string through `ChromeClient::requestTextRecognition()`
https://bugs.webkit.org/show_bug.cgi?id=233210

Reviewed by Dean Jackson.

Source/WebCore:

See WebKit/ChangeLog for more details.

* accessibility/AXImage.cpp:
(WebCore::AXImage::imageOverlayElements):
* page/ChromeClient.h:
(WebCore::ChromeClient::requestTextRecognition):
* page/ImageAnalysisQueue.cpp:
(WebCore::ImageAnalysisQueue::resumeProcessing):
* testing/Internals.cpp:
(WebCore::Internals::requestTextRecognition):

Source/WebCore/PAL:

Add another WebKitAdditions extension point.

* pal/spi/cocoa/VisionKitCoreSPI.h:

Source/WebKit:

Add an optional (i.e. null-by-default) identifier string to the `requestTextRecognition()` WebKit client hook,
and call into a new helper function in TextRecognitionUtilities.h, that's implemented in WebKitAdditions (with
an empty stub in open source code).

See corresponding radar for more information.

* Platform/cocoa/TextRecognitionUtilities.h:
* Platform/cocoa/TextRecognitionUtilities.mm:
(WebKit::requestImageAnalysisWithIdentifier):
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::requestTextRecognition):
* UIProcess/PageClient.h:
(WebKit::PageClient::requestTextRecognition):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::requestTextRecognition):
* UIProcess/WebPageProxy.h:
* UIProcess/WebPageProxy.messages.in:
* UIProcess/ios/PageClientImplIOS.h:
* UIProcess/ios/PageClientImplIOS.mm:
(WebKit::PageClientImpl::requestTextRecognition):
* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView requestTextRecognition:imageData:identifier:completionHandler:]):
(-[WKContentView requestTextRecognition:imageData:completionHandler:]): Deleted.
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::requestTextRecognition):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::requestTextRecognition):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::requestTextRecognition):
* WebProcess/WebPage/WebPage.h:
(WebKit::WebPage::requestTextRecognition):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (285972 => 285973)


--- trunk/Source/WebCore/ChangeLog	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebCore/ChangeLog	2021-11-18 03:13:16 UTC (rev 285973)
@@ -1,3 +1,21 @@
+2021-11-17  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [Live Text] Plumb an identifier string through `ChromeClient::requestTextRecognition()`
+        https://bugs.webkit.org/show_bug.cgi?id=233210
+
+        Reviewed by Dean Jackson.
+
+        See WebKit/ChangeLog for more details.
+
+        * accessibility/AXImage.cpp:
+        (WebCore::AXImage::imageOverlayElements):
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::requestTextRecognition):
+        * page/ImageAnalysisQueue.cpp:
+        (WebCore::ImageAnalysisQueue::resumeProcessing):
+        * testing/Internals.cpp:
+        (WebCore::Internals::requestTextRecognition):
+
 2021-11-17  Takashi Komori  <takashi.kom...@sony.com>
 
         [Curl] Remove unnecessary option setting

Modified: trunk/Source/WebCore/PAL/ChangeLog (285972 => 285973)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-11-18 03:13:16 UTC (rev 285973)
@@ -1,3 +1,14 @@
+2021-11-17  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [Live Text] Plumb an identifier string through `ChromeClient::requestTextRecognition()`
+        https://bugs.webkit.org/show_bug.cgi?id=233210
+
+        Reviewed by Dean Jackson.
+
+        Add another WebKitAdditions extension point.
+
+        * pal/spi/cocoa/VisionKitCoreSPI.h:
+
 2021-11-16  Devin Rousso  <drou...@apple.com>
 
         [Apple Pay] handle unknown setup features

Modified: trunk/Source/WebCore/PAL/pal/spi/cocoa/VisionKitCoreSPI.h (285972 => 285973)


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/VisionKitCoreSPI.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/VisionKitCoreSPI.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -146,4 +146,8 @@
 
 #endif
 
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/VisionKitCoreSPIAdditions.h>
+#endif
+
 #endif // HAVE(VK_IMAGE_ANALYSIS)

Modified: trunk/Source/WebCore/accessibility/AXImage.cpp (285972 => 285973)


--- trunk/Source/WebCore/accessibility/AXImage.cpp	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebCore/accessibility/AXImage.cpp	2021-11-18 03:13:16 UTC (rev 285973)
@@ -72,7 +72,7 @@
     if (!element)
         return std::nullopt;
 
-    page->chrome().client().requestTextRecognition(*element, [] (RefPtr<Element>&& imageOverlayHost) {
+    page->chrome().client().requestTextRecognition(*element, { }, [] (RefPtr<Element>&& imageOverlayHost) {
         if (!imageOverlayHost)
             return;
 

Modified: trunk/Source/WebCore/page/ChromeClient.h (285972 => 285973)


--- trunk/Source/WebCore/page/ChromeClient.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebCore/page/ChromeClient.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -585,7 +585,7 @@
 #endif
 
 #if ENABLE(IMAGE_ANALYSIS)
-    virtual void requestTextRecognition(Element&, CompletionHandler<void(RefPtr<Element>&&)>&& completion = { })
+    virtual void requestTextRecognition(Element&, const String& = { }, CompletionHandler<void(RefPtr<Element>&&)>&& completion = { })
     {
         if (completion)
             completion({ });

Modified: trunk/Source/WebCore/page/ImageAnalysisQueue.cpp (285972 => 285973)


--- trunk/Source/WebCore/page/ImageAnalysisQueue.cpp	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebCore/page/ImageAnalysisQueue.cpp	2021-11-18 03:13:16 UTC (rev 285973)
@@ -93,7 +93,7 @@
 
         m_pendingRequestCount++;
         m_page->resetTextRecognitionResult(*element);
-        m_page->chrome().client().requestTextRecognition(*element, [this, page = m_page] (auto&&) {
+        m_page->chrome().client().requestTextRecognition(*element, identifier, [this, page = m_page] (auto&&) {
             if (!page)
                 return;
 

Modified: trunk/Source/WebCore/testing/Internals.cpp (285972 => 285973)


--- trunk/Source/WebCore/testing/Internals.cpp	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebCore/testing/Internals.cpp	2021-11-18 03:13:16 UTC (rev 285973)
@@ -5791,7 +5791,7 @@
     }
 
 #if ENABLE(IMAGE_ANALYSIS)
-    page->chrome().client().requestTextRecognition(element, [callback = WTFMove(callback)] (auto&&) {
+    page->chrome().client().requestTextRecognition(element, { }, [callback = WTFMove(callback)] (auto&&) {
         if (callback)
             callback->handleEvent();
     });

Modified: trunk/Source/WebKit/ChangeLog (285972 => 285973)


--- trunk/Source/WebKit/ChangeLog	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/ChangeLog	2021-11-18 03:13:16 UTC (rev 285973)
@@ -1,3 +1,46 @@
+2021-11-17  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [Live Text] Plumb an identifier string through `ChromeClient::requestTextRecognition()`
+        https://bugs.webkit.org/show_bug.cgi?id=233210
+
+        Reviewed by Dean Jackson.
+
+        Add an optional (i.e. null-by-default) identifier string to the `requestTextRecognition()` WebKit client hook,
+        and call into a new helper function in TextRecognitionUtilities.h, that's implemented in WebKitAdditions (with
+        an empty stub in open source code).
+
+        See corresponding radar for more information.
+
+        * Platform/cocoa/TextRecognitionUtilities.h:
+        * Platform/cocoa/TextRecognitionUtilities.mm:
+        (WebKit::requestImageAnalysisWithIdentifier):
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::requestTextRecognition):
+        * UIProcess/PageClient.h:
+        (WebKit::PageClient::requestTextRecognition):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::requestTextRecognition):
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/WebPageProxy.messages.in:
+        * UIProcess/ios/PageClientImplIOS.h:
+        * UIProcess/ios/PageClientImplIOS.mm:
+        (WebKit::PageClientImpl::requestTextRecognition):
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView requestTextRecognition:imageData:identifier:completionHandler:]):
+        (-[WKContentView requestTextRecognition:imageData:completionHandler:]): Deleted.
+        * UIProcess/mac/PageClientImplMac.h:
+        * UIProcess/mac/PageClientImplMac.mm:
+        (WebKit::PageClientImpl::requestTextRecognition):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::requestTextRecognition):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::WebPage::requestTextRecognition):
+        * WebProcess/WebPage/WebPage.h:
+        (WebKit::WebPage::requestTextRecognition):
+
 2021-11-17  John Wilander  <wilan...@apple.com>
 
         PCM: Add capability for click destination to fire triggering event without cross-site requests to the click source

Modified: trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h (285972 => 285973)


--- trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -28,6 +28,7 @@
 #if ENABLE(IMAGE_ANALYSIS)
 
 #import <pal/spi/cocoa/VisionKitCoreSPI.h>
+#import <wtf/CompletionHandler.h>
 #import <wtf/RetainPtr.h>
 
 namespace WebCore {
@@ -43,6 +44,10 @@
 RetainPtr<VKImageAnalyzer> createImageAnalyzer();
 RetainPtr<VKImageAnalyzerRequest> createImageAnalyzerRequest(CGImageRef, VKAnalysisTypes);
 
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+void requestImageAnalysisWithIdentifier(VKImageAnalyzer *, const String& identifier, CGImageRef, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
+#endif
+
 }
 
 #endif // ENABLE(IMAGE_ANALYSIS)

Modified: trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm (285972 => 285973)


--- trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm	2021-11-18 03:13:16 UTC (rev 285973)
@@ -28,6 +28,7 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
 
+#import "Logging.h"
 #import <WebCore/TextRecognitionResult.h>
 #import <pal/cocoa/VisionKitCoreSoftLink.h>
 #import <pal/spi/cocoa/FeatureFlagsSPI.h>
@@ -138,6 +139,15 @@
     return true;
 }
 
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+
+void requestImageAnalysisWithIdentifier(VKImageAnalyzer *, const String&, CGImageRef, CompletionHandler<void(TextRecognitionResult&&)>&& completion)
+{
+    completion({ });
+}
+
+#endif // ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+
 #endif
 
 bool isLiveTextAvailableAndEnabled()

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -598,7 +598,7 @@
     bool shouldRequestCandidates() const;
 
 #if ENABLE(IMAGE_ANALYSIS)
-    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
+    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
     void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2021-11-18 03:13:16 UTC (rev 285973)
@@ -204,7 +204,7 @@
     return request;
 }
 
-void WebViewImpl::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion)
+void WebViewImpl::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(TextRecognitionResult&&)>&& completion)
 {
     if (!isLiveTextAvailableAndEnabled()) {
         completion({ });
@@ -218,6 +218,14 @@
     }
 
     auto cgImage = imageBitmap->makeCGImage();
+
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+    if (!identifier.isEmpty())
+        return requestImageAnalysisWithIdentifier(ensureImageAnalyzer(), identifier, cgImage.get(), WTFMove(completion));
+#else
+    UNUSED_PARAM(identifier);
+#endif
+
     auto request = createImageAnalyzerRequest(cgImage.get(), imageURL, [NSURL _web_URLWithWTFString:m_page->currentURL()], VKAnalysisTypeText);
     auto startTime = MonotonicTime::now();
     [ensureImageAnalyzer() processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion), startTime] (VKImageAnalysis *analysis, NSError *) mutable {

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -547,7 +547,7 @@
 #endif
 
 #if ENABLE(IMAGE_ANALYSIS)
-    virtual void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion) { completion({ }); }
+    virtual void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion) { completion({ }); }
     virtual void computeHasImageAnalysisResults(const URL&, ShareableBitmap&, ImageAnalysisType, CompletionHandler<void(bool)>&& completion) { completion(false); }
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-11-18 03:13:16 UTC (rev 285973)
@@ -8616,9 +8616,9 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
 
-void WebPageProxy::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completionHandler)
+void WebPageProxy::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(TextRecognitionResult&&)>&& completionHandler)
 {
-    pageClient().requestTextRecognition(imageURL, imageData, WTFMove(completionHandler));
+    pageClient().requestTextRecognition(imageURL, imageData, identifier, WTFMove(completionHandler));
 }
 
 void WebPageProxy::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -1698,7 +1698,7 @@
 #endif
 
 #if ENABLE(IMAGE_ANALYSIS)
-    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
+    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
     void updateWithTextRecognitionResult(WebCore::TextRecognitionResult&&, const WebCore::ElementContext&, const WebCore::FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&&);
     void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
     void startImageAnalysis(const String& identifier);

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in	2021-11-18 03:13:16 UTC (rev 285973)
@@ -216,7 +216,7 @@
     SetHasHadSelectionChangesFromUserInteraction(bool hasHadUserSelectionChanges)
 
 #if ENABLE(IMAGE_ANALYSIS)
-    RequestTextRecognition(URL imageURL, WebKit::ShareableBitmap::Handle imageData) -> (struct WebCore::TextRecognitionResult result) Async
+    RequestTextRecognition(URL imageURL, WebKit::ShareableBitmap::Handle imageData, String identifier) -> (struct WebCore::TextRecognitionResult result) Async
 #endif
 
 #if HAVE(TRANSLATION_UI_SERVICES) && ENABLE(CONTEXT_MENUS)

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -121,7 +121,7 @@
 #endif
 
 #if ENABLE(IMAGE_ANALYSIS)
-    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&) final;
+    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&) final;
 #endif
 
     RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;

Modified: trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/ios/PageClientImplIOS.mm	2021-11-18 03:13:16 UTC (rev 285973)
@@ -463,9 +463,9 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
 
-void PageClientImpl::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion)
+void PageClientImpl::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(TextRecognitionResult&&)>&& completion)
 {
-    [m_contentView requestTextRecognition:imageURL imageData:imageData completionHandler:WTFMove(completion)];
+    [m_contentView requestTextRecognition:imageURL imageData:imageData identifier:identifier completionHandler:WTFMove(completion)];
 }
 
 #endif // ENABLE(IMAGE_ANALYSIS)

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -758,7 +758,7 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
 - (void)_endImageAnalysisGestureDeferral:(WebKit::ShouldPreventGestures)shouldPreventGestures;
-- (void)requestTextRecognition:(NSURL *)imageURL imageData:(const WebKit::ShareableBitmap::Handle&)imageData completionHandler:(CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&)completion;
+- (void)requestTextRecognition:(NSURL *)imageURL imageData:(const WebKit::ShareableBitmap::Handle&)imageData identifier:(NSString *)identifier completionHandler:(CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&)completion;
 #endif
 
 @end

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-11-18 03:13:16 UTC (rev 285973)
@@ -10150,7 +10150,7 @@
     return NO;
 }
 
-- (void)requestTextRecognition:(NSURL *)imageURL imageData:(const WebKit::ShareableBitmap::Handle&)imageData completionHandler:(CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&)completion
+- (void)requestTextRecognition:(NSURL *)imageURL imageData:(const WebKit::ShareableBitmap::Handle&)imageData identifier:(NSString *)identifier completionHandler:(CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&)completion
 {
     auto imageBitmap = WebKit::ShareableBitmap::create(imageData);
     if (!imageBitmap) {
@@ -10164,8 +10164,15 @@
         return;
     }
 
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+    if (identifier.length)
+        return WebKit::requestImageAnalysisWithIdentifier(self.imageAnalyzer, identifier, cgImage.get(), WTFMove(completion));
+#else
+    UNUSED_PARAM(identifier);
+#endif
+
     auto request = [self createImageAnalyzerRequest:VKAnalysisTypeText image:cgImage.get()];
-    [[self imageAnalyzer] processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion)] (VKImageAnalysis *result, NSError *) mutable {
+    [self.imageAnalyzer processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion)] (VKImageAnalysis *result, NSError *) mutable {
         completion(WebKit::makeTextRecognitionResult(result));
     }).get()];
 }

Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -131,7 +131,7 @@
     void doneWithKeyEvent(const NativeWebKeyboardEvent&, bool wasEventHandled) override;
 
 #if ENABLE(IMAGE_ANALYSIS)
-    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&) override;
+    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&) override;
     void computeHasImageAnalysisResults(const URL&, ShareableBitmap&, ImageAnalysisType, CompletionHandler<void(bool)>&&) override;
 #endif
 

Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (285972 => 285973)


--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2021-11-18 03:13:16 UTC (rev 285973)
@@ -480,9 +480,9 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
 
-void PageClientImpl::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(TextRecognitionResult&&)>&& completion)
+void PageClientImpl::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(TextRecognitionResult&&)>&& completion)
 {
-    m_impl->requestTextRecognition(imageURL, imageData, WTFMove(completion));
+    m_impl->requestTextRecognition(imageURL, imageData, identifier, WTFMove(completion));
 }
 
 void PageClientImpl::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (285972 => 285973)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-11-18 03:13:16 UTC (rev 285973)
@@ -1492,9 +1492,9 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
 
-void WebChromeClient::requestTextRecognition(Element& element, CompletionHandler<void(RefPtr<Element>&&)>&& completion)
+void WebChromeClient::requestTextRecognition(Element& element, const String& identifier, CompletionHandler<void(RefPtr<Element>&&)>&& completion)
 {
-    m_page.requestTextRecognition(element, WTFMove(completion));
+    m_page.requestTextRecognition(element, identifier, WTFMove(completion));
 }
 
 #endif

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (285972 => 285973)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -431,7 +431,7 @@
 #endif
 
 #if ENABLE(IMAGE_ANALYSIS)
-    void requestTextRecognition(WebCore::Element&, CompletionHandler<void(RefPtr<WebCore::Element>&&)>&& = { }) final;
+    void requestTextRecognition(WebCore::Element&, const String& identifier = { }, CompletionHandler<void(RefPtr<WebCore::Element>&&)>&& = { }) final;
 #endif
 
     bool needsImageOverlayControllerForSelectionPainting() const final

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp (285972 => 285973)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp	2021-11-18 03:13:16 UTC (rev 285973)
@@ -7502,7 +7502,7 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
 
-void WebPage::requestTextRecognition(WebCore::Element& element, CompletionHandler<void(RefPtr<WebCore::Element>&&)>&& completion)
+void WebPage::requestTextRecognition(Element& element, const String& identifier, CompletionHandler<void(RefPtr<Element>&&)>&& completion)
 {
     if (!is<HTMLElement>(element)) {
         if (completion)
@@ -7561,7 +7561,7 @@
 
     auto cachedImage = renderImage.cachedImage();
     auto imageURL = cachedImage ? element.document().completeURL(cachedImage->url().string()) : URL { };
-    sendWithAsyncReply(Messages::WebPageProxy::RequestTextRecognition(WTFMove(imageURL), WTFMove(bitmapHandle)), [webPage = WeakPtr { *this }, weakElement = WeakPtr { element }] (auto&& result) {
+    sendWithAsyncReply(Messages::WebPageProxy::RequestTextRecognition(WTFMove(imageURL), WTFMove(bitmapHandle), identifier), [webPage = WeakPtr { *this }, weakElement = WeakPtr { element }] (auto&& result) {
         RefPtr protectedPage { webPage.get() };
         if (!protectedPage)
             return;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (285972 => 285973)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-11-18 03:05:08 UTC (rev 285972)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-11-18 03:13:16 UTC (rev 285973)
@@ -1430,7 +1430,7 @@
     void isPlayingMediaDidChange(WebCore::MediaProducerMediaStateFlags);
 
 #if ENABLE(IMAGE_ANALYSIS)
-    void requestTextRecognition(WebCore::Element&, CompletionHandler<void(RefPtr<WebCore::Element>&&)>&&);
+    void requestTextRecognition(WebCore::Element&, const String& identifier = { }, CompletionHandler<void(RefPtr<WebCore::Element>&&)>&& = { });
     void updateWithTextRecognitionResult(const WebCore::TextRecognitionResult&, const WebCore::ElementContext&, const WebCore::FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&&);
     void startImageAnalysis(const String& identifier);
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to