Title: [280603] trunk/Source
Revision
280603
Author
drou...@apple.com
Date
2021-08-03 11:22:46 -0700 (Tue, 03 Aug 2021)

Log Message

[Live Text] [iOS] Provide a presenting `UIViewController` for machine readable code actions so that they are related to the same view
https://bugs.webkit.org/show_bug.cgi?id=228722

Reviewed by Tim Horton.

Source/WebCore/PAL:

* pal/spi/cocoa/VisionKitCoreSPI.h:

Source/WebKit:

* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _updateContextMenuForMachineReadableCodeForImageAnalysis:]): Added.
(-[WKContentView imageAnalysisGestureDidBegin:]):
(-[WKContentView imageAnalysisGestureDidTimeOut:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/PAL/ChangeLog (280602 => 280603)


--- trunk/Source/WebCore/PAL/ChangeLog	2021-08-03 17:49:05 UTC (rev 280602)
+++ trunk/Source/WebCore/PAL/ChangeLog	2021-08-03 18:22:46 UTC (rev 280603)
@@ -1,3 +1,12 @@
+2021-08-03  Devin Rousso  <drou...@apple.com>
+
+        [Live Text] [iOS] Provide a presenting `UIViewController` for machine readable code actions so that they are related to the same view
+        https://bugs.webkit.org/show_bug.cgi?id=228722
+
+        Reviewed by Tim Horton.
+
+        * pal/spi/cocoa/VisionKitCoreSPI.h:
+
 2021-08-02  Devin Rousso  <drou...@apple.com>
 
         [Live Text] SPI for machine readable codes is only available on iOS

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


--- trunk/Source/WebCore/PAL/pal/spi/cocoa/VisionKitCoreSPI.h	2021-08-03 17:49:05 UTC (rev 280602)
+++ trunk/Source/WebCore/PAL/pal/spi/cocoa/VisionKitCoreSPI.h	2021-08-03 18:22:46 UTC (rev 280603)
@@ -130,6 +130,7 @@
 @property (nonatomic, readonly) NSArray<VKWKLineInfo *> *allLines;
 #if HAVE(VK_IMAGE_ANALYSIS_FOR_MACHINE_READABLE_CODES)
 @property (nonatomic) UIMenu *mrcMenu;
+@property (nonatomic, nullable, weak) UIViewController *presentingViewControllerForMrcAction;
 #endif
 @end
 

Modified: trunk/Source/WebKit/ChangeLog (280602 => 280603)


--- trunk/Source/WebKit/ChangeLog	2021-08-03 17:49:05 UTC (rev 280602)
+++ trunk/Source/WebKit/ChangeLog	2021-08-03 18:22:46 UTC (rev 280603)
@@ -1,3 +1,15 @@
+2021-08-03  Devin Rousso  <drou...@apple.com>
+
+        [Live Text] [iOS] Provide a presenting `UIViewController` for machine readable code actions so that they are related to the same view
+        https://bugs.webkit.org/show_bug.cgi?id=228722
+
+        Reviewed by Tim Horton.
+
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _updateContextMenuForMachineReadableCodeForImageAnalysis:]): Added.
+        (-[WKContentView imageAnalysisGestureDidBegin:]):
+        (-[WKContentView imageAnalysisGestureDidTimeOut:]):
+
 2021-08-02  Peng Liu  <peng.l...@apple.com>
 
         [GPUP] RemoteAudioSession::setPreferredBufferSize() does not change its preferredBufferSize

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (280602 => 280603)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-08-03 17:49:05 UTC (rev 280602)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2021-08-03 18:22:46 UTC (rev 280603)
@@ -10156,6 +10156,16 @@
     return [self createImageAnalysisRequest:analysisTypes image:image imageURL:_positionInformation.imageURL];
 }
 
+#if USE(UICONTEXTMENU) && ENABLE(IMAGE_ANALYSIS_FOR_MACHINE_READABLE_CODES)
+
+- (void)_updateContextMenuForMachineReadableCodeForImageAnalysis:(VKImageAnalysis *)analysis
+{
+    analysis.presentingViewControllerForMrcAction = [UIViewController _viewControllerForFullScreenPresentationFromView:self];
+    _contextMenuForMachineReadableCode = [analysis hasResultsForAnalysisTypes:VKAnalysisTypeMachineReadableCode | VKAnalysisTypeAppClip] ? analysis.mrcMenu : nil;
+}
+
+#endif // USE(UICONTEXTMENU) && ENABLE(IMAGE_ANALYSIS_FOR_MACHINE_READABLE_CODES)
+
 - (BOOL)validateImageAnalysisRequestIdentifier:(WebKit::ImageAnalysisRequestIdentifier)identifier
 {
     if (_pendingImageAnalysisRequestIdentifier == identifier)
@@ -10323,7 +10333,7 @@
                     UNUSED_PARAM(hasTextResults);
 #endif
 #if USE(UICONTEXTMENU) && ENABLE(IMAGE_ANALYSIS_FOR_MACHINE_READABLE_CODES)
-                    strongSelf->_contextMenuForMachineReadableCode = [result hasResultsForAnalysisTypes:VKAnalysisTypeMachineReadableCode | VKAnalysisTypeAppClip] ? result.mrcMenu : nil;
+                    [strongSelf _updateContextMenuForMachineReadableCodeForImageAnalysis:result];
 #endif // USE(UICONTEXTMENU) && ENABLE(IMAGE_ANALYSIS_FOR_MACHINE_READABLE_CODES)
                     [strongSelf _invokeAllActionsToPerformAfterPendingImageAnalysis:WebKit::ProceedWithTextSelectionInImage::No];
                 }];
@@ -10392,7 +10402,7 @@
 
 #if USE(UICONTEXTMENU)
 #if ENABLE(IMAGE_ANALYSIS_FOR_MACHINE_READABLE_CODES)
-            strongSelf->_contextMenuForMachineReadableCode = [result hasResultsForAnalysisTypes:VKAnalysisTypeMachineReadableCode | VKAnalysisTypeAppClip] ? result.mrcMenu : nil;
+            [strongSelf _updateContextMenuForMachineReadableCodeForImageAnalysis:result];
 #endif // ENABLE(IMAGE_ANALYSIS_FOR_MACHINE_READABLE_CODES)
             strongSelf->_contextMenuWasTriggeredByImageAnalysisTimeout = YES;
             [strongSelf->_contextMenuInteraction _presentMenuAtLocation:location];
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to