[GTK] Add context menu API to Web Process Extensions
authorcarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Nov 2014 15:08:07 +0000 (15:08 +0000)
committercarlosgc@webkit.org <carlosgc@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 6 Nov 2014 15:08:07 +0000 (15:08 +0000)
commit23d09956eafaf87730a29f76dd499f1eaac5a072
tree6f6d35d0238dd5502e2abdf210487d9b6c6996b6
parentaa0ca45afb4a47eb6e9926dbf33b1f2dd41e0a40
[GTK] Add context menu API to Web Process Extensions
https://bugs.webkit.org/show_bug.cgi?id=138311

Reviewed by Gustavo Noronha Silva.

Source/WebKit2:

Add WebKitWebPage::context-menu signal, similar to the
WebKitWebView one, but that receives a WebKitWebHitTestResult, a
class that extends WebKitTestResult to provide the WebKitDOMNode
from the Web Process Extensions API. This makes WebKitContextMenu,
WebKitContextMenuItem and WebKitTestResult classes shared between
UI and Web Extensions APIs. In addition to be able to customize
the context menu, it also provides API to set user data, as a
GVariant, in the Web Process that is sent to the UI Process.

* PlatformGTK.cmake: Add new files.
* UIProcess/API/gtk/WebKitContextMenu.cpp:
(webkit_context_menu_set_user_data): Add user data to the context
menu as a GVariant.
(webkit_context_menu_get_user_data): Get the user data previously
set with webkit_context_menu_set_user_data() either from the Web
or UI processes.
* UIProcess/API/gtk/WebKitContextMenu.h:
* UIProcess/API/gtk/WebKitContextMenuActions.h:
* UIProcess/API/gtk/WebKitContextMenuClient.cpp:
(getContextMenuFromProposedMenu): Convert the received user data
into a GVariant and pass it to webkitWebViewPopulateContextMenu().
* UIProcess/API/gtk/WebKitContextMenuItem.h:
* UIProcess/API/gtk/WebKitForwardDeclarations.h:
* UIProcess/API/gtk/WebKitHitTestResult.h:
* UIProcess/API/gtk/WebKitWebView.cpp:
(webkitWebViewPopulateContextMenu): Set the user data received
from the Web Process to the WebKitContextMenu before emitting
WebKitWebView::context-menu.
* UIProcess/API/gtk/WebKitWebViewPrivate.h:
* UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new section for WebKitWebHitTestResult.
* UIProcess/API/gtk/docs/webkit2gtk-sections.txt: Add new symbols.
* UIProcess/API/gtk/docs/webkit2gtk.types: Add webkit_web_hit_test_result_get_type.
* WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.cpp: Added.
(webkitWebHitTestResultGetProperty): Add getter for node property.
(webkitWebHitTestResultSetProperty): Add setter for node property.
(webkit_web_hit_test_result_class_init): Add node property.
(webkitWebHitTestResultCreate): Create a new
WebKitWebHitTestResult for the given InjectedBundleHitTestResult.
(webkit_web_hit_test_result_get_node): Return the WebKitDOMNode.
* WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.h: Added.
* WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResultPrivate.h: Added.
* WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp:
(getContextMenuFromDefaultMenu): Build a WebKitContextMenu and
WebKitWebHitTestResult and emit WebKitWebPage::context-menu signal.
(webkit_web_page_class_init): Add WebKitWebPage::context-menu signal.
(webkitWebPageCreate): Add implementation for getContextMenuFromDefaultMenu.
* WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h:

Tools:

Add tests cases for WebKitWebPage::context-menu signal.

* TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp:
(testContextMenuWebExtensionMenu):
(testContextMenuWebExtensionNode):
(beforeAll):
* TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp:
(serializeContextMenu):
(serializeNode):
(contextMenuCallback):
(pageCreatedCallback):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@175694 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
Source/WebKit2/ChangeLog
Source/WebKit2/PlatformGTK.cmake
Source/WebKit2/UIProcess/API/gtk/WebKitContextMenu.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitContextMenu.h
Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuActions.h
Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuClient.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitContextMenuItem.h
Source/WebKit2/UIProcess/API/gtk/WebKitForwardDeclarations.h
Source/WebKit2/UIProcess/API/gtk/WebKitHitTestResult.h
Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-sections.txt
Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk.types
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.cpp [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResult.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebHitTestResultPrivate.h [new file with mode: 0644]
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/WebKitWebPage.cpp
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/webkit-web-extension.h
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WebKit2Gtk/TestContextMenu.cpp
Tools/TestWebKitAPI/Tests/WebKit2Gtk/WebExtensionTest.cpp