⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 293299 in webkit


Ignore:
Timestamp:
Apr 23, 2022, 8:45:52 PM (4 years ago)
Author:
Wenson Hsieh
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:
Location:
trunk/Source
Files:
1 deleted
28 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r293285 r293299  
     12022-04-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove the `PreferInlineTextSelectionInImages` internal feature flag
     4        https://bugs.webkit.org/show_bug.cgi?id=234849
     5
     6        Reviewed by Sam Weinig.
     7
     8        See WebKit/ChangeLog for more details.
     9
     10        * Scripts/Preferences/WebPreferencesInternal.yaml:
     11
    1122022-04-22  Chris Dumez  <cdumez@apple.com>
    213
  • trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml

    r293233 r293299  
    745745      default: false
    746746
    747 PreferInlineTextSelectionInImages:
    748   type: bool
    749   humanReadableName: "Inline Text Selection in Images"
    750   humanReadableDescription: "Prefer inline text selection in images over using the context menu"
    751   condition: ENABLE(IMAGE_ANALYSIS)
    752   defaultValue:
    753     WebCore:
    754       "HAVE(UIKIT_WEBKIT_INTERNALS)": false
    755       default: true
    756     WebKitLegacy:
    757       "HAVE(UIKIT_WEBKIT_INTERNALS)": false
    758       default: true
    759     WebKit:
    760       "HAVE(UIKIT_WEBKIT_INTERNALS)": false
    761       default: true
    762 
    763747PreferSandboxedMediaParsing:
    764748  type: bool
  • trunk/Source/WebCore/ChangeLog

    r293298 r293299  
     12022-04-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove the `PreferInlineTextSelectionInImages` internal feature flag
     4        https://bugs.webkit.org/show_bug.cgi?id=234849
     5
     6        Reviewed by Sam Weinig.
     7
     8        See WebKit/ChangeLog for more details.
     9
     10        * en.lproj/Localizable.strings:
     11        * page/ContextMenuController.cpp:
     12        (WebCore::ContextMenuController::contextMenuItemSelected):
     13        (WebCore::ContextMenuController::populate):
     14        (WebCore::ContextMenuController::checkOrEnableIfNeeded const):
     15        * page/EventHandler.cpp:
     16        (WebCore::EventHandler::updateMouseEventTargetNode):
     17        * platform/ContextMenuItem.cpp:
     18        (WebCore::isValidContextMenuAction):
     19        * platform/ContextMenuItem.h:
     20        * platform/LocalizedStrings.h:
     21        * platform/cocoa/LocalizedStringsCocoa.mm:
     22        (WebCore::contextMenuItemTagQuickLookImage): Deleted.
     23        (WebCore::contextMenuItemTagQuickLookImageForTextSelection): Deleted.
     24        (WebCore::contextMenuItemTagQuickLookImageForVisualSearch): Deleted.
     25
    1262022-04-23  Andres Gonzalez  <andresg_22@apple.com>
    227
  • trunk/Source/WebCore/en.lproj/Localizable.strings

    r292898 r293299  
    623623"Look Up in Dictionary" = "Look Up in Dictionary";
    624624
    625 /* Title for Quick Look action button for images with visual search results */
    626 "Look Up in Quick Look" = "Look Up in Quick Look";
    627 
    628625/* Look Up context menu item with selected word */
    629626"Look Up “%@”" = "Look Up “%@”";
     
    803800"Preparing (file upload)" = "Preparing…";
    804801
    805 /* Title for Quick Look action button */
    806 "Quick Look" = "Quick Look";
    807 
    808802/* Undo action name */
    809803"Raise Baseline (Undo action name)" = "Raise Baseline";
     
    848842"Search with %@" = "Search with %@";
    849843
    850 /* Title for Quick Look action button for images with text */
    851 "Select Text in Quick Look" = "Select Text in Quick Look";
    852 
    853844/* Validation message for required file inputs that have no value */
    854845"Select a file" = "Select a file";
  • trunk/Source/WebCore/page/ContextMenuController.cpp

    r292408 r293299  
    528528        break;
    529529    case ContextMenuItemTagCopyCroppedImage:
    530     case ContextMenuItemTagQuickLookImage:
     530    case ContextMenuItemTagLookUpImage:
    531531        // These should be handled at the client layer.
    532532        ASSERT_NOT_REACHED();
     
    837837    ContextMenuItem InsertEmojiItem(ActionType, ContextMenuItemTagInsertEmoji, contextMenuItemTagInsertEmoji());
    838838#endif
     839#if ENABLE(IMAGE_ANALYSIS)
     840    ContextMenuItem LookUpImageItem(ActionType, ContextMenuItemTagLookUpImage, contextMenuItemTagLookUpImage());
     841#endif
    839842
    840843#if PLATFORM(GTK) || PLATFORM(WIN)
     
    863866    if (m_context.controlledImage())
    864867        return;
    865 #endif
    866 
    867 #if ENABLE(IMAGE_ANALYSIS)
    868     bool shouldAppendQuickLookImageItem = false;
    869     auto quickLookItemTitle = frame->settings().preferInlineTextSelectionInImages() ? contextMenuItemTagLookUpImage() : contextMenuItemTagQuickLookImage();
    870     ContextMenuItem QuickLookImageItem { ActionType, ContextMenuItemTagQuickLookImage, quickLookItemTitle };
    871868#endif
    872869
     
    924921#endif
    925922#if ENABLE(IMAGE_ANALYSIS)
    926                     shouldAppendQuickLookImageItem = m_client.supportsLookUpInImages();
     923                    if (m_client.supportsLookUpInImages())
     924                        appendItem(LookUpImageItem, m_contextMenu.get());
    927925#endif
    928926                }
     
    11891187        }
    11901188    }
    1191 
    1192 #if ENABLE(IMAGE_ANALYSIS)
    1193     if (shouldAppendQuickLookImageItem) {
    1194         if (!frame->settings().preferInlineTextSelectionInImages()) {
    1195             // In the case where inline text selection is enabled, the Look Up item is only added if
    1196             // we discover visual look up results after image analysis. In that scenario, a separator
    1197             // is only added before the Look Up item once we're certain that we want to show it.
    1198             appendItem(*separatorItem(), m_contextMenu.get());
    1199         }
    1200         appendItem(QuickLookImageItem, m_contextMenu.get());
    1201     }
    1202 #endif // ENABLE(IMAGE_ANALYSIS)
    12031189}
    12041190
     
    15271513            shouldCheck = shouldEnable &&  m_context.hitTestResult().mediaMuted();
    15281514            break;
    1529         case ContextMenuItemTagQuickLookImage:
     1515        case ContextMenuItemTagLookUpImage:
    15301516        case ContextMenuItemTagTranslate:
    15311517            break;
  • trunk/Source/WebCore/page/EventHandler.cpp

    r293137 r293299  
    25792579
    25802580#if ENABLE(IMAGE_ANALYSIS)
    2581     if (m_frame.settings().preferInlineTextSelectionInImages()) {
    2582         if (!textRecognitionCandidateElement())
    2583             m_textRecognitionHoverTimer.stop();
    2584         else if (!platformMouseEvent.movementDelta().isZero())
    2585             m_textRecognitionHoverTimer.restart();
    2586     }
     2581    if (!textRecognitionCandidateElement())
     2582        m_textRecognitionHoverTimer.stop();
     2583    else if (!platformMouseEvent.movementDelta().isZero())
     2584        m_textRecognitionHoverTimer.restart();
    25872585#endif // ENABLE(IMAGE_ANALYSIS)
    25882586
  • trunk/Source/WebCore/platform/ContextMenuItem.cpp

    r289851 r293299  
    260260    case ContextMenuAction::ContextMenuItemTagShareMenu:
    261261    case ContextMenuAction::ContextMenuItemTagToggleVideoEnhancedFullscreen:
    262     case ContextMenuAction::ContextMenuItemTagQuickLookImage:
     262    case ContextMenuAction::ContextMenuItemTagLookUpImage:
    263263    case ContextMenuAction::ContextMenuItemTagTranslate:
    264264    case ContextMenuAction::ContextMenuItemBaseCustomTag:
  • trunk/Source/WebCore/platform/ContextMenuItem.h

    r289851 r293299  
    148148    ContextMenuItemTagAddHighlightToCurrentQuickNote,
    149149    ContextMenuItemTagAddHighlightToNewQuickNote,
    150     ContextMenuItemTagQuickLookImage,
     150    ContextMenuItemTagLookUpImage,
    151151    ContextMenuItemTagTranslate,
    152152    ContextMenuItemTagCopyCroppedImage,
  • trunk/Source/WebCore/platform/LocalizedStrings.h

    r291863 r293299  
    373373#if ENABLE(IMAGE_ANALYSIS)
    374374    WEBCORE_EXPORT String contextMenuItemTagLookUpImage();
    375     WEBCORE_EXPORT String contextMenuItemTagQuickLookImage();
    376     WEBCORE_EXPORT String contextMenuItemTagQuickLookImageForTextSelection();
    377     WEBCORE_EXPORT String contextMenuItemTagQuickLookImageForVisualSearch();
    378 #endif // ENABLE(IMAGE_ANALYSIS)
     375#endif
    379376
    380377#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
  • trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm

    r289882 r293299  
    303303}
    304304
    305 String contextMenuItemTagQuickLookImage()
    306 {
    307     return WEB_UI_STRING("Quick Look", "Title for Quick Look action button");
    308 }
    309 
    310 String contextMenuItemTagQuickLookImageForTextSelection()
    311 {
    312     return WEB_UI_STRING("Select Text in Quick Look", "Title for Quick Look action button for images with text");
    313 }
    314 
    315 String contextMenuItemTagQuickLookImageForVisualSearch()
    316 {
    317     return WEB_UI_STRING("Look Up in Quick Look", "Title for Quick Look action button for images with visual search results");
    318 }
    319 
    320 #endif // ENABLE(IMAGE_ANALYSIS)
     305#endif
    321306
    322307#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
  • trunk/Source/WebKit/ChangeLog

    r293296 r293299  
     12022-04-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove the `PreferInlineTextSelectionInImages` internal feature flag
     4        https://bugs.webkit.org/show_bug.cgi?id=234849
     5
     6        Reviewed by Sam Weinig.
     7
     8        This patch reverts r279164, which introduced an internal feature to avoid Live Text analysis when hovering over
     9        images, and instead added a new context menu item to reveal selectable text in the image by launching the
     10        QuickLook panel in Live Text mode.
     11
     12        This alternate Live Text experience was originally devised as a way to mitigate the power and performance impact
     13        of passively triggering Live Text analysis when hovering over images on pre-M1 devices, but this mitigation was
     14        ultimately deemed unnecessary in macOS 12.
     15
     16        * Shared/API/c/WKSharedAPICast.h:
     17        (WebKit::toAPI):
     18        (WebKit::toImpl):
     19        * UIProcess/Cocoa/QuickLookPreviewActivity.h: Removed.
     20        * UIProcess/Cocoa/WebViewImpl.h:
     21        * UIProcess/Cocoa/WebViewImpl.mm:
     22        (WebKit::WebViewImpl::computeHasVisualSearchResults):
     23        (WebKit::WebViewImpl::computeHasImageAnalysisResults): Deleted.
     24        * UIProcess/PageClient.h:
     25        (WebKit::PageClient::computeHasVisualSearchResults):
     26        (WebKit::PageClient::computeHasImageAnalysisResults): Deleted.
     27        * UIProcess/WebContextMenuProxy.h:
     28        (WebKit::WebContextMenuProxy::quickLookPreviewActivity const): Deleted.
     29        * UIProcess/WebPageProxy.cpp:
     30        (WebKit::WebPageProxy::contextMenuItemSelected):
     31        (WebKit::WebPageProxy::computeHasVisualSearchResults):
     32        (WebKit::WebPageProxy::computeHasImageAnalysisResults): Deleted.
     33        * UIProcess/WebPageProxy.h:
     34        * UIProcess/mac/PageClientImplMac.h:
     35        * UIProcess/mac/PageClientImplMac.mm:
     36        (WebKit::PageClientImpl::computeHasVisualSearchResults):
     37        (WebKit::PageClientImpl::computeHasImageAnalysisResults): Deleted.
     38        * UIProcess/mac/WKQuickLookPreviewController.h:
     39        * UIProcess/mac/WKQuickLookPreviewController.mm:
     40        * UIProcess/mac/WebContextMenuProxyMac.h:
     41        * UIProcess/mac/WebContextMenuProxyMac.mm:
     42        (WebKit::menuItemIdentifier):
     43        (WebKit::WebContextMenuProxyMac::getContextMenuFromItems):
     44        (WebKit::WebContextMenuProxyMac::insertOrUpdateQuickLookImageItem): Deleted.
     45        (WebKit::WebContextMenuProxyMac::updateQuickLookContextMenuItemTitle): Deleted.
     46        * UIProcess/mac/WebPageProxyMac.mm:
     47        (WebKit::WebPageProxy::handleContextMenuLookUpImage):
     48        (WebKit::WebPageProxy::handleContextMenuQuickLookImage): Deleted.
     49        * WebKit.xcodeproj/project.pbxproj:
     50
    1512022-04-23  Brady Eidson  <beidson@apple.com>
    252
  • trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h

    r289851 r293299  
    544544    case WebCore::ContextMenuItemTagShareMenu:
    545545        return kWKContextMenuItemTagShareMenu;
    546     case WebCore::ContextMenuItemTagQuickLookImage:
     546    case WebCore::ContextMenuItemTagLookUpImage:
    547547        return kWKContextMenuItemTagRevealImage;
    548548    case WebCore::ContextMenuItemTagTranslate:
     
    749749#endif
    750750    case kWKContextMenuItemTagRevealImage:
    751         return WebCore::ContextMenuItemTagQuickLookImage;
     751        return WebCore::ContextMenuItemTagLookUpImage;
    752752    case kWKContextMenuItemTagTranslate:
    753753        return WebCore::ContextMenuItemTagTranslate;
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h

    r292356 r293299  
    172172
    173173enum class ContinueUnsafeLoad : bool;
    174 enum class ImageAnalysisType : uint8_t;
    175174enum class UndoOrRedo : bool;
    176175
     
    597596#if ENABLE(IMAGE_ANALYSIS)
    598597    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
    599     void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
     598    void computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&&);
    600599#endif
    601600
  • trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm

    r292935 r293299  
    281281}
    282282
    283 void WebViewImpl::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
     283void WebViewImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
    284284{
    285285    if (!isLiveTextAvailableAndEnabled()) {
     
    289289
    290290    auto cgImage = imageBitmap.makeCGImage();
    291     auto analysisType = type == ImageAnalysisType::VisualSearch ? VKAnalysisTypeVisualSearch : VKAnalysisTypeText;
    292     auto request = createImageAnalyzerRequest(cgImage.get(), imageURL, [NSURL _web_URLWithWTFString:m_page->currentURL()], analysisType);
     291    auto request = createImageAnalyzerRequest(cgImage.get(), imageURL, [NSURL _web_URLWithWTFString:m_page->currentURL()], VKAnalysisTypeVisualSearch);
    293292    auto startTime = MonotonicTime::now();
    294     [ensureImageAnalyzer() processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion), startTime, analysisType] (CocoaImageAnalysis *analysis, NSError *) mutable {
    295         BOOL result = [analysis hasResultsForAnalysisTypes:analysisType];
    296         CFRunLoopPerformBlock(CFRunLoopGetMain(), (__bridge CFStringRef)NSEventTrackingRunLoopMode, makeBlockPtr([completion = WTFMove(completion), result, analysisType, startTime] () mutable {
    297             RELEASE_LOG(Images, "Image analysis completed in %.0f ms (found %s? %d)", (MonotonicTime::now() - startTime).milliseconds(), analysisType == VKAnalysisTypeVisualSearch ? "visual search results" : "text", result);
     293    [ensureImageAnalyzer() processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion), startTime] (CocoaImageAnalysis *analysis, NSError *) mutable {
     294        BOOL result = [analysis hasResultsForAnalysisTypes:VKAnalysisTypeVisualSearch];
     295        CFRunLoopPerformBlock(CFRunLoopGetMain(), (__bridge CFStringRef)NSEventTrackingRunLoopMode, makeBlockPtr([completion = WTFMove(completion), result, startTime] () mutable {
     296            RELEASE_LOG(Images, "Image analysis completed in %.0f ms (found visual search results? %d)", (MonotonicTime::now() - startTime).milliseconds(), result);
    298297            completion(result);
    299298        }).get());
  • trunk/Source/WebKit/UIProcess/PageClient.h

    r292812 r293299  
    166166enum class ContinueUnsafeLoad : bool { No, Yes };
    167167
    168 #if ENABLE(IMAGE_ANALYSIS)
    169 enum class ImageAnalysisType : uint8_t { Text, VisualSearch };
    170 #endif
    171 
    172168struct FocusedElementInformation;
    173169struct FrameInfoData;
     
    561557#if ENABLE(IMAGE_ANALYSIS)
    562558    virtual void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion) { completion({ }); }
    563     virtual void computeHasImageAnalysisResults(const URL&, ShareableBitmap&, ImageAnalysisType, CompletionHandler<void(bool)>&& completion) { completion(false); }
     559    virtual void computeHasVisualSearchResults(const URL&, ShareableBitmap&, CompletionHandler<void(bool)>&& completion) { completion(false); }
    564560#endif
    565561
  • trunk/Source/WebKit/UIProcess/WebContextMenuProxy.h

    r279164 r293299  
    3434#include <wtf/WeakPtr.h>
    3535
    36 #if PLATFORM(COCOA)
    37 #include "QuickLookPreviewActivity.h"
    38 #endif
    39 
    4036OBJC_CLASS NSMenu;
    4137
     
    5652    virtual NSMenu *platformMenu() const = 0;
    5753    virtual NSArray *platformData() const = 0;
    58     virtual QuickLookPreviewActivity quickLookPreviewActivity() const { return QuickLookPreviewActivity::None; };
    5954#endif // PLATFORM(COCOA)
    6055
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r293063 r293299  
    217217#if PLATFORM(COCOA)
    218218#include "InsertTextOptions.h"
    219 #include "QuickLookPreviewActivity.h"
    220219#include "RemoteLayerTreeDrawingAreaProxy.h"
    221220#include "RemoteLayerTreeScrollingPerformanceData.h"
     
    72077206        break;
    72087207
    7209     case ContextMenuItemTagQuickLookImage:
     7208    case ContextMenuItemTagLookUpImage:
    72107209#if ENABLE(IMAGE_ANALYSIS)
    7211         if (m_activeContextMenu)
    7212             handleContextMenuQuickLookImage(m_activeContextMenu->quickLookPreviewActivity());
     7210        handleContextMenuLookUpImage();
    72137211#endif
    72147212        return;
     
    88438841}
    88448842
    8845 void WebPageProxy::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
    8846 {
    8847     pageClient().computeHasImageAnalysisResults(imageURL, imageBitmap, type, WTFMove(completion));
     8843void WebPageProxy::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
     8844{
     8845    pageClient().computeHasVisualSearchResults(imageURL, imageBitmap, WTFMove(completion));
    88488846}
    88498847
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r293230 r293299  
    422422struct WebSpeechSynthesisVoice;
    423423
    424 enum class ImageAnalysisType : uint8_t;
    425 enum class TapHandlingResult : uint8_t;
    426424enum class TextRecognitionUpdateResult : uint8_t;
    427425enum class NegotiatedLegacyTLS : bool;
     
    17631761    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
    17641762    void updateWithTextRecognitionResult(WebCore::TextRecognitionResult&&, const WebCore::ElementContext&, const WebCore::FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&&);
    1765     void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
     1763    void computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&&);
    17661764    void startImageAnalysis(const String& identifier);
    17671765#endif
     
    20352033#if ENABLE(CONTEXT_MENUS)
    20362034#if ENABLE(IMAGE_ANALYSIS)
    2037     void handleContextMenuQuickLookImage(QuickLookPreviewActivity);
     2035    void handleContextMenuLookUpImage();
    20382036#endif
    20392037#if ENABLE(IMAGE_ANALYSIS_ENHANCEMENTS)
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h

    r292356 r293299  
    133133#if ENABLE(IMAGE_ANALYSIS)
    134134    void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, const String& identifier, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&) override;
    135     void computeHasImageAnalysisResults(const URL&, ShareableBitmap&, ImageAnalysisType, CompletionHandler<void(bool)>&&) override;
     135    void computeHasVisualSearchResults(const URL&, ShareableBitmap&, CompletionHandler<void(bool)>&&) override;
    136136#endif
    137137
  • trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm

    r292356 r293299  
    490490}
    491491
    492 void PageClientImpl::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
    493 {
    494     m_impl->computeHasImageAnalysisResults(imageURL, imageBitmap, type, WTFMove(completion));
    495 }
    496 
    497 #endif // ENABLE(IMAGE_ANALYSIS)
     492void PageClientImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
     493{
     494    m_impl->computeHasVisualSearchResults(imageURL, imageBitmap, WTFMove(completion));
     495}
     496
     497#endif
    498498
    499499RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page)
  • trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h

    r279164 r293299  
    3232namespace WebKit {
    3333class WebPageProxy;
    34 enum class QuickLookPreviewActivity : uint8_t;
     34enum class QuickLookPreviewActivity : uint8_t { None, VisualSearch };
    3535}
    3636
  • trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.mm

    r290394 r293299  
    2929#if HAVE(QUICKLOOK_PREVIEW_ITEM_DATA_PROVIDER)
    3030
    31 #import "QuickLookPreviewActivity.h"
    3231#import "WebPageProxy.h"
    3332#import <wtf/RetainPtr.h>
  • trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h

    r289882 r293299  
    6262    WebContextMenuProxyMac(NSView *, WebPageProxy&, ContextMenuContextData&&, const UserData&);
    6363
    64     QuickLookPreviewActivity quickLookPreviewActivity() const final { return m_quickLookPreviewActivity; }
    65 
    66 #if ENABLE(IMAGE_ANALYSIS)
    67     void insertOrUpdateQuickLookImageItem(const URL& imageURL, Ref<ShareableBitmap>&& imageBitmap, std::optional<WebContextMenuItemData>&&, bool);
    68     void updateQuickLookContextMenuItemTitle(const String&);
    69 #endif
    70 
    7164    void show() override;
    7265    void showContextMenuWithItems(Vector<Ref<WebContextMenuItem>>&&) override;
     
    8881    RetainPtr<WKMenuDelegate> m_menuDelegate;
    8982    WeakObjCPtr<NSView> m_webView;
    90     QuickLookPreviewActivity m_quickLookPreviewActivity { QuickLookPreviewActivity::None };
    9183};
    9284
  • trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm

    r292898 r293299  
    4242#import "WebContextMenuItemData.h"
    4343#import "WebPageProxy.h"
    44 #import "WebPreferences.h"
    4544#import <WebCore/GraphicsContext.h>
    4645#import <WebCore/IntRect.h>
     
    514513        return _WKMenuItemIdentifierReload;
    515514
    516     case ContextMenuItemTagQuickLookImage:
     515    case ContextMenuItemTagLookUpImage:
    517516        return _WKMenuItemIdentifierRevealImage;
    518517
     
    603602    }
    604603
    605     bool shouldUpdateQuickLookItemTitle = false;
    606     std::optional<WebContextMenuItemData> quickLookItemToInsertIfNeeded;
     604    std::optional<WebContextMenuItemData> lookUpImageItem;
    607605
    608606#if ENABLE(IMAGE_ANALYSIS)
    609     auto indexOfQuickLookItem = filteredItems.findIf([&] (auto& item) {
    610         return item.action() == WebCore::ContextMenuItemTagQuickLookImage;
     607    filteredItems.removeFirstMatching([&] (auto& item) {
     608        if (item.action() != WebCore::ContextMenuItemTagLookUpImage)
     609            return false;
     610
     611        lookUpImageItem = { item };
     612        return true;
    611613    });
    612 
    613     if (indexOfQuickLookItem != notFound) {
    614         if (auto page = this->page(); page && page->preferences().preferInlineTextSelectionInImages()) {
    615             quickLookItemToInsertIfNeeded = filteredItems[indexOfQuickLookItem];
    616             filteredItems.remove(indexOfQuickLookItem);
    617         } else
    618             shouldUpdateQuickLookItemTitle = true;
    619     }
    620 #endif // ENABLE(IMAGE_ANALYSIS)
     614#endif
    621615
    622616#if HAVE(TRANSLATION_UI_SERVICES)
     
    634628    auto imageBitmap = hitTestData.imageBitmap;
    635629
    636     auto sparseMenuItems = retainPtr([NSPointerArray strongObjectsPointerArray]);
    637     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 {
     630    RetainPtr sparseMenuItems = [NSPointerArray strongObjectsPointerArray];
     631    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 {
    638632        ASSERT(index < [sparseMenuItems count]);
    639633        ASSERT(![sparseMenuItems pointerAtIndex:index]);
     
    644638        [menu setItemArray:[sparseMenuItems allObjects]];
    645639
    646         RefPtr page { weakPage.get() };
    647         if (page && imageBitmap) {
     640        RefPtr page = weakPage.get();
     641        if (lookUpImageItem && page && imageBitmap) {
    648642#if ENABLE(IMAGE_ANALYSIS)
    649             protectedThis->insertOrUpdateQuickLookImageItem(imageURL, imageBitmap.releaseNonNull(), WTFMove(quickLookItemToInsertIfNeeded), shouldUpdateQuickLookItemTitle);
     643            page->computeHasVisualSearchResults(imageURL, *imageBitmap, [protectedThis = WTFMove(protectedThis), lookUpImageItem = WTFMove(*lookUpImageItem)] (bool hasVisualSearchResults) mutable {
     644                if (hasVisualSearchResults)
     645                    [protectedThis->m_menu addItem:createMenuActionItem(lookUpImageItem).get()];
     646            });
    650647#else
    651             UNUSED_PARAM(quickLookItemToInsertIfNeeded);
    652             UNUSED_PARAM(shouldUpdateQuickLookItemTitle);
    653648            UNUSED_PARAM(imageURL);
    654649#endif
     
    665660    }
    666661}
    667 
    668 #if ENABLE(IMAGE_ANALYSIS)
    669 
    670 void WebContextMenuProxyMac::insertOrUpdateQuickLookImageItem(const URL& imageURL, Ref<ShareableBitmap>&& imageBitmap, std::optional<WebContextMenuItemData>&& quickLookItemToInsertIfNeeded, bool shouldUpdateQuickLookItemTitle)
    671 {
    672     Ref page = *this->page();
    673     if (quickLookItemToInsertIfNeeded) {
    674         page->computeHasImageAnalysisResults(imageURL, imageBitmap.get(), ImageAnalysisType::VisualSearch, [weakThis = WeakPtr { *this }, quickLookItemToInsertIfNeeded = WTFMove(*quickLookItemToInsertIfNeeded)] (bool hasVisualSearchResults) mutable {
    675             if (RefPtr protectedThis = weakThis.get(); protectedThis && hasVisualSearchResults) {
    676                 protectedThis->m_quickLookPreviewActivity = QuickLookPreviewActivity::VisualSearch;
    677                 [protectedThis->m_menu addItem:NSMenuItem.separatorItem];
    678                 [protectedThis->m_menu addItem:createMenuActionItem(quickLookItemToInsertIfNeeded).get()];
    679             }
    680         });
    681         return;
    682     }
    683 
    684     if (shouldUpdateQuickLookItemTitle) {
    685         page->computeHasImageAnalysisResults(imageURL, imageBitmap.get(), ImageAnalysisType::VisualSearch, [weakThis = WeakPtr { *this }, weakPage = WeakPtr { page }, imageURL, imageBitmap = WTFMove(imageBitmap)] (bool hasVisualSearchResults) mutable {
    686             RefPtr protectedThis { weakThis.get() };
    687             if (!protectedThis)
    688                 return;
    689 
    690             RefPtr page { weakPage.get() };
    691             if (!page)
    692                 return;
    693 
    694             if (hasVisualSearchResults) {
    695                 protectedThis->m_quickLookPreviewActivity = QuickLookPreviewActivity::VisualSearch;
    696                 protectedThis->updateQuickLookContextMenuItemTitle(contextMenuItemTagQuickLookImageForVisualSearch());
    697                 return;
    698             }
    699 
    700             page->computeHasImageAnalysisResults(imageURL, imageBitmap.get(), ImageAnalysisType::Text, [weakThis = WTFMove(weakThis), weakPage] (bool hasText) mutable {
    701                 RefPtr protectedThis { weakThis.get() };
    702                 if (!protectedThis)
    703                     return;
    704 
    705                 if (RefPtr page = weakPage.get(); page && hasText)
    706                     protectedThis->updateQuickLookContextMenuItemTitle(contextMenuItemTagQuickLookImageForTextSelection());
    707             });
    708         });
    709     }
    710 }
    711 
    712 void WebContextMenuProxyMac::updateQuickLookContextMenuItemTitle(const String& newTitle)
    713 {
    714     for (NSInteger itemIndex = 0; itemIndex < [m_menu numberOfItems]; ++itemIndex) {
    715         auto item = [m_menu itemAtIndex:itemIndex];
    716         if (static_cast<ContextMenuAction>(item.tag) == ContextMenuItemTagQuickLookImage) {
    717             item.title = newTitle;
    718             break;
    719         }
    720     }
    721 }
    722 
    723 #endif // ENABLE(IMAGE_ANALYSIS)
    724662
    725663void WebContextMenuProxyMac::getContextMenuItem(const WebContextMenuItemData& item, CompletionHandler<void(NSMenuItem *)>&& completionHandler)
  • trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm

    r292800 r293299  
    731731#if ENABLE(IMAGE_ANALYSIS)
    732732
    733 void WebPageProxy::handleContextMenuQuickLookImage(QuickLookPreviewActivity activity)
     733void WebPageProxy::handleContextMenuLookUpImage()
    734734{
    735735    ASSERT(m_activeContextMenuContextData.webHitTestResultData());
     
    739739        return;
    740740
    741     showImageInQuickLookPreviewPanel(*result.imageBitmap, result.toolTipText, URL { result.absoluteImageURL }, activity);
     741    showImageInQuickLookPreviewPanel(*result.imageBitmap, result.toolTipText, URL { result.absoluteImageURL }, QuickLookPreviewActivity::VisualSearch);
    742742}
    743743
  • trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj

    r293296 r293299  
    72047204                F451C1002703D853002BA03B /* RemoteDisplayListRecorder.messages.in */ = {isa = PBXFileReference; lastKnownFileType = text; path = RemoteDisplayListRecorder.messages.in; sourceTree = "<group>"; };
    72057205                F4660BC125DEF08100E86598 /* PasteboardAccessIntent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PasteboardAccessIntent.h; sourceTree = "<group>"; };
    7206                 F47A051626827A09007E5CF2 /* QuickLookPreviewActivity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = QuickLookPreviewActivity.h; sourceTree = "<group>"; };
    72077206                F48570A22644BEC400C05F71 /* Timeout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Timeout.h; sourceTree = "<group>"; };
    72087207                F48BB8DD26F9635D001C1C40 /* RemoteDisplayListRecorderProxy.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = RemoteDisplayListRecorderProxy.h; sourceTree = "<group>"; };
     
    82358234                                C145CC0E23DCA427003A5EEB /* PreferenceObserver.h */,
    82368235                                C15CBB3323F34C3800300CC7 /* PreferenceObserver.mm */,
    8237                                 F47A051626827A09007E5CF2 /* QuickLookPreviewActivity.h */,
    82388236                                5CB7AFDD23C5273D00E49CF3 /* ResourceLoadDelegate.h */,
    82398237                                5CB7AFDE23C5273D00E49CF3 /* ResourceLoadDelegate.mm */,
  • trunk/Source/WebKitLegacy/mac/ChangeLog

    r293199 r293299  
     12022-04-23  Wenson Hsieh  <wenson_hsieh@apple.com>
     2
     3        Remove the `PreferInlineTextSelectionInImages` internal feature flag
     4        https://bugs.webkit.org/show_bug.cgi?id=234849
     5
     6        Reviewed by Sam Weinig.
     7
     8        See WebKit/ChangeLog for more details.
     9
     10        * WebView/WebHTMLView.mm:
     11        (toTag):
     12
    1132022-04-21  Brent Fulgham  <bfulgham@apple.com>
    214
  • trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm

    r292587 r293299  
    600600    case ContextMenuItemTagTranslate:
    601601        return WebMenuItemTagTranslate;
    602     case ContextMenuItemTagQuickLookImage:
    603602    case ContextMenuItemTagCopyCroppedImage:
     603    case ContextMenuItemTagLookUpImage:
    604604        return std::nullopt;
    605605
Note: See TracChangeset for help on using the changeset viewer.