Diff
Modified: trunk/Source/WebCore/PAL/ChangeLog (278803 => 278804)
--- trunk/Source/WebCore/PAL/ChangeLog 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebCore/PAL/ChangeLog 2021-06-12 01:42:32 UTC (rev 278804)
@@ -1,3 +1,19 @@
+2021-06-11 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [Cocoa] Clean up some VisionKitCore soft linking code in WebKit
+ https://bugs.webkit.org/show_bug.cgi?id=226941
+
+ Reviewed by Tim Horton.
+
+ Move softlinking code out of implementation files in WebKit (see WebKit/ChangeLog for details), and into
+ dedicated VisionKitCore SPI and soft-linking headers in PAL.
+
+ * PAL.xcodeproj/project.pbxproj:
+ * pal/PlatformMac.cmake:
+ * pal/cocoa/VisionKitCoreSoftLink.h: Copied from Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h.
+ * pal/cocoa/VisionKitCoreSoftLink.mm: Copied from Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h.
+ * pal/spi/cocoa/VisionKitCoreSPI.h: Renamed from Source/WebKit/Platform/spi/Cocoa/VisionKitSPI.h.
+
2021-06-11 Jonathan Bedard <jbed...@apple.com>
[Monterey] Support building WebKit (Follow-up fix)
Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (278803 => 278804)
--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj 2021-06-12 01:42:32 UTC (rev 278804)
@@ -207,6 +207,8 @@
F44291601FA5261E002CC93E /* FileSizeFormatter.h in Headers */ = {isa = PBXBuildFile; fileRef = F442915F1FA5261E002CC93E /* FileSizeFormatter.h */; };
F44291641FA52670002CC93E /* FileSizeFormatter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F44291621FA52670002CC93E /* FileSizeFormatter.cpp */; };
F44291681FA52705002CC93E /* FileSizeFormatterCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44291661FA52705002CC93E /* FileSizeFormatterCocoa.mm */; };
+ F46B8C4D26740918007A6554 /* VisionKitCoreSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = F46B8C4C26740918007A6554 /* VisionKitCoreSoftLink.mm */; };
+ F46B8C4F26740AD8007A6554 /* VisionKitCoreSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = F46B8C4E26740AD8007A6554 /* VisionKitCoreSPI.h */; };
F4974EA3265EEA2200B49B8C /* RevealSoftLink.h in Headers */ = {isa = PBXBuildFile; fileRef = F4974EA1265EEA2200B49B8C /* RevealSoftLink.h */; };
F4974EA4265EEA2200B49B8C /* RevealSoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4974EA2265EEA2200B49B8C /* RevealSoftLink.mm */; };
F4C85A4E2658551A005B89CC /* QuickLookUISoftLink.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4C85A4C26585519005B89CC /* QuickLookUISoftLink.mm */; };
@@ -428,6 +430,9 @@
F442915F1FA5261E002CC93E /* FileSizeFormatter.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FileSizeFormatter.h; sourceTree = "<group>"; };
F44291621FA52670002CC93E /* FileSizeFormatter.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FileSizeFormatter.cpp; sourceTree = "<group>"; };
F44291661FA52705002CC93E /* FileSizeFormatterCocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FileSizeFormatterCocoa.mm; sourceTree = "<group>"; };
+ F46B8C4B267408FA007A6554 /* VisionKitCoreSoftLink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VisionKitCoreSoftLink.h; sourceTree = "<group>"; };
+ F46B8C4C26740918007A6554 /* VisionKitCoreSoftLink.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VisionKitCoreSoftLink.mm; sourceTree = "<group>"; };
+ F46B8C4E26740AD8007A6554 /* VisionKitCoreSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VisionKitCoreSPI.h; sourceTree = "<group>"; };
F4974EA1265EEA2200B49B8C /* RevealSoftLink.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RevealSoftLink.h; sourceTree = "<group>"; };
F4974EA2265EEA2200B49B8C /* RevealSoftLink.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = RevealSoftLink.mm; sourceTree = "<group>"; };
F4C85A4C26585519005B89CC /* QuickLookUISoftLink.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = QuickLookUISoftLink.mm; sourceTree = "<group>"; };
@@ -556,6 +561,7 @@
0C2DA13C1F3BEB4900DBC317 /* ServersSPI.h */,
93B38EC125821D2200198E63 /* SpeechSPI.h */,
0C2DA12B1F3BEB4900DBC317 /* URLFormattingSPI.h */,
+ F46B8C4E26740AD8007A6554 /* VisionKitCoreSPI.h */,
0C2DA13D1F3BEB4900DBC317 /* WebFilterEvaluatorSPI.h */,
);
path = cocoa;
@@ -739,6 +745,8 @@
93B38EBF25821CD700198E63 /* SpeechSoftLink.mm */,
07611DB4243FA5BE00D80704 /* UsageTrackingSoftLink.h */,
07611DB5243FA5BF00D80704 /* UsageTrackingSoftLink.mm */,
+ F46B8C4B267408FA007A6554 /* VisionKitCoreSoftLink.h */,
+ F46B8C4C26740918007A6554 /* VisionKitCoreSoftLink.mm */,
);
path = cocoa;
sourceTree = "<group>";
@@ -987,6 +995,7 @@
0C5AF9221F43A4C7002EAC02 /* UIKitSPI.h in Headers */,
0C2DA1471F3BEB4900DBC317 /* URLFormattingSPI.h in Headers */,
07611DB6243FA5BF00D80704 /* UsageTrackingSoftLink.h in Headers */,
+ F46B8C4F26740AD8007A6554 /* VisionKitCoreSPI.h in Headers */,
0C2DA1591F3BEB4900DBC317 /* WebFilterEvaluatorSPI.h in Headers */,
A10826F91F576292004772AC /* WebPanel.h in Headers */,
);
@@ -1120,6 +1129,7 @@
2E1342CD215AA10A007199D2 /* UIKitSoftLink.mm in Sources */,
07611DB7243FA5BF00D80704 /* UsageTrackingSoftLink.mm in Sources */,
41E1F344248A6A000022D5DE /* VideoToolboxSoftLink.cpp in Sources */,
+ F46B8C4D26740918007A6554 /* VisionKitCoreSoftLink.mm in Sources */,
A10826FA1F576292004772AC /* WebPanel.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Modified: trunk/Source/WebCore/PAL/pal/PlatformMac.cmake (278803 => 278804)
--- trunk/Source/WebCore/PAL/pal/PlatformMac.cmake 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebCore/PAL/pal/PlatformMac.cmake 2021-06-12 01:42:32 UTC (rev 278804)
@@ -19,6 +19,7 @@
cocoa/RevealSoftLink.h
cocoa/SpeechSoftLink.h
cocoa/UsageTrackingSoftLink.h
+ cocoa/VisionKitCoreSoftLink.h
mac/DataDetectorsSoftLink.h
mac/LookupSoftLink.h
@@ -86,6 +87,7 @@
spi/cocoa/ServersSPI.h
spi/cocoa/SpeechSPI.h
spi/cocoa/URLFormattingSPI.h
+ spi/cocoa/VisionKitCoreSPI.h
spi/cocoa/WebFilterEvaluatorSPI.h
spi/cocoa/pthreadSPI.h
@@ -161,6 +163,7 @@
cocoa/RevealSoftLink.mm
cocoa/SpeechSoftLink.mm
cocoa/UsageTrackingSoftLink.mm
+ cocoa/VisionKitCoreSoftLink.mm
crypto/commoncrypto/CryptoDigestCommonCrypto.cpp
Copied: trunk/Source/WebCore/PAL/pal/cocoa/VisionKitCoreSoftLink.h (from rev 278803, trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h) (0 => 278804)
--- trunk/Source/WebCore/PAL/pal/cocoa/VisionKitCoreSoftLink.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/cocoa/VisionKitCoreSoftLink.h 2021-06-12 01:42:32 UTC (rev 278804)
@@ -0,0 +1,37 @@
+/*
+ * 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 HAVE(VK_IMAGE_ANALYSIS)
+
+#import <pal/spi/cocoa/VisionKitCoreSPI.h>
+#import <wtf/SoftLinking.h>
+
+SOFT_LINK_FRAMEWORK_FOR_HEADER(PAL, VisionKitCore)
+SOFT_LINK_CLASS_FOR_HEADER(PAL, VKImageAnalyzer)
+SOFT_LINK_CLASS_FOR_HEADER(PAL, VKImageAnalyzerRequest)
+
+#endif // HAVE(VK_IMAGE_ANALYSIS)
Copied: trunk/Source/WebCore/PAL/pal/cocoa/VisionKitCoreSoftLink.mm (from rev 278803, trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h) (0 => 278804)
--- trunk/Source/WebCore/PAL/pal/cocoa/VisionKitCoreSoftLink.mm (rev 0)
+++ trunk/Source/WebCore/PAL/pal/cocoa/VisionKitCoreSoftLink.mm 2021-06-12 01:42:32 UTC (rev 278804)
@@ -0,0 +1,37 @@
+/*
+ * 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"
+
+#if HAVE(VK_IMAGE_ANALYSIS)
+
+#import <pal/spi/cocoa/VisionKitCoreSPI.h>
+#import <wtf/SoftLinking.h>
+
+SOFT_LINK_PRIVATE_FRAMEWORK_FOR_SOURCE_WITH_EXPORT(PAL, VisionKitCore, PAL_EXPORT)
+SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, VisionKitCore, VKImageAnalyzer, PAL_EXPORT)
+SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, VisionKitCore, VKImageAnalyzerRequest, PAL_EXPORT)
+
+#endif // HAVE(VK_IMAGE_ANALYSIS)
Copied: trunk/Source/WebCore/PAL/pal/spi/cocoa/VisionKitCoreSPI.h (from rev 278803, trunk/Source/WebKit/Platform/spi/Cocoa/VisionKitSPI.h) (0 => 278804)
--- trunk/Source/WebCore/PAL/pal/spi/cocoa/VisionKitCoreSPI.h (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/VisionKitCoreSPI.h 2021-06-12 01:42:32 UTC (rev 278804)
@@ -0,0 +1,140 @@
+/*
+ * 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.
+ */
+
+#if HAVE(VK_IMAGE_ANALYSIS)
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#import <VisionKitCore/VKImageAnalysis_WebKit.h>
+#import <VisionKitCore/VisionKitCore.h>
+
+#else
+
+#import <CoreGraphics/CoreGraphics.h>
+#import <Foundation/Foundation.h>
+
+#if PLATFORM(IOS_FAMILY)
+#import <UIKit/UIKit.h>
+#endif
+
+NS_ASSUME_NONNULL_BEGIN
+
+typedef int32_t VKImageAnalysisRequestID;
+
+typedef NS_OPTIONS(NSUInteger, VKAnalysisTypes) {
+ VKAnalysisTypeText = 1 << 0,
+ VKAnalysisTypeTextDataDetector = 1 << 1,
+ VKAnalysisTypeMachineReadableCode = 1 << 2,
+ VKAnalysisTypeAppClip = 1 << 3,
+ VKAnalysisTypeVisualSearch = 1 << 4,
+ VKAnalysisTypeNone = 0,
+ VKAnalysisTypeAll = NSUIntegerMax,
+};
+
+#if PLATFORM(IOS_FAMILY)
+
+typedef UIImage VKImageClass;
+typedef UIImageOrientation VKImageOrientation;
+
+#define VKImageOrientationUp UIImageOrientationUp
+#define VKImageOrientationDown UIImageOrientationDown
+#define VKImageOrientationLeft UIImageOrientationLeft
+#define VKImageOrientationRight UIImageOrientationRight
+#define VKImageOrientationUpMirrored UIImageOrientationUpMirrored
+#define VKImageOrientationDownMirrored UIImageOrientationDownMirrored
+#define VKImageOrientationLeftMirrored UIImageOrientationLeftMirrored
+#define VKImageOrientationRightMirrored UIImageOrientationRightMirrored
+
+#else
+
+typedef NSImage VKImageClass;
+
+typedef NS_ENUM(NSInteger, VKImageOrientation) {
+ VKImageOrientationUp,
+ VKImageOrientationDown,
+ VKImageOrientationLeft,
+ VKImageOrientationRight,
+ VKImageOrientationUpMirrored,
+ VKImageOrientationDownMirrored,
+ VKImageOrientationLeftMirrored,
+ VKImageOrientationRightMirrored,
+};
+
+#endif
+
+@interface VKImageAnalysis : NSObject <NSSecureCoding>
+- (BOOL)hasResultsForAnalysisTypes:(VKAnalysisTypes)analysisTypes;
+@end
+
+@protocol VKFeedbackAssetsProvider <NSObject>
+- (BOOL)saveAssetsToFeedbackAttachmentsFolder:(NSURL *)attachmentsFolderURL error:(NSError *)error;
+@end
+
+@interface VKImageAnalyzerRequest : NSObject <NSCopying, VKFeedbackAssetsProvider>
+- (instancetype)init NS_UNAVAILABLE;
+- (instancetype)initWithImage:(VKImageClass *)image orientation:(VKImageOrientation)orientation requestType:(VKAnalysisTypes)analysisType;
+- (instancetype)initWithCGImage:(CGImageRef)image orientation:(VKImageOrientation)orientation requestType:(VKAnalysisTypes)analysisType;
+@end
+
+@interface VKImageAnalyzerRequest (VI)
+@property (nonatomic) NSURL *imageURL;
+@property (nonatomic) NSURL *pageURL;
+@end
+
+@interface VKImageAnalyzer : NSObject
+@property (nonatomic, strong, nullable) dispatch_queue_t callbackQueue;
+- (VKImageAnalysisRequestID)processRequest:(VKImageAnalyzerRequest *)request progressHandler:(void (^_Nullable)(double progress))progressHandler completionHandler:(void (^)(VKImageAnalysis *_Nullable analysis, NSError *_Nullable error))completionHandler;
+- (void)cancelAllRequests;
+@end
+
+@interface VKQuad : NSObject <NSCopying, NSSecureCoding>
+@property (nonatomic, readonly) CGPoint topLeft;
+@property (nonatomic, readonly) CGPoint topRight;
+@property (nonatomic, readonly) CGPoint bottomLeft;
+@property (nonatomic, readonly) CGPoint bottomRight;
+@property (nonatomic, readonly) CGRect boundingBox;
+@end
+
+@interface VKWKTextInfo : NSObject
+@property (nonatomic, readonly) NSString *string;
+@property (nonatomic, readonly) VKQuad *quad;
+@end
+
+@interface VKWKLineInfo : VKWKTextInfo
+@property (nonatomic, readonly) NSArray<VKWKTextInfo *> *children;
+@end
+
+@interface VKImageAnalysis (WebKitSPI)
+@property (nonatomic, readonly) NSArray<VKWKLineInfo *> *allLines;
+#if PLATFORM(IOS)
+@property (nonatomic) UIMenu *mrcMenu;
+#endif
+@end
+
+NS_ASSUME_NONNULL_END
+
+#endif
+
+#endif // HAVE(VK_IMAGE_ANALYSIS)
Modified: trunk/Source/WebKit/ChangeLog (278803 => 278804)
--- trunk/Source/WebKit/ChangeLog 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebKit/ChangeLog 2021-06-12 01:42:32 UTC (rev 278804)
@@ -1,3 +1,38 @@
+2021-06-11 Wenson Hsieh <wenson_hs...@apple.com>
+
+ [Cocoa] Clean up some VisionKitCore soft linking code in WebKit
+ https://bugs.webkit.org/show_bug.cgi?id=226941
+
+ Reviewed by Tim Horton.
+
+ Remove softlinking macros from several files in WebKit; instead, import and use the new PAL soft-linking helper
+ functions. Additionally, move a couple of staging forward declarations into the non-internal SDK section of the
+ VisionKitCore SPI header.
+
+ * Platform/cocoa/TextRecognitionUtilities.h:
+ * Platform/cocoa/TextRecognitionUtilities.mm:
+ (WebKit::isLiveTextEnabled):
+ (WebKit::isLiveTextAvailableAndEnabled):
+
+ Additionally replace `isLiveTextEnabled` with `isLiveTextAvailableAndEnabled`, and have it check for the
+ presence of the VisionKitCore framework in addition to whether the system feature flag is enabled (at least,
+ when building with the internal SDK).
+
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::ensureImageAnalyzer):
+ (WebKit::createImageAnalysisRequest):
+ (WebKit::WebViewImpl::requestTextRecognition):
+ (WebKit::WebViewImpl::computeHasVisualSearchResults):
+ * UIProcess/ios/WKContentViewInteraction.mm:
+ (-[WKContentView setUpInteraction]):
+ (-[WKContentView actionSheetAssistant:shouldIncludeShowTextActionForElement:]):
+ (-[WKContentView actionSheetAssistant:shouldIncludeLookUpImageActionForElement:]):
+ (-[WKContentView imageAnalyzer]):
+ (-[WKContentView _setUpImageAnalysis]):
+ (-[WKContentView _tearDownImageAnalysis]):
+ (-[WKContentView createImageAnalysisRequest:image:imageURL:]):
+ (-[WKContentView imageAnalysisGestureDidBegin:]):
+
2021-06-11 Alex Christensen <achristen...@webkit.org>
Partition CrossOriginPreflightResultCache by SessionID
Modified: trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h (278803 => 278804)
--- trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.h 2021-06-12 01:42:32 UTC (rev 278804)
@@ -35,7 +35,7 @@
namespace WebKit {
-bool isLiveTextEnabled();
+bool isLiveTextAvailableAndEnabled();
WebCore::TextRecognitionResult makeTextRecognitionResult(VKImageAnalysis *);
}
Modified: trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm (278803 => 278804)
--- trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebKit/Platform/cocoa/TextRecognitionUtilities.mm 2021-06-12 01:42:32 UTC (rev 278804)
@@ -28,8 +28,8 @@
#if ENABLE(IMAGE_ANALYSIS)
-#import "VisionKitSPI.h"
#import <WebCore/TextRecognitionResult.h>
+#import <pal/cocoa/VisionKitCoreSoftLink.h>
#import <pal/spi/cocoa/FeatureFlagsSPI.h>
// Note that this is actually declared as an Objective-C class in VisionKit headers.
@@ -101,7 +101,7 @@
#include <WebKitAdditions/TextRecognitionUtilitiesAdditions.mm>
#else
-bool isLiveTextEnabled()
+static bool isLiveTextEnabled()
{
return true;
}
@@ -108,6 +108,11 @@
#endif
+bool isLiveTextAvailableAndEnabled()
+{
+ return PAL::isVisionKitCoreFrameworkAvailable() && isLiveTextEnabled();
+}
+
} // namespace WebKit
#endif // ENABLE(IMAGE_ANALYSIS)
Deleted: trunk/Source/WebKit/Platform/spi/Cocoa/VisionKitSPI.h (278803 => 278804)
--- trunk/Source/WebKit/Platform/spi/Cocoa/VisionKitSPI.h 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebKit/Platform/spi/Cocoa/VisionKitSPI.h 2021-06-12 01:42:32 UTC (rev 278804)
@@ -1,131 +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.
- */
-
-#if HAVE(VK_IMAGE_ANALYSIS)
-
-#if USE(APPLE_INTERNAL_SDK)
-
-#import <VisionKitCore/VKImageAnalysis_WebKit.h>
-#import <VisionKitCore/VKImageAnalyzer.h>
-#import <VisionKitCore/VKQuad.h>
-
-#else
-
-NS_ASSUME_NONNULL_BEGIN
-
-typedef int32_t VKImageAnalysisRequestID;
-
-typedef NS_OPTIONS(NSUInteger, VKAnalysisTypes) {
- VKAnalysisTypeText = 1 << 0,
- VKAnalysisTypeTextDataDetector = 1 << 1,
- VKAnalysisTypeMachineReadableCode = 1 << 2,
- VKAnalysisTypeAppClip = 1 << 3,
- VKAnalysisTypeVisualSearch = 1 << 4,
- VKAnalysisTypeNone = 0,
- VKAnalysisTypeAll = NSUIntegerMax,
-};
-
-#if PLATFORM(IOS)
-
-typedef UIImage VKImageClass;
-
-typedef UIImageOrientation VKImageOrientation;
-
-#define VKImageOrientationUp UIImageOrientationUp
-#define VKImageOrientationDown UIImageOrientationDown
-#define VKImageOrientationLeft UIImageOrientationLeft
-#define VKImageOrientationRight UIImageOrientationRight
-#define VKImageOrientationUpMirrored UIImageOrientationUpMirrored
-#define VKImageOrientationDownMirrored UIImageOrientationDownMirrored
-#define VKImageOrientationLeftMirrored UIImageOrientationLeftMirrored
-#define VKImageOrientationRightMirrored UIImageOrientationRightMirrored
-
-#else
-
-typedef NSImage VKImageClass;
-
-typedef NS_ENUM(NSInteger, VKImageOrientation) {
- VKImageOrientationUp,
- VKImageOrientationDown,
- VKImageOrientationLeft,
- VKImageOrientationRight,
- VKImageOrientationUpMirrored,
- VKImageOrientationDownMirrored,
- VKImageOrientationLeftMirrored,
- VKImageOrientationRightMirrored,
-};
-
-#endif
-
-@interface VKImageAnalysis : NSObject <NSSecureCoding>
-- (BOOL)hasResultsForAnalysisTypes:(VKAnalysisTypes)analysisTypes;
-@end
-
-@protocol VKFeedbackAssetsProvider <NSObject>
-- (BOOL)saveAssetsToFeedbackAttachmentsFolder:(NSURL *)attachmentsFolderURL error:(NSError *)error;
-@end
-
-@interface VKImageAnalyzerRequest : NSObject <NSCopying, VKFeedbackAssetsProvider>
-- (instancetype)init NS_UNAVAILABLE;
-- (instancetype)initWithImage:(VKImageClass *)image requestType:(VKAnalysisTypes)analysisType;
-- (instancetype)initWithCGImage:(CGImageRef)image orientation:(VKImageOrientation)orientation requestType:(VKAnalysisTypes)analysisType;
-@end
-
-@interface VKImageAnalyzer : NSObject
-@property (nonatomic, strong, nullable) dispatch_queue_t callbackQueue;
-- (VKImageAnalysisRequestID)processRequest:(VKImageAnalyzerRequest *)request
- progressHandler:(void (^_Nullable)(double progress))progressHandler
- completionHandler:(void (^)(VKImageAnalysis* _Nullable analysis, NSError * _Nullable error))completionHandler;
-@end
-
-@interface VKQuad : NSObject <NSCopying, NSSecureCoding>
-@property (nonatomic, readonly) CGPoint topLeft;
-@property (nonatomic, readonly) CGPoint topRight;
-@property (nonatomic, readonly) CGPoint bottomLeft;
-@property (nonatomic, readonly) CGPoint bottomRight;
-@property (nonatomic, readonly) CGRect boundingBox;
-@end
-
-@interface VKWKTextInfo : NSObject
-@property (nonatomic, readonly) NSString *string;
-@property (nonatomic, readonly) VKQuad *quad;
-@end
-
-@interface VKWKLineInfo : VKWKTextInfo
-@property (nonatomic, readonly) NSArray<VKWKTextInfo *> *children;
-@end
-
-@interface VKImageAnalysis (WebKitSPI)
-@property (nonatomic, readonly) NSArray <VKWKLineInfo *> *allLines;
-#if PLATFORM(IOS)
-@property (nonatomic) UIMenu * mrcMenu;
-#endif
-@end
-
-NS_ASSUME_NONNULL_END
-
-#endif
-
-#endif
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (278803 => 278804)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-06-12 01:42:32 UTC (rev 278804)
@@ -146,8 +146,6 @@
#include "MediaSessionCoordinatorProxyPrivate.h"
#endif
-#import "VisionKitSPI.h"
-
#if HAVE(TRANSLATION_UI_SERVICES)
#import <TranslationUIServices/LTUITranslationViewController.h>
@@ -160,6 +158,7 @@
#endif
#import <pal/cocoa/RevealSoftLink.h>
+#import <pal/cocoa/VisionKitCoreSoftLink.h>
#import <pal/mac/DataDetectorsSoftLink.h>
#if HAVE(TOUCH_BAR) && ENABLE(WEB_PLAYBACK_CONTROLS_MANAGER)
@@ -187,16 +186,6 @@
#if ENABLE(IMAGE_ANALYSIS)
-SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(VisionKitCore)
-SOFT_LINK_CLASS_OPTIONAL(VisionKitCore, VKImageAnalyzer)
-SOFT_LINK_CLASS_OPTIONAL(VisionKitCore, VKImageAnalyzerRequest)
-
-// FIXME: Remove this once <rdar://72480459> is in the SDK.
-@interface VKImageAnalyzerRequest (Staging_72480459)
-@property (nonatomic) NSURL *imageURL;
-@property (nonatomic) NSURL *pageURL;
-@end
-
namespace WebKit {
VKImageAnalyzer *WebViewImpl::ensureImageAnalyzer()
@@ -203,7 +192,7 @@
{
if (!m_imageAnalyzer) {
m_imageAnalyzerQueue = WorkQueue::create("WebKit image analyzer queue");
- m_imageAnalyzer = adoptNS([allocVKImageAnalyzerInstance() init]);
+ m_imageAnalyzer = adoptNS([PAL::allocVKImageAnalyzerInstance() init]);
[m_imageAnalyzer setCallbackQueue:m_imageAnalyzerQueue->dispatchQueue()];
}
return m_imageAnalyzer.get();
@@ -211,7 +200,7 @@
static RetainPtr<VKImageAnalyzerRequest> createImageAnalysisRequest(CGImageRef image, const URL& imageURL, const URL& pageURL, VKAnalysisTypes types)
{
- auto request = adoptNS([allocVKImageAnalyzerRequestInstance() initWithCGImage:image orientation:VKImageOrientationUp requestType:types]);
+ auto request = adoptNS([PAL::allocVKImageAnalyzerRequestInstance() initWithCGImage:image orientation:VKImageOrientationUp requestType:types]);
[request setImageURL:imageURL];
[request setPageURL:pageURL];
return request;
@@ -219,7 +208,7 @@
void WebViewImpl::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion)
{
- if (!isLiveTextEnabled()) {
+ if (!isLiveTextAvailableAndEnabled()) {
completion({ });
return;
}
@@ -243,7 +232,7 @@
void WebViewImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
{
- if (!isLiveTextEnabled()) {
+ if (!isLiveTextAvailableAndEnabled()) {
completion(false);
return;
}
Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (278803 => 278804)
--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-06-12 01:42:09 UTC (rev 278803)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm 2021-06-12 01:42:32 UTC (rev 278804)
@@ -174,22 +174,7 @@
#import "PepperUICoreSPI.h"
#endif
-#if ENABLE(IMAGE_ANALYSIS)
-
-// FIXME: This should be pulled out into a separate softlinking header (either in PAL or WebKit2).
-#import "VisionKitSPI.h"
-SOFT_LINK_PRIVATE_FRAMEWORK_OPTIONAL(VisionKitCore)
-SOFT_LINK_CLASS_OPTIONAL(VisionKitCore, VKImageAnalyzer)
-SOFT_LINK_CLASS_OPTIONAL(VisionKitCore, VKImageAnalyzerRequest)
-
-// FIXME: Remove this once <rdar://72480459> is in the SDK.
-@interface VKImageAnalyzerRequest (Staging_72480459)
-@property (nonatomic) NSURL *imageURL;
-@property (nonatomic) NSURL *pageURL;
-@end
-
-#endif // ENABLE(IMAGE_ANALYSIS)
-
+#import <pal/cocoa/VisionKitCoreSoftLink.h>
#import <pal/ios/ManagedConfigurationSoftLink.h>
#import <pal/ios/QuickLookSoftLink.h>
@@ -880,7 +865,7 @@
_imageAnalysisDeferringGestureRecognizer = adoptNS([[WKDeferringGestureRecognizer alloc] initWithDeferringGestureDelegate:self]);
[_imageAnalysisDeferringGestureRecognizer setName:@"Deferrer for image analysis"];
[_imageAnalysisDeferringGestureRecognizer setImmediatelyFailsAfterTouchEnd:YES];
- [_imageAnalysisDeferringGestureRecognizer setEnabled:WebKit::isLiveTextEnabled()];
+ [_imageAnalysisDeferringGestureRecognizer setEnabled:WebKit::isLiveTextAvailableAndEnabled()];
#endif
for (WKDeferringGestureRecognizer *gesture in self.deferringGestures) {
@@ -9913,7 +9898,7 @@
- (bool)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeShowTextActionForElement:(_WKActivatedElementInfo *)element
{
- return WebKit::isLiveTextEnabled() && _hasSelectableTextInImage;
+ return WebKit::isLiveTextAvailableAndEnabled() && _hasSelectableTextInImage;
}
- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant showTextForImage:(UIImage *)image imageURL:(NSURL *)imageURL title:(NSString *)title imageBounds:(CGRect)imageBounds
@@ -9923,7 +9908,7 @@
- (bool)actionSheetAssistant:(WKActionSheetAssistant *)assistant shouldIncludeLookUpImageActionForElement:(_WKActivatedElementInfo *)element
{
- return WebKit::isLiveTextEnabled() && _hasVisualSearchResults;
+ return WebKit::isLiveTextAvailableAndEnabled() && _hasVisualSearchResults;
}
- (void)actionSheetAssistant:(WKActionSheetAssistant *)assistant lookUpImage:(UIImage *)image imageURL:(NSURL *)imageURL title:(NSString *)title imageBounds:(CGRect)imageBounds
@@ -9938,7 +9923,7 @@
- (VKImageAnalyzer *)imageAnalyzer
{
if (!_imageAnalyzer)
- _imageAnalyzer = adoptNS([allocVKImageAnalyzerInstance() init]);
+ _imageAnalyzer = adoptNS([PAL::allocVKImageAnalyzerInstance() init]);
return _imageAnalyzer.get();
}
@@ -9949,7 +9934,7 @@
- (void)_setUpImageAnalysis
{
- if (!WebKit::isLiveTextEnabled())
+ if (!WebKit::isLiveTextAvailableAndEnabled())
return;
_pendingImageAnalysisRequestIdentifier = std::nullopt;
@@ -9973,7 +9958,7 @@
- (void)_tearDownImageAnalysis
{
- if (!WebKit::isLiveTextEnabled())
+ if (!WebKit::isLiveTextAvailableAndEnabled())
return;
[_imageAnalysisGestureRecognizer setDelegate:nil];
@@ -10007,7 +9992,7 @@
- (RetainPtr<VKImageAnalyzerRequest>)createImageAnalysisRequest:(VKAnalysisTypes)analysisTypes image:(UIImage *)image imageURL:(NSURL *)imageURL
{
- auto request = adoptNS([allocVKImageAnalyzerRequestInstance() initWithImage:image orientation:VKImageOrientationUp requestType:analysisTypes]);
+ auto request = adoptNS([PAL::allocVKImageAnalyzerRequestInstance() initWithImage:image orientation:VKImageOrientationUp requestType:analysisTypes]);
[request setImageURL:imageURL];
[request setPageURL:[NSURL _web_URLWithWTFString:_page->currentURL()]];
return request;
@@ -10063,7 +10048,7 @@
- (void)imageAnalysisGestureDidBegin:(WKImageAnalysisGestureRecognizer *)gestureRecognizer
{
- ASSERT(WebKit::isLiveTextEnabled());
+ ASSERT(WebKit::isLiveTextAvailableAndEnabled());
auto requestIdentifier = WebKit::ImageAnalysisRequestIdentifier::generate();