Diff
Modified: trunk/Source/WTF/ChangeLog (279163 => 279164)
--- trunk/Source/WTF/ChangeLog 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WTF/ChangeLog 2021-06-23 01:32:54 UTC (rev 279164)
@@ -1,3 +1,15 @@
+2021-06-22 Wenson Hsieh <[email protected]>
+
+ [Live Text] [macOS] Add an internal option to disable inline text selection in images
+ https://bugs.webkit.org/show_bug.cgi?id=227265
+ rdar://79460142
+
+ Reviewed by Tim Horton.
+
+ Add a new internal feature flag. See WebKit ChangeLog for more details.
+
+ * Scripts/Preferences/WebPreferencesInternal.yaml:
+
2021-06-22 Fujii Hironori <[email protected]>
[GLib] Rewrite NetworkCache::Data::adoptMap without FileSystem::MappedFileData::leakHandle and munmap
Modified: trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml (279163 => 279164)
--- trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WTF/Scripts/Preferences/WebPreferencesInternal.yaml 2021-06-23 01:32:54 UTC (rev 279164)
@@ -584,6 +584,19 @@
"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:
+ default: true
+ WebKitLegacy:
+ default: true
+ WebKit:
+ default: true
+
PreferPageRenderingUpdatesNear60FPSEnabled:
type: bool
humanReadableName: "Prefer Page Rendering Updates near 60fps"
Modified: trunk/Source/WebCore/ChangeLog (279163 => 279164)
--- trunk/Source/WebCore/ChangeLog 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebCore/ChangeLog 2021-06-23 01:32:54 UTC (rev 279164)
@@ -1,3 +1,51 @@
+2021-06-22 Wenson Hsieh <[email protected]>
+
+ [Live Text] [macOS] Add an internal option to disable inline text selection in images
+ https://bugs.webkit.org/show_bug.cgi?id=227265
+ rdar://79460142
+
+ Reviewed by Tim Horton.
+
+ Add support for the new feature flag. See WebKit/ChangeLog for more details.
+
+ * en.lproj/Localizable.strings:
+
+ Add additional localizable strings to represent each of the possible titles for the "Quick Look"/"Look Up"
+ context menu item. When inline text selection is enabled, the item shows up as "Look Up", and is only added if
+ we actually discover visual search results.
+
+ However, when inline text selection is disabled, this item will always be added to the context menu under the
+ title "Quick Look", and will be retitled to either "Look Up in Quick Look" or "Select Text in Quick Look" once
+ either visual search results or text is recognized, respectively.
+
+ * page/ContextMenuController.cpp:
+ (WebCore::ContextMenuController::contextMenuItemSelected):
+ (WebCore::ContextMenuController::populate):
+
+ In the case where inline text selection is disabled, add the Quick Look item to the end of the context menu,
+ after a separator. Note that in the case where inline text selection is enabled, it doesn't actually matter
+ where we add this item, since it is automatically removed and only reinserted if we find visual search results
+ for the image.
+
+ (WebCore::ContextMenuController::checkOrEnableIfNeeded const):
+
+ Rename the existing ContextMenuItemTagLookUpImage to ContextMenuItemTagQuickLookImage, since it is no longer
+ limited to the visual look up feature.
+
+ * page/EventHandler.cpp:
+ (WebCore::EventHandler::updateMouseEventTargetNode):
+
+ Consult the feature flag and avoid kicking off the text recognition timer if inline text selection is disabled.
+
+ * platform/ContextMenuItem.cpp:
+ (WebCore::isValidContextMenuAction):
+ * platform/ContextMenuItem.h:
+ * platform/LocalizedStrings.h:
+ * platform/cocoa/LocalizedStringsCocoa.mm:
+ (WebCore::contextMenuItemTagQuickLookImage):
+ (WebCore::contextMenuItemTagQuickLookImageForTextSelection):
+ (WebCore::contextMenuItemTagQuickLookImageForVisualSearch):
+
2021-06-22 Devin Rousso <[email protected]>
REGRESSION: [iOS] ASSERTION FAILED: pixelBuffer->data().length() >= 4 under WebCore::sampleColor
Modified: trunk/Source/WebCore/en.lproj/Localizable.strings (279163 => 279164)
--- trunk/Source/WebCore/en.lproj/Localizable.strings 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebCore/en.lproj/Localizable.strings 2021-06-23 01:32:54 UTC (rev 279164)
@@ -577,6 +577,9 @@
/* 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 “%@”";
@@ -751,6 +754,9 @@
/* Description of the PostScript type supported by the PDF pseudo plug-in. Visible in the Installed Plug-ins page in Safari. */
"PostScript" = "PostScript";
+/* Title for Quick Look action button */
+"Quick Look" = "Quick Look";
+
/* Undo action name */
"Raise Baseline (Undo action name)" = "Raise Baseline";
@@ -793,6 +799,9 @@
/* 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 (279163 => 279164)
--- trunk/Source/WebCore/page/ContextMenuController.cpp 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp 2021-06-23 01:32:54 UTC (rev 279164)
@@ -515,7 +515,7 @@
case ContextMenuItemTagDictationAlternative:
frame->editor().applyDictationAlternative(title);
break;
- case ContextMenuItemTagLookUpImage:
+ case ContextMenuItemTagQuickLookImage:
// This should be handled at the client layer.
ASSERT_NOT_REACHED();
break;
@@ -824,9 +824,6 @@
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;
@@ -851,6 +848,12 @@
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;
@@ -900,7 +903,7 @@
#if ENABLE(IMAGE_ANALYSIS)
if (m_client.supportsLookUpInImages() && image && !image->isAnimated())
- appendItem(LookUpImageItem, m_contextMenu.get());
+ shouldAppendQuickLookImageItem = true;
#endif
}
#if PLATFORM(GTK)
@@ -1164,6 +1167,18 @@
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()
@@ -1489,7 +1504,7 @@
shouldEnable = m_context.hitTestResult().mediaHasAudio();
shouldCheck = shouldEnable && m_context.hitTestResult().mediaMuted();
break;
- case ContextMenuItemTagLookUpImage:
+ case ContextMenuItemTagQuickLookImage:
case ContextMenuItemTagTranslate:
break;
}
Modified: trunk/Source/WebCore/page/EventHandler.cpp (279163 => 279164)
--- trunk/Source/WebCore/page/EventHandler.cpp 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebCore/page/EventHandler.cpp 2021-06-23 01:32:54 UTC (rev 279164)
@@ -2537,10 +2537,12 @@
m_elementUnderMouse = targetElement;
#if ENABLE(IMAGE_ANALYSIS)
- if (!m_elementUnderMouse || !is<RenderImage>(m_elementUnderMouse->renderer()))
- m_textRecognitionHoverTimer.stop();
- else if (!platformMouseEvent.movementDelta().isZero())
- m_textRecognitionHoverTimer.restart();
+ if (m_frame.settings().preferInlineTextSelectionInImages()) {
+ if (!m_elementUnderMouse || !is<RenderImage>(m_elementUnderMouse->renderer()))
+ 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 (279163 => 279164)
--- trunk/Source/WebCore/platform/ContextMenuItem.cpp 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebCore/platform/ContextMenuItem.cpp 2021-06-23 01:32:54 UTC (rev 279164)
@@ -258,7 +258,7 @@
case ContextMenuAction::ContextMenuItemTagToggleVideoFullscreen:
case ContextMenuAction::ContextMenuItemTagShareMenu:
case ContextMenuAction::ContextMenuItemTagToggleVideoEnhancedFullscreen:
- case ContextMenuAction::ContextMenuItemTagLookUpImage:
+ case ContextMenuAction::ContextMenuItemTagQuickLookImage:
case ContextMenuAction::ContextMenuItemTagTranslate:
case ContextMenuAction::ContextMenuItemBaseCustomTag:
case ContextMenuAction::ContextMenuItemLastCustomTag:
Modified: trunk/Source/WebCore/platform/ContextMenuItem.h (279163 => 279164)
--- trunk/Source/WebCore/platform/ContextMenuItem.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebCore/platform/ContextMenuItem.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -147,7 +147,7 @@
ContextMenuItemTagToggleVideoEnhancedFullscreen,
ContextMenuItemTagAddHighlightToCurrentQuickNote,
ContextMenuItemTagAddHighlightToNewQuickNote,
- ContextMenuItemTagLookUpImage,
+ ContextMenuItemTagQuickLookImage,
ContextMenuItemTagTranslate,
ContextMenuItemBaseCustomTag = 5000,
ContextMenuItemLastCustomTag = 5999,
Modified: trunk/Source/WebCore/platform/LocalizedStrings.h (279163 => 279164)
--- trunk/Source/WebCore/platform/LocalizedStrings.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebCore/platform/LocalizedStrings.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -368,7 +368,10 @@
#if ENABLE(IMAGE_ANALYSIS)
WEBCORE_EXPORT String contextMenuItemTagLookUpImage();
-#endif
+ WEBCORE_EXPORT String contextMenuItemTagQuickLookImage();
+ WEBCORE_EXPORT String contextMenuItemTagQuickLookImageForTextSelection();
+ WEBCORE_EXPORT String contextMenuItemTagQuickLookImageForVisualSearch();
+#endif // ENABLE(IMAGE_ANALYSIS)
#if HAVE(TRANSLATION_UI_SERVICES)
String contextMenuItemTagTranslate(const String& selectedString);
Modified: trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm (279163 => 279164)
--- trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebCore/platform/cocoa/LocalizedStringsCocoa.mm 2021-06-23 01:32:54 UTC (rev 279164)
@@ -319,6 +319,21 @@
return WEB_UI_STRING("Look Up", "Title for Look Up action button");
}
-#endif
+String contextMenuItemTagQuickLookImage()
+{
+ return WEB_UI_STRING("Quick Look", "Title for Quick Look action button");
+}
+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)
+
} // namespace WebCore
Modified: trunk/Source/WebKit/ChangeLog (279163 => 279164)
--- trunk/Source/WebKit/ChangeLog 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/ChangeLog 2021-06-23 01:32:54 UTC (rev 279164)
@@ -1,3 +1,86 @@
+2021-06-22 Wenson Hsieh <[email protected]>
+
+ [Live Text] [macOS] Add an internal option to disable inline text selection in images
+ https://bugs.webkit.org/show_bug.cgi?id=227265
+ rdar://79460142
+
+ Reviewed by Tim Horton.
+
+ Refactor Live Text and Visual Look Up logic, such that the ability to select text inside of images is behind an
+ internal feature flag that can be toggled at runtime. When Live Text is disabled, we'll unconditionally show the
+ "Look Up" context menu action using the more generic title "Quick Look". This "Quick Look" action is then
+ retitled to either "Look Up in Quick Look" or "Select Text in Quick Look" once image analysis completes.
+
+ * Shared/API/c/WKSharedAPICast.h:
+ (WebKit::toAPI):
+ (WebKit::toImpl):
+
+ Rename ContextMenuItemTagLookUpImage to ContextMenuItemTagQuickLookImage.
+
+ * UIProcess/Cocoa/QuickLookPreviewActivity.h: Copied from Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h.
+
+ Move this enum out of WKQuickLookPreviewController.h, such that we can use and import it in non-Cocoa headers
+ and implementation files.
+
+ * UIProcess/Cocoa/WebViewImpl.h:
+ * UIProcess/Cocoa/WebViewImpl.mm:
+ (WebKit::WebViewImpl::computeHasImageAnalysisResults):
+
+ Rename `computeHasVisualSearchResults` to `computeHasImageAnalysisResults`, and allow it to take a flag to
+ indicate whether or not it should request text recognition results or visual search results. We use this for the
+ "Quick Look" context menu action when inline text selection is disabled, in order to retitle the item to "Select
+ Text in Quick Look".
+
+ (WebKit::WebViewImpl::computeHasVisualSearchResults): Deleted.
+ * UIProcess/PageClient.h:
+ (WebKit::PageClient::computeHasImageAnalysisResults):
+ (WebKit::PageClient::computeHasVisualSearchResults): Deleted.
+ * UIProcess/WebContextMenuProxy.h:
+ (WebKit::WebContextMenuProxy::quickLookPreviewActivity const):
+
+ Add a flag to WebContextMenuProxy to determine what initial activity to use when presenting the QuickLook
+ preview panel after selecting the ContextMenuItemTagQuickLookImage item.
+
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::contextMenuItemSelected):
+ (WebKit::WebPageProxy::computeHasImageAnalysisResults):
+ (WebKit::WebPageProxy::computeHasVisualSearchResults): Deleted.
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/mac/PageClientImplMac.h:
+ * UIProcess/mac/PageClientImplMac.mm:
+ (WebKit::PageClientImpl::computeHasImageAnalysisResults):
+ (WebKit::PageClientImpl::computeHasVisualSearchResults): Deleted.
+ * UIProcess/mac/WKQuickLookPreviewController.h:
+ * UIProcess/mac/WKQuickLookPreviewController.mm:
+ * UIProcess/mac/WebContextMenuProxyMac.h:
+ * UIProcess/mac/WebContextMenuProxyMac.mm:
+ (WebKit::menuItemIdentifier):
+ (WebKit::WebContextMenuProxyMac::getContextMenuFromItems):
+
+ Add logic to either remove and reinsert the "Look Up" context menu action (if inline text selection in images is
+ enabled), or to promote the "Quick Look" context menu action to either "Select Text in Quick Look" or "Look Up
+ in Quick Look" in the case where inline text selection in images is disabled.
+
+ Note that when inline text selection in images is disabled, we'll first check for visual search results before
+ checking for text. This is because visual search results will take precedence over text selection (i.e., we'll
+ show "Look Up in Quick Look" even if both visual search results and text is present), so we can avoid performing
+ text analysis in the case where we already found visual search results.
+
+ (WebKit::WebContextMenuProxyMac::insertOrUpdateQuickLookImageItem):
+ (WebKit::WebContextMenuProxyMac::updateQuickLookContextMenuItemTitle):
+
+ Add a helper method to find and update the title of the NSMenuItem corresponding to
+ ContextMenuItemTagQuickLookImage. See `getContextMenuFromItems` above for more details.
+
+ * UIProcess/mac/WebPageProxyMac.mm:
+ (WebKit::WebPageProxy::handleContextMenuQuickLookImage):
+ (WebKit::WebPageProxy::handleContextMenuLookUpImage): Deleted.
+
+ Rename this to `handleContextMenuQuickLookImage`, and have it take an argument to indicate whether the QuickLook
+ panel should start out in Visual Look Up mode.
+
+ * WebKit.xcodeproj/project.pbxproj:
+
2021-06-22 Chris Dumez <[email protected]>
[macOS] Suspend WebProcesses that are in the process cache
Modified: trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h (279163 => 279164)
--- trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/Shared/API/c/WKSharedAPICast.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -543,7 +543,7 @@
#endif
case WebCore::ContextMenuItemTagShareMenu:
return kWKContextMenuItemTagShareMenu;
- case WebCore::ContextMenuItemTagLookUpImage:
+ case WebCore::ContextMenuItemTagQuickLookImage:
return kWKContextMenuItemTagRevealImage;
case WebCore::ContextMenuItemTagTranslate:
return kWKContextMenuItemTagTranslate;
@@ -746,7 +746,7 @@
return WebCore::ContextMenuItemTagShareMenu;
#endif
case kWKContextMenuItemTagRevealImage:
- return WebCore::ContextMenuItemTagLookUpImage;
+ return WebCore::ContextMenuItemTagQuickLookImage;
case kWKContextMenuItemTagTranslate:
return WebCore::ContextMenuItemTagTranslate;
case kWKContextMenuItemTagOpenLinkInThisWindow:
Copied: trunk/Source/WebKit/UIProcess/Cocoa/QuickLookPreviewActivity.h (from rev 279158, trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h) (0 => 279164)
--- trunk/Source/WebKit/UIProcess/Cocoa/QuickLookPreviewActivity.h (rev 0)
+++ trunk/Source/WebKit/UIProcess/Cocoa/QuickLookPreviewActivity.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -0,0 +1,39 @@
+/*
+ * 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 (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -168,6 +168,7 @@
struct WebHitTestResultData;
enum class ContinueUnsafeLoad : bool;
+enum class ImageAnalysisType : uint8_t;
enum class UndoOrRedo : bool;
typedef id <NSValidatedUserInterfaceItem> ValidationItem;
@@ -598,7 +599,7 @@
#if ENABLE(IMAGE_ANALYSIS)
void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
- void computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&&);
+ void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
#endif
bool acceptsPreviewPanelControl(QLPreviewPanel *);
Modified: trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/Cocoa/WebViewImpl.mm 2021-06-23 01:32:54 UTC (rev 279164)
@@ -230,7 +230,7 @@
}).get()];
}
-void WebViewImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
+void WebViewImpl::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
{
if (!isLiveTextAvailableAndEnabled()) {
completion(false);
@@ -238,12 +238,13 @@
}
auto cgImage = imageBitmap.makeCGImage();
- auto request = createImageAnalysisRequest(cgImage.get(), imageURL, [NSURL _web_URLWithWTFString:m_page->currentURL()], VKAnalysisTypeVisualSearch);
+ auto analysisType = type == ImageAnalysisType::VisualSearch ? VKAnalysisTypeVisualSearch : VKAnalysisTypeText;
+ auto request = createImageAnalysisRequest(cgImage.get(), imageURL, [NSURL _web_URLWithWTFString:m_page->currentURL()], analysisType);
auto startTime = MonotonicTime::now();
- [ensureImageAnalyzer() processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion), startTime] (VKImageAnalysis *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);
+ [ensureImageAnalyzer() processRequest:request.get() progressHandler:nil completionHandler:makeBlockPtr([completion = WTFMove(completion), startTime, analysisType] (VKImageAnalysis *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);
completion(result);
}).get());
CFRunLoopWakeUp(CFRunLoopGetMain());
Modified: trunk/Source/WebKit/UIProcess/PageClient.h (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/PageClient.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/PageClient.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -160,6 +160,10 @@
enum class ContinueUnsafeLoad : bool { No, Yes };
+#if ENABLE(IMAGE_ANALYSIS)
+enum class ImageAnalysisType : uint8_t { Text, VisualSearch };
+#endif
+
struct FocusedElementInformation;
struct FrameInfoData;
struct InteractionInformationAtPosition;
@@ -540,7 +544,7 @@
#if ENABLE(IMAGE_ANALYSIS)
virtual void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completion) { completion({ }); }
- virtual void computeHasVisualSearchResults(const URL&, ShareableBitmap&, CompletionHandler<void(bool)>&& completion) { completion(false); }
+ virtual void computeHasImageAnalysisResults(const URL&, ShareableBitmap&, ImageAnalysisType, CompletionHandler<void(bool)>&& completion) { completion(false); }
#endif
#if ENABLE(MEDIA_CONTROLS_CONTEXT_MENUS) && USE(UICONTEXTMENU)
Modified: trunk/Source/WebKit/UIProcess/WebContextMenuProxy.h (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/WebContextMenuProxy.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/WebContextMenuProxy.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -33,6 +33,10 @@
#include <wtf/RefCounted.h>
#include <wtf/WeakPtr.h>
+#if PLATFORM(COCOA)
+#include "QuickLookPreviewActivity.h"
+#endif
+
OBJC_CLASS NSMenu;
namespace WebKit {
@@ -51,6 +55,7 @@
#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 (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2021-06-23 01:32:54 UTC (rev 279164)
@@ -212,6 +212,7 @@
#if PLATFORM(COCOA)
#include "InsertTextOptions.h"
+#include "QuickLookPreviewActivity.h"
#include "RemoteLayerTreeDrawingAreaProxy.h"
#include "RemoteLayerTreeScrollingPerformanceData.h"
#include "UserMediaCaptureManagerProxy.h"
@@ -6905,9 +6906,10 @@
++m_pendingLearnOrIgnoreWordMessageCount;
break;
- case ContextMenuItemTagLookUpImage:
+ case ContextMenuItemTagQuickLookImage:
#if ENABLE(IMAGE_ANALYSIS)
- handleContextMenuLookUpImage();
+ if (m_activeContextMenu)
+ handleContextMenuQuickLookImage(m_activeContextMenu->quickLookPreviewActivity());
#endif
return;
@@ -8499,14 +8501,15 @@
#if ENABLE(IMAGE_ANALYSIS)
+
void WebPageProxy::requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&& completionHandler)
{
pageClient().requestTextRecognition(imageURL, imageData, WTFMove(completionHandler));
}
-void WebPageProxy::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
+void WebPageProxy::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
{
- pageClient().computeHasVisualSearchResults(imageURL, imageBitmap, WTFMove(completion));
+ pageClient().computeHasImageAnalysisResults(imageURL, imageBitmap, type, WTFMove(completion));
}
void WebPageProxy::updateWithTextRecognitionResult(TextRecognitionResult&& results, const ElementContext& context, const FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&& completionHandler)
@@ -8518,8 +8521,9 @@
sendWithAsyncReply(Messages::WebPage::UpdateWithTextRecognitionResult(WTFMove(results), context, location), WTFMove(completionHandler));
}
-#endif
+#endif // ENABLE(IMAGE_ANALYSIS)
+
#if ENABLE(ENCRYPTED_MEDIA)
MediaKeySystemPermissionRequestManagerProxy& WebPageProxy::mediaKeySystemPermissionRequestManager()
{
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -402,6 +402,7 @@
struct WebPopupItem;
struct WebSpeechSynthesisVoice;
+enum class ImageAnalysisType : uint8_t;
enum class TextRecognitionUpdateResult : uint8_t;
enum class NegotiatedLegacyTLS : bool;
enum class ProcessSwapRequestedByClient : bool;
@@ -1659,7 +1660,7 @@
#if ENABLE(IMAGE_ANALYSIS)
void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&);
void updateWithTextRecognitionResult(WebCore::TextRecognitionResult&&, const WebCore::ElementContext&, const WebCore::FloatPoint& location, CompletionHandler<void(TextRecognitionUpdateResult)>&&);
- void computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&&);
+ void computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType, CompletionHandler<void(bool)>&&);
#endif
#if ENABLE(MEDIA_CONTROLS_CONTEXT_MENUS) && USE(UICONTEXTMENU)
@@ -1906,6 +1907,7 @@
#if ENABLE(IMAGE_ANALYSIS) && ENABLE(CONTEXT_MENUS)
void handleContextMenuLookUpImage();
+ void handleContextMenuQuickLookImage(QuickLookPreviewActivity);
#endif
#if USE(APPKIT)
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -132,7 +132,7 @@
#if ENABLE(IMAGE_ANALYSIS)
void requestTextRecognition(const URL& imageURL, const ShareableBitmap::Handle& imageData, CompletionHandler<void(WebCore::TextRecognitionResult&&)>&&) override;
- void computeHasVisualSearchResults(const URL&, ShareableBitmap&, CompletionHandler<void(bool)>&&) override;
+ void computeHasImageAnalysisResults(const URL&, ShareableBitmap&, ImageAnalysisType, CompletionHandler<void(bool)>&&) override;
#endif
RefPtr<WebPopupMenuProxy> createPopupMenuProxy(WebPageProxy&) override;
Modified: trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/mac/PageClientImplMac.mm 2021-06-23 01:32:54 UTC (rev 279164)
@@ -485,12 +485,12 @@
m_impl->requestTextRecognition(imageURL, imageData, WTFMove(completion));
}
-void PageClientImpl::computeHasVisualSearchResults(const URL& imageURL, ShareableBitmap& imageBitmap, CompletionHandler<void(bool)>&& completion)
+void PageClientImpl::computeHasImageAnalysisResults(const URL& imageURL, ShareableBitmap& imageBitmap, ImageAnalysisType type, CompletionHandler<void(bool)>&& completion)
{
- m_impl->computeHasVisualSearchResults(imageURL, imageBitmap, WTFMove(completion));
+ m_impl->computeHasImageAnalysisResults(imageURL, imageBitmap, type, WTFMove(completion));
}
-#endif
+#endif // ENABLE(IMAGE_ANALYSIS)
RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page)
{
Modified: trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -31,7 +31,7 @@
namespace WebKit {
class WebPageProxy;
-enum class QuickLookPreviewActivity : uint8_t { None, VisualSearch };
+enum class QuickLookPreviewActivity : uint8_t;
}
@class QLPreviewPanel;
Modified: trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.mm (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.mm 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/mac/WKQuickLookPreviewController.mm 2021-06-23 01:32:54 UTC (rev 279164)
@@ -28,6 +28,7 @@
#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 (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.h 2021-06-23 01:32:54 UTC (rev 279164)
@@ -60,6 +60,13 @@
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;
@@ -79,6 +86,7 @@
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 (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm 2021-06-23 01:32:54 UTC (rev 279164)
@@ -38,6 +38,7 @@
#import "WebContextMenuItem.h"
#import "WebContextMenuItemData.h"
#import "WebPageProxy.h"
+#import "WebPreferences.h"
#import <WebCore/GraphicsContext.h>
#import <WebCore/IntRect.h>
#import <WebCore/LocalizedStrings.h>
@@ -436,7 +437,7 @@
case ContextMenuItemTagReload:
return _WKMenuItemIdentifierReload;
- case ContextMenuItemTagLookUpImage:
+ case ContextMenuItemTagQuickLookImage:
return _WKMenuItemIdentifierRevealImage;
case ContextMenuItemTagSearchWeb:
@@ -507,18 +508,23 @@
});
}
- std::optional<WebContextMenuItemData> lookUpImageItem;
+ bool shouldUpdateQuickLookItemTitle = false;
+ std::optional<WebContextMenuItemData> quickLookItemToInsertIfNeeded;
#if ENABLE(IMAGE_ANALYSIS)
- filteredItems.removeFirstMatching([&] (auto& item) {
- if (item.action() != WebCore::ContextMenuItemTagLookUpImage)
- return false;
-
- lookUpImageItem = { item };
- return true;
+ auto indexOfQuickLookItem = filteredItems.findMatching([&] (auto& item) {
+ return item.action() == WebCore::ContextMenuItemTagQuickLookImage;
});
-#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) {
@@ -531,7 +537,7 @@
auto imageBitmap = m_context.webHitTestResultData().imageBitmap;
auto sparseMenuItems = retainPtr([NSPointerArray strongObjectsPointerArray]);
- auto insertMenuItem = makeBlockPtr([protectedThis = makeRef(*this), weakPage = makeWeakPtr(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 {
+ auto insertMenuItem = makeBlockPtr([protectedThis = makeRef(*this), weakPage = makeWeakPtr(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 {
ASSERT(index < [sparseMenuItems count]);
ASSERT(![sparseMenuItems pointerAtIndex:index]);
[sparseMenuItems replacePointerAtIndex:index withPointer:item];
@@ -541,13 +547,12 @@
[menu setItemArray:[sparseMenuItems allObjects]];
auto page = makeRefPtr(weakPage.get());
- if (lookUpImageItem && page && imageBitmap) {
+ if (page && imageBitmap) {
#if ENABLE(IMAGE_ANALYSIS)
- page->computeHasVisualSearchResults(imageURL, *imageBitmap, [protectedThis = WTFMove(protectedThis), lookUpImageItem = WTFMove(*lookUpImageItem)] (bool hasVisualSearchResults) mutable {
- if (hasVisualSearchResults)
- [protectedThis->m_menu addItem:createMenuActionItem(lookUpImageItem).get()];
- });
+ protectedThis->insertOrUpdateQuickLookImageItem(imageURL, imageBitmap.releaseNonNull(), WTFMove(quickLookItemToInsertIfNeeded), shouldUpdateQuickLookItemTitle);
#else
+ UNUSED_PARAM(quickLookItemToInsertIfNeeded);
+ UNUSED_PARAM(shouldUpdateQuickLookItemTitle);
UNUSED_PARAM(imageURL);
#endif
}
@@ -563,6 +568,63 @@
}
}
+#if ENABLE(IMAGE_ANALYSIS)
+
+void WebContextMenuProxyMac::insertOrUpdateQuickLookImageItem(const URL& imageURL, Ref<ShareableBitmap>&& imageBitmap, std::optional<WebContextMenuItemData>&& quickLookItemToInsertIfNeeded, bool shouldUpdateQuickLookItemTitle)
+{
+ auto page = makeRef(*this->page());
+ if (quickLookItemToInsertIfNeeded) {
+ page->computeHasImageAnalysisResults(imageURL, imageBitmap.get(), ImageAnalysisType::VisualSearch, [weakThis = makeWeakPtr(*this), quickLookItemToInsertIfNeeded = WTFMove(*quickLookItemToInsertIfNeeded)] (bool hasVisualSearchResults) mutable {
+ if (auto protectedThis = makeRefPtr(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 = makeWeakPtr(*this), weakPage = makeWeakPtr(page.get()), imageURL, imageBitmap = WTFMove(imageBitmap)] (bool hasVisualSearchResults) mutable {
+ auto protectedThis = makeRefPtr(weakThis.get());
+ if (!protectedThis)
+ return;
+
+ auto page = makeRefPtr(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 {
+ auto protectedThis = makeRefPtr(weakThis.get());
+ if (!protectedThis)
+ return;
+
+ if (auto page = makeRefPtr(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 (279163 => 279164)
--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm 2021-06-23 01:32:54 UTC (rev 279164)
@@ -746,13 +746,13 @@
#if ENABLE(IMAGE_ANALYSIS)
-void WebPageProxy::handleContextMenuLookUpImage()
+void WebPageProxy::handleContextMenuQuickLookImage(QuickLookPreviewActivity activity)
{
auto& result = m_activeContextMenuContextData.webHitTestResultData();
if (!result.imageBitmap)
return;
- showImageInQuickLookPreviewPanel(*result.imageBitmap, result.toolTipText, URL { URL { }, result.absoluteImageURL }, QuickLookPreviewActivity::VisualSearch);
+ showImageInQuickLookPreviewPanel(*result.imageBitmap, result.toolTipText, URL { URL { }, result.absoluteImageURL }, activity);
}
void WebPageProxy::showImageInQuickLookPreviewPanel(ShareableBitmap& imageBitmap, const String& tooltip, const URL& imageURL, QuickLookPreviewActivity activity)
Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (279163 => 279164)
--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj 2021-06-23 01:32:54 UTC (rev 279164)
@@ -5995,6 +5995,7 @@
F44DFEB01E9E752F0038D196 /* WebIconUtilities.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebIconUtilities.h; path = ios/WebIconUtilities.h; sourceTree = "<group>"; };
F44DFEB11E9E752F0038D196 /* WebIconUtilities.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = WebIconUtilities.mm; path = ios/WebIconUtilities.mm; 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>"; };
F48D2A8421583A0200C6752B /* AppKitSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppKitSPI.h; sourceTree = "<group>"; };
F496A42F1F58A272004C1757 /* DragDropInteractionState.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DragDropInteractionState.h; path = ios/DragDropInteractionState.h; sourceTree = "<group>"; };
@@ -7057,6 +7058,7 @@
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 (279163 => 279164)
--- trunk/Source/WebKitLegacy/mac/ChangeLog 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog 2021-06-23 01:32:54 UTC (rev 279164)
@@ -1,3 +1,16 @@
+2021-06-22 Wenson Hsieh <[email protected]>
+
+ [Live Text] [macOS] Add an internal option to disable inline text selection in images
+ https://bugs.webkit.org/show_bug.cgi?id=227265
+ rdar://79460142
+
+ Reviewed by Tim Horton.
+
+ Rename ContextMenuItemTagLookUpImage to ContextMenuItemTagQuickLookImage.
+
+ * WebView/WebHTMLView.mm:
+ (toTag):
+
2021-06-21 Wenson Hsieh <[email protected]>
[macOS] [WebKitLegacy] Non-actionable "Look Up" action appears when right clicking images
Modified: trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm (279163 => 279164)
--- trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm 2021-06-23 01:19:44 UTC (rev 279163)
+++ trunk/Source/WebKitLegacy/mac/WebView/WebHTMLView.mm 2021-06-23 01:32:54 UTC (rev 279164)
@@ -615,7 +615,7 @@
return WebMenuItemTagToggleVideoEnhancedFullscreen;
case ContextMenuItemTagTranslate:
return WebMenuItemTagTranslate;
- case ContextMenuItemTagLookUpImage:
+ case ContextMenuItemTagQuickLookImage:
return std::nullopt;
case ContextMenuItemBaseCustomTag ... ContextMenuItemLastCustomTag: