Title: [286762] trunk/Source
Revision
286762
Author
megan_gard...@apple.com
Date
2021-12-08 21:27:01 -0800 (Wed, 08 Dec 2021)

Log Message

Show correct content menu for images services chevron.
https://bugs.webkit.org/show_bug.cgi?id=233970

Reviewed by Tim Horton.

Add support for showing the correct context menu for image services.
Since this is internal only and can never be affected by web content, we bypass
the web content round trip and directly message the UIProcess about showing
a context menu for images. And because it would be bizarre if the web content
could prevent a menu from popping up on a button they have no control over.

Source/WebCore:

* dom/mac/ImageControlsMac.cpp:
(WebCore::ImageControlsMac::isImageControlsButtonElement):
(WebCore::ImageControlsMac::imageFromImageElementNode):
(WebCore::ImageControlsMac::handleEvent):
(WebCore::ImageControlsMac::imageControlHost): Deleted.
* dom/mac/ImageControlsMac.h:
* html/HTMLButtonElement.cpp:
(WebCore::HTMLButtonElement::defaultEventHandler):
* page/ChromeClient.h:
(WebCore::ChromeClient::handleImageServiceClick):
* page/ContextMenuController.cpp:
(WebCore::ContextMenuController::maybeCreateContextMenu):
(WebCore::imageFromImageElementNode): Deleted.

Source/WebKit:

* Shared/ContextMenuContextData.cpp:
(WebKit::ContextMenuContextData::ContextMenuContextData):
(WebKit::m_selectionIsEditable):
(WebKit::ContextMenuContextData::setImage):
(WebKit::ContextMenuContextData::controlledDataIsEditable const):
* Shared/ContextMenuContextData.h:
(WebKit::ContextMenuContextData::webHitTestResultData):
(WebKit::ContextMenuContextData::webHitTestResultData const):
* UIProcess/WebContextMenuProxy.cpp:
(WebKit::WebContextMenuProxy::show):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::contextMenuItemSelected):
* UIProcess/mac/WebContextMenuProxyMac.mm:
(WebKit::WebContextMenuProxyMac::getShareMenuItem):
(WebKit::WebContextMenuProxyMac::getContextMenuFromItems):
(WebKit::WebContextMenuProxyMac::useContextMenuItems):
* UIProcess/mac/WebPageProxyMac.mm:
(WebKit::WebPageProxy::handleContextMenuQuickLookImage):
* WebProcess/WebCoreSupport/WebChromeClient.cpp:
(WebKit::WebChromeClient::handleImageServiceClick):
* WebProcess/WebCoreSupport/WebChromeClient.h:
* WebProcess/WebPage/WebPage.h:
* WebProcess/WebPage/mac/WebPageMac.mm:
(WebKit::WebPage::handleImageServiceClick):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (286761 => 286762)


--- trunk/Source/WebCore/ChangeLog	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebCore/ChangeLog	2021-12-09 05:27:01 UTC (rev 286762)
@@ -1,3 +1,30 @@
+2021-12-08  Megan Gardner  <megan_gard...@apple.com>
+
+        Show correct content menu for images services chevron.
+        https://bugs.webkit.org/show_bug.cgi?id=233970
+
+        Reviewed by Tim Horton.
+
+        Add support for showing the correct context menu for image services.
+        Since this is internal only and can never be affected by web content, we bypass
+        the web content round trip and directly message the UIProcess about showing 
+        a context menu for images. And because it would be bizarre if the web content 
+        could prevent a menu from popping up on a button they have no control over.
+
+        * dom/mac/ImageControlsMac.cpp:
+        (WebCore::ImageControlsMac::isImageControlsButtonElement):
+        (WebCore::ImageControlsMac::imageFromImageElementNode):
+        (WebCore::ImageControlsMac::handleEvent):
+        (WebCore::ImageControlsMac::imageControlHost): Deleted.
+        * dom/mac/ImageControlsMac.h:
+        * html/HTMLButtonElement.cpp:
+        (WebCore::HTMLButtonElement::defaultEventHandler):
+        * page/ChromeClient.h:
+        (WebCore::ChromeClient::handleImageServiceClick):
+        * page/ContextMenuController.cpp:
+        (WebCore::ContextMenuController::maybeCreateContextMenu):
+        (WebCore::imageFromImageElementNode): Deleted.
+
 2021-12-08  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         [MacCatalyst] Fix Mac Catalyst build

Modified: trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp (286761 => 286762)


--- trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebCore/dom/mac/ImageControlsMac.cpp	2021-12-09 05:27:01 UTC (rev 286762)
@@ -26,9 +26,14 @@
 #include "config.h"
 #include "ImageControlsMac.h"
 
+#include "Chrome.h"
+#include "ChromeClient.h"
+#include "ContextMenuController.h"
 #include "ElementInlines.h"
+#include "EventHandler.h"
 #include "HTMLButtonElement.h"
 #include "HTMLDivElement.h"
+#include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "HTMLStyleElement.h"
 #include "RenderImage.h"
@@ -62,26 +67,9 @@
     return shadowRoot->hasElementWithId(*imageControlsElementIdentifier().impl());
 }
 
-static RefPtr<HTMLElement> imageControlHost(const Node& node)
-{
-    auto host = node.shadowHost();
-    if (!is<HTMLElement>(host))
-        return nullptr;
-
-    RefPtr element { &downcast<HTMLElement>(*host) };
-    return hasControls(*element) ? element : nullptr;
-}
-
 bool isImageControlsButtonElement(const Node& node)
 {
-    auto host = imageControlHost(node);
-    if (!host)
-        return false;
-
-    if (RefPtr controlRoot = static_cast<TreeScope&>(*host->userAgentShadowRoot()).getElementById(imageControlsButtonIdentifier()))
-        return node.isDescendantOf(*controlRoot);
-
-    return false;
+    return is<Element>(node) && downcast<Element>(node).getIdAttribute() == imageControlsButtonIdentifier();
 }
 
 void createImageControls(HTMLElement& element)
@@ -105,6 +93,51 @@
         downcast<RenderImage>(*renderObject).setHasShadowControls(true);
 }
 
+static Image* imageFromImageElementNode(Node& node)
+{
+    auto* renderer = node.renderer();
+    if (!is<RenderImage>(renderer))
+        return nullptr;
+    auto* image = downcast<RenderImage>(*renderer).cachedImage();
+    if (!image || image->errorOccurred())
+        return nullptr;
+    return image->imageForRenderer(renderer);
+}
+
+bool handleEvent(HTMLElement& element, Event& event)
+{
+    if (event.type() != eventNames().clickEvent)
+        return false;
+    
+    RefPtr frame = element.document().frame();
+    if (!frame)
+        return false;
+
+    Page* page = element.document().page();
+    if (!page)
+        return false;
+    
+    if (!is<MouseEvent>(event))
+        return false;
+    
+    auto& mouseEvent = downcast<MouseEvent>(event);
+    if (!is<Node>(mouseEvent.target()))
+        return false;
+    auto& node = downcast<Node>(*mouseEvent.target());
+
+    if (ImageControlsMac::isImageControlsButtonElement(node)) {
+        auto imageElement = node.shadowHost();
+        if (!imageElement)
+            return false;
+        if (auto* image = imageFromImageElementNode(*imageElement)) {
+            page->chrome().client().handleImageServiceClick(roundedIntPoint(mouseEvent.absoluteLocation()), *image, imageElement->isContentEditable());
+            event.setDefaultHandled();
+            return true;
+        }
+    }
+    return false;
+}
+
 #endif // ENABLE(SERVICE_CONTROLS)
 
 } // namespace ImageControlsMac

Modified: trunk/Source/WebCore/dom/mac/ImageControlsMac.h (286761 => 286762)


--- trunk/Source/WebCore/dom/mac/ImageControlsMac.h	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebCore/dom/mac/ImageControlsMac.h	2021-12-09 05:27:01 UTC (rev 286762)
@@ -39,6 +39,7 @@
 bool hasControls(const HTMLElement&);
 bool isImageControlsButtonElement(const Node&);
 void createImageControls(HTMLElement&);
+bool handleEvent(HTMLElement&, Event&);
 
 #endif // ENABLE(SERVICE_CONTROLS)
 

Modified: trunk/Source/WebCore/html/HTMLButtonElement.cpp (286761 => 286762)


--- trunk/Source/WebCore/html/HTMLButtonElement.cpp	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebCore/html/HTMLButtonElement.cpp	2021-12-09 05:27:01 UTC (rev 286762)
@@ -37,6 +37,10 @@
 #include <wtf/SetForScope.h>
 #include <wtf/StdLibExtras.h>
 
+#if ENABLE(SERVICE_CONTROLS)
+#include "ImageControlsMac.h"
+#endif
+
 namespace WebCore {
 
 WTF_MAKE_ISO_ALLOCATED_IMPL(HTMLButtonElement);
@@ -128,6 +132,10 @@
 
 void HTMLButtonElement::defaultEventHandler(Event& event)
 {
+#if ENABLE(SERVICE_CONTROLS)
+    if (ImageControlsMac::handleEvent(*this, event))
+        return;
+#endif
     if (event.type() == eventNames().DOMActivateEvent && !isDisabledFormControl()) {
         RefPtr<HTMLFormElement> protectedForm(form());
 

Modified: trunk/Source/WebCore/page/ChromeClient.h (286761 => 286762)


--- trunk/Source/WebCore/page/ChromeClient.h	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebCore/page/ChromeClient.h	2021-12-09 05:27:01 UTC (rev 286762)
@@ -532,6 +532,7 @@
 #if ENABLE(SERVICE_CONTROLS)
     virtual void handleSelectionServiceClick(FrameSelection&, const Vector<String>&, const IntPoint&) { }
     virtual bool hasRelevantSelectionServices(bool /*isTextOnly*/) const { return false; }
+    virtual void handleImageServiceClick(const IntPoint&, Image&, bool /*isEditable*/) { }
 #endif
 
     virtual bool shouldDispatchFakeMouseMoveEvents() const { return true; }

Modified: trunk/Source/WebCore/page/ContextMenuController.cpp (286761 => 286762)


--- trunk/Source/WebCore/page/ContextMenuController.cpp	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebCore/page/ContextMenuController.cpp	2021-12-09 05:27:01 UTC (rev 286762)
@@ -147,21 +147,6 @@
     showContextMenu(event);
 }
 
-#if ENABLE(SERVICE_CONTROLS)
-
-static Image* imageFromImageElementNode(Node& node)
-{
-    auto* renderer = node.renderer();
-    if (!is<RenderImage>(renderer))
-        return nullptr;
-    auto* image = downcast<RenderImage>(*renderer).cachedImage();
-    if (!image || image->errorOccurred())
-        return nullptr;
-    return image->imageForRenderer(renderer);
-}
-
-#endif
-
 std::unique_ptr<ContextMenu> ContextMenuController::maybeCreateContextMenu(Event& event, OptionSet<HitTestRequest::Type> hitType, ContextMenuContext::Type contextType)
 {
     if (!is<MouseEvent>(event))
@@ -180,16 +165,6 @@
         return nullptr;
 
     m_context = ContextMenuContext(contextType, result);
-
-#if ENABLE(SERVICE_CONTROLS)
-    if (ImageControlsMac::isImageControlsButtonElement(node)) {
-        if (auto* image = imageFromImageElementNode(*result.innerNonSharedNode()))
-            m_context.setControlledImage(image);
-
-        // FIXME: If we couldn't get the image then we shouldn't try to show the image controls menu for it.
-        return nullptr;
-    }
-#endif
     
     return makeUnique<ContextMenu>();
 }

Modified: trunk/Source/WebKit/ChangeLog (286761 => 286762)


--- trunk/Source/WebKit/ChangeLog	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/ChangeLog	2021-12-09 05:27:01 UTC (rev 286762)
@@ -1,3 +1,41 @@
+2021-12-08  Megan Gardner  <megan_gard...@apple.com>
+
+        Show correct content menu for images services chevron.
+        https://bugs.webkit.org/show_bug.cgi?id=233970
+
+        Reviewed by Tim Horton.
+
+        Add support for showing the correct context menu for image services.
+        Since this is internal only and can never be affected by web content, we bypass
+        the web content round trip and directly message the UIProcess about showing 
+        a context menu for images. And because it would be bizarre if the web content 
+        could prevent a menu from popping up on a button they have no control over.
+
+        * Shared/ContextMenuContextData.cpp:
+        (WebKit::ContextMenuContextData::ContextMenuContextData):
+        (WebKit::m_selectionIsEditable):
+        (WebKit::ContextMenuContextData::setImage):
+        (WebKit::ContextMenuContextData::controlledDataIsEditable const):
+        * Shared/ContextMenuContextData.h:
+        (WebKit::ContextMenuContextData::webHitTestResultData):
+        (WebKit::ContextMenuContextData::webHitTestResultData const):
+        * UIProcess/WebContextMenuProxy.cpp:
+        (WebKit::WebContextMenuProxy::show):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::contextMenuItemSelected):
+        * UIProcess/mac/WebContextMenuProxyMac.mm:
+        (WebKit::WebContextMenuProxyMac::getShareMenuItem):
+        (WebKit::WebContextMenuProxyMac::getContextMenuFromItems):
+        (WebKit::WebContextMenuProxyMac::useContextMenuItems):
+        * UIProcess/mac/WebPageProxyMac.mm:
+        (WebKit::WebPageProxy::handleContextMenuQuickLookImage):
+        * WebProcess/WebCoreSupport/WebChromeClient.cpp:
+        (WebKit::WebChromeClient::handleImageServiceClick):
+        * WebProcess/WebCoreSupport/WebChromeClient.h:
+        * WebProcess/WebPage/WebPage.h:
+        * WebProcess/WebPage/mac/WebPageMac.mm:
+        (WebKit::WebPage::handleImageServiceClick):
+
 2021-12-08  Kyle Piddington  <kpidding...@apple.com>
 
         [MacCatalyst] Update header search paths for ANGLE Catalyst

Modified: trunk/Source/WebKit/Shared/ContextMenuContextData.cpp (286761 => 286762)


--- trunk/Source/WebKit/Shared/ContextMenuContextData.cpp	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/Shared/ContextMenuContextData.cpp	2021-12-09 05:27:01 UTC (rev 286762)
@@ -51,7 +51,7 @@
 #endif
     , m_menuLocation(menuLocation)
     , m_menuItems(menuItems)
-    , m_webHitTestResultData(context.hitTestResult(), true)
+    , m_webHitTestResultData({ context.hitTestResult(), true })
     , m_selectedText(context.selectedText())
 #if ENABLE(SERVICE_CONTROLS)
     , m_selectionIsEditable(false)
@@ -61,7 +61,22 @@
     Image* image = context.controlledImage();
     if (!image)
         return;
+    
+    setImage(image);
+#endif
+}
 
+#if ENABLE(SERVICE_CONTROLS)
+ContextMenuContextData::ContextMenuContextData(const WebCore::IntPoint& menuLocation, WebCore::Image& image, bool isEditable)
+    : m_type(Type::ServicesMenu)
+    , m_menuLocation(menuLocation)
+    , m_selectionIsEditable(isEditable)
+{
+    setImage(&image);
+}
+
+void ContextMenuContextData::setImage(WebCore::Image* image)
+{
     // FIXME: figure out the rounding strategy for ShareableBitmap.
     m_controlledImage = ShareableBitmap::createShareable(IntSize(image->size()), { });
     auto graphicsContext = m_controlledImage->createGraphicsContext();
@@ -68,8 +83,8 @@
     if (!graphicsContext)
         return;
     graphicsContext->drawImage(*image, IntPoint());
+}
 #endif
-}
 
 void ContextMenuContextData::encode(IPC::Encoder& encoder) const
 {
@@ -129,12 +144,9 @@
 #if ENABLE(SERVICE_CONTROLS)
 bool ContextMenuContextData::controlledDataIsEditable() const
 {
-    if (!m_controlledSelectionData.isEmpty())
+    if (!m_controlledSelectionData.isEmpty() || m_controlledImage)
         return m_selectionIsEditable;
 
-    if (m_controlledImage)
-        return m_webHitTestResultData.isContentEditable;
-
     return false;
 }
 #endif

Modified: trunk/Source/WebKit/Shared/ContextMenuContextData.h (286761 => 286762)


--- trunk/Source/WebKit/Shared/ContextMenuContextData.h	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/Shared/ContextMenuContextData.h	2021-12-09 05:27:01 UTC (rev 286762)
@@ -51,8 +51,7 @@
     const WebCore::IntPoint& menuLocation() const { return m_menuLocation; }
     const Vector<WebKit::WebContextMenuItemData>& menuItems() const { return m_menuItems; }
 
-    WebHitTestResultData& webHitTestResultData() { return m_webHitTestResultData; }
-    const WebHitTestResultData& webHitTestResultData() const { return m_webHitTestResultData; }
+    const std::optional<WebHitTestResultData>& webHitTestResultData() const { return m_webHitTestResultData; }
     const String& selectedText() const { return m_selectedText; }
 
 #if ENABLE(SERVICE_CONTROLS)
@@ -64,6 +63,8 @@
         , m_selectionIsEditable(isEditable)
     {
     }
+    
+    ContextMenuContextData(const WebCore::IntPoint& menuLocation, WebCore::Image&, bool isEditable);
 
     ShareableBitmap* controlledImage() const { return m_controlledImage.get(); }
     const Vector<uint8_t>& controlledSelectionData() const { return m_controlledSelectionData; }
@@ -82,10 +83,12 @@
     WebCore::IntPoint m_menuLocation;
     Vector<WebKit::WebContextMenuItemData> m_menuItems;
 
-    WebHitTestResultData m_webHitTestResultData;
+    std::optional<WebHitTestResultData> m_webHitTestResultData;
     String m_selectedText;
 
 #if ENABLE(SERVICE_CONTROLS)
+    void setImage(WebCore::Image*);
+    
     RefPtr<ShareableBitmap> m_controlledImage;
     Vector<uint8_t> m_controlledSelectionData;
     Vector<String> m_selectedTelephoneNumbers;

Modified: trunk/Source/WebKit/UIProcess/WebContextMenuProxy.cpp (286761 => 286762)


--- trunk/Source/WebKit/UIProcess/WebContextMenuProxy.cpp	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/UIProcess/WebContextMenuProxy.cpp	2021-12-09 05:27:01 UTC (rev 286762)
@@ -53,8 +53,10 @@
 
 void WebContextMenuProxy::show()
 {
+    ASSERT(m_context.webHitTestResultData());
+    
     m_contextMenuListener = WebContextMenuListenerProxy::create(*this);
-    page()->contextMenuClient().getContextMenuFromProposedMenu(*page(), proposedItems(), *m_contextMenuListener, m_context.webHitTestResultData(), page()->process().transformHandlesToObjects(m_userData.object()).get());
+    page()->contextMenuClient().getContextMenuFromProposedMenu(*page(), proposedItems(), *m_contextMenuListener, m_context.webHitTestResultData().value(), page()->process().transformHandlesToObjects(m_userData.object()).get());
 }
 
 void WebContextMenuProxy::useContextMenuItems(Vector<Ref<WebContextMenuItem>>&& items)

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (286761 => 286762)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2021-12-09 05:27:01 UTC (rev 286762)
@@ -6930,6 +6930,10 @@
         String suggestedFilename;
     };
     std::optional<DownloadInfo> downloadInfo;
+    
+    ASSERT(m_activeContextMenuContextData.webHitTestResultData());
+    
+    auto hitTestData = m_activeContextMenuContextData.webHitTestResultData().value();
 
     switch (item.action()) {
 #if PLATFORM(COCOA)
@@ -6968,17 +6972,16 @@
 #endif
 
     case ContextMenuItemTagDownloadImageToDisk:
-        downloadInfo = {{ m_activeContextMenuContextData.webHitTestResultData().absoluteImageURL, { } }};
+        downloadInfo = { { hitTestData.absoluteImageURL, { } } };
         break;
 
     case ContextMenuItemTagDownloadLinkToDisk: {
-        auto& hitTestResult = m_activeContextMenuContextData.webHitTestResultData();
-        downloadInfo = {{ hitTestResult.absoluteLinkURL, hitTestResult.linkSuggestedFilename }};
+        downloadInfo = { { hitTestData.absoluteLinkURL, hitTestData.linkSuggestedFilename } };
         break;
     }
 
     case ContextMenuItemTagDownloadMediaToDisk:
-        downloadInfo = {{ m_activeContextMenuContextData.webHitTestResultData().absoluteMediaURL, { } }};
+        downloadInfo = { { hitTestData.absoluteMediaURL, { } } };
         break;
 
     case ContextMenuItemTagCheckSpellingWhileTyping:

Modified: trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm (286761 => 286762)


--- trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/UIProcess/mac/WebContextMenuProxyMac.mm	2021-12-09 05:27:01 UTC (rev 286762)
@@ -309,7 +309,8 @@
 
 void WebContextMenuProxyMac::getShareMenuItem(CompletionHandler<void(NSMenuItem *)>&& completionHandler)
 {
-    const WebHitTestResultData& hitTestData = m_context.webHitTestResultData();
+    ASSERT(m_context.webHitTestResultData());
+    auto hitTestData = m_context.webHitTestResultData().value();
 
     auto items = adoptNS([[NSMutableArray alloc] init]);
 
@@ -533,8 +534,11 @@
     }
 #endif
 
-    auto imageURL = URL { URL { }, m_context.webHitTestResultData().absoluteImageURL };
-    auto imageBitmap = m_context.webHitTestResultData().imageBitmap;
+    ASSERT(m_context.webHitTestResultData());
+    auto hitTestData = m_context.webHitTestResultData().value();
+    
+    auto imageURL = URL { URL { }, hitTestData.absoluteImageURL };
+    auto imageBitmap = hitTestData.imageBitmap;
 
     auto sparseMenuItems = retainPtr([NSPointerArray strongObjectsPointerArray]);
     auto insertMenuItem = makeBlockPtr([protectedThis = Ref { *this }, weakPage = WeakPtr { page() }, imageURL = WTFMove(imageURL), imageBitmap = WTFMove(imageBitmap), shouldUpdateQuickLookItemTitle, quickLookItemToInsertIfNeeded = WTFMove(quickLookItemToInsertIfNeeded), completionHandler = WTFMove(completionHandler), itemsRemaining = filteredItems.size(), menu = WTFMove(menu), sparseMenuItems](NSMenuItem *item, NSUInteger index) mutable {
@@ -715,8 +719,9 @@
             menuFromProposedMenu(menu);
             return;
         }
-
-        page()->contextMenuClient().menuFromProposedMenu(*page(), menu, m_context.webHitTestResultData(), m_userData.object(), WTFMove(menuFromProposedMenu));
+        
+        ASSERT(m_context.webHitTestResultData());
+        page()->contextMenuClient().menuFromProposedMenu(*page(), menu, m_context.webHitTestResultData().value(), m_userData.object(), WTFMove(menuFromProposedMenu));
     });
 }
 

Modified: trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm (286761 => 286762)


--- trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/UIProcess/mac/WebPageProxyMac.mm	2021-12-09 05:27:01 UTC (rev 286762)
@@ -751,7 +751,9 @@
 
 void WebPageProxy::handleContextMenuQuickLookImage(QuickLookPreviewActivity activity)
 {
-    auto& result = m_activeContextMenuContextData.webHitTestResultData();
+    ASSERT(m_activeContextMenuContextData.webHitTestResultData());
+    
+    auto result = m_activeContextMenuContextData.webHitTestResultData().value();
     if (!result.imageBitmap)
         return;
 

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp (286761 => 286762)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.cpp	2021-12-09 05:27:01 UTC (rev 286762)
@@ -1347,6 +1347,11 @@
     return (isTextOnly && WebProcess::singleton().hasSelectionServices()) || WebProcess::singleton().hasRichContentServices();
 }
 
+void WebChromeClient::handleImageServiceClick(const IntPoint& point, Image& image, bool isEditable)
+{
+    m_page.handleImageServiceClick(point, image, isEditable);
+}
+
 #endif
 
 bool WebChromeClient::shouldDispatchFakeMouseMoveEvents() const

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h (286761 => 286762)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/WebChromeClient.h	2021-12-09 05:27:01 UTC (rev 286762)
@@ -381,6 +381,7 @@
 #if ENABLE(SERVICE_CONTROLS)
     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&) final;
     bool hasRelevantSelectionServices(bool isTextOnly) const final;
+    void handleImageServiceClick(const WebCore::IntPoint&, WebCore::Image&, bool isEditable) final;
 #endif
 
     bool shouldDispatchFakeMouseMoveEvents() const final;

Modified: trunk/Source/WebKit/WebProcess/WebPage/WebPage.h (286761 => 286762)


--- trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/WebProcess/WebPage/WebPage.h	2021-12-09 05:27:01 UTC (rev 286762)
@@ -1203,6 +1203,7 @@
 #if ENABLE(SERVICE_CONTROLS) || ENABLE(TELEPHONE_NUMBER_DETECTION)
     void handleTelephoneNumberClick(const String& number, const WebCore::IntPoint&);
     void handleSelectionServiceClick(WebCore::FrameSelection&, const Vector<String>& telephoneNumbers, const WebCore::IntPoint&);
+    void handleImageServiceClick(const WebCore::IntPoint&, WebCore::Image&, bool isEditable);
 #endif
 
     void didChangeScrollOffsetForFrame(WebCore::Frame*);

Modified: trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm (286761 => 286762)


--- trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2021-12-09 04:21:43 UTC (rev 286761)
+++ trunk/Source/WebKit/WebProcess/WebPage/mac/WebPageMac.mm	2021-12-09 05:27:01 UTC (rev 286762)
@@ -828,6 +828,11 @@
     send(Messages::WebPageProxy::ShowContextMenu(ContextMenuContextData(point, selectionDataVector, phoneNumbers, selection.selection().isContentEditable()), UserData()));
 }
 
+void WebPage::handleImageServiceClick(const IntPoint& point, Image& image, bool isEditable)
+{
+    send(Messages::WebPageProxy::ShowContextMenu(ContextMenuContextData(point, image, isEditable), UserData()));
+}
+
 #endif
 
 String WebPage::platformUserAgent(const URL&) const
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to