Title: [293299] trunk/Source
Revision
293299
Author
[email protected]
Date
2022-04-23 20:45:52 -0700 (Sat, 23 Apr 2022)

Log Message

Remove the `PreferInlineTextSelectionInImages` internal feature flag
https://bugs.webkit.org/show_bug.cgi?id=234849

Reviewed by Sam Weinig.

Source/WebCore:

See WebKit/ChangeLog for more details.

* en.lproj/Localizable.strings:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::contextMenuItemSelected):
(WebCore::ContextMenuController::populate):
(WebCore::ContextMenuController::checkOrEnableIfNeeded const):
* page/EventHandler.cpp:
(WebCore::EventHandler::updateMouseEventTargetNode):
* platform/ContextMenuItem.cpp:
(WebCore::isValidContextMenuAction):
* platform/ContextMenuItem.h:
* platform/LocalizedStrings.h:
* platform/cocoa/LocalizedStringsCocoa.mm:
(WebCore::contextMenuItemTagQuickLookImage): Deleted.
(WebCore::contextMenuItemTagQuickLookImageForTextSelection): Deleted.
(WebCore::contextMenuItemTagQuickLookImageForVisualSearch): Deleted.

Source/WebKit:

This patch reverts r279164, which introduced an internal feature to avoid Live Text analysis when hovering over
images, and instead added a new context menu item to reveal selectable text in the image by launching the
QuickLook panel in Live Text mode.

This alternate Live Text experience was originally devised as a way to mitigate the power and performance impact
of passively triggering Live Text analysis when hovering over images on pre-M1 devices, but this mitigation was
ultimately deemed unnecessary in macOS 12.

* Shared/API/c/WKSharedAPICast.h:
(WebKit::toAPI):
(WebKit::toImpl):
* UIProcess/Cocoa/QuickLookPreviewActivity.h: Removed.
* UIProcess/Cocoa/WebViewImpl.h:
* UIProcess/Cocoa/WebViewImpl.mm:
(WebKit::WebViewImpl::computeHasVisualSearchResults):
(WebKit::WebViewImpl::computeHasImageAnalysisResults): Deleted.
* UIProcess/PageClient.h:
(WebKit::PageClient::computeHasVisualSearchResults):
(WebKit::PageClient::computeHasImageAnalysisResults): Deleted.
* UIProcess/WebContextMenuProxy.h:
(WebKit::WebContextMenuProxy::quickLookPreviewActivity const): Deleted.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::contextMenuItemSelected):
(WebKit::WebPageProxy::computeHasVisualSearchResults):
(WebKit::WebPageProxy::computeHasImageAnalysisResults): Deleted.
* UIProcess/WebPageProxy.h:
* UIProcess/mac/PageClientImplMac.h:
* UIProcess/mac/PageClientImplMac.mm:
(WebKit::PageClientImpl::computeHasVisualSearchResults):
(WebKit::PageClientImpl::computeHasImageAnalysisResults): Deleted.
* UIProcess/mac/WKQuickLookPreviewController.h:
* UIProcess/mac/WKQuickLookPreviewController.mm:
* UIProcess/mac/WebContextMenuProxyMac.h:
* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::menuItemIdentifier):
(WebKit::WebContextMenuProxyMac::getContextMenuFromItems):
(WebKit::WebContextMenuProxyMac::insertOrUpdateQuickLookImageItem): Deleted.
(WebKit::WebContextMenuProxyMac::updateQuickLookContextMenuItemTitle): Deleted.
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::handleContextMenuLookUpImage):
(WebKit::WebPageProxy::handleContextMenuQuickLookImage): Deleted.
* WebKit.xcodeproj/project.pbxproj:

Source/WebKitLegacy/mac:

See WebKit/ChangeLog for more details.

* WebView/WebHTMLView.mm:
(toTag):

Source/WTF:

See WebKit/ChangeLog for more details.

* Scripts/Preferences/WebPreferencesInternal.yaml:

Modified Paths

Removed Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (293298 => 293299)


--- trunk/Source/WTF/ChangeLog	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WTF/ChangeLog	2022-04-24 03:45:52 UTC (rev 293299)
@@ -1,3 +1,14 @@
+2022-04-23  Wenson Hsieh  <[email protected]>
+
+        Remove the `PreferInlineTextSelectionInImages` internal feature flag
+        https://bugs.webkit.org/show_bug.cgi?id=234849
+
+        Reviewed by Sam Weinig.
+
+        See WebKit/ChangeLog for more details.
+
+        * Scripts/Preferences/WebPreferencesInternal.yaml:
+
 2022-04-22  Chris Dumez  <[email protected]>
 
         Move global AtomStrings to a common header to promote reuse

Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml (293298 => 293299)


--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml	2022-04-24 03:45:52 UTC (rev 293299)
@@ -744,22 +744,6 @@
       "PLATFORM(IOS_FAMILY) && !PLATFORM(WATCHOS)": true
       default: false
 
-PreferInlineTextSelectionInImages:
-  type: bool
-  humanReadableName: "Inline Text Selection in Images"
-  humanReadableDescription: "Prefer inline text selection in images over using the context menu"
-  condition: ENABLE(IMAGE_ANALYSIS)
-  defaultValue:
-    WebCore:
-      "HAVE(UIKIT_WEBKIT_INTERNALS)": false
-      default: true
-    WebKitLegacy:
-      "HAVE(UIKIT_WEBKIT_INTERNALS)": false
-      default: true
-    WebKit:
-      "HAVE(UIKIT_WEBKIT_INTERNALS)": false
-      default: true
-
 PreferSandboxedMediaParsing:
   type: bool
   humanReadableName: "Prefer Sandboxed Parsing of Media"

Modified: trunk/Source/WebCore/ChangeLog (293298 => 293299)


--- trunk/Source/WebCore/ChangeLog	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebCore/ChangeLog	2022-04-24 03:45:52 UTC (rev 293299)
@@ -1,3 +1,28 @@
+2022-04-23  Wenson Hsieh  <[email protected]>
+
+        Remove the `PreferInlineTextSelectionInImages` internal feature flag
+        https://bugs.webkit.org/show_bug.cgi?id=234849
+
+        Reviewed by Sam Weinig.
+
+        See WebKit/ChangeLog for more details.
+
+        * en.lproj/Localizable.strings:
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::contextMenuItemSelected):
+        (WebCore::ContextMenuController::populate):
+        (WebCore::ContextMenuController::checkOrEnableIfNeeded const):
+        * page/EventHandler.cpp:
+        (WebCore::EventHandler::updateMouseEventTargetNode):
+        * platform/ContextMenuItem.cpp:
+        (WebCore::isValidContextMenuAction):
+        * platform/ContextMenuItem.h:
+        * platform/LocalizedStrings.h:
+        * platform/cocoa/LocalizedStringsCocoa.mm:
+        (WebCore::contextMenuItemTagQuickLookImage): Deleted.
+        (WebCore::contextMenuItemTagQuickLookImageForTextSelection): Deleted.
+        (WebCore::contextMenuItemTagQuickLookImageForVisualSearch): Deleted.
+
 2022-04-23  Andres Gonzalez  <[email protected]>
 
         Code cleanup in preparation for optimizing use of AccessibilityObject::elementsFromAttribute.

Modified: trunk/Source/WebCore/en.lproj/Localizable.strings (293298 => 293299)


--- trunk/Source/WebCore/en.lproj/Localizable.strings	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebCore/en.lproj/Localizable.strings	2022-04-24 03:45:52 UTC (rev 293299)
@@ -622,9 +622,6 @@
 /* Look Up in Dictionary context menu item */
 "Look Up in Dictionary" = "Look Up in Dictionary";
 
-/* Title for Quick Look action button for images with visual search results */
-"Look Up in Quick Look" = "Look Up in Quick Look";
-
 /* Look Up context menu item with selected word */
 "Look Up “%@”" = "Look Up “%@”";
 
@@ -802,9 +799,6 @@
 /* Title for file upload progress view */
 "Preparing (file upload)" = "Preparing…";
 
-/* Title for Quick Look action button */
-"Quick Look" = "Quick Look";
-
 /* Undo action name */
 "Raise Baseline (Undo action name)" = "Raise Baseline";
 
@@ -847,9 +841,6 @@
 /* Search with search provider context menu item with provider name inserted */
 "Search with %@" = "Search with %@";
 
-/* Title for Quick Look action button for images with text */
-"Select Text in Quick Look" = "Select Text in Quick Look";
-
 /* Validation message for required file inputs that have no value */
 "Select a file" = "Select a file";
 

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (293298 => 293299)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2022-04-24 03:45:52 UTC (rev 293299)
@@ -527,7 +527,7 @@
         frame->editor().applyDictationAlternative(title);
         break;
     case ContextMenuItemTagCopyCroppedImage:
-    case ContextMenuItemTagQuickLookImage:
+    case ContextMenuItemTagLookUpImage:
         // These should be handled at the client layer.
         ASSERT_NOT_REACHED();
         break;
@@ -836,6 +836,9 @@
     ContextMenuItem SelectAllItem(ActionType, ContextMenuItemTagSelectAll, contextMenuItemTagSelectAll());
     ContextMenuItem InsertEmojiItem(ActionType, ContextMenuItemTagInsertEmoji, contextMenuItemTagInsertEmoji());
 #endif
+#if ENABLE(IMAGE_ANALYSIS)
+    ContextMenuItem LookUpImageItem(ActionType, ContextMenuItemTagLookUpImage, contextMenuItemTagLookUpImage());
+#endif
 
 #if PLATFORM(GTK) || PLATFORM(WIN)
     ContextMenuItem ShareMenuItem;
@@ -864,12 +867,6 @@
         return;
 #endif
 
-#if ENABLE(IMAGE_ANALYSIS)
-    bool shouldAppendQuickLookImageItem = false;
-    auto quickLookItemTitle = frame->settings().preferInlineTextSelectionInImages() ? contextMenuItemTagLookUpImage() : contextMenuItemTagQuickLookImage();
-    ContextMenuItem QuickLookImageItem { ActionType, ContextMenuItemTagQuickLookImage, quickLookItemTitle };
-#endif
-
     auto addSelectedTextActionsIfNeeded = [&] (const String& selectedText) {
         if (selectedText.isEmpty())
             return;
@@ -923,7 +920,8 @@
                         appendItem(copyCroppedImageItem, m_contextMenu.get());
 #endif
 #if ENABLE(IMAGE_ANALYSIS)
-                    shouldAppendQuickLookImageItem = m_client.supportsLookUpInImages();
+                    if (m_client.supportsLookUpInImages())
+                        appendItem(LookUpImageItem, m_contextMenu.get());
 #endif
                 }
             }
@@ -1188,18 +1186,6 @@
             appendItem(ShareMenuItem, m_contextMenu.get());
         }
     }
-
-#if ENABLE(IMAGE_ANALYSIS)
-    if (shouldAppendQuickLookImageItem) {
-        if (!frame->settings().preferInlineTextSelectionInImages()) {
-            // In the case where inline text selection is enabled, the Look Up item is only added if
-            // we discover visual look up results after image analysis. In that scenario, a separator
-            // is only added before the Look Up item once we're certain that we want to show it.
-            appendItem(*separatorItem(), m_contextMenu.get());
-        }
-        appendItem(QuickLookImageItem, m_contextMenu.get());
-    }
-#endif // ENABLE(IMAGE_ANALYSIS)
 }
 
 void ContextMenuController::addInspectElementItem()
@@ -1526,7 +1512,7 @@
             shouldEnable = m_context.hitTestResult().mediaHasAudio();
             shouldCheck = shouldEnable &&  m_context.hitTestResult().mediaMuted();
             break;
-        case ContextMenuItemTagQuickLookImage:
+        case ContextMenuItemTagLookUpImage:
         case ContextMenuItemTagTranslate:
             break;
     }

Modified: trunk/Source/WebCore/page/EventHandler.cpp (293298 => 293299)


--- trunk/Source/WebCore/page/EventHandler.cpp	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebCore/page/EventHandler.cpp	2022-04-24 03:45:52 UTC (rev 293299)
@@ -2578,12 +2578,10 @@
     m_elementUnderMouse = targetElement;
 
 #if ENABLE(IMAGE_ANALYSIS)
-    if (m_frame.settings().preferInlineTextSelectionInImages()) {
-        if (!textRecognitionCandidateElement())
-            m_textRecognitionHoverTimer.stop();
-        else if (!platformMouseEvent.movementDelta().isZero())
-            m_textRecognitionHoverTimer.restart();
-    }
+    if (!textRecognitionCandidateElement())
+        m_textRecognitionHoverTimer.stop();
+    else if (!platformMouseEvent.movementDelta().isZero())
+        m_textRecognitionHoverTimer.restart();
 #endif // ENABLE(IMAGE_ANALYSIS)
 
     if (auto* page = m_frame.page())

Modified: trunk/Source/WebCore/platform/ContextMenuItem.cpp (293298 => 293299)


--- trunk/Source/WebCore/platform/ContextMenuItem.cpp	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebCore/platform/ContextMenuItem.cpp	2022-04-24 03:45:52 UTC (rev 293299)
@@ -259,7 +259,7 @@
     case ContextMenuAction::ContextMenuItemTagToggleVideoFullscreen:
     case ContextMenuAction::ContextMenuItemTagShareMenu:
     case ContextMenuAction::ContextMenuItemTagToggleVideoEnhancedFullscreen:
-    case ContextMenuAction::ContextMenuItemTagQuickLookImage:
+    case ContextMenuAction::ContextMenuItemTagLookUpImage:
     case ContextMenuAction::ContextMenuItemTagTranslate:
     case ContextMenuAction::ContextMenuItemBaseCustomTag:
     case ContextMenuAction::ContextMenuItemLastCustomTag:

Modified: trunk/Source/WebCore/platform/ContextMenuItem.h (293298 => 293299)


--- trunk/Source/WebCore/platform/ContextMenuItem.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebCore/platform/ContextMenuItem.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -147,7 +147,7 @@
     ContextMenuItemTagToggleVideoEnhancedFullscreen,
     ContextMenuItemTagAddHighlightToCurrentQuickNote,
     ContextMenuItemTagAddHighlightToNewQuickNote,
-    ContextMenuItemTagQuickLookImage,
+    ContextMenuItemTagLookUpImage,
     ContextMenuItemTagTranslate,
     ContextMenuItemTagCopyCroppedImage,
     ContextMenuItemLastNonCustomTag = ContextMenuItemTagCopyCroppedImage,

Modified: trunk/Source/WebCore/platform/LocalizedStrings.h (293298 => 293299)


--- trunk/Source/WebCore/platform/LocalizedStrings.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebCore/platform/LocalizedStrings.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -372,10 +372,7 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
     WEBCORE_EXPORT String contextMenuItemTagLookUpImage();
-    WEBCORE_EXPORT String contextMenuItemTagQuickLookImage();
-    WEBCORE_EXPORT String contextMenuItemTagQuickLookImageForTextSelection();
-    WEBCORE_EXPORT String contextMenuItemTagQuickLookImageForVisualSearch();
-#endif // ENABLE(IMAGE_ANALYSIS)
+#endif
 
 #if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
     WEBCORE_EXPORT String contextMenuItemTagCopyCroppedImage();

Modified: trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm (293298 => 293299)


--- trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm	2022-04-24 03:45:52 UTC (rev 293299)
@@ -302,23 +302,8 @@
     return WEB_UI_STRING("Look Up", "Title for Look Up action button");
 }
 
-String contextMenuItemTagQuickLookImage()
-{
-    return WEB_UI_STRING("Quick Look", "Title for Quick Look action button");
-}
+#endif
 
-String contextMenuItemTagQuickLookImageForTextSelection()
-{
-    return WEB_UI_STRING("Select Text in Quick Look", "Title for Quick Look action button for images with text");
-}
-
-String contextMenuItemTagQuickLookImageForVisualSearch()
-{
-    return WEB_UI_STRING("Look Up in Quick Look", "Title for Quick Look action button for images with visual search results");
-}
-
-#endif // ENABLE(IMAGE_ANALYSIS)
-
 #if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
 
 String contextMenuItemTagCopyCroppedImage()

Modified: trunk/Source/WebKit/ChangeLog (293298 => 293299)


--- trunk/Source/WebKit/ChangeLog	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/ChangeLog	2022-04-24 03:45:52 UTC (rev 293299)
@@ -1,3 +1,53 @@
+2022-04-23  Wenson Hsieh  <[email protected]>
+
+        Remove the `PreferInlineTextSelectionInImages` internal feature flag
+        https://bugs.webkit.org/show_bug.cgi?id=234849
+
+        Reviewed by Sam Weinig.
+
+        This patch reverts r279164, which introduced an internal feature to avoid Live Text analysis when hovering over
+        images, and instead added a new context menu item to reveal selectable text in the image by launching the
+        QuickLook panel in Live Text mode.
+
+        This alternate Live Text experience was originally devised as a way to mitigate the power and performance impact
+        of passively triggering Live Text analysis when hovering over images on pre-M1 devices, but this mitigation was
+        ultimately deemed unnecessary in macOS 12.
+
+        * Shared/API/c/WKSharedAPICast.h:
+        (WebKit::toAPI):
+        (WebKit::toImpl):
+        * UIProcess/Cocoa/QuickLookPreviewActivity.h: Removed.
+        * UIProcess/Cocoa/WebViewImpl.h:
+        * UIProcess/Cocoa/WebViewImpl.mm:
+        (WebKit::WebViewImpl::computeHasVisualSearchResults):
+        (WebKit::WebViewImpl::computeHasImageAnalysisResults): Deleted.
+        * UIProcess/PageClient.h:
+        (WebKit::PageClient::computeHasVisualSearchResults):
+        (WebKit::PageClient::computeHasImageAnalysisResults): Deleted.
+        * UIProcess/WebContextMenuProxy.h:
+        (WebKit::WebContextMenuProxy::quickLookPreviewActivity const): Deleted.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::contextMenuItemSelected):
+        (WebKit::WebPageProxy::computeHasVisualSearchResults):
+        (WebKit::WebPageProxy::computeHasImageAnalysisResults): Deleted.
+        * UIProcess/WebPageProxy.h:
+        * UIProcess/mac/PageClientImplMac.h:
+        * UIProcess/mac/PageClientImplMac.mm:
+        (WebKit::PageClientImpl::computeHasVisualSearchResults):
+        (WebKit::PageClientImpl::computeHasImageAnalysisResults): Deleted.
+        * UIProcess/mac/WKQuickLookPreviewController.h:
+        * UIProcess/mac/WKQuickLookPreviewController.mm:
+        * UIProcess/mac/WebContextMenuProxyMac.h:
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::menuItemIdentifier):
+        (WebKit::WebContextMenuProxyMac::getContextMenuFromItems):
+        (WebKit::WebContextMenuProxyMac::insertOrUpdateQuickLookImageItem): Deleted.
+        (WebKit::WebContextMenuProxyMac::updateQuickLookContextMenuItemTitle): Deleted.
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::handleContextMenuLookUpImage):
+        (WebKit::WebPageProxy::handleContextMenuQuickLookImage): Deleted.
+        * WebKit.xcodeproj/project.pbxproj:
+
 2022-04-23  Brady Eidson  <[email protected]>
 
         Add WKNotification and WKWebsiteDataStore SPI for handling click/close of persistent notifications

Modified: trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h (293298 => 293299)


--- trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -543,7 +543,7 @@
 #endif
     case WebCore::ContextMenuItemTagShareMenu:
         return kWKContextMenuItemTagShareMenu;
-    case WebCore::ContextMenuItemTagQuickLookImage:
+    case WebCore::ContextMenuItemTagLookUpImage:
         return kWKContextMenuItemTagRevealImage;
     case WebCore::ContextMenuItemTagTranslate:
         return kWKContextMenuItemTagTranslate;
@@ -748,7 +748,7 @@
         return WebCore::ContextMenuItemTagShareMenu;
 #endif
     case kWKContextMenuItemTagRevealImage:
-        return WebCore::ContextMenuItemTagQuickLookImage;
+        return WebCore::ContextMenuItemTagLookUpImage;
     case kWKContextMenuItemTagTranslate:
         return WebCore::ContextMenuItemTagTranslate;
     case kWKContextMenuItemTagCopyCroppedImage:

Deleted: trunk/Source/WebKit/UIProcess/Cocoa/QuickLookPreviewActivity.h (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/Cocoa/QuickLookPreviewActivity.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/Cocoa/QuickLookPreviewActivity.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -1,39 +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 PLATFORM(COCOA)
-
-namespace WebKit {
-
-enum class QuickLookPreviewActivity : uint8_t {
-    None,
-    VisualSearch,
-};
-
-} // namespace WebKit
-
-#endif // PLATFORM(COCOA)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -171,7 +171,6 @@
 struct WebHitTestResultData;
 
 enum class ContinueUnsafeLoad : bool;
-enum class ImageAnalysisType : uint8_t;
 enum class UndoOrRedo : bool;
 
 typedef id <NSValidatedUserInterfaceItem> ValidationItem;
@@ -596,7 +595,7 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
     void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
-    void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
+    void computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&&);
 #endif
 
 #if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)

Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm	2022-04-24 03:45:52 UTC (rev 293299)
@@ -280,7 +280,7 @@
     });
 }
 
-void WebViewImpl::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
+void WebViewImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
 {
     if (!isLiveTextAvailableAndEnabled()) {
         completion(false);
@@ -288,13 +288,12 @@
     }
 
     auto cgImage = imageBitmap.makeCGImage();
-    auto analysisType = type == ImageAnalysisType::VisualSearch ? VKAnalysisTypeVisualSearch : VKAnalysisTypeText;
-    auto request = createImageAnalyzerRequest(cgImage.get(), imageURL, [NSURL _web_URLWithWTFString:m_page->currentURL()], analysisType);
+    auto request = createImageAnalyzerRequest(cgImage.get(), imageURL, [NSURL _web_URLWithWTFString:m_page->currentURL()], VKAnalysisTypeVisualSearch);
     auto startTime = MonotonicTime::now();
-    [ensureImageAnalyzer() processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion), startTime, analysisType] (CocoaImageAnalysis *analysis, NSError *) mutable {
-        BOOL result = [analysis hasResultsForAnalysisTypes:analysisType];
-        CFRunLoopPerformBlock(CFRunLoopGetMain(), (__bridge CFStringRef)NSEventTrackingRunLoopMode, makeBlockPtr([completion = WTFMove(completion), result, analysisType, startTime] () mutable {
-            RELEASE_LOG(Images, "Image analysis completed in %.0f ms (found %s? %d)", (MonotonicTime::now() - startTime).milliseconds(), analysisType == VKAnalysisTypeVisualSearch ? "visual search results" : "text", result);
+    [ensureImageAnalyzer() processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion), startTime] (CocoaImageAnalysis *analysis, NSError *) mutable {
+        BOOL result = [analysis hasResultsForAnalysisTypes:VKAnalysisTypeVisualSearch];
+        CFRunLoopPerformBlock(CFRunLoopGetMain(), (__bridge CFStringRef)NSEventTrackingRunLoopMode, makeBlockPtr([completion = WTFMove(completion), result, startTime] () mutable {
+            RELEASE_LOG(Images, "Image analysis completed in %.0f ms (found visual search results? %d)", (MonotonicTime::now() - startTime).milliseconds(), result);
             completion(result);
         }).get());
         CFRunLoopWakeUp(CFRunLoopGetMain());

Modified: trunk/Source/WebKit/UIProcess/PageClient.h (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/PageClient.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/PageClient.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -165,10 +165,6 @@
 
 enum class ContinueUnsafeLoad : bool { No, Yes };
 
-#if ENABLE(IMAGE_ANALYSIS)
-enum class ImageAnalysisType : uint8_t { Text, VisualSearch };
-#endif
-
 struct FocusedElementInformation;
 struct FrameInfoData;
 struct InteractionInformationAtPosition;
@@ -560,7 +556,7 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
     virtual void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion) { completion({ }); }
-    virtual void computeHasImageAnalysisResults(const URL&, ShareableBitmap&, ImageAnalysisType, CompletionHandler<void(bool)>&& completion) { completion(false); }
+    virtual void computeHasVisualSearchResults(const URL&, ShareableBitmap&, CompletionHandler<void(bool)>&& completion) { completion(false); }
 #endif
 
 #if ENABLE(MEDIA_CONTROLS_CONTEXT_MENUS) && USE(UICONTEXTMENU)

Modified: trunk/Source/WebKit/UIProcess/WebContextMenuProxy.h (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/WebContextMenuProxy.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/WebContextMenuProxy.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -33,10 +33,6 @@
 #include <wtf/RefCounted.h>
 #include <wtf/WeakPtr.h>
 
-#if PLATFORM(COCOA)
-#include "QuickLookPreviewActivity.h"
-#endif
-
 OBJC_CLASS NSMenu;
 
 namespace WebKit {
@@ -55,7 +51,6 @@
 #if PLATFORM(COCOA)
     virtual NSMenu *platformMenu() const = 0;
     virtual NSArray *platformData() const = 0;
-    virtual QuickLookPreviewActivity quickLookPreviewActivity() const { return QuickLookPreviewActivity::None; };
 #endif // PLATFORM(COCOA)
 
 protected:

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2022-04-24 03:45:52 UTC (rev 293299)
@@ -216,7 +216,6 @@
 
 #if PLATFORM(COCOA)
 #include "InsertTextOptions.h"
-#include "QuickLookPreviewActivity.h"
 #include "RemoteLayerTreeDrawingAreaProxy.h"
 #include "RemoteLayerTreeScrollingPerformanceData.h"
 #include "UserMediaCaptureManagerProxy.h"
@@ -7206,10 +7205,9 @@
         ++m_pendingLearnOrIgnoreWordMessageCount;
         break;
 
-    case ContextMenuItemTagQuickLookImage:
+    case ContextMenuItemTagLookUpImage:
 #if ENABLE(IMAGE_ANALYSIS)
-        if (m_activeContextMenu)
-            handleContextMenuQuickLookImage(m_activeContextMenu->quickLookPreviewActivity());
+        handleContextMenuLookUpImage();
 #endif
         return;
 
@@ -8842,9 +8840,9 @@
     pageClient().requestTextRecognition(imageURL, imageData, identifier, WTFMove(completionHandler));
 }
 
-void WebPageProxy::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
+void WebPageProxy::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
 {
-    pageClient().computeHasImageAnalysisResults(imageURL, imageBitmap, type, WTFMove(completion));
+    pageClient().computeHasVisualSearchResults(imageURL, imageBitmap, WTFMove(completion));
 }
 
 void WebPageProxy::updateWithTextRecognitionResult(TextRecognitionResult&& results, const ElementContext& context, const FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&& completionHandler)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -421,8 +421,6 @@
 struct WebPopupItem;
 struct WebSpeechSynthesisVoice;
 
-enum class ImageAnalysisType : uint8_t;
-enum class TapHandlingResult : uint8_t;
 enum class TextRecognitionUpdateResult : uint8_t;
 enum class NegotiatedLegacyTLS : bool;
 enum class ProcessSwapRequestedByClient : bool;
@@ -1762,7 +1760,7 @@
 #if ENABLE(IMAGE_ANALYSIS)
     void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
     void updateWithTextRecognitionResult(WebCore::TextRecognitionResult&&, const WebCore::ElementContext&, const WebCore::FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&&);
-    void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
+    void computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&&);
     void startImageAnalysis(const String& identifier);
 #endif
 
@@ -2034,7 +2032,7 @@
 
 #if ENABLE(CONTEXT_MENUS)
 #if ENABLE(IMAGE_ANALYSIS)
-    void handleContextMenuQuickLookImage(QuickLookPreviewActivity);
+    void handleContextMenuLookUpImage();
 #endif
 #if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
     void handleContextMenuCopyCroppedImage(ShareableBitmap&, const String& preferredMIMEType);

Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -132,7 +132,7 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
     void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&) override;
-    void computeHasImageAnalysisResults(const URL&, ShareableBitmap&, ImageAnalysisType, CompletionHandler<void(bool)>&&) override;
+    void computeHasVisualSearchResults(const URL&, ShareableBitmap&, CompletionHandler<void(bool)>&&) override;
 #endif
 
     RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;

Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm	2022-04-24 03:45:52 UTC (rev 293299)
@@ -489,12 +489,12 @@
     m_impl->requestTextRecognition(imageURL, imageData, identifier, WTFMove(completion));
 }
 
-void PageClientImpl::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
+void PageClientImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
 {
-    m_impl->computeHasImageAnalysisResults(imageURL, imageBitmap, type, WTFMove(completion));
+    m_impl->computeHasVisualSearchResults(imageURL, imageBitmap, WTFMove(completion));
 }
 
-#endif // ENABLE(IMAGE_ANALYSIS)
+#endif
 
 RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page)
 {

Modified: trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -31,7 +31,7 @@
 
 namespace WebKit {
 class WebPageProxy;
-enum class QuickLookPreviewActivity : uint8_t;
+enum class QuickLookPreviewActivity : uint8_t { None, VisualSearch };
 }
 
 @class QLPreviewPanel;

Modified: trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.mm (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.mm	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.mm	2022-04-24 03:45:52 UTC (rev 293299)
@@ -28,7 +28,6 @@
 
 #if HAVE(QUICKLOOK_PREVIEW_ITEM_DATA_PROVIDER)
 
-#import "QuickLookPreviewActivity.h"
 #import "WebPageProxy.h"
 #import <wtf/RetainPtr.h>
 #import <pal/mac/QuickLookUISoftLink.h>

Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h	2022-04-24 03:45:52 UTC (rev 293299)
@@ -61,13 +61,6 @@
 private:
     WebContextMenuProxyMac(NSView *, WebPageProxy&, ContextMenuContextData&&, const UserData&);
 
-    QuickLookPreviewActivity quickLookPreviewActivity() const final { return m_quickLookPreviewActivity; }
-
-#if ENABLE(IMAGE_ANALYSIS)
-    void insertOrUpdateQuickLookImageItem(const URL& imageURL, Ref<ShareableBitmap>&& imageBitmap, std::optional<WebContextMenuItemData>&&, bool);
-    void updateQuickLookContextMenuItemTitle(const String&);
-#endif
-
     void show() override;
     void showContextMenuWithItems(Vector<Ref<WebContextMenuItem>>&&) override;
     void useContextMenuItems(Vector<Ref<WebContextMenuItem>>&&) override;
@@ -87,7 +80,6 @@
     RetainPtr<NSMenu> m_menu;
     RetainPtr<WKMenuDelegate> m_menuDelegate;
     WeakObjCPtr<NSView> m_webView;
-    QuickLookPreviewActivity m_quickLookPreviewActivity { QuickLookPreviewActivity::None };
 };
 
 } // namespace WebKit

Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2022-04-24 03:45:52 UTC (rev 293299)
@@ -41,7 +41,6 @@
 #import "WebContextMenuItem.h"
 #import "WebContextMenuItemData.h"
 #import "WebPageProxy.h"
-#import "WebPreferences.h"
 #import <WebCore/GraphicsContext.h>
 #import <WebCore/IntRect.h>
 #import <WebCore/LocalizedStrings.h>
@@ -513,7 +512,7 @@
     case ContextMenuItemTagReload:
         return _WKMenuItemIdentifierReload;
 
-    case ContextMenuItemTagQuickLookImage:
+    case ContextMenuItemTagLookUpImage:
         return _WKMenuItemIdentifierRevealImage;
 
     case ContextMenuItemTagSearchWeb:
@@ -602,23 +601,18 @@
         });
     }
 
-    bool shouldUpdateQuickLookItemTitle = false;
-    std::optional<WebContextMenuItemData> quickLookItemToInsertIfNeeded;
+    std::optional<WebContextMenuItemData> lookUpImageItem;
 
 #if ENABLE(IMAGE_ANALYSIS)
-    auto indexOfQuickLookItem = filteredItems.findIf([&] (auto& item) {
-        return item.action() == WebCore::ContextMenuItemTagQuickLookImage;
+    filteredItems.removeFirstMatching([&] (auto& item) {
+        if (item.action() != WebCore::ContextMenuItemTagLookUpImage)
+            return false;
+
+        lookUpImageItem = { item };
+        return true;
     });
+#endif
 
-    if (indexOfQuickLookItem != notFound) {
-        if (auto page = this->page(); page && page->preferences().preferInlineTextSelectionInImages()) {
-            quickLookItemToInsertIfNeeded = filteredItems[indexOfQuickLookItem];
-            filteredItems.remove(indexOfQuickLookItem);
-        } else
-            shouldUpdateQuickLookItemTitle = true;
-    }
-#endif // ENABLE(IMAGE_ANALYSIS)
-
 #if HAVE(TRANSLATION_UI_SERVICES)
     if (!page()->canHandleContextMenuTranslation() || isPopover) {
         filteredItems.removeAllMatching([] (auto& item) {
@@ -633,8 +627,8 @@
     auto imageURL = URL { hitTestData.absoluteImageURL };
     auto imageBitmap = hitTestData.imageBitmap;
 
-    auto sparseMenuItems = retainPtr([NSPointerArray strongObjectsPointerArray]);
-    auto insertMenuItem = makeBlockPtr([protectedThis = Ref { *this }, weakPage = WeakPtr { page() }, imageURL = WTFMove(imageURL), imageBitmap = WTFMove(imageBitmap), shouldUpdateQuickLookItemTitle, quickLookItemToInsertIfNeeded = WTFMove(quickLookItemToInsertIfNeeded), completionHandler = WTFMove(completionHandler), itemsRemaining = filteredItems.size(), menu = WTFMove(menu), sparseMenuItems](NSMenuItem *item, NSUInteger index) mutable {
+    RetainPtr sparseMenuItems = [NSPointerArray strongObjectsPointerArray];
+    auto insertMenuItem = makeBlockPtr([protectedThis = Ref { *this }, weakPage = WeakPtr { page() }, imageURL = WTFMove(imageURL), imageBitmap = WTFMove(imageBitmap), lookUpImageItem = WTFMove(lookUpImageItem), completionHandler = WTFMove(completionHandler), itemsRemaining = filteredItems.size(), menu = WTFMove(menu), sparseMenuItems](NSMenuItem *item, NSUInteger index) mutable {
         ASSERT(index < [sparseMenuItems count]);
         ASSERT(![sparseMenuItems pointerAtIndex:index]);
         [sparseMenuItems replacePointerAtIndex:index withPointer:item];
@@ -643,13 +637,14 @@
 
         [menu setItemArray:[sparseMenuItems allObjects]];
 
-        RefPtr page { weakPage.get() };
-        if (page && imageBitmap) {
+        RefPtr page = weakPage.get();
+        if (lookUpImageItem && page && imageBitmap) {
 #if ENABLE(IMAGE_ANALYSIS)
-            protectedThis->insertOrUpdateQuickLookImageItem(imageURL, imageBitmap.releaseNonNull(), WTFMove(quickLookItemToInsertIfNeeded), shouldUpdateQuickLookItemTitle);
+            page->computeHasVisualSearchResults(imageURL, *imageBitmap, [protectedThis = WTFMove(protectedThis), lookUpImageItem = WTFMove(*lookUpImageItem)] (bool hasVisualSearchResults) mutable {
+                if (hasVisualSearchResults)
+                    [protectedThis->m_menu addItem:createMenuActionItem(lookUpImageItem).get()];
+            });
 #else
-            UNUSED_PARAM(quickLookItemToInsertIfNeeded);
-            UNUSED_PARAM(shouldUpdateQuickLookItemTitle);
             UNUSED_PARAM(imageURL);
 #endif
         }
@@ -665,63 +660,6 @@
     }
 }
 
-#if ENABLE(IMAGE_ANALYSIS)
-
-void WebContextMenuProxyMac::insertOrUpdateQuickLookImageItem(const URL& imageURL, Ref<ShareableBitmap>&& imageBitmap, std::optional<WebContextMenuItemData>&& quickLookItemToInsertIfNeeded, bool shouldUpdateQuickLookItemTitle)
-{
-    Ref page = *this->page();
-    if (quickLookItemToInsertIfNeeded) {
-        page->computeHasImageAnalysisResults(imageURL, imageBitmap.get(), ImageAnalysisType::VisualSearch, [weakThis = WeakPtr { *this }, quickLookItemToInsertIfNeeded = WTFMove(*quickLookItemToInsertIfNeeded)] (bool hasVisualSearchResults) mutable {
-            if (RefPtr protectedThis = weakThis.get(); protectedThis && hasVisualSearchResults) {
-                protectedThis->m_quickLookPreviewActivity = QuickLookPreviewActivity::VisualSearch;
-                [protectedThis->m_menu addItem:NSMenuItem.separatorItem];
-                [protectedThis->m_menu addItem:createMenuActionItem(quickLookItemToInsertIfNeeded).get()];
-            }
-        });
-        return;
-    }
-
-    if (shouldUpdateQuickLookItemTitle) {
-        page->computeHasImageAnalysisResults(imageURL, imageBitmap.get(), ImageAnalysisType::VisualSearch, [weakThis = WeakPtr { *this }, weakPage = WeakPtr { page }, imageURL, imageBitmap = WTFMove(imageBitmap)] (bool hasVisualSearchResults) mutable {
-            RefPtr protectedThis { weakThis.get() };
-            if (!protectedThis)
-                return;
-
-            RefPtr page { weakPage.get() };
-            if (!page)
-                return;
-
-            if (hasVisualSearchResults) {
-                protectedThis->m_quickLookPreviewActivity = QuickLookPreviewActivity::VisualSearch;
-                protectedThis->updateQuickLookContextMenuItemTitle(contextMenuItemTagQuickLookImageForVisualSearch());
-                return;
-            }
-
-            page->computeHasImageAnalysisResults(imageURL, imageBitmap.get(), ImageAnalysisType::Text, [weakThis = WTFMove(weakThis), weakPage] (bool hasText) mutable {
-                RefPtr protectedThis { weakThis.get() };
-                if (!protectedThis)
-                    return;
-
-                if (RefPtr page = weakPage.get(); page && hasText)
-                    protectedThis->updateQuickLookContextMenuItemTitle(contextMenuItemTagQuickLookImageForTextSelection());
-            });
-        });
-    }
-}
-
-void WebContextMenuProxyMac::updateQuickLookContextMenuItemTitle(const String& newTitle)
-{
-    for (NSInteger itemIndex = 0; itemIndex < [m_menu numberOfItems]; ++itemIndex) {
-        auto item = [m_menu itemAtIndex:itemIndex];
-        if (static_cast<ContextMenuAction>(item.tag) == ContextMenuItemTagQuickLookImage) {
-            item.title = newTitle;
-            break;
-        }
-    }
-}
-
-#endif // ENABLE(IMAGE_ANALYSIS)
-
 void WebContextMenuProxyMac::getContextMenuItem(const WebContextMenuItemData& item, CompletionHandler<void(NSMenuItem *)>&& completionHandler)
 {
 #if ENABLE(SERVICE_CONTROLS)

Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (293298 => 293299)


--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2022-04-24 03:45:52 UTC (rev 293299)
@@ -730,7 +730,7 @@
 
 #if ENABLE(IMAGE_ANALYSIS)
 
-void WebPageProxy::handleContextMenuQuickLookImage(QuickLookPreviewActivity activity)
+void WebPageProxy::handleContextMenuLookUpImage()
 {
     ASSERT(m_activeContextMenuContextData.webHitTestResultData());
     
@@ -738,7 +738,7 @@
     if (!result.imageBitmap)
         return;
 
-    showImageInQuickLookPreviewPanel(*result.imageBitmap, result.toolTipText, URL { result.absoluteImageURL }, activity);
+    showImageInQuickLookPreviewPanel(*result.imageBitmap, result.toolTipText, URL { result.absoluteImageURL }, QuickLookPreviewActivity::VisualSearch);
 }
 
 void WebPageProxy::showImageInQuickLookPreviewPanel(ShareableBitmap& imageBitmap, const String& tooltip, const URL& imageURL, QuickLookPreviewActivity activity)

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (293298 => 293299)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2022-04-24 03:45:52 UTC (rev 293299)
@@ -7203,7 +7203,6 @@
 		F4517D7A26FBCD38004C8475 /* RemoteRenderingBackendMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RemoteRenderingBackendMessages.h; path = DerivedSources/WebKit/RemoteRenderingBackendMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		F451C1002703D853002BA03B /* RemoteDisplayListRecorder.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteDisplayListRecorder.messages.in; sourceTree = "<group>"; };
 		F4660BC125DEF08100E86598 /* PasteboardAccessIntent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardAccessIntent.h; sourceTree = "<group>"; };
-		F47A051626827A09007E5CF2 /* QuickLookPreviewActivity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QuickLookPreviewActivity.h; sourceTree = "<group>"; };
 		F48570A22644BEC400C05F71 /* Timeout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timeout.h; sourceTree = "<group>"; };
 		F48BB8DD26F9635D001C1C40 /* RemoteDisplayListRecorderProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteDisplayListRecorderProxy.h; sourceTree = "<group>"; };
 		F48BB8DE26F9635D001C1C40 /* RemoteDisplayListRecorderProxy.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = RemoteDisplayListRecorderProxy.cpp; sourceTree = "<group>"; };
@@ -8234,7 +8233,6 @@
 				CDA29A1F1CBEB5FB00901CCF /* PlaybackSessionManagerProxy.mm */,
 				C145CC0E23DCA427003A5EEB /* PreferenceObserver.h */,
 				C15CBB3323F34C3800300CC7 /* PreferenceObserver.mm */,
-				F47A051626827A09007E5CF2 /* QuickLookPreviewActivity.h */,
 				5CB7AFDD23C5273D00E49CF3 /* ResourceLoadDelegate.h */,
 				5CB7AFDE23C5273D00E49CF3 /* ResourceLoadDelegate.mm */,
 				5CA9854B210BEB730057EB6B /* SafeBrowsingWarningCocoa.mm */,

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (293298 => 293299)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2022-04-24 03:45:52 UTC (rev 293299)
@@ -1,3 +1,15 @@
+2022-04-23  Wenson Hsieh  <[email protected]>
+
+        Remove the `PreferInlineTextSelectionInImages` internal feature flag
+        https://bugs.webkit.org/show_bug.cgi?id=234849
+
+        Reviewed by Sam Weinig.
+
+        See WebKit/ChangeLog for more details.
+
+        * WebView/WebHTMLView.mm:
+        (toTag):
+
 2022-04-21  Brent Fulgham  <[email protected]>
 
         Remove XSS Auditor: Part 4 (Settings)

Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (293298 => 293299)


--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2022-04-24 02:27:34 UTC (rev 293298)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm	2022-04-24 03:45:52 UTC (rev 293299)
@@ -599,8 +599,8 @@
         return WebMenuItemTagToggleVideoEnhancedFullscreen;
     case ContextMenuItemTagTranslate:
         return WebMenuItemTagTranslate;
-    case ContextMenuItemTagQuickLookImage:
     case ContextMenuItemTagCopyCroppedImage:
+    case ContextMenuItemTagLookUpImage:
         return std::nullopt;
 
     case ContextMenuItemBaseCustomTag ... ContextMenuItemLastCustomTag:
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to