Title: [279098] trunk
Revision
279098
Author
[email protected]
Date
2021-06-21 18:22:20 -0700 (Mon, 21 Jun 2021)

Log Message

[macOS] [WebKitLegacy] Non-actionable "Look Up" action appears when right clicking images
https://bugs.webkit.org/show_bug.cgi?id=227240

Reviewed by Devin Rousso.

Source/WebCore:

The "Look Up" action currently appears in legacy WebKit, despite visual search not being supported in WebKit1.
Add and consult a context menu client hook to avoid inserting this item when its functionality is unsupported.

Test: fast/events/contextmenu-lookup-action-for-image.html

* loader/EmptyClients.cpp:
* page/ContextMenuClient.h:
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::populate):

Source/WebKit:

Override the new client hook and return true.

* WebProcess/WebCoreSupport/WebContextMenuClient.h:

Source/WebKitLegacy/mac:

Override the new client hook and return false in legacy WebKit.

* WebCoreSupport/WebContextMenuClient.h:

LayoutTests:

Add a layout test to check whether or not the "Look Up" action is available when right clicking image elements.
In WebKit2 prior to Monterey as well as legacy WebKit, this context menu action should not be present.

* fast/events/contextmenu-lookup-action-for-image-expected.txt: Added.
* fast/events/contextmenu-lookup-action-for-image.html: Added.
* platform/ios/TestExpectations:
* platform/win/TestExpectations:
* platform/wincairo-wk1/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (279097 => 279098)


--- trunk/LayoutTests/ChangeLog	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/LayoutTests/ChangeLog	2021-06-22 01:22:20 UTC (rev 279098)
@@ -1,3 +1,19 @@
+2021-06-21  Wenson Hsieh  <[email protected]>
+
+        [macOS] [WebKitLegacy] Non-actionable "Look Up" action appears when right clicking images
+        https://bugs.webkit.org/show_bug.cgi?id=227240
+
+        Reviewed by Devin Rousso.
+
+        Add a layout test to check whether or not the "Look Up" action is available when right clicking image elements.
+        In WebKit2 prior to Monterey as well as legacy WebKit, this context menu action should not be present.
+
+        * fast/events/contextmenu-lookup-action-for-image-expected.txt: Added.
+        * fast/events/contextmenu-lookup-action-for-image.html: Added.
+        * platform/ios/TestExpectations:
+        * platform/win/TestExpectations:
+        * platform/wincairo-wk1/TestExpectations:
+
 2021-06-21  Aditya Keerthi  <[email protected]>
 
         [iOS] Update textfield border color to match specification

Added: trunk/LayoutTests/fast/events/contextmenu-lookup-action-for-image-expected.txt (0 => 279098)


--- trunk/LayoutTests/fast/events/contextmenu-lookup-action-for-image-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/contextmenu-lookup-action-for-image-expected.txt	2021-06-22 01:22:20 UTC (rev 279098)
@@ -0,0 +1,2 @@
+
+Found lookup item? false

Added: trunk/LayoutTests/fast/events/contextmenu-lookup-action-for-image.html (0 => 279098)


--- trunk/LayoutTests/fast/events/contextmenu-lookup-action-for-image.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/contextmenu-lookup-action-for-image.html	2021-06-22 01:22:20 UTC (rev 279098)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+addEventListener("load", () => {
+    let image = document.querySelector("img");
+    eventSender.mouseMoveTo(130, 130);
+    testRunner.dumpAsText();
+
+    let foundLookUpItem = eventSender.contextClick().some((item) => (item.title || item).includes?.("Look Up"));
+    document.querySelector("pre").textContent = `Found lookup item? ${foundLookUpItem}`;
+});
+</script>
+</head>
+<body>
+<img src=""
+<pre></pre>
+</body>
+</html>
\ No newline at end of file

Modified: trunk/LayoutTests/platform/ios/TestExpectations (279097 => 279098)


--- trunk/LayoutTests/platform/ios/TestExpectations	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/LayoutTests/platform/ios/TestExpectations	2021-06-22 01:22:20 UTC (rev 279098)
@@ -456,6 +456,7 @@
 fast/events/clientXY-in-zoom-and-scroll.html [ Skip ]
 fast/events/context-onmousedown-event.html [ Skip ]
 fast/events/contextmenu-actions-in-selected-text.html [ Skip ]
+fast/events/contextmenu-lookup-action-for-image.html [ Skip ]
 fast/events/contextmenu-scrolled-page-with-frame.html [ Skip ]
 fast/events/data-transfer-files-attribute-identity.html [ Skip ]
 fast/events/dblclick-addEventListener.html [ Skip ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (279097 => 279098)


--- trunk/LayoutTests/platform/win/TestExpectations	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/LayoutTests/platform/win/TestExpectations	2021-06-22 01:22:20 UTC (rev 279098)
@@ -3458,6 +3458,7 @@
 fast/dom/collection-iterators.html [ Failure ]
 fast/events/context-activated-by-key-event.html [ Failure ]
 fast/events/contextmenu-actions-in-selected-text.html [ Failure ImageOnlyFailure ]
+fast/events/contextmenu-lookup-action-for-image.html [ Failure ]
 fast/events/webkit-media-key-events-constructor.html [ Failure ]
 fast/forms/validation-message-maxLength.html [ Failure ]
 fast/mediacapturefromelement/CanvasCaptureMediaStream-2d-events.html [ Failure ]

Modified: trunk/LayoutTests/platform/wincairo-wk1/TestExpectations (279097 => 279098)


--- trunk/LayoutTests/platform/wincairo-wk1/TestExpectations	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/LayoutTests/platform/wincairo-wk1/TestExpectations	2021-06-22 01:22:20 UTC (rev 279098)
@@ -447,3 +447,4 @@
 editing/pasteboard/smart-paste-paragraph-003.html [ Failure ]
 
 fast/events/contextmenu-actions-in-selected-text.html [ ImageOnlyFailure ]
+fast/events/contextmenu-lookup-action-for-image.html [ Failure ]

Modified: trunk/Source/WebCore/ChangeLog (279097 => 279098)


--- trunk/Source/WebCore/ChangeLog	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/Source/WebCore/ChangeLog	2021-06-22 01:22:20 UTC (rev 279098)
@@ -1,3 +1,20 @@
+2021-06-21  Wenson Hsieh  <[email protected]>
+
+        [macOS] [WebKitLegacy] Non-actionable "Look Up" action appears when right clicking images
+        https://bugs.webkit.org/show_bug.cgi?id=227240
+
+        Reviewed by Devin Rousso.
+
+        The "Look Up" action currently appears in legacy WebKit, despite visual search not being supported in WebKit1.
+        Add and consult a context menu client hook to avoid inserting this item when its functionality is unsupported.
+
+        Test: fast/events/contextmenu-lookup-action-for-image.html
+
+        * loader/EmptyClients.cpp:
+        * page/ContextMenuClient.h:
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::populate):
+
 2021-06-21  Aditya Keerthi  <[email protected]>
 
         [iOS] Update textfield border color to match specification

Modified: trunk/Source/WebCore/loader/EmptyClients.cpp (279097 => 279098)


--- trunk/Source/WebCore/loader/EmptyClients.cpp	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/Source/WebCore/loader/EmptyClients.cpp	2021-06-22 01:22:20 UTC (rev 279098)
@@ -130,6 +130,10 @@
 #if USE(ACCESSIBILITY_CONTEXT_MENUS)
     void showContextMenu() final { }
 #endif
+
+#if ENABLE(IMAGE_ANALYSIS)
+    bool supportsLookUpInImages() final { return false; }
+#endif
 };
 
 #endif // ENABLE(CONTEXT_MENUS)

Modified: trunk/Source/WebCore/page/ContextMenuClient.h (279097 => 279098)


--- trunk/Source/WebCore/page/ContextMenuClient.h	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/Source/WebCore/page/ContextMenuClient.h	2021-06-22 01:22:20 UTC (rev 279098)
@@ -51,6 +51,10 @@
     virtual void speak(const String&) = 0;
     virtual void stopSpeaking() = 0;
 
+#if ENABLE(IMAGE_ANALYSIS)
+    virtual bool supportsLookUpInImages() = 0;
+#endif
+
 #if HAVE(TRANSLATION_UI_SERVICES)
     virtual void handleTranslation(const TranslationContextMenuInfo&) = 0;
 #endif

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (279097 => 279098)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2021-06-22 01:22:20 UTC (rev 279098)
@@ -899,7 +899,7 @@
                 appendItem(CopyImageItem, m_contextMenu.get());
 
 #if ENABLE(IMAGE_ANALYSIS)
-                if (image && !image->isAnimated())
+                if (m_client.supportsLookUpInImages() && image && !image->isAnimated())
                     appendItem(LookUpImageItem, m_contextMenu.get());
 #endif
             }

Modified: trunk/Source/WebKit/ChangeLog (279097 => 279098)


--- trunk/Source/WebKit/ChangeLog	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/Source/WebKit/ChangeLog	2021-06-22 01:22:20 UTC (rev 279098)
@@ -1,3 +1,14 @@
+2021-06-21  Wenson Hsieh  <[email protected]>
+
+        [macOS] [WebKitLegacy] Non-actionable "Look Up" action appears when right clicking images
+        https://bugs.webkit.org/show_bug.cgi?id=227240
+
+        Reviewed by Devin Rousso.
+
+        Override the new client hook and return true.
+
+        * WebProcess/WebCoreSupport/WebContextMenuClient.h:
+
 2021-06-21  Don Olmstead  <[email protected]>
 
         Non-unified build fixes late June 2021 edition

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.h (279097 => 279098)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.h	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebContextMenuClient.h	2021-06-22 01:22:20 UTC (rev 279098)
@@ -52,6 +52,10 @@
     void speak(const String&) override;
     void stopSpeaking() override;
 
+#if ENABLE(IMAGE_ANALYSIS)
+    bool supportsLookUpInImages() final { return true; }
+#endif
+
 #if PLATFORM(COCOA)
     void searchWithSpotlight() override;
 #endif

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (279097 => 279098)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2021-06-22 01:22:20 UTC (rev 279098)
@@ -1,3 +1,14 @@
+2021-06-21  Wenson Hsieh  <[email protected]>
+
+        [macOS] [WebKitLegacy] Non-actionable "Look Up" action appears when right clicking images
+        https://bugs.webkit.org/show_bug.cgi?id=227240
+
+        Reviewed by Devin Rousso.
+
+        Override the new client hook and return false in legacy WebKit.
+
+        * WebCoreSupport/WebContextMenuClient.h:
+
 2021-06-17  Alex Christensen  <[email protected]>
 
         Remove empty header WebTypesInternal.h

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.h (279097 => 279098)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.h	2021-06-22 01:00:24 UTC (rev 279097)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebContextMenuClient.h	2021-06-22 01:22:20 UTC (rev 279098)
@@ -60,6 +60,10 @@
     void searchWithSpotlight() override;
     void showContextMenu() override;
 
+#if ENABLE(IMAGE_ANALYSIS)
+    bool supportsLookUpInImages() final { return false; }
+#endif
+
 #if ENABLE(SERVICE_CONTROLS)
     // WebSharingServicePickerClient
     void sharingServicePickerWillBeDestroyed(WebSharingServicePickerController &) override;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to