Title: [291022] trunk/Source/WebKit
Revision
291022
Author
[email protected]
Date
2022-03-08 17:17:14 -0800 (Tue, 08 Mar 2022)

Log Message

Rename TextRecognitionUtilities.* to ImageAnalysisUtilities.*
https://bugs.webkit.org/show_bug.cgi?id=237613
rdar://89982051

Reviewed by Tim Horton and Kate Cheney.

Rename TextRecognitionUtilities.h and TextRecognitionUtilities.mm to ImageAnalysisUtilities.h and
ImageAnalysisUtilities.mm, respectively. This is because this file now contains helper functions that are not
specific to just the text recognition aspect of visual intelligence features on Cocoa, but rather encompass a
variety of image analysis helpers.

* Platform/cocoa/ImageAnalysisUtilities.h: Renamed from Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h.
* Platform/cocoa/ImageAnalysisUtilities.mm: Renamed from Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm.
(WebKit::createImageAnalyzer):
(WebKit::createImageAnalyzerRequest):
(WebKit::floatQuad):
(WebKit::floatQuads):
(WebKit::makeTextRecognitionResult):
(WebKit::textRecognitionEnhancementsSystemFeatureEnabled):
(WebKit::imageAnalysisQueueSystemFeatureEnabled):
(WebKit::isImageAnalysisMarkupSystemFeatureEnabled):
(WebKit::isLiveTextAvailableAndEnabled):
* Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm:
* SourcesCocoa.txt:
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/ios/ProcessAssertionIOS.mm:
(-[WKRBSAssertionDelegate assertion:didInvalidateWithError:]):

Drive-by fix: additionally tweak a couple of release logging arguments that are currently in reverse order.

* UIProcess/ios/WKActionSheetAssistant.mm:
* UIProcess/ios/WKContentViewInteraction.mm:
* UIProcess/mac/WebContextMenuProxyMac.mm:
* UIProcess/mac/WebPageProxyMac.mm:
* WebKit.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (291021 => 291022)


--- trunk/Source/WebKit/ChangeLog	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/ChangeLog	2022-03-09 01:17:14 UTC (rev 291022)
@@ -1,3 +1,41 @@
+2022-03-08  Wenson Hsieh  <[email protected]>
+
+        Rename TextRecognitionUtilities.* to ImageAnalysisUtilities.*
+        https://bugs.webkit.org/show_bug.cgi?id=237613
+        rdar://89982051
+
+        Reviewed by Tim Horton and Kate Cheney.
+
+        Rename TextRecognitionUtilities.h and TextRecognitionUtilities.mm to ImageAnalysisUtilities.h and
+        ImageAnalysisUtilities.mm, respectively. This is because this file now contains helper functions that are not
+        specific to just the text recognition aspect of visual intelligence features on Cocoa, but rather encompass a
+        variety of image analysis helpers.
+
+        * Platform/cocoa/ImageAnalysisUtilities.h: Renamed from Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h.
+        * Platform/cocoa/ImageAnalysisUtilities.mm: Renamed from Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm.
+        (WebKit::createImageAnalyzer):
+        (WebKit::createImageAnalyzerRequest):
+        (WebKit::floatQuad):
+        (WebKit::floatQuads):
+        (WebKit::makeTextRecognitionResult):
+        (WebKit::textRecognitionEnhancementsSystemFeatureEnabled):
+        (WebKit::imageAnalysisQueueSystemFeatureEnabled):
+        (WebKit::isImageAnalysisMarkupSystemFeatureEnabled):
+        (WebKit::isLiveTextAvailableAndEnabled):
+        * Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm:
+        * SourcesCocoa.txt:
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/ios/ProcessAssertionIOS.mm:
+        (-[WKRBSAssertionDelegate assertion:didInvalidateWithError:]):
+
+        Drive-by fix: additionally tweak a couple of release logging arguments that are currently in reverse order.
+
+        * UIProcess/ios/WKActionSheetAssistant.mm:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        * UIProcess/mac/WebPageProxyMac.mm:
+        * WebKit.xcodeproj/project.pbxproj:
+
 2022-03-08  Alex Christensen  <[email protected]>
 
         Enable CFPrefs direct mode in adattributiond

Copied: trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.h (from rev 291021, trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h) (0 => 291022)


--- trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.h	                        (rev 0)
+++ trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.h	2022-03-09 01:17:14 UTC (rev 291022)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2021-2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if ENABLE(IMAGE_ANALYSIS)
+
+#import <pal/spi/cocoa/VisionKitCoreSPI.h>
+#import <wtf/CompletionHandler.h>
+#import <wtf/RetainPtr.h>
+
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+using CocoaImageAnalysis = VKCImageAnalysis;
+using CocoaImageAnalyzer = VKCImageAnalyzer;
+using CocoaImageAnalyzerRequest = VKCImageAnalyzerRequest;
+#else
+using CocoaImageAnalysis = VKImageAnalysis;
+using CocoaImageAnalyzer = VKImageAnalyzer;
+using CocoaImageAnalyzerRequest = VKImageAnalyzerRequest;
+#endif
+
+namespace WebCore {
+struct TextRecognitionResult;
+}
+
+namespace WebKit {
+
+bool isLiveTextAvailableAndEnabled();
+bool textRecognitionEnhancementsSystemFeatureEnabled();
+bool imageAnalysisQueueSystemFeatureEnabled();
+bool isImageAnalysisMarkupSystemFeatureEnabled();
+
+WebCore::TextRecognitionResult makeTextRecognitionResult(CocoaImageAnalysis *);
+
+RetainPtr<CocoaImageAnalyzer> createImageAnalyzer();
+RetainPtr<CocoaImageAnalyzerRequest> createImageAnalyzerRequest(CGImageRef, VKAnalysisTypes);
+
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+void requestImageAnalysisWithIdentifier(CocoaImageAnalyzer *, const String& identifier, CGImageRef, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
+void requestImageAnalysisMarkup(CGImageRef, CompletionHandler<void(CGImageRef, CGRect)>&&);
+#endif
+
+}
+
+#endif // ENABLE(IMAGE_ANALYSIS)

Copied: trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.mm (from rev 291021, trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm) (0 => 291022)


--- trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.mm	                        (rev 0)
+++ trunk/Source/WebKit/Platform/cocoa/ImageAnalysisUtilities.mm	2022-03-09 01:17:14 UTC (rev 291022)
@@ -0,0 +1,179 @@
+/*
+ * Copyright (C) 2021-2022 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+#import "ImageAnalysisUtilities.h"
+
+#if ENABLE(IMAGE_ANALYSIS)
+
+#import "CocoaImage.h"
+#import "Logging.h"
+#import "TransactionID.h"
+#import <WebCore/TextRecognitionResult.h>
+#import <pal/spi/cocoa/FeatureFlagsSPI.h>
+#import <wtf/WorkQueue.h>
+
+#import <pal/cocoa/VisionKitCoreSoftLink.h>
+
+namespace WebKit {
+using namespace WebCore;
+
+RetainPtr<CocoaImageAnalyzer> createImageAnalyzer()
+{
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+    return adoptNS([PAL::allocVKCImageAnalyzerInstance() init]);
+#else
+    return adoptNS([PAL::allocVKImageAnalyzerInstance() init]);
+#endif
+}
+
+RetainPtr<CocoaImageAnalyzerRequest> createImageAnalyzerRequest(CGImageRef image, VKAnalysisTypes types)
+{
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+    return adoptNS([(PAL::allocVKCImageAnalyzerRequestInstance()) initWithCGImage:image orientation:VKImageOrientationUp requestType:types]);
+#else
+    return adoptNS([PAL::allocVKImageAnalyzerRequestInstance() initWithCGImage:image orientation:VKImageOrientationUp requestType:types]);
+#endif
+}
+
+static FloatQuad floatQuad(VKQuad *quad)
+{
+    return { quad.topLeft, quad.topRight, quad.bottomRight, quad.bottomLeft };
+}
+
+static Vector<FloatQuad> floatQuads(NSArray<VKQuad *> *vkQuads)
+{
+    Vector<FloatQuad> quads;
+    quads.reserveInitialCapacity(vkQuads.count);
+    for (VKQuad *vkQuad in vkQuads)
+        quads.uncheckedAppend(floatQuad(vkQuad));
+    return quads;
+}
+
+TextRecognitionResult makeTextRecognitionResult(CocoaImageAnalysis *analysis)
+{
+    NSArray<VKWKLineInfo *> *allLines = analysis.allLines;
+    TextRecognitionResult result;
+    result.lines.reserveInitialCapacity(allLines.count);
+
+    bool isFirstLine = true;
+    size_t nextLineIndex = 1;
+    for (VKWKLineInfo *line in allLines) {
+        Vector<TextRecognitionWordData> children;
+        NSArray<VKWKTextInfo *> *vkChildren = line.children;
+        children.reserveInitialCapacity(vkChildren.count);
+
+        String lineText = line.string;
+        unsigned searchLocation = 0;
+        for (VKWKTextInfo *child in vkChildren) {
+            if (searchLocation >= lineText.length()) {
+                ASSERT_NOT_REACHED();
+                continue;
+            }
+
+            String childText = child.string;
+            auto matchLocation = lineText.find(childText, searchLocation);
+            if (matchLocation == notFound) {
+                ASSERT_NOT_REACHED();
+                continue;
+            }
+
+            bool hasLeadingWhitespace = ([&] {
+                if (matchLocation == searchLocation)
+                    return !isFirstLine && !searchLocation;
+
+                auto textBeforeMatch = lineText.substring(searchLocation, matchLocation - searchLocation);
+                return !textBeforeMatch.isEmpty() && isSpaceOrNewline(textBeforeMatch[0]);
+            })();
+
+            searchLocation = matchLocation + childText.length();
+            children.uncheckedAppend({ WTFMove(childText), floatQuad(child.quad), hasLeadingWhitespace });
+        }
+        VKWKLineInfo *nextLine = nextLineIndex < allLines.count ? allLines[nextLineIndex] : nil;
+        // The `shouldWrap` property indicates whether or not a line should wrap, relative to the previous line.
+        bool hasTrailingNewline = nextLine && (![nextLine respondsToSelector:@selector(shouldWrap)] || ![nextLine shouldWrap]);
+        result.lines.uncheckedAppend({ floatQuad(line.quad), WTFMove(children), hasTrailingNewline });
+        isFirstLine = false;
+        nextLineIndex++;
+    }
+
+#if ENABLE(DATA_DETECTION)
+    if ([analysis respondsToSelector:@selector(textDataDetectors)]) {
+        auto dataDetectors = RetainPtr { analysis.textDataDetectors };
+        result.dataDetectors.reserveInitialCapacity([dataDetectors count]);
+        for (VKWKDataDetectorInfo *info in dataDetectors.get())
+            result.dataDetectors.uncheckedAppend({ info.result, floatQuads(info.boundingQuads) });
+    }
+#endif // ENABLE(DATA_DETECTION)
+
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+    if ([analysis isKindOfClass:PAL::getVKCImageAnalysisClass()])
+        result.platformData = analysis;
+#endif
+
+    return result;
+}
+
+#if USE(APPLE_INTERNAL_SDK)
+#include <WebKitAdditions/ImageAnalysisUtilitiesAdditions.mm>
+#else
+
+bool textRecognitionEnhancementsSystemFeatureEnabled()
+{
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+    return true;
+#else
+    return false;
+#endif
+}
+
+bool imageAnalysisQueueSystemFeatureEnabled()
+{
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+    return true;
+#else
+    return false;
+#endif
+}
+
+bool isImageAnalysisMarkupSystemFeatureEnabled()
+{
+#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
+    return true;
+#else
+    return false;
+#endif
+}
+
+#endif
+
+bool isLiveTextAvailableAndEnabled()
+{
+    return PAL::isVisionKitCoreFrameworkAvailable();
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(IMAGE_ANALYSIS)

Deleted: trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h (291021 => 291022)


--- trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h	2022-03-09 01:17:14 UTC (rev 291022)
@@ -1,67 +0,0 @@
-/*
- * Copyright (C) 2021 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#pragma once
-
-#if ENABLE(IMAGE_ANALYSIS)
-
-#import <pal/spi/cocoa/VisionKitCoreSPI.h>
-#import <wtf/CompletionHandler.h>
-#import <wtf/RetainPtr.h>
-
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-using CocoaImageAnalysis = VKCImageAnalysis;
-using CocoaImageAnalyzer = VKCImageAnalyzer;
-using CocoaImageAnalyzerRequest = VKCImageAnalyzerRequest;
-#else
-using CocoaImageAnalysis = VKImageAnalysis;
-using CocoaImageAnalyzer = VKImageAnalyzer;
-using CocoaImageAnalyzerRequest = VKImageAnalyzerRequest;
-#endif
-
-namespace WebCore {
-struct TextRecognitionResult;
-}
-
-namespace WebKit {
-
-bool isLiveTextAvailableAndEnabled();
-bool textRecognitionEnhancementsSystemFeatureEnabled();
-bool imageAnalysisQueueSystemFeatureEnabled();
-bool isImageAnalysisMarkupSystemFeatureEnabled();
-
-WebCore::TextRecognitionResult makeTextRecognitionResult(CocoaImageAnalysis *);
-
-RetainPtr<CocoaImageAnalyzer> createImageAnalyzer();
-RetainPtr<CocoaImageAnalyzerRequest> createImageAnalyzerRequest(CGImageRef, VKAnalysisTypes);
-
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-void requestImageAnalysisWithIdentifier(CocoaImageAnalyzer *, const String& identifier, CGImageRef, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
-void requestImageAnalysisMarkup(CGImageRef, CompletionHandler<void(CGImageRef, CGRect)>&&);
-#endif
-
-}
-
-#endif // ENABLE(IMAGE_ANALYSIS)

Deleted: trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm (291021 => 291022)


--- trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm	2022-03-09 01:17:14 UTC (rev 291022)
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2021 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "config.h"
-#import "TextRecognitionUtilities.h"
-
-#if ENABLE(IMAGE_ANALYSIS)
-
-#import "CocoaImage.h"
-#import "Logging.h"
-#import <WebCore/TextRecognitionResult.h>
-#import <pal/spi/cocoa/FeatureFlagsSPI.h>
-#import <wtf/WorkQueue.h>
-
-#import <pal/cocoa/VisionKitCoreSoftLink.h>
-
-namespace WebKit {
-using namespace WebCore;
-
-RetainPtr<CocoaImageAnalyzer> createImageAnalyzer()
-{
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-    return adoptNS([PAL::allocVKCImageAnalyzerInstance() init]);
-#else
-    return adoptNS([PAL::allocVKImageAnalyzerInstance() init]);
-#endif
-}
-
-RetainPtr<CocoaImageAnalyzerRequest> createImageAnalyzerRequest(CGImageRef image, VKAnalysisTypes types)
-{
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-    return adoptNS([(PAL::allocVKCImageAnalyzerRequestInstance()) initWithCGImage:image orientation:VKImageOrientationUp requestType:types]);
-#else
-    return adoptNS([PAL::allocVKImageAnalyzerRequestInstance() initWithCGImage:image orientation:VKImageOrientationUp requestType:types]);
-#endif
-}
-
-static FloatQuad floatQuad(VKQuad *quad)
-{
-    return { quad.topLeft, quad.topRight, quad.bottomRight, quad.bottomLeft };
-}
-
-static Vector<FloatQuad> floatQuads(NSArray<VKQuad *> *vkQuads)
-{
-    Vector<FloatQuad> quads;
-    quads.reserveInitialCapacity(vkQuads.count);
-    for (VKQuad *vkQuad in vkQuads)
-        quads.uncheckedAppend(floatQuad(vkQuad));
-    return quads;
-}
-
-TextRecognitionResult makeTextRecognitionResult(CocoaImageAnalysis *analysis)
-{
-    NSArray<VKWKLineInfo *> *allLines = analysis.allLines;
-    TextRecognitionResult result;
-    result.lines.reserveInitialCapacity(allLines.count);
-
-    bool isFirstLine = true;
-    size_t nextLineIndex = 1;
-    for (VKWKLineInfo *line in allLines) {
-        Vector<TextRecognitionWordData> children;
-        NSArray<VKWKTextInfo *> *vkChildren = line.children;
-        children.reserveInitialCapacity(vkChildren.count);
-
-        String lineText = line.string;
-        unsigned searchLocation = 0;
-        for (VKWKTextInfo *child in vkChildren) {
-            if (searchLocation >= lineText.length()) {
-                ASSERT_NOT_REACHED();
-                continue;
-            }
-
-            String childText = child.string;
-            auto matchLocation = lineText.find(childText, searchLocation);
-            if (matchLocation == notFound) {
-                ASSERT_NOT_REACHED();
-                continue;
-            }
-
-            bool hasLeadingWhitespace = ([&] {
-                if (matchLocation == searchLocation)
-                    return !isFirstLine && !searchLocation;
-
-                auto textBeforeMatch = lineText.substring(searchLocation, matchLocation - searchLocation);
-                return !textBeforeMatch.isEmpty() && isSpaceOrNewline(textBeforeMatch[0]);
-            })();
-
-            searchLocation = matchLocation + childText.length();
-            children.uncheckedAppend({ WTFMove(childText), floatQuad(child.quad), hasLeadingWhitespace });
-        }
-        VKWKLineInfo *nextLine = nextLineIndex < allLines.count ? allLines[nextLineIndex] : nil;
-        // The `shouldWrap` property indicates whether or not a line should wrap, relative to the previous line.
-        bool hasTrailingNewline = nextLine && (![nextLine respondsToSelector:@selector(shouldWrap)] || ![nextLine shouldWrap]);
-        result.lines.uncheckedAppend({ floatQuad(line.quad), WTFMove(children), hasTrailingNewline });
-        isFirstLine = false;
-        nextLineIndex++;
-    }
-
-#if ENABLE(DATA_DETECTION)
-    if ([analysis respondsToSelector:@selector(textDataDetectors)]) {
-        auto dataDetectors = RetainPtr { analysis.textDataDetectors };
-        result.dataDetectors.reserveInitialCapacity([dataDetectors count]);
-        for (VKWKDataDetectorInfo *info in dataDetectors.get())
-            result.dataDetectors.uncheckedAppend({ info.result, floatQuads(info.boundingQuads) });
-    }
-#endif // ENABLE(DATA_DETECTION)
-
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-    if ([analysis isKindOfClass:PAL::getVKCImageAnalysisClass()])
-        result.platformData = analysis;
-#endif
-
-    return result;
-}
-
-#if USE(APPLE_INTERNAL_SDK)
-#include <WebKitAdditions/TextRecognitionUtilitiesAdditions.mm>
-#else
-
-bool textRecognitionEnhancementsSystemFeatureEnabled()
-{
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-    return true;
-#else
-    return false;
-#endif
-}
-
-bool imageAnalysisQueueSystemFeatureEnabled()
-{
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-    return true;
-#else
-    return false;
-#endif
-}
-
-bool isImageAnalysisMarkupSystemFeatureEnabled()
-{
-#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
-    return true;
-#else
-    return false;
-#endif
-}
-
-#endif
-
-bool isLiveTextAvailableAndEnabled()
-{
-    return PAL::isVisionKitCoreFrameworkAvailable();
-}
-
-} // namespace WebKit
-
-#endif // ENABLE(IMAGE_ANALYSIS)

Modified: trunk/Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm (291021 => 291022)


--- trunk/Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/Shared/Cocoa/WebPreferencesDefaultValuesCocoa.mm	2022-03-09 01:17:14 UTC (rev 291022)
@@ -28,7 +28,7 @@
 
 #if PLATFORM(COCOA)
 
-#import "TextRecognitionUtilities.h"
+#import "ImageAnalysisUtilities.h"
 #import <Foundation/NSBundle.h>
 #import <pal/spi/cocoa/FeatureFlagsSPI.h>
 #import <wtf/RetainPtr.h>

Modified: trunk/Source/WebKit/SourcesCocoa.txt (291021 => 291022)


--- trunk/Source/WebKit/SourcesCocoa.txt	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/SourcesCocoa.txt	2022-03-09 01:17:14 UTC (rev 291022)
@@ -84,11 +84,11 @@
 Platform/classifier/ResourceLoadStatisticsClassifier.cpp
 
 Platform/cocoa/CocoaImage.mm
+Platform/cocoa/ImageAnalysisUtilities.mm
 Platform/cocoa/LayerHostingContext.mm
 Platform/cocoa/PaymentAuthorizationPresenter.mm
 Platform/cocoa/PaymentAuthorizationViewController.mm
 Platform/cocoa/SharedMemoryCocoa.cpp
-Platform/cocoa/TextRecognitionUtilities.mm
 Platform/cocoa/WKCrashReporter.mm
 Platform/cocoa/WKPaymentAuthorizationDelegate.mm
 Platform/cocoa/WebKitAdditions.mm @no-unify

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (291021 => 291022)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2022-03-09 01:17:14 UTC (rev 291022)
@@ -27,9 +27,9 @@
 
 #if PLATFORM(MAC)
 
+#include "ImageAnalysisUtilities.h"
 #include "PDFPluginIdentifier.h"
 #include "ShareableBitmap.h"
-#include "TextRecognitionUtilities.h"
 #include "WKLayoutMode.h"
 #include <WebCore/DOMPasteAccess.h>
 #include <WebCore/FocusDirection.h>

Modified: trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm (291021 => 291022)


--- trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/UIProcess/ios/ProcessAssertionIOS.mm	2022-03-09 01:17:14 UTC (rev 291022)
@@ -280,7 +280,7 @@
 
 - (void)assertion:(RBSAssertion *)assertion didInvalidateWithError:(NSError *)error
 {
-    RELEASE_LOG(ProcessSuspension, "%p - WKRBSAssertionDelegate: assertion was invalidated, error: %{public}@", error, self);
+    RELEASE_LOG(ProcessSuspension, "%p - WKRBSAssertionDelegate: assertion was invalidated, error: %{public}@", self, error);
 
     RunLoop::main().dispatch([weakSelf = WeakObjCPtr<WKRBSAssertionDelegate>(self)] {
         auto strongSelf = weakSelf.get();

Modified: trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm (291021 => 291022)


--- trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/UIProcess/ios/WKActionSheetAssistant.mm	2022-03-09 01:17:14 UTC (rev 291022)
@@ -29,7 +29,7 @@
 #if PLATFORM(IOS_FAMILY)
 
 #import "APIUIClient.h"
-#import "TextRecognitionUtilities.h"
+#import "ImageAnalysisUtilities.h"
 #import "UIKitSPI.h"
 #import "WKActionSheet.h"
 #import "WKContentViewInteraction.h"

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (291021 => 291022)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2022-03-09 01:17:14 UTC (rev 291022)
@@ -32,6 +32,7 @@
 #import "CocoaImage.h"
 #import "CompletionHandlerCallChecker.h"
 #import "DocumentEditingContext.h"
+#import "ImageAnalysisUtilities.h"
 #import "InputViewUpdateDeferrer.h"
 #import "InsertTextOptions.h"
 #import "Logging.h"
@@ -45,7 +46,6 @@
 #import "TextChecker.h"
 #import "TextInputSPI.h"
 #import "TextRecognitionUpdateResult.h"
-#import "TextRecognitionUtilities.h"
 #import "UIKitSPI.h"
 #import "UserInterfaceIdiom.h"
 #import "WKActionSheetAssistant.h"

Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (291021 => 291022)


--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2022-03-09 01:17:14 UTC (rev 291022)
@@ -31,11 +31,11 @@
 #import "APIAttachment.h"
 #import "APIContextMenuClient.h"
 #import "CocoaImage.h"
+#import "ImageAnalysisUtilities.h"
 #import "MenuUtilities.h"
 #import "PageClientImplMac.h"
 #import "ServicesController.h"
 #import "ShareableBitmap.h"
-#import "TextRecognitionUtilities.h"
 #import "WKMenuItemIdentifiersPrivate.h"
 #import "WKSharingServicePickerDelegate.h"
 #import "WebContextMenuItem.h"

Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (291021 => 291022)


--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2022-03-09 01:17:14 UTC (rev 291022)
@@ -35,6 +35,7 @@
 #import "EditorState.h"
 #import "FontInfo.h"
 #import "FrameInfoData.h"
+#import "ImageAnalysisUtilities.h"
 #import "InsertTextOptions.h"
 #import "MenuUtilities.h"
 #import "NativeWebKeyboardEvent.h"
@@ -44,7 +45,6 @@
 #import "RemoteLayerTreeHost.h"
 #import "StringUtilities.h"
 #import "TextChecker.h"
-#import "TextRecognitionUtilities.h"
 #import "WKBrowsingContextControllerInternal.h"
 #import "WKQuickLookPreviewController.h"
 #import "WKSharingServicePickerDelegate.h"

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (291021 => 291022)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-03-09 00:52:43 UTC (rev 291021)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-03-09 01:17:14 UTC (rev 291022)
@@ -2044,7 +2044,7 @@
 		F42D634122A0EFDF00D2FB3A /* WebAutocorrectionData.h in Headers */ = {isa = PBXBuildFile; fileRef = F42D633F22A0EFD300D2FB3A /* WebAutocorrectionData.h */; };
 		F430E9422247335F005FE053 /* WebsiteMetaViewportPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */; };
 		F430E94422473DFF005FE053 /* WebContentMode.h in Headers */ = {isa = PBXBuildFile; fileRef = F430E94322473DB8005FE053 /* WebContentMode.h */; };
-		F4351B9E25EEC84C00D63892 /* TextRecognitionUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = F4351B9D25EEC84C00D63892 /* TextRecognitionUtilities.h */; };
+		F4351B9E25EEC84C00D63892 /* ImageAnalysisUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = F4351B9D25EEC84C00D63892 /* ImageAnalysisUtilities.h */; };
 		F438CD1C2241421400DE6DDA /* WKWebpagePreferences.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		F438CD1F22414D4000DE6DDA /* WKWebpagePreferencesInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */; };
 		F438CD212241F69500DE6DDA /* WKWebpagePreferencesPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = F438CD202241F69500DE6DDA /* WKWebpagePreferencesPrivate.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -6590,8 +6590,8 @@
 		F42D634022A0EFD300D2FB3A /* WebAutocorrectionData.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebAutocorrectionData.mm; path = ios/WebAutocorrectionData.mm; sourceTree = "<group>"; };
 		F430E941224732A9005FE053 /* WebsiteMetaViewportPolicy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebsiteMetaViewportPolicy.h; sourceTree = "<group>"; };
 		F430E94322473DB8005FE053 /* WebContentMode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebContentMode.h; sourceTree = "<group>"; };
-		F4351B9D25EEC84C00D63892 /* TextRecognitionUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = TextRecognitionUtilities.h; sourceTree = "<group>"; };
-		F4351B9F25EEC87800D63892 /* TextRecognitionUtilities.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = TextRecognitionUtilities.mm; sourceTree = "<group>"; };
+		F4351B9D25EEC84C00D63892 /* ImageAnalysisUtilities.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImageAnalysisUtilities.h; sourceTree = "<group>"; };
+		F4351B9F25EEC87800D63892 /* ImageAnalysisUtilities.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ImageAnalysisUtilities.mm; sourceTree = "<group>"; };
 		F438CD1B224140A600DE6DDA /* WKWebpagePreferences.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferences.h; sourceTree = "<group>"; };
 		F438CD1D22414AD600DE6DDA /* WKWebpagePreferences.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebpagePreferences.mm; sourceTree = "<group>"; };
 		F438CD1E22414D4000DE6DDA /* WKWebpagePreferencesInternal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WKWebpagePreferencesInternal.h; sourceTree = "<group>"; };
@@ -9438,6 +9438,8 @@
 			children = (
 				4482734624528F6000A95493 /* CocoaImage.h */,
 				F4E47BB527B5AE5B00813B38 /* CocoaImage.mm */,
+				F4351B9D25EEC84C00D63892 /* ImageAnalysisUtilities.h */,
+				F4351B9F25EEC87800D63892 /* ImageAnalysisUtilities.mm */,
 				BCE0937614FB128B001138D9 /* LayerHostingContext.h */,
 				BCE0937514FB128B001138D9 /* LayerHostingContext.mm */,
 				A1798B3D222D97A2000764BD /* PaymentAuthorizationPresenter.h */,
@@ -9445,8 +9447,6 @@
 				A1798B3F222D98B6000764BD /* PaymentAuthorizationViewController.h */,
 				A1798B40222D98B6000764BD /* PaymentAuthorizationViewController.mm */,
 				4450AEBF1DC3FAE5009943F2 /* SharedMemoryCocoa.cpp */,
-				F4351B9D25EEC84C00D63892 /* TextRecognitionUtilities.h */,
-				F4351B9F25EEC87800D63892 /* TextRecognitionUtilities.mm */,
 				A181A79721ACAC610059A316 /* WebKitAdditions.mm */,
 				A1FB68221F6E518200C43F9F /* WKCrashReporter.h */,
 				A1FB68231F6E518200C43F9F /* WKCrashReporter.mm */,
@@ -13255,6 +13255,7 @@
 				93B631E827ABA65D00443A44 /* IDBStorageManager.h in Headers */,
 				93B631ED27ABA6B400443A44 /* IDBStorageRegistry.h in Headers */,
 				51E351CB180F2CCC00E53BE9 /* IDBUtilities.h in Headers */,
+				F4351B9E25EEC84C00D63892 /* ImageAnalysisUtilities.h in Headers */,
 				BCCF6B2512C93E7A008F9C35 /* ImageOptions.h in Headers */,
 				1A1EC69E1872092100B951F0 /* ImportanceAssertion.h in Headers */,
 				BC204EE311C83E98008F3375 /* InjectedBundle.h in Headers */,
@@ -13621,7 +13622,6 @@
 				53CFBBC82224D1B500266546 /* TextCheckerCompletion.h in Headers */,
 				1A5E4DA412D3BD3D0099A2BB /* TextCheckerState.h in Headers */,
 				CE1A0BD71A48E6C60054EF74 /* TextInputSPI.h in Headers */,
-				F4351B9E25EEC84C00D63892 /* TextRecognitionUtilities.h in Headers */,
 				1AAF263914687C39004A1E8A /* TiledCoreAnimationDrawingArea.h in Headers */,
 				1AF05D8714688348008B1E81 /* TiledCoreAnimationDrawingAreaProxy.h in Headers */,
 				F48570A32644BEC500C05F71 /* Timeout.h in Headers */,
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to