<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[207558] trunk/Source/WebKit2</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/207558">207558</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2016-10-19 12:45:49 -0700 (Wed, 19 Oct 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>https://bugs.webkit.org/show_bug.cgi?id=163292

Patch by Damian Kaleta &lt;dkaleta@apple.com&gt; on 2016-10-19
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:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2ChangeLog">trunk/Source/WebKit2/ChangeLog</a></li>
<li><a href="#trunkSourceWebKit2SharedAPIAPIObjecth">trunk/Source/WebKit2/Shared/API/APIObject.h</a></li>
<li><a href="#trunkSourceWebKit2SharedAPIcWKBaseh">trunk/Source/WebKit2/Shared/API/c/WKBase.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPIAPIContextMenuClienth">trunk/Source/WebKit2/UIProcess/API/APIContextMenuClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKAPICasth">trunk/Source/WebKit2/UIProcess/API/C/WKAPICast.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPagecpp">trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKPageContextMenuClienth">trunk/Source/WebKit2/UIProcess/API/C/WKPageContextMenuClient.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebContextMenuProxyh">trunk/Source/WebKit2/UIProcess/WebContextMenuProxy.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcesseflWebContextMenuProxyEflcpp">trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcesseflWebContextMenuProxyEflh">trunk/Source/WebKit2/UIProcess/efl/WebContextMenuProxyEfl.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWebContextMenuProxyGtkcpp">trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessgtkWebContextMenuProxyGtkh">trunk/Source/WebKit2/UIProcess/gtk/WebContextMenuProxyGtk.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWebContextMenuProxyMach">trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessmacWebContextMenuProxyMacmm">trunk/Source/WebKit2/UIProcess/mac/WebContextMenuProxyMac.mm</a></li>
<li><a href="#trunkSourceWebKit2WebKit2xcodeprojprojectpbxproj">trunk/Source/WebKit2/WebKit2.xcodeproj/project.pbxproj</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKContextMenuListenercpp">trunk/Source/WebKit2/UIProcess/API/C/WKContextMenuListener.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessAPICWKContextMenuListenerh">trunk/Source/WebKit2/UIProcess/API/C/WKContextMenuListener.h</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebContextMenuListenerProxycpp">trunk/Source/WebKit2/UIProcess/WebContextMenuListenerProxy.cpp</a></li>
<li><a href="#trunkSourceWebKit2UIProcessWebContextMenuListenerProxyh">trunk/Source/WebKit2/UIProcess/WebContextMenuListenerProxy.h</a></li>
</ul>

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

</body>
</html>