Title: [279479] trunk
Revision
279479
Author
wenson_hs...@apple.com
Date
2021-07-01 13:22:09 -0700 (Thu, 01 Jul 2021)

Log Message

Selecting or dragging images that contain recognizable text is difficult in Mail compose
https://bugs.webkit.org/show_bug.cgi?id=227544

Reviewed by Devin Rousso.

Source/WebKit:

Long pressing images in editable content on iOS initiates dragging, and a tap-and-half gesture over the image
selects the entire image. Both of these are common interactions for image attachments in Mail compose that
take precedence over new Live Text interactions, so there's no advantage to triggering image analysis on images
in editable content.

Avoid doing this extra work by adjusting `-imageAnalysisGestureDidBegin:` to bail early if the image is inside
editable content.

Tests:  ImageAnalysisTests.DoNotAnalyzeImagesInEditableContent
        ImageAnalysisTests.HandleImageAnalyzerError

* Shared/ios/InteractionInformationAtPosition.h:
* Shared/ios/InteractionInformationAtPosition.mm:
(WebKit::InteractionInformationAtPosition::encode const):
(WebKit::InteractionInformationAtPosition::decode):

Add an `isContentEditable` flag.

* UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
* UIProcess/API/ios/WKWebViewTestingIOS.mm:
(-[WKWebView _imageAnalysisGestureRecognizer]):

Add a testing hook to return the gesture recognizer used to trigger image analysis.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView imageAnalysisGestureRecognizer]):
(-[WKContentView imageAnalysisGestureDidBegin:]):

Pull logic for avoiding image analysis out into a separate lambda, and add a check for `isContentEditable`.

* WebProcess/WebPage/ios/WebPageIOS.mm:
(WebKit::WebPage::positionInformation):

Populate the `isContentEditable` flag based on whether or not the node found by the position information request
is editable.

Tools:

See WebKit/ChangeLog for more details.

* TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig:

Link against VisionKitCore on iOS 15+ and macOS 12+.

* TestWebKitAPI/Configurations/WebKitTargetConditionals.xcconfig:

Update WebKitTargetConditionals to be consistent with the other target conditions in WebKit, so that we can use
`IOS_SINCE_15` in TestWebKitAPI.xcconfig.

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm: Added.

Add new API tests that trigger the image analysis gesture recognizer and check whether or not we requested image
analysis from VisionKit.

(TestWebKitAPI::swizzledLocationInView):
(TestWebKitAPI::swizzledProcessRequest):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (279478 => 279479)


--- trunk/Source/WebKit/ChangeLog	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Source/WebKit/ChangeLog	2021-07-01 20:22:09 UTC (rev 279479)
@@ -1,3 +1,47 @@
+2021-07-01  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Selecting or dragging images that contain recognizable text is difficult in Mail compose
+        https://bugs.webkit.org/show_bug.cgi?id=227544
+
+        Reviewed by Devin Rousso.
+
+        Long pressing images in editable content on iOS initiates dragging, and a tap-and-half gesture over the image
+        selects the entire image. Both of these are common interactions for image attachments in Mail compose that
+        take precedence over new Live Text interactions, so there's no advantage to triggering image analysis on images
+        in editable content.
+
+        Avoid doing this extra work by adjusting `-imageAnalysisGestureDidBegin:` to bail early if the image is inside
+        editable content.
+
+        Tests:  ImageAnalysisTests.DoNotAnalyzeImagesInEditableContent
+                ImageAnalysisTests.HandleImageAnalyzerError
+
+        * Shared/ios/InteractionInformationAtPosition.h:
+        * Shared/ios/InteractionInformationAtPosition.mm:
+        (WebKit::InteractionInformationAtPosition::encode const):
+        (WebKit::InteractionInformationAtPosition::decode):
+
+        Add an `isContentEditable` flag.
+
+        * UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h:
+        * UIProcess/API/ios/WKWebViewTestingIOS.mm:
+        (-[WKWebView _imageAnalysisGestureRecognizer]):
+
+        Add a testing hook to return the gesture recognizer used to trigger image analysis.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView imageAnalysisGestureRecognizer]):
+        (-[WKContentView imageAnalysisGestureDidBegin:]):
+
+        Pull logic for avoiding image analysis out into a separate lambda, and add a check for `isContentEditable`.
+
+        * WebProcess/WebPage/ios/WebPageIOS.mm:
+        (WebKit::WebPage::positionInformation):
+
+        Populate the `isContentEditable` flag based on whether or not the node found by the position information request
+        is editable.
+
 2021-07-01  Antoine Quint  <grao...@webkit.org>
 
         [Model] Restrict IPC calls to ARKit SPI availability and runtime flag

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h (279478 => 279479)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.h	2021-07-01 20:22:09 UTC (rev 279479)
@@ -63,6 +63,7 @@
     bool isAttachment { false };
     bool isAnimatedImage { false };
     bool isElement { false };
+    bool isContentEditable { false };
     WebCore::ScrollingNodeID containerScrollingNodeID { 0 };
 #if ENABLE(DATA_DETECTION)
     bool isDataDetectorLink { false };

Modified: trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm (279478 => 279479)


--- trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Source/WebKit/Shared/ios/InteractionInformationAtPosition.mm	2021-07-01 20:22:09 UTC (rev 279479)
@@ -50,6 +50,7 @@
     encoder << isAttachment;
     encoder << isAnimatedImage;
     encoder << isElement;
+    encoder << isContentEditable;
     encoder << containerScrollingNodeID;
     encoder << adjustedPointForNodeRespondingToClickEvents;
     encoder << url;
@@ -128,6 +129,9 @@
     if (!decoder.decode(result.isElement))
         return false;
 
+    if (!decoder.decode(result.isContentEditable))
+        return false;
+
     if (!decoder.decode(result.containerScrollingNodeID))
         return false;
 

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h (279478 => 279479)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewPrivateForTestingIOS.h	2021-07-01 20:22:09 UTC (rev 279479)
@@ -30,6 +30,7 @@
 
 @class _WKTextInputContext;
 @class UIEventAttribution;
+@class UIGestureRecognizer;
 @class UIWKDocumentContext;
 @class UIWKDocumentRequest;
 
@@ -45,6 +46,7 @@
 @property (nonatomic, readonly) CGRect _dragCaretRect;
 @property (nonatomic, readonly, getter=_isAnimatingDragCancel) BOOL _animatingDragCancel;
 @property (nonatomic, readonly) CGRect _tapHighlightViewRect;
+@property (nonatomic, readonly) UIGestureRecognizer *_imageAnalysisGestureRecognizer;
 
 - (void)keyboardAccessoryBarNext;
 - (void)keyboardAccessoryBarPrevious;

Modified: trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm (279478 => 279479)


--- trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Source/WebKit/UIProcess/API/ios/WKWebViewTestingIOS.mm	2021-07-01 20:22:09 UTC (rev 279479)
@@ -341,6 +341,11 @@
     return [_contentView tapHighlightViewRect];
 }
 
+- (UIGestureRecognizer *)_imageAnalysisGestureRecognizer
+{
+    return [_contentView imageAnalysisGestureRecognizer];
+}
+
 - (void)_simulateElementAction:(_WKElementActionType)actionType atLocation:(CGPoint)location
 {
     [_contentView _simulateElementAction:actionType atLocation:location];

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (279478 => 279479)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2021-07-01 20:22:09 UTC (rev 279479)
@@ -545,6 +545,7 @@
 @property (nonatomic, readonly) NSArray<WKDeferringGestureRecognizer *> *deferringGestures;
 @property (nonatomic, readonly) WebKit::GestureRecognizerConsistencyEnforcer& gestureRecognizerConsistencyEnforcer;
 @property (nonatomic, readonly) CGRect tapHighlightViewRect;
+@property (nonatomic, readonly) UIGestureRecognizer *imageAnalysisGestureRecognizer;
 
 #if ENABLE(DATALIST_ELEMENT)
 @property (nonatomic, strong) UIView <WKFormControl> *dataListTextSuggestionsInputView;

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (279478 => 279479)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-07-01 20:22:09 UTC (rev 279479)
@@ -2030,6 +2030,15 @@
     return [_highlightView frame];
 }
 
+- (UIGestureRecognizer *)imageAnalysisGestureRecognizer
+{
+#if ENABLE(IMAGE_ANALYSIS)
+    return _imageAnalysisGestureRecognizer.get();
+#else
+    return nil;
+#endif
+}
+
 - (void)_showTapHighlight
 {
     auto shouldPaintTapHighlight = [&](const WebCore::FloatRect& rect) {
@@ -10109,8 +10118,6 @@
     return NO;
 }
 
-#pragma mark - WKImageAnalysisGestureRecognizerDelegate
-
 - (void)requestTextRecognition:(NSURL *)imageURL imageData:(const WebKit::ShareableBitmap::Handle&)imageData completionHandler:(CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&)completion
 {
     auto imageBitmap = WebKit::ShareableBitmap::create(imageData);
@@ -10137,6 +10144,8 @@
     }).get()];
 }
 
+#pragma mark - WKImageAnalysisGestureRecognizerDelegate
+
 - (void)imageAnalysisGestureDidBegin:(WKImageAnalysisGestureRecognizer *)gestureRecognizer
 {
     ASSERT(WebKit::isLiveTextAvailableAndEnabled());
@@ -10164,7 +10173,25 @@
         if (![strongSelf validateImageAnalysisRequestIdentifier:requestIdentifier])
             return;
 
-        bool shouldAnalyzeImageAtLocation = information.isImage && information.image && information.imageElementContext && !information.isAnimatedImage;
+        bool shouldAnalyzeImageAtLocation = ([&] {
+            if (!information.isImage)
+                return false;
+
+            if (!information.image)
+                return false;
+
+            if (!information.imageElementContext)
+                return false;
+
+            if (information.isAnimatedImage)
+                return false;
+
+            if (information.isContentEditable)
+                return false;
+
+            return true;
+        })();
+
         if (!strongSelf->_pendingImageAnalysisRequestIdentifier || !shouldAnalyzeImageAtLocation) {
             [strongSelf _invokeAllActionsToPerformAfterPendingImageAnalysis:WebKit::ProceedWithTextSelectionInImage::No];
             return;

Modified: trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm (279478 => 279479)


--- trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Source/WebKit/WebProcess/WebPage/ios/WebPageIOS.mm	2021-07-01 20:22:09 UTC (rev 279479)
@@ -3075,6 +3075,7 @@
     FloatPoint adjustedPoint;
     auto* nodeRespondingToClickEvents = m_page->mainFrame().nodeRespondingToClickEvents(request.point, adjustedPoint);
 
+    info.isContentEditable = nodeRespondingToClickEvents && nodeRespondingToClickEvents->isContentEditable();
     info.adjustedPointForNodeRespondingToClickEvents = adjustedPoint;
 
     if (request.includeHasDoubleClickHandler)

Modified: trunk/Tools/ChangeLog (279478 => 279479)


--- trunk/Tools/ChangeLog	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Tools/ChangeLog	2021-07-01 20:22:09 UTC (rev 279479)
@@ -1,3 +1,30 @@
+2021-07-01  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Selecting or dragging images that contain recognizable text is difficult in Mail compose
+        https://bugs.webkit.org/show_bug.cgi?id=227544
+
+        Reviewed by Devin Rousso.
+
+        See WebKit/ChangeLog for more details.
+
+        * TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig:
+
+        Link against VisionKitCore on iOS 15+ and macOS 12+.
+
+        * TestWebKitAPI/Configurations/WebKitTargetConditionals.xcconfig:
+
+        Update WebKitTargetConditionals to be consistent with the other target conditions in WebKit, so that we can use
+        `IOS_SINCE_15` in TestWebKitAPI.xcconfig.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm: Added.
+
+        Add new API tests that trigger the image analysis gesture recognizer and check whether or not we requested image
+        analysis from VisionKit.
+
+        (TestWebKitAPI::swizzledLocationInView):
+        (TestWebKitAPI::swizzledProcessRequest):
+
 2021-07-01  Philippe Normand  <pnorm...@igalia.com>
 
         [WPE] Pack Cog modules in built-product archive

Modified: trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig (279478 => 279479)


--- trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Tools/TestWebKitAPI/Configurations/TestWebKitAPI.xcconfig	2021-07-01 20:22:09 UTC (rev 279479)
@@ -54,6 +54,11 @@
 WK_HID_LDFLAGS_macosx = $(WK_HID_LDFLAGS$(WK_MACOS_1015));
 WK_HID_LDFLAGS_MACOS_SINCE_1015 = -framework HID;
 
+WK_VISIONKITCORE_LDFLAGS = $(WK_VISIONKITCORE_LDFLAGS_$(WK_PLATFORM_NAME));
+WK_VISIONKITCORE_LDFLAGS_iphoneos = $(WK_VISIONKITCORE_LDFLAGS$(WK_IOS_15));
+WK_VISIONKITCORE_LDFLAGS_iphonesimulator = $(WK_VISIONKITCORE_LDFLAGS$(WK_IOS_15));
+WK_VISIONKITCORE_LDFLAGS_IOS_SINCE_15 = -framework VisionKitCore;
+
 WK_OPENGL_LDFLAGS = $(WK_OPENGL_LDFLAGS_$(WK_PLATFORM_NAME));
 WK_OPENGL_LDFLAGS_iphoneos = -framework OpenGLES;
 WK_OPENGL_LDFLAGS_maccatalyst = -framework OpenGL;
@@ -81,7 +86,7 @@
 
 OTHER_CPLUSPLUSFLAGS = $(inherited) -isystem $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders;
 
-OTHER_LDFLAGS = $(inherited) -lgtest -force_load $(BUILT_PRODUCTS_DIR)/libTestWebKitAPI.a -framework _javascript_Core -framework WebKit -lWebCoreTestSupport $(WK_AUTHKIT_LDFLAGS) -framework Network $(WK_HID_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SYSTEM_LDFLAGS) $(WK_UIKITMACHELPER_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM_$(WK_COCOA_TOUCH));
+OTHER_LDFLAGS = $(inherited) -lgtest -force_load $(BUILT_PRODUCTS_DIR)/libTestWebKitAPI.a -framework _javascript_Core -framework WebKit -lWebCoreTestSupport $(WK_AUTHKIT_LDFLAGS) -framework Network $(WK_HID_LDFLAGS) $(WK_OPENGL_LDFLAGS) $(WK_PDFKIT_LDFLAGS) $(WK_SYSTEM_LDFLAGS) $(WK_UIKITMACHELPER_LDFLAGS) $(WK_VISIONKITCORE_LDFLAGS) $(OTHER_LDFLAGS_PLATFORM_$(WK_COCOA_TOUCH));
 OTHER_LDFLAGS_PLATFORM_ = -framework Cocoa -framework Carbon;
 
 // FIXME: This should not be built on iOS. Instead we should create and use a TestWebKitAPI application.

Modified: trunk/Tools/TestWebKitAPI/Configurations/WebKitTargetConditionals.xcconfig (279478 => 279479)


--- trunk/Tools/TestWebKitAPI/Configurations/WebKitTargetConditionals.xcconfig	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Tools/TestWebKitAPI/Configurations/WebKitTargetConditionals.xcconfig	2021-07-01 20:22:09 UTC (rev 279479)
@@ -1,4 +1,4 @@
-// Copyright (C) 2018 Apple Inc. All rights reserved.
+// 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
@@ -71,6 +71,13 @@
 WK_MACOS_BEFORE_1200_101500 = YES;
 WK_MACOS_BEFORE_1200_110000 = YES;
 
+WK_MACOS_BEFORE_1300 = $(WK_MACOS_BEFORE_1300_$(TARGET_MAC_OS_X_VERSION_MAJOR));
+WK_MACOS_BEFORE_1300_101300 = YES;
+WK_MACOS_BEFORE_1300_101400 = YES;
+WK_MACOS_BEFORE_1300_101500 = YES;
+WK_MACOS_BEFORE_1300_110000 = YES;
+WK_MACOS_BEFORE_1300_120000 = YES;
+
 WK_MACOS_1014 = $(WK_MACOS_1014_$(WK_MACOS_BEFORE_1014));
 WK_MACOS_1014_ = _MACOS_SINCE_1014;
 WK_MACOS_1014_YES = _MACOS_BEFORE_1014;
@@ -91,6 +98,10 @@
 WK_MACOS_1014_1200_ = $(WK_MACOS_1200);
 WK_MACOS_1014_1200_YES = _MACOS_BEFORE_1014;
 
+WK_MACOS_1014_1300 = $(WK_MACOS_1014_1300_$(WK_MACOS_BEFORE_1014));
+WK_MACOS_1014_1300_ = $(WK_MACOS_1300);
+WK_MACOS_1014_1300_YES = _MACOS_BEFORE_1014;
+
 WK_MACOS_1015 = $(WK_MACOS_1015_$(WK_MACOS_BEFORE_1015));
 WK_MACOS_1015_ = _MACOS_SINCE_1015;
 WK_MACOS_1015_YES = _MACOS_BEFORE_1015;
@@ -107,6 +118,10 @@
 WK_MACOS_1015_1200_ = $(WK_MACOS_1200);
 WK_MACOS_1015_1200_YES = _MACOS_BEFORE_1015;
 
+WK_MACOS_1015_1300 = $(WK_MACOS_1015_1300_$(WK_MACOS_BEFORE_1015));
+WK_MACOS_1015_1300_ = $(WK_MACOS_1300);
+WK_MACOS_1015_1300_YES = _MACOS_BEFORE_1015;
+
 WK_MACOS_1016 = $(WK_MACOS_1016_$(WK_MACOS_BEFORE_1016));
 WK_MACOS_1016_ = _MACOS_SINCE_1016;
 WK_MACOS_1016_YES = _MACOS_BEFORE_1016;
@@ -119,6 +134,10 @@
 WK_MACOS_1016_1200 = _MACOS_SINCE_1016;
 WK_MACOS_1016_1200_YES = _MACOS_BEFORE_1016;
 
+WK_MACOS_1016_1300 = $(WK_MACOS_1016_$(WK_MACOS_BEFORE_1016));
+WK_MACOS_1016_1300 = _MACOS_SINCE_1016;
+WK_MACOS_1016_1300_YES = _MACOS_BEFORE_1016;
+
 WK_MACOS_1100 = $(WK_MACOS_1100_$(WK_MACOS_BEFORE_1100));
 WK_MACOS_1100_ = _MACOS_SINCE_1100;
 WK_MACOS_1100_YES = _MACOS_BEFORE_1100;
@@ -127,42 +146,38 @@
 WK_MACOS_1100_1200 = _MACOS_SINCE_1100;
 WK_MACOS_1100_1200_YES = _MACOS_BEFORE_1100;
 
+WK_MACOS_1100_1300 = $(WK_MACOS_1100_$(WK_MACOS_BEFORE_1100));
+WK_MACOS_1100_1300 = _MACOS_SINCE_1100;
+WK_MACOS_1100_1300_YES = _MACOS_BEFORE_1100;
+
 WK_MACOS_1200 = $(WK_MACOS_1200_$(WK_MACOS_BEFORE_1200));
 WK_MACOS_1200_ = _MACOS_SINCE_1200;
 WK_MACOS_1200_YES = _MACOS_BEFORE_1200;
 
-// iOS
+WK_MACOS_1200_1300 = $(WK_MACOS_1200_$(WK_MACOS_BEFORE_1200));
+WK_MACOS_1200_1300 = _MACOS_SINCE_1200;
+WK_MACOS_1200_1300_YES = _MACOS_BEFORE_1200;
 
-WK_IOS_BEFORE_11 = $(WK_IOS_BEFORE_11_$(IPHONEOS_DEPLOYMENT_TARGET:base));
+WK_MACOS_1300 = $(WK_MACOS_1300_$(WK_MACOS_BEFORE_1300));
+WK_MACOS_1300_ = _MACOS_SINCE_1300;
+WK_MACOS_1300_YES = _MACOS_BEFORE_1300;
 
-WK_IOS_BEFORE_12 = $(WK_IOS_BEFORE_12_$(IPHONEOS_DEPLOYMENT_TARGET:base));
-WK_IOS_BEFORE_12_11 = YES;
+// iOS
 
 WK_IOS_BEFORE_13 = $(WK_IOS_BEFORE_13_$(IPHONEOS_DEPLOYMENT_TARGET:base));
-WK_IOS_BEFORE_13_11 = YES;
-WK_IOS_BEFORE_13_12 = YES;
 
 WK_IOS_BEFORE_14 = $(WK_IOS_BEFORE_14_$(IPHONEOS_DEPLOYMENT_TARGET:base));
-WK_IOS_BEFORE_14_11 = YES;
-WK_IOS_BEFORE_14_12 = YES;
 WK_IOS_BEFORE_14_13 = YES;
 
-WK_IOS_11 = $(WK_IOS_11_$(WK_IOS_BEFORE_11));
-WK_IOS_11_ = _IOS_SINCE_11;
-WK_IOS_11_YES = _IOS_BEFORE_11;
+WK_IOS_BEFORE_15 = $(WK_IOS_BEFORE_15_$(IPHONEOS_DEPLOYMENT_TARGET:base));
+WK_IOS_BEFORE_15_13 = YES;
+WK_IOS_BEFORE_15_14 = YES;
 
-WK_IOS_12 = $(WK_IOS_12_$(WK_IOS_BEFORE_12));
-WK_IOS_12_ = _IOS_SINCE_12;
-WK_IOS_12_YES = _IOS_BEFORE_12;
+WK_IOS_BEFORE_16 = $(WK_IOS_BEFORE_16_$(IPHONEOS_DEPLOYMENT_TARGET:base));
+WK_IOS_BEFORE_16_13 = YES;
+WK_IOS_BEFORE_16_14 = YES;
+WK_IOS_BEFORE_16_15 = YES;
 
-WK_IOS_12_13 = $(WK_IOS_12_13_$(WK_IOS_BEFORE_12));
-WK_IOS_12_13_ = $(WK_IOS_13);
-WK_IOS_12_13_YES = _IOS_BEFORE_12;
-
-WK_IOS_12_14 = $(WK_IOS_12_14_$(WK_IOS_BEFORE_12));
-WK_IOS_12_14_ = $(WK_IOS_14);
-WK_IOS_12_14_YES = _IOS_BEFORE_12;
-
 WK_IOS_13 = $(WK_IOS_13_$(WK_IOS_BEFORE_13));
 WK_IOS_13_ = _IOS_SINCE_13;
 WK_IOS_13_YES = _IOS_BEFORE_13;
@@ -171,6 +186,34 @@
 WK_IOS_13_14_ = $(WK_IOS_14);
 WK_IOS_13_14_YES = _IOS_BEFORE_13;
 
+WK_IOS_13_15 = $(WK_IOS_13_15_$(WK_IOS_BEFORE_13));
+WK_IOS_13_15_ = $(WK_IOS_15);
+WK_IOS_13_15_YES = _IOS_BEFORE_13;
+
+WK_IOS_13_16 = $(WK_IOS_13_16_$(WK_IOS_BEFORE_13));
+WK_IOS_13_16_ = $(WK_IOS_16);
+WK_IOS_13_16_YES = _IOS_BEFORE_13;
+
 WK_IOS_14 = $(WK_IOS_14_$(WK_IOS_BEFORE_14));
 WK_IOS_14_ = _IOS_SINCE_14;
 WK_IOS_14_YES = _IOS_BEFORE_14;
+
+WK_IOS_14_15 = $(WK_IOS_14_15_$(WK_IOS_BEFORE_14));
+WK_IOS_14_15_ = $(WK_IOS_15);
+WK_IOS_14_15_YES = _IOS_BEFORE_14;
+
+WK_IOS_14_16 = $(WK_IOS_14_16_$(WK_IOS_BEFORE_14));
+WK_IOS_14_16_ = $(WK_IOS_16);
+WK_IOS_14_16_YES = _IOS_BEFORE_14;
+
+WK_IOS_15 = $(WK_IOS_15_$(WK_IOS_BEFORE_15));
+WK_IOS_15_ = _IOS_SINCE_15;
+WK_IOS_15_YES = _IOS_BEFORE_15;
+
+WK_IOS_15_16 = $(WK_IOS_15_16_$(WK_IOS_BEFORE_15));
+WK_IOS_15_16_ = $(WK_IOS_16);
+WK_IOS_15_16_YES = _IOS_BEFORE_15;
+
+WK_IOS_16 = $(WK_IOS_16_$(WK_IOS_BEFORE_16));
+WK_IOS_16_ = _IOS_SINCE_16;
+WK_IOS_16_YES = _IOS_BEFORE_16;

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (279478 => 279479)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-07-01 19:59:38 UTC (rev 279478)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2021-07-01 20:22:09 UTC (rev 279479)
@@ -1193,6 +1193,7 @@
 		F442851D2140DF2900CCDA22 /* NSFontPanelTesting.mm in Sources */ = {isa = PBXBuildFile; fileRef = F442851C2140DF2900CCDA22 /* NSFontPanelTesting.mm */; };
 		F4451C761EB8FD890020C5DA /* two-paragraph-contenteditable.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = F4451C751EB8FD7C0020C5DA /* two-paragraph-contenteditable.html */; };
 		F44A531121B8990300DBB99C /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44A531021B8976900DBB99C /* InstanceMethodSwizzler.mm */; };
+		F44A7D20268D5C6900B49BB8 /* ImageAnalysisTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44A7D1F268D5C6900B49BB8 /* ImageAnalysisTests.mm */; };
 		F44A9AF72649BBDD00E7CB16 /* ImmediateActionTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44A9AF62649BBDD00E7CB16 /* ImmediateActionTests.mm */; };
 		F44C79FF20F9E8710014478C /* ParserYieldTokenTests.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44C79FE20F9E8710014478C /* ParserYieldTokenTests.mm */; };
 		F44C7A0020F9EEBF0014478C /* ParserYieldTokenPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44C79FB20F9E50C0014478C /* ParserYieldTokenPlugIn.mm */; };
@@ -3033,6 +3034,7 @@
 		F44A530E21B8976900DBB99C /* ClassMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ClassMethodSwizzler.mm; path = ../TestRunnerShared/cocoa/ClassMethodSwizzler.mm; sourceTree = "<group>"; };
 		F44A530F21B8976900DBB99C /* ClassMethodSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ClassMethodSwizzler.h; path = ../TestRunnerShared/cocoa/ClassMethodSwizzler.h; sourceTree = "<group>"; };
 		F44A531021B8976900DBB99C /* InstanceMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = InstanceMethodSwizzler.mm; path = ../TestRunnerShared/cocoa/InstanceMethodSwizzler.mm; sourceTree = "<group>"; };
+		F44A7D1F268D5C6900B49BB8 /* ImageAnalysisTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ImageAnalysisTests.mm; sourceTree = "<group>"; };
 		F44A9AF52649BBDD00E7CB16 /* ImmediateActionTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ImmediateActionTests.h; sourceTree = "<group>"; };
 		F44A9AF62649BBDD00E7CB16 /* ImmediateActionTests.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ImmediateActionTests.mm; sourceTree = "<group>"; };
 		F44C79FB20F9E50C0014478C /* ParserYieldTokenPlugIn.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ParserYieldTokenPlugIn.mm; sourceTree = "<group>"; };
@@ -3471,6 +3473,7 @@
 				510477751D298E03009747EB /* IDBDeleteRecovery.mm */,
 				5110FCEF1E01CBAA006F8D0B /* IDBIndexUpgradeToV2.mm */,
 				93BCBC8023CC6EE800CA2221 /* IDBObjectStoreInfoUpgradeToV2.mm */,
+				F44A7D1F268D5C6900B49BB8 /* ImageAnalysisTests.mm */,
 				49AEEF6B2407358600C87E4C /* InAppBrowserPrivacy.mm */,
 				491AEEF42652DDD000D530A8 /* InAppBrowserPrivacyPlugIn.mm */,
 				51A587841D272EF3004BA9AF /* IndexedDBDatabaseProcessKill.mm */,
@@ -5506,6 +5509,7 @@
 				CDCF78A8244A32F700480311 /* FullscreenAlert.mm in Sources */,
 				CD78E11D1DB7EA660014A2DE /* FullscreenDelegate.mm in Sources */,
 				CDB213BD24EF522800FDE301 /* FullscreenFocus.mm in Sources */,
+				F44A7D20268D5C6900B49BB8 /* ImageAnalysisTests.mm in Sources */,
 				CDE77D2525A6591C00D4115E /* FullscreenPointerLeave.mm in Sources */,
 				CDDC7C6925FFF6D000224278 /* FullscreenRemoveNodeBeforeEnter.mm in Sources */,
 				CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm (0 => 279479)


--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ImageAnalysisTests.mm	2021-07-01 20:22:09 UTC (rev 279479)
@@ -0,0 +1,85 @@
+/*
+* 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 ENABLE(IMAGE_ANALYSIS)
+
+#import "InstanceMethodSwizzler.h"
+#import "PlatformUtilities.h"
+#import "TestWKWebView.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKWebViewPrivate.h>
+#import <WebKit/WKWebViewPrivateForTesting.h>
+#import <pal/spi/cocoa/VisionKitCoreSPI.h>
+
+namespace TestWebKitAPI {
+
+#if PLATFORM(IOS_FAMILY)
+
+static CGPoint swizzledLocationInView(id, SEL, UIView *)
+{
+    return CGPointMake(100, 100);
+}
+
+static bool gDidProcessRequest = false;
+static void swizzledProcessRequest(id, SEL, VKImageAnalyzerRequest *, void (^)(double progress), void (^completion)(VKImageAnalysis *analysis, NSError *error))
+{
+    gDidProcessRequest = true;
+    completion(nil, [NSError errorWithDomain:NSCocoaErrorDomain code:1 userInfo:nil]);
+}
+
+TEST(ImageAnalysisTests, DoNotAnalyzeImagesInEditableContent)
+{
+    InstanceMethodSwizzler gestureLocationSwizzler { UIGestureRecognizer.class, @selector(locationInView:), reinterpret_cast<IMP>(swizzledLocationInView) };
+    InstanceMethodSwizzler imageAnalysisRequestSwizzler { VKImageAnalyzer.class, @selector(processRequest:progressHandler:completionHandler:), reinterpret_cast<IMP>(swizzledProcessRequest) };
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)]);
+    [webView _setEditable:YES];
+    [webView synchronouslyLoadTestPageNamed:@"image"];
+
+    [webView _imageAnalysisGestureRecognizer].state = UIGestureRecognizerStateBegan;
+    [webView waitForNextPresentationUpdate];
+    EXPECT_FALSE(gDidProcessRequest);
+}
+
+TEST(ImageAnalysisTests, HandleImageAnalyzerError)
+{
+    InstanceMethodSwizzler gestureLocationSwizzler { UIGestureRecognizer.class, @selector(locationInView:), reinterpret_cast<IMP>(swizzledLocationInView) };
+    InstanceMethodSwizzler imageAnalysisRequestSwizzler { VKImageAnalyzer.class, @selector(processRequest:progressHandler:completionHandler:), reinterpret_cast<IMP>(swizzledProcessRequest) };
+
+    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)]);
+    [webView synchronouslyLoadTestPageNamed:@"image"];
+
+    [webView _imageAnalysisGestureRecognizer].state = UIGestureRecognizerStateBegan;
+    [webView waitForNextPresentationUpdate];
+    EXPECT_TRUE(gDidProcessRequest);
+}
+
+#endif // PLATFORM(IOS_FAMILY)
+
+} // namespace TestWebKitAPI
+
+#endif // ENABLE(IMAGE_ANALYSIS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to