Diff
Modified: trunk/Source/WebKit2/ChangeLog (207557 => 207558)
--- trunk/Source/WebKit2/ChangeLog 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/ChangeLog 2016-10-19 19:45:49 UTC (rev 207558)
@@ -1,3 +1,36 @@
+2016-10-19 Damian Kaleta <dkal...@apple.com>
+
+ https://bugs.webkit.org/show_bug.cgi?id=163292
+
+ Reviewed by Brady Eidson.
+
+ Added ability to display context menu asynchronously.
+
+ * Shared/API/APIObject.h: Added ContextMenuListener.
+ * Shared/API/c/WKBase.h: Added WKContextMenuListenerRef struct.
+ * UIProcess/API/APIContextMenuClient.h:
+ (API::ContextMenuClient::getContextMenuFromProposedMenuAsync): New method that allows showing context menu asynchronously.
+ * UIProcess/API/C/WKAPICast.h: Added a new mapping for WebContextMenuListenerProxy.
+ * UIProcess/API/C/WKContextMenuListener.cpp: Added. New class that allow a client to return results asynchronously.
+ (WKContextMenuListenerGetTypeID):
+ (WKContextMenuListenerUseContextMenuItems):
+ * UIProcess/API/C/WKContextMenuListener.h: Added.
+ * UIProcess/API/C/WKPage.cpp: Added WKPageContextMenuClientV4.
+ (WKPageSetPageContextMenuClient):
+ * UIProcess/API/C/WKPageContextMenuClient.h:
+ * UIProcess/WebContextMenuListenerProxy.cpp: Copied from Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h.
+ (WebKit::WebContextMenuListenerProxy::WebContextMenuListenerProxy):
+ (WebKit::WebContextMenuListenerProxy::~WebContextMenuListenerProxy):
+ (WebKit::WebContextMenuListenerProxy::useContextMenuItems): Passes items to m_contextMenuMac.
+ (WebKit::WebContextMenuListenerProxy::invalidate):
+ * UIProcess/WebContextMenuListenerProxy.h: Copied from Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h.
+ (WebKit::WebContextMenuListenerProxy::create):
+ * UIProcess/mac/WebContextMenuProxyMac.h:
+ * UIProcess/mac/WebContextMenuProxyMac.mm:
+ (WebKit::WebContextMenuProxyMac::showContextMenuWithItems): Shows context menu.
+ (WebKit::WebContextMenuProxyMac::showContextMenu): Extracted some logic to showContextMenuWithItems().
+ * WebKit2.xcodeproj/project.pbxproj:
+
2016-10-19 Myles C. Maxfield <mmaxfi...@apple.com>
[macOS] [iOS] Disable variation fonts on macOS El Capitan and iOS 9
Modified: trunk/Source/WebKit2/Shared/API/APIObject.h (207557 => 207558)
--- trunk/Source/WebKit2/Shared/API/APIObject.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/Shared/API/APIObject.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -105,6 +105,7 @@
BatteryStatus,
CacheManager,
ColorPickerResultListener,
+ ContextMenuListener,
CookieManager,
Download,
ExperimentalFeature,
Modified: trunk/Source/WebKit2/Shared/API/c/WKBase.h (207557 => 207558)
--- trunk/Source/WebKit2/Shared/API/c/WKBase.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/Shared/API/c/WKBase.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -95,6 +95,7 @@
typedef const struct OpaqueWKColorPickerResultListener* WKColorPickerResultListenerRef;
typedef const struct OpaqueWKContext* WKContextRef;
typedef const struct OpaqueWKContextConfiguration* WKContextConfigurationRef;
+typedef const struct OpaqueWKContextMenuListener* WKContextMenuListenerRef;
typedef const struct OpaqueWKCookieManager* WKCookieManagerRef;
typedef const struct OpaqueWKCredential* WKCredentialRef;
typedef const struct OpaqueWKDownload* WKDownloadRef;
Modified: trunk/Source/WebKit2/UIProcess/API/APIContextMenuClient.h (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/API/APIContextMenuClient.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/API/APIContextMenuClient.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -28,7 +28,9 @@
#if ENABLE(CONTEXT_MENUS)
+#include "WebContextMenuListenerProxy.h"
#include "WebHitTestResultData.h"
+#include <WebKit/WKBase.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
@@ -51,6 +53,7 @@
virtual ~ContextMenuClient() { }
virtual bool getContextMenuFromProposedMenu(WebKit::WebPageProxy&, const Vector<RefPtr<WebKit::WebContextMenuItem>>& /* proposedMenu */, Vector<RefPtr<WebKit::WebContextMenuItem>>& /* customMenu */, const WebKit::WebHitTestResultData&, API::Object* /* userData */) { return false; }
+ virtual bool getContextMenuFromProposedMenuAsync(WebKit::WebPageProxy&, const Vector<RefPtr<WebKit::WebContextMenuItem>>& /* proposedMenu */, WebKit::WebContextMenuListenerProxy*, const WebKit::WebHitTestResultData&, API::Object* /* userData */) { return false; }
virtual void customContextMenuItemSelected(WebKit::WebPageProxy&, const WebKit::WebContextMenuItemData&) { }
virtual bool showContextMenu(WebKit::WebPageProxy&, const WebCore::IntPoint&, const Vector<RefPtr<WebKit::WebContextMenuItem>>&) { return false; }
virtual bool hideContextMenu(WebKit::WebPageProxy&) { return false; }
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -84,6 +84,7 @@
class WebBatteryManagerProxy;
class WebBatteryStatus;
class WebColorPickerResultListenerProxy;
+class WebContextMenuListenerProxy;
class WebCookieManagerProxy;
class WebCredential;
class WebFormSubmissionListenerProxy;
@@ -122,6 +123,7 @@
WK_ADD_API_MAPPING(WKColorPickerResultListenerRef, WebColorPickerResultListenerProxy)
WK_ADD_API_MAPPING(WKContextRef, WebProcessPool)
WK_ADD_API_MAPPING(WKContextConfigurationRef, API::ProcessPoolConfiguration)
+WK_ADD_API_MAPPING(WKContextMenuListenerRef, WebContextMenuListenerProxy)
WK_ADD_API_MAPPING(WKCookieManagerRef, WebCookieManagerProxy)
WK_ADD_API_MAPPING(WKCredentialRef, WebCredential)
WK_ADD_API_MAPPING(WKDownloadRef, DownloadProxy)
Copied: trunk/Source/WebKit2/UIProcess/API/C/WKContextMenuListener.cpp (from rev 207557, trunk/Source/WebKit2/UIProcess/WebContextMenuProxy.h) (0 => 207558)
--- trunk/Source/WebKit2/UIProcess/API/C/WKContextMenuListener.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContextMenuListener.cpp 2016-10-19 19:45:49 UTC (rev 207558)
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#include "config.h"
+#include "WKContextMenuListener.h"
+
+#include "WKAPICast.h"
+#include "WebContextMenuListenerProxy.h"
+
+using namespace WebKit;
+
+WKTypeID WKContextMenuListenerGetTypeID()
+{
+#if ENABLE(CONTEXT_MENUS)
+ return toAPI(WebContextMenuListenerProxy::APIType);
+#else
+ return toAPI(API::Object::Type::Null);
+#endif
+}
+
+void WKContextMenuListenerUseContextMenuItems(WKContextMenuListenerRef listenerRef, WKArrayRef items)
+{
+#if ENABLE(CONTEXT_MENUS)
+ toImpl(listenerRef)->useContextMenuItems(items);
+#else
+ UNUSED_PARAM(listenerRef);
+ UNUSED_PARAM(items);
+#endif
+}
Copied: trunk/Source/WebKit2/UIProcess/API/C/WKContextMenuListener.h (from rev 207557, trunk/Source/WebKit2/UIProcess/WebContextMenuProxy.h) (0 => 207558)
--- trunk/Source/WebKit2/UIProcess/API/C/WKContextMenuListener.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKContextMenuListener.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2016 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
+
+#include <WebKit/WKBase.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+WK_EXPORT WKTypeID WKContextMenuListenerGetTypeID();
+
+WK_EXPORT void WKContextMenuListenerUseContextMenuItems(WKContextMenuListenerRef, WKArrayRef);
+
+#ifdef __cplusplus
+}
+#endif
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2016-10-19 19:45:49 UTC (rev 207558)
@@ -114,7 +114,7 @@
#if ENABLE(CONTEXT_MENUS)
template<> struct ClientTraits<WKPageContextMenuClientBase> {
- typedef std::tuple<WKPageContextMenuClientV0, WKPageContextMenuClientV1, WKPageContextMenuClientV2, WKPageContextMenuClientV3> Versions;
+ typedef std::tuple<WKPageContextMenuClientV0, WKPageContextMenuClientV1, WKPageContextMenuClientV2, WKPageContextMenuClientV3, WKPageContextMenuClientV4> Versions;
};
#endif
@@ -852,6 +852,23 @@
return true;
}
+ bool getContextMenuFromProposedMenuAsync(WebPageProxy& page, const Vector<RefPtr<WebKit::WebContextMenuItem>>& proposedMenuVector, WebKit::WebContextMenuListenerProxy* contextMenuListener, const WebHitTestResultData& hitTestResultData, API::Object* userData) override
+ {
+ if (m_client.base.version < 4 || !m_client.getContextMenuFromProposedMenuAsync)
+ return false;
+
+ Vector<RefPtr<API::Object>> proposedMenuItems;
+ proposedMenuItems.reserveInitialCapacity(proposedMenuVector.size());
+
+ for (const auto& menuItem : proposedMenuVector)
+ proposedMenuItems.uncheckedAppend(menuItem);
+
+ RefPtr<API::HitTestResult> webHitTestResult = API::HitTestResult::create(hitTestResultData);
+ m_client.getContextMenuFromProposedMenuAsync(toAPI(&page), toAPI(API::Array::create(WTFMove(proposedMenuItems)).ptr()), toAPI(contextMenuListener), toAPI(webHitTestResult.get()), toAPI(userData), m_client.base.clientInfo);
+
+ return true;
+ }
+
void customContextMenuItemSelected(WebPageProxy& page, const WebContextMenuItemData& itemData) override
{
if (!m_client.customContextMenuItemSelected)
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPageContextMenuClient.h (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPageContextMenuClient.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPageContextMenuClient.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -34,6 +34,7 @@
#endif
typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo);
+typedef void (*WKPageGetContextMenuFromProposedContextMenuCallbackAsync)(WKPageRef page, WKArrayRef proposedMenu, WKContextMenuListenerRef listener, WKHitTestResultRef hitTestResult, WKTypeRef userData, const void* clientInfo);
typedef void (*WKPageCustomContextMenuItemSelectedCallback)(WKPageRef page, WKContextMenuItemRef contextMenuItem, const void* clientInfo);
typedef void (*WKPageContextMenuDismissedCallback)(WKPageRef page, const void* clientInfo);
typedef void (*WKPageShowContextMenuCallback)(WKPageRef page, WKPoint menuLocation, WKArrayRef menuItems, const void* clientInfo);
@@ -98,6 +99,28 @@
WKPageHideContextMenuCallback hideContextMenu;
} WKPageContextMenuClientV3;
+typedef struct WKPageContextMenuClientV4 {
+ WKPageContextMenuClientBase base;
+
+ // Version 0.
+ WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0 getContextMenuFromProposedMenu_deprecatedForUseWithV0;
+ WKPageCustomContextMenuItemSelectedCallback customContextMenuItemSelected;
+
+ // Version 1.
+ WKPageContextMenuDismissedCallback contextMenuDismissed;
+
+ // Version 2.
+ WKPageGetContextMenuFromProposedContextMenuCallback getContextMenuFromProposedMenu;
+
+ // Version 3.
+ WKPageShowContextMenuCallback showContextMenu;
+ WKPageHideContextMenuCallback hideContextMenu;
+
+ // Version 4.
+ WKPageGetContextMenuFromProposedContextMenuCallbackAsync getContextMenuFromProposedMenuAsync;
+
+} WKPageContextMenuClientV4;
+
#ifdef __cplusplus
}
#endif
Copied: trunk/Source/WebKit2/UIProcess/WebContextMenuListenerProxy.cpp (from rev 207557, trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.h) (0 => 207558)
--- trunk/Source/WebKit2/UIProcess/WebContextMenuListenerProxy.cpp (rev 0)
+++ trunk/Source/WebKit2/UIProcess/WebContextMenuListenerProxy.cpp 2016-10-19 19:45:49 UTC (rev 207558)
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2016 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.
+ */
+
+#if ENABLE(CONTEXT_MENUS)
+
+#include "config.h"
+#include "WebContextMenuListenerProxy.h"
+
+#include "WKAPICast.h"
+#include "WKArray.h"
+#include "WebContextMenuItem.h"
+#include "WebContextMenuItemData.h"
+
+using namespace WebCore;
+
+namespace WebKit {
+
+WebContextMenuListenerProxy::WebContextMenuListenerProxy(WebContextMenuProxy* contextMenuMac)
+ : m_contextMenuMac(contextMenuMac)
+{
+}
+
+WebContextMenuListenerProxy::~WebContextMenuListenerProxy()
+{
+}
+
+void WebContextMenuListenerProxy::useContextMenuItems(WKArrayRef items)
+{
+ if (!m_contextMenuMac)
+ return;
+
+ RefPtr<API::Array> array = toImpl(items);
+ Vector<WebContextMenuItemData> dataItems;
+
+ size_t newSize = array ? array->size() : 0;
+ for (size_t i = 0; i < newSize; ++i) {
+ WebContextMenuItem* item = array->at<WebContextMenuItem>(i);
+ if (!item)
+ continue;
+
+ dataItems.append(item->data());
+ }
+
+ m_contextMenuMac->showContextMenuWithItems(dataItems);
+}
+
+void WebContextMenuListenerProxy::invalidate()
+{
+ m_contextMenuMac = nullptr;
+}
+
+} // namespace WebKit
+
+#endif // ENABLE(CONTEXT_MENUS)
Copied: trunk/Source/WebKit2/UIProcess/WebContextMenuListenerProxy.h (from rev 207557, trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.h) (0 => 207558)
--- trunk/Source/WebKit2/UIProcess/WebContextMenuListenerProxy.h (rev 0)
+++ trunk/Source/WebKit2/UIProcess/WebContextMenuListenerProxy.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 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 ENABLE(CONTEXT_MENUS)
+
+#include "APIObject.h"
+#include "WKArray.h"
+#include "WebContextMenuProxy.h"
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefPtr.h>
+
+namespace WebKit {
+class WebContextMenuProxyMac;
+
+class WebContextMenuListenerProxy : public API::ObjectImpl<API::Object::Type::ContextMenuListener> {
+public:
+ static PassRefPtr<WebContextMenuListenerProxy> create(WebContextMenuProxy* contextMenuMac)
+ {
+ return adoptRef(new WebContextMenuListenerProxy(contextMenuMac));
+ }
+
+ virtual ~WebContextMenuListenerProxy();
+
+ void useContextMenuItems(WKArrayRef items);
+
+ void invalidate();
+private:
+ explicit WebContextMenuListenerProxy(WebContextMenuProxy*);
+
+ WebContextMenuProxy* m_contextMenuMac;
+};
+
+} // namespace WebKit
+
+#endif // ENABLE(CONTEXT_MENUS)
Modified: trunk/Source/WebKit2/UIProcess/WebContextMenuProxy.h (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/WebContextMenuProxy.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/WebContextMenuProxy.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -42,6 +42,8 @@
virtual void show() = 0;
+ virtual void showContextMenuWithItems(const Vector<WebContextMenuItemData>& items) = 0;
+
protected:
WebContextMenuProxy(const ContextMenuContextData&, const UserData&);
Modified: trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.cpp (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.cpp 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.cpp 2016-10-19 19:45:49 UTC (rev 207558)
@@ -55,6 +55,10 @@
showContextMenu();
}
+void WebContextMenuProxyEfl::showContextMenuWithItems(const Vector<WebContextMenuItemData>& items)
+{
+}
+
void WebContextMenuProxyEfl::showContextMenu()
{
Vector<RefPtr<WebContextMenuItem>> proposedAPIItems;
Modified: trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.h (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -46,6 +46,7 @@
private:
void show() override;
+ void showContextMenuWithItems(const Vector<WebContextMenuItemData>&) override;
void showContextMenu();
void hideContextMenu();
Modified: trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp 2016-10-19 19:45:49 UTC (rev 207558)
@@ -167,6 +167,10 @@
event ? event->button.button : 3, event ? event->button.time : GDK_CURRENT_TIME);
}
+void WebContextMenuProxyGtk::showContextMenuWithItems(const Vector<WebContextMenuItemData>& items)
+{
+}
+
WebContextMenuProxyGtk::WebContextMenuProxyGtk(GtkWidget* webView, WebPageProxy& page, const ContextMenuContextData& context, const UserData& userData)
: WebContextMenuProxy(context, userData)
, m_webView(webView)
Modified: trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -52,6 +52,7 @@
private:
void show() override;
+ void showContextMenuWithItems(const Vector<WebContextMenuItemData>&) override;
void append(GMenu*, const WebContextMenuItemGtk&);
GRefPtr<GMenu> buildMenu(const Vector<WebContextMenuItemGtk>&);
void populate(const Vector<RefPtr<WebContextMenuItem>>&);
Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h 2016-10-19 19:45:49 UTC (rev 207558)
@@ -28,9 +28,12 @@
#if PLATFORM(MAC)
+#include "WKArray.h"
#include "WebContextMenuProxy.h"
#include <wtf/RetainPtr.h>
+OBJC_CLASS NSMenu;
+OBJC_CLASS NSMenuItem;
OBJC_CLASS NSPopUpButtonCell;
OBJC_CLASS NSView;
OBJC_CLASS NSWindow;
@@ -40,6 +43,7 @@
class ShareableBitmap;
class UserData;
class WebContextMenuItemData;
+class WebContextMenuListenerProxy;
class WebPageProxy;
class WebContextMenuProxyMac : public WebContextMenuProxy {
@@ -48,6 +52,7 @@
~WebContextMenuProxyMac();
void contextMenuItemSelected(const WebContextMenuItemData&);
+ void showContextMenuWithItems(const Vector<WebContextMenuItemData>&) override;
#if ENABLE(SERVICE_CONTROLS)
void clearServicesMenu();
@@ -59,6 +64,7 @@
private:
void show() override;
+ RefPtr<WebContextMenuListenerProxy> m_contextMenuListener;
RetainPtr<NSMenuItem> createContextMenuItem(const WebContextMenuItemData&);
RetainPtr<NSMenu> createContextMenuFromItems(const Vector<WebContextMenuItemData>&);
void showContextMenu();
Modified: trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm (207557 => 207558)
--- trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm 2016-10-19 19:45:49 UTC (rev 207558)
@@ -39,6 +39,7 @@
#import "WKSharingServicePickerDelegate.h"
#import "WebContextMenuItem.h"
#import "WebContextMenuItemData.h"
+#import "WebContextMenuListenerProxy.h"
#import "WebProcessProxy.h"
#import <WebCore/GraphicsContext.h>
#import <WebCore/IntRect.h>
@@ -162,6 +163,11 @@
WebContextMenuProxyMac::~WebContextMenuProxyMac()
{
[m_menu cancelTracking];
+
+ if (m_contextMenuListener) {
+ m_contextMenuListener->invalidate();
+ m_contextMenuListener = nullptr;
+ }
}
void WebContextMenuProxyMac::contextMenuItemSelected(const WebContextMenuItemData& item)
@@ -449,6 +455,26 @@
}
}
+void WebContextMenuProxyMac::showContextMenuWithItems(const Vector<WebContextMenuItemData>& items)
+{
+ auto menu = createContextMenuFromItems(items);
+ m_menu = m_page.contextMenuClient().menuFromProposedMenu(m_page, menu.get(), m_context.webHitTestResultData(), m_userData.object());
+
+ [[WKMenuTarget sharedMenuTarget] setMenuProxy:this];
+
+ NSPoint menuLocation = [m_webView convertPoint:m_context.menuLocation() toView:nil];
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wdeprecated-declarations"
+ NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseUp location:menuLocation modifierFlags:0 timestamp:0 windowNumber:m_webView.window.windowNumber context:nil eventNumber:0 clickCount:0 pressure:0];
+#pragma clang diagnostic pop
+ [NSMenu popUpContextMenu:m_menu.get() withEvent:event forView:m_webView];
+
+ if (m_contextMenuListener) {
+ m_contextMenuListener->invalidate();
+ m_contextMenuListener = nullptr;
+ }
+}
+
void WebContextMenuProxyMac::showContextMenu()
{
Vector<RefPtr<WebContextMenuItem>> proposedAPIItems;
@@ -458,6 +484,16 @@
Vector<RefPtr<WebContextMenuItem>> clientItems;
bool useProposedItems = true;
+ if (m_contextMenuListener) {
+ m_contextMenuListener->invalidate();
+ m_contextMenuListener = nullptr;
+ }
+
+ m_contextMenuListener = WebContextMenuListenerProxy::create(this);
+
+ if (m_page.contextMenuClient().getContextMenuFromProposedMenuAsync(m_page, proposedAPIItems, m_contextMenuListener.get(), m_context.webHitTestResultData(), m_page.process().transformHandlesToObjects(m_userData.object()).get()))
+ return;
+
// FIXME: Get rid of these two client calls once we don't need to support the C SPI.
if (m_page.contextMenuClient().getContextMenuFromProposedMenu(m_page, proposedAPIItems, clientItems, m_context.webHitTestResultData(), m_page.process().transformHandlesToObjects(m_userData.object()).get()))
useProposedItems = false;
@@ -472,17 +508,7 @@
if (items.isEmpty())
return;
- auto menu = createContextMenuFromItems(items);
- m_menu = m_page.contextMenuClient().menuFromProposedMenu(m_page, menu.get(), m_context.webHitTestResultData(), m_userData.object());
-
- [[WKMenuTarget sharedMenuTarget] setMenuProxy:this];
-
- NSPoint menuLocation = [m_webView convertPoint:m_context.menuLocation() toView:nil];
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wdeprecated-declarations"
- NSEvent *event = [NSEvent mouseEventWithType:NSRightMouseUp location:menuLocation modifierFlags:0 timestamp:0 windowNumber:m_webView.window.windowNumber context:nil eventNumber:0 clickCount:0 pressure:0];
-#pragma clang diagnostic pop
- [NSMenu popUpContextMenu:m_menu.get() withEvent:event forView:m_webView];
+ showContextMenuWithItems(items);
}
NSWindow *WebContextMenuProxyMac::window() const
Modified: trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj (207557 => 207558)
--- trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-10-19 19:40:49 UTC (rev 207557)
+++ trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj 2016-10-19 19:45:49 UTC (rev 207558)
@@ -1297,8 +1297,12 @@
A1A4FE6118DD54A400B5EA8A /* _WKDownloadDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = A1A4FE6018DD54A400B5EA8A /* _WKDownloadDelegate.h */; settings = {ATTRIBUTES = (Private, ); }; };
A1C512C8190656E500448914 /* WebQuickLookHandleClient.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1C512C6190656E500448914 /* WebQuickLookHandleClient.cpp */; };
A1C512C9190656E500448914 /* WebQuickLookHandleClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1C512C7190656E500448914 /* WebQuickLookHandleClient.h */; };
+ A1D420471DB5578500BB6B0D /* WKContextMenuListener.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1EA02351DABFF7E0096021F /* WKContextMenuListener.cpp */; };
A1DF631218E0B7C8003A3E2A /* DownloadClient.mm in Sources */ = {isa = PBXBuildFile; fileRef = A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */; };
A1DF631318E0B7C8003A3E2A /* DownloadClient.h in Headers */ = {isa = PBXBuildFile; fileRef = A1DF631118E0B7C8003A3E2A /* DownloadClient.h */; };
+ A1EA02381DABFF7E0096021F /* WKContextMenuListener.h in Headers */ = {isa = PBXBuildFile; fileRef = A1EA02361DABFF7E0096021F /* WKContextMenuListener.h */; settings = {ATTRIBUTES = (Private, ); }; };
+ A1EA023F1DAC31DB0096021F /* WebContextMenuListenerProxy.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1EA023D1DAC31DB0096021F /* WebContextMenuListenerProxy.cpp */; };
+ A1EA02401DAC31DB0096021F /* WebContextMenuListenerProxy.h in Headers */ = {isa = PBXBuildFile; fileRef = A1EA023E1DAC31DB0096021F /* WebContextMenuListenerProxy.h */; };
A54293A4195A43DA002782C7 /* WKInspectorNodeSearchGestureRecognizer.h in Headers */ = {isa = PBXBuildFile; fileRef = A54293A2195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.h */; };
A54293A5195A43DD002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm in Sources */ = {isa = PBXBuildFile; fileRef = A54293A3195A43C6002782C7 /* WKInspectorNodeSearchGestureRecognizer.mm */; };
A55BA8101BA1317E007CD33D /* _WKRemoteWebInspectorViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = A55BA80C1BA12BE1007CD33D /* _WKRemoteWebInspectorViewController.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -3393,6 +3397,10 @@
A1C512C7190656E500448914 /* WebQuickLookHandleClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebQuickLookHandleClient.h; path = ios/WebQuickLookHandleClient.h; sourceTree = "<group>"; };
A1DF631018E0B7C8003A3E2A /* DownloadClient.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DownloadClient.mm; sourceTree = "<group>"; };
A1DF631118E0B7C8003A3E2A /* DownloadClient.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DownloadClient.h; sourceTree = "<group>"; };
+ A1EA02351DABFF7E0096021F /* WKContextMenuListener.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKContextMenuListener.cpp; sourceTree = "<group>"; };
+ A1EA02361DABFF7E0096021F /* WKContextMenuListener.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKContextMenuListener.h; sourceTree = "<group>"; };
+ A1EA023D1DAC31DB0096021F /* WebContextMenuListenerProxy.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebContextMenuListenerProxy.cpp; sourceTree = "<group>"; };
+ A1EA023E1DAC31DB0096021F /* WebContextMenuListenerProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebContextMenuListenerProxy.h; sourceTree = "<group>"; };
A1EDD2D91884ACE000BBFE98 /* All.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = All.xcconfig; sourceTree = "<group>"; };
A1EDD2DB1884B96400BBFE98 /* PluginProcessShim.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = PluginProcessShim.xcconfig; sourceTree = "<group>"; };
A1EDD2DC1884B9B500BBFE98 /* SecItemShim.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = SecItemShim.xcconfig; sourceTree = "<group>"; };
@@ -6122,6 +6130,8 @@
BC09B8F7147460F7005F5625 /* WebContextConnectionClient.h */,
BCDE059A11CDA8AE00E41AF1 /* WebContextInjectedBundleClient.cpp */,
BCDE059911CDA8AE00E41AF1 /* WebContextInjectedBundleClient.h */,
+ A1EA023D1DAC31DB0096021F /* WebContextMenuListenerProxy.cpp */,
+ A1EA023E1DAC31DB0096021F /* WebContextMenuListenerProxy.h */,
51A84CE2127F386B00CA6EA4 /* WebContextMenuProxy.cpp */,
51ACBB81127A8BAD00D203B9 /* WebContextMenuProxy.h */,
BCF4DE24168FA44800C94AFC /* WebContextSupplement.h */,
@@ -6289,6 +6299,8 @@
1A445BA2184D5FCF004B3414 /* WKContextDownloadClient.h */,
1A445BA0184D5FC1004B3414 /* WKContextHistoryClient.h */,
1A445B9E184D5FB5004B3414 /* WKContextInjectedBundleClient.h */,
+ A1EA02351DABFF7E0096021F /* WKContextMenuListener.cpp */,
+ A1EA02361DABFF7E0096021F /* WKContextMenuListener.h */,
BCC938E01180DE440085E5FE /* WKContextPrivate.h */,
330934581315B9980097A7BC /* WKCookieManager.cpp */,
330934591315B9980097A7BC /* WKCookieManager.h */,
@@ -7976,6 +7988,7 @@
BC7B625212A43C9600D174A4 /* WebPageGroupData.h in Headers */,
BC7B621512A4219A00D174A4 /* WebPageGroupProxy.h in Headers */,
2D9EA30F1A96CBFF002D2807 /* WebPageInjectedBundleClient.h in Headers */,
+ A1EA02381DABFF7E0096021F /* WKContextMenuListener.h in Headers */,
C0CE72A11247E71D00BC0EC4 /* WebPageMessages.h in Headers */,
2D5C9D0619C81D8F00B3C5C1 /* WebPageOverlay.h in Headers */,
BC032DD110F4389F0058C15A /* WebPageProxy.h in Headers */,
@@ -8227,6 +8240,7 @@
7CD5EBB91746A15B000C1C45 /* WKObjCTypeWrapperRef.h in Headers */,
378E1A40181EDA010031007A /* WKObject.h in Headers */,
1ACC50F21CBC381D003C7D03 /* WKOpenPanelParameters.h in Headers */,
+ A1EA02401DAC31DB0096021F /* WebContextMenuListenerProxy.h in Headers */,
1A67CD2E1CBC513F00BFE3EA /* WKOpenPanelParametersInternal.h in Headers */,
BC857FE612B843D800EDEB2E /* WKOpenPanelParametersRef.h in Headers */,
BC1DFE8F12B31CA8005DF730 /* WKOpenPanelResultListener.h in Headers */,
@@ -9560,6 +9574,7 @@
1A53C2A91A32572B004E8C70 /* WebsiteDataStore.cpp in Sources */,
1A4832C31A965A3C008B4DFE /* WebsiteDataStoreCocoa.mm in Sources */,
5C7706741D1138380012700F /* WebSocketProvider.cpp in Sources */,
+ A1D420471DB5578500BB6B0D /* WKContextMenuListener.cpp in Sources */,
8360349F1ACB34D600626549 /* WebSQLiteDatabaseTracker.cpp in Sources */,
1A52C0F71A38CDC70016160A /* WebStorageNamespaceProvider.cpp in Sources */,
BCC5715C115ADAEF001CCAF9 /* WebSystemInterface.mm in Sources */,
@@ -9656,6 +9671,7 @@
E1AEA23014687BDB00804569 /* WKFullKeyboardAccessWatcher.mm in Sources */,
CDCA85C8132ABA4E00E961DF /* WKFullScreenWindowController.mm in Sources */,
BC54CC1312D674EE005C67B0 /* WKGeolocationManager.cpp in Sources */,
+ A1EA023F1DAC31DB0096021F /* WebContextMenuListenerProxy.cpp in Sources */,
BC06F44F12DBDF3F002D78DE /* WKGeolocationPermissionRequest.cpp in Sources */,
BC0E619912D6CD120012A72A /* WKGeolocationPosition.cpp in Sources */,
0FCB4E5018BBE044000FCFC9 /* WKGeolocationProviderIOS.mm in Sources */,