Diff
Modified: trunk/Source/WebKit2/ChangeLog (148419 => 148420)
--- trunk/Source/WebKit2/ChangeLog 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/ChangeLog 2013-04-15 09:02:25 UTC (rev 148420)
@@ -1,3 +1,35 @@
+2013-04-15 Michał Pakuła vel Rutka <m.pak...@samsung.com>
+
+ [WK2] Add new callbacks and a function for WebKit2 context menu API
+ https://bugs.webkit.org/show_bug.cgi?id=111552
+
+ Reviewed by Anders Carlsson.
+
+ Add contextMenuHide and contextMenuShow callbacks to WKPageContextMenuClient
+ and WKPageContextMenuSelected API so context menus can be handled outside
+ WebKit. API version of this client was bumped so older client version still
+ can be used
+
+ * Shared/APIClientTraits.cpp:
+ (WebKit):
+ * Shared/APIClientTraits.h:
+ * UIProcess/API/C/WKPage.cpp:
+ (WKPageSelectContextMenuItem):
+ * UIProcess/API/C/WKPage.h:
+ * UIProcess/API/gtk/WebKitContextMenuClient.cpp:
+ (attachContextMenuClientToView):
+ * UIProcess/WebPageContextMenuClient.cpp:
+ (WebKit::WebPageContextMenuClient::getContextMenuFromProposedMenu):
+ (WebKit::WebPageContextMenuClient::showContextMenu):
+ (WebKit):
+ (WebKit::WebPageContextMenuClient::hideContextMenu):
+ * UIProcess/WebPageContextMenuClient.h:
+ (WebPageContextMenuClient):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::internalShowContextMenu):
+ * UIProcess/efl/ContextMenuClientEfl.cpp:
+ (ContextMenuClientEfl::ContextMenuClientEfl):
+
2013-04-14 Christophe Dumez <ch.du...@sisa.samsung.com>
[EFL][WK2] Regression(r148274): Broke rendering in the browser
Modified: trunk/Source/WebKit2/Shared/APIClientTraits.cpp (148419 => 148420)
--- trunk/Source/WebKit2/Shared/APIClientTraits.cpp 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/Shared/APIClientTraits.cpp 2013-04-15 09:02:25 UTC (rev 148420)
@@ -58,6 +58,7 @@
const size_t APIClientTraits<WKPageContextMenuClient>::interfaceSizesByVersion[] = {
offsetof(WKPageContextMenuClient, contextMenuDismissed),
offsetof(WKPageContextMenuClient, getContextMenuFromProposedMenu),
+ offsetof(WKPageContextMenuClient, showContextMenu),
sizeof(WKPageContextMenuClient)
};
Modified: trunk/Source/WebKit2/Shared/APIClientTraits.h (148419 => 148420)
--- trunk/Source/WebKit2/Shared/APIClientTraits.h 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/Shared/APIClientTraits.h 2013-04-15 09:02:25 UTC (rev 148420)
@@ -60,7 +60,7 @@
};
template<> struct APIClientTraits<WKPageContextMenuClient> {
- static const size_t interfaceSizesByVersion[3];
+ static const size_t interfaceSizesByVersion[4];
};
template<> struct APIClientTraits<WKPageLoaderClient> {
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp (148419 => 148420)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.cpp 2013-04-15 09:02:25 UTC (rev 148420)
@@ -40,6 +40,10 @@
#include <Block.h>
#endif
+#if ENABLE(CONTEXT_MENUS)
+#include "WebContextMenuItem.h"
+#endif
+
using namespace WebCore;
using namespace WebKit;
@@ -879,3 +883,10 @@
{
return toImpl(pageRef)->overridePrivateBrowsingEnabled();
}
+
+void WKPageSelectContextMenuItem(WKPageRef page, WKContextMenuItemRef item)
+{
+#if ENABLE(CONTEXT_MENUS)
+ toImpl(page)->contextMenuItemSelected(*(toImpl(item)->data()));
+#endif
+}
Modified: trunk/Source/WebKit2/UIProcess/API/C/WKPage.h (148419 => 148420)
--- trunk/Source/WebKit2/UIProcess/API/C/WKPage.h 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/UIProcess/API/C/WKPage.h 2013-04-15 09:02:25 UTC (rev 148420)
@@ -324,6 +324,8 @@
typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, 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);
+typedef void (*WKPageHideContextMenuCallback)(WKPageRef page, const void* clientInfo);
// Deprecated
typedef void (*WKPageGetContextMenuFromProposedContextMenuCallback_deprecatedForUseWithV0)(WKPageRef page, WKArrayRef proposedMenu, WKArrayRef* newMenu, WKTypeRef userData, const void* clientInfo);
@@ -340,10 +342,14 @@
// Version 2
WKPageGetContextMenuFromProposedContextMenuCallback getContextMenuFromProposedMenu;
+
+ // Version 3
+ WKPageShowContextMenuCallback showContextMenu;
+ WKPageHideContextMenuCallback hideContextMenu;
};
typedef struct WKPageContextMenuClient WKPageContextMenuClient;
-enum { kWKPageContextMenuClientCurrentVersion = 2 };
+enum { kWKPageContextMenuClientCurrentVersion = 3 };
WK_EXPORT WKTypeID WKPageGetTypeID();
@@ -548,7 +554,9 @@
/* Value type: WKURLRef */
WK_EXPORT WKStringRef WKPageGetPluginInformationPluginURLKey();
+WK_EXPORT void WKPageSelectContextMenuItem(WKPageRef page, WKContextMenuItemRef item);
+
#ifdef __cplusplus
}
#endif
Modified: trunk/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp (148419 => 148420)
--- trunk/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp 2013-04-15 09:02:25 UTC (rev 148420)
@@ -40,6 +40,8 @@
0, // customContextMenuItemSelected
0, // contextMenuDismissed
getContextMenuFromProposedMenu,
+ 0, // showContextMenu
+ 0, // hideContextMenu
};
WKPageRef wkPage = toAPI(webkitWebViewBaseGetPage(WEBKIT_WEB_VIEW_BASE(webView)));
WKPageSetPageContextMenuClient(wkPage, &wkContextMenuClient);
Modified: trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp (148419 => 148420)
--- trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.cpp 2013-04-15 09:02:25 UTC (rev 148420)
@@ -42,7 +42,7 @@
if (!m_client.getContextMenuFromProposedMenu && !m_client.getContextMenuFromProposedMenu_deprecatedForUseWithV0)
return false;
- if (m_client.version == kWKPageContextMenuClientCurrentVersion && !m_client.getContextMenuFromProposedMenu)
+ if (m_client.version >= 2 && !m_client.getContextMenuFromProposedMenu)
return false;
unsigned size = proposedMenuVector.size();
@@ -52,7 +52,7 @@
proposedMenu->append(WebContextMenuItem::create(proposedMenuVector[i]).get());
WKArrayRef newMenu = 0;
- if (m_client.version == kWKPageContextMenuClientCurrentVersion) {
+ if (m_client.version >= 2) {
RefPtr<WebHitTestResult> webHitTestResult = WebHitTestResult::create(hitTestResultData);
m_client.getContextMenuFromProposedMenu(toAPI(page), toAPI(proposedMenu.get()), &newMenu, toAPI(webHitTestResult.get()), toAPI(userData), m_client.clientInfo);
} else
@@ -93,5 +93,33 @@
m_client.contextMenuDismissed(toAPI(page), m_client.clientInfo);
}
+bool WebPageContextMenuClient::showContextMenu(WebPageProxy* page, const WebCore::IntPoint& menuLocation, const Vector<WebContextMenuItemData>& menuItemsVector)
+{
+ if (!m_client.showContextMenu)
+ return false;
+
+ unsigned size = menuItemsVector.size();
+
+ Vector<RefPtr<APIObject> > menuItems;
+ menuItems.reserveCapacity(size);
+
+ for (unsigned i = 0; i < size; ++i)
+ menuItems.uncheckedAppend(WebContextMenuItem::create(menuItemsVector[i]).get());
+
+ m_client.showContextMenu(toAPI(page), toAPI(menuLocation), toAPI(ImmutableArray::adopt(menuItems).get()), m_client.clientInfo);
+
+ return true;
+}
+
+bool WebPageContextMenuClient::hideContextMenu(WebPageProxy* page)
+{
+ if (!m_client.hideContextMenu)
+ return false;
+
+ m_client.hideContextMenu(toAPI(page), m_client.clientInfo);
+
+ return true;
+}
+
} // namespace WebKit
#endif // ENABLE(CONTEXT_MENUS)
Modified: trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.h (148419 => 148420)
--- trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.h 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/UIProcess/WebPageContextMenuClient.h 2013-04-15 09:02:25 UTC (rev 148420)
@@ -31,6 +31,7 @@
#include "APIClient.h"
#include "WebHitTestResult.h"
#include "WKPage.h"
+#include <WebCore/IntPoint.h>
#include <wtf/Vector.h>
namespace WebKit {
@@ -44,6 +45,8 @@
bool getContextMenuFromProposedMenu(WebPageProxy*, const Vector<WebContextMenuItemData>& proposedMenu, Vector<WebContextMenuItemData>& customMenu, const WebHitTestResult::Data&, APIObject* userData);
void customContextMenuItemSelected(WebPageProxy*, const WebContextMenuItemData&);
void contextMenuDismissed(WebPageProxy*);
+ bool showContextMenu(WebPageProxy*, const WebCore::IntPoint&, const Vector<WebContextMenuItemData>&);
+ bool hideContextMenu(WebPageProxy*);
};
} // namespace WebKit
Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (148419 => 148420)
--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp 2013-04-15 09:02:25 UTC (rev 148420)
@@ -3248,7 +3248,7 @@
m_activeContextMenuHitTestResultData = hitTestResultData;
- if (m_activeContextMenu) {
+ if (!m_contextMenuClient.hideContextMenu(this) && m_activeContextMenu) {
m_activeContextMenu->hideContextMenu();
m_activeContextMenu = 0;
}
@@ -3262,9 +3262,10 @@
// Give the PageContextMenuClient one last swipe at changing the menu.
Vector<WebContextMenuItemData> items;
- if (!m_contextMenuClient.getContextMenuFromProposedMenu(this, proposedItems, items, hitTestResultData, userData.get()))
- m_activeContextMenu->showContextMenu(menuLocation, proposedItems);
- else
+ if (!m_contextMenuClient.getContextMenuFromProposedMenu(this, proposedItems, items, hitTestResultData, userData.get())) {
+ if (!m_contextMenuClient.showContextMenu(this, menuLocation, proposedItems))
+ m_activeContextMenu->showContextMenu(menuLocation, proposedItems);
+ } else if (!m_contextMenuClient.showContextMenu(this, menuLocation, items))
m_activeContextMenu->showContextMenu(menuLocation, items);
m_contextMenuClient.contextMenuDismissed(this);
Modified: trunk/Source/WebKit2/UIProcess/efl/ContextMenuClientEfl.cpp (148419 => 148420)
--- trunk/Source/WebKit2/UIProcess/efl/ContextMenuClientEfl.cpp 2013-04-15 08:20:53 UTC (rev 148419)
+++ trunk/Source/WebKit2/UIProcess/efl/ContextMenuClientEfl.cpp 2013-04-15 09:02:25 UTC (rev 148420)
@@ -54,6 +54,8 @@
contextMenuClient.customContextMenuItemSelected = 0;
contextMenuClient.contextMenuDismissed = 0;
contextMenuClient.getContextMenuFromProposedMenu = 0;
+ contextMenuClient.showContextMenu = 0;
+ contextMenuClient.hideContextMenu = 0;
WKPageSetPageContextMenuClient(pageRef, &contextMenuClient);
}