Changeset 218325 in webkit
- Timestamp:
- Jun 15, 2017 2:41:27 AM (7 years ago)
- Location:
- trunk
- Files:
-
- 9 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r218324 r218325 1 2017-06-15 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add API to allow overriding popup menus 4 https://bugs.webkit.org/show_bug.cgi?id=172905 5 6 Reviewed by Michael Catanzaro. 7 8 The GTK+ API uses GTK+ for the default implementation of several UI elements like the file chooser, print dialog, 9 color picker, context menu, etc. but in all those cases it allows to override the default implementation. It's 10 not possible to override the popup menu used for select elements. This patch adds WebKitOptionMenu to represent 11 a select dropdown menu. It's passed as an argument of the new signal WebKitWebView::show-option-menu, and 12 contains WebKitOptionMenuItem elements representing the items to be displayed. 13 14 * PlatformGTK.cmake: 15 * UIProcess/API/gtk/PageClientImpl.cpp: 16 (WebKit::PageClientImpl::createPopupMenuProxy): Create a WebKitPopupMenu. 17 * UIProcess/API/gtk/WebKitOptionMenu.cpp: Added. 18 (webkitOptionMenuCreate): 19 (webkit_option_menu_get_n_items): 20 (webkit_option_menu_get_item): 21 (webkit_option_menu_select_item): 22 (webkit_option_menu_activate_item): 23 (webkit_option_menu_close): 24 * UIProcess/API/gtk/WebKitOptionMenu.h: Added. 25 * UIProcess/API/gtk/WebKitOptionMenuItem.cpp: Added. 26 (webkit_option_menu_item_copy): 27 (webkit_option_menu_item_free): 28 (webkit_option_menu_item_get_label): 29 (webkit_option_menu_item_get_tooltip): 30 (webkit_option_menu_item_is_group_label): 31 (webkit_option_menu_item_is_group_child): 32 (webkit_option_menu_item_is_enabled): 33 (webkit_option_menu_item_is_selected): 34 * UIProcess/API/gtk/WebKitOptionMenuItem.h: Added. 35 * UIProcess/API/gtk/WebKitOptionMenuItemPrivate.h: Added. 36 (_WebKitOptionMenuItem::_WebKitOptionMenuItem): 37 * UIProcess/API/gtk/WebKitOptionMenuPrivate.h: Added. 38 * UIProcess/API/gtk/WebKitPopupMenu.cpp: Added. 39 (WebKit::WebKitPopupMenu::WebKitPopupMenu): 40 (WebKit::menuCloseCallback): 41 (WebKit::WebKitPopupMenu::showPopupMenu): Call webkitWebViewShowOptionMenu() falling back to default 42 implementation if the user didn't handle the signal. 43 (WebKit::WebKitPopupMenu::hidePopupMenu): 44 (WebKit::WebKitPopupMenu::cancelTracking): 45 (WebKit::WebKitPopupMenu::selectItem): 46 (WebKit::WebKitPopupMenu::activateItem): 47 * UIProcess/API/gtk/WebKitPopupMenu.h: Added. 48 * UIProcess/API/gtk/WebKitWebView.cpp: 49 (webkit_web_view_class_init): 50 (webkitWebViewShowOptionMenu): Emit WebKitWebView::show-option-menu. 51 * UIProcess/API/gtk/WebKitWebView.h: 52 * UIProcess/API/gtk/WebKitWebViewPrivate.h: 53 * UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt: Add new symbols. 54 * UIProcess/API/gtk/docs/webkit2gtk-4.0.types: Add new get_type functions. 55 * UIProcess/API/gtk/docs/webkit2gtk-docs.sgml: Add new sections. 56 * UIProcess/API/gtk/webkit2.h: Add new public headers. 57 * UIProcess/gtk/WebPopupMenuProxyGtk.cpp: 58 (WebKit::WebPopupMenuProxyGtk::WebPopupMenuProxyGtk): Do not create the GtkMenu in constructor. 59 (WebKit::WebPopupMenuProxyGtk::showPopupMenu): Create the GtkMenu and connect to the signals here. 60 (WebKit::WebPopupMenuProxyGtk::hidePopupMenu): Return early if the Gtk hasn't been shown. 61 * UIProcess/gtk/WebPopupMenuProxyGtk.h: Make constructor and webview protected. 62 1 63 2017-06-14 Carlos Garcia Campos <cgarcia@igalia.com> 2 64 -
trunk/Source/WebKit2/PlatformGTK.cmake
r218089 r218325 213 213 UIProcess/API/gtk/WebKitNotificationProvider.cpp 214 214 UIProcess/API/gtk/WebKitNotificationProvider.h 215 UIProcess/API/gtk/WebKitOptionMenu.cpp 216 UIProcess/API/gtk/WebKitOptionMenu.h 217 UIProcess/API/gtk/WebKitOptionMenuPrivate.h 218 UIProcess/API/gtk/WebKitOptionMenuItem.cpp 219 UIProcess/API/gtk/WebKitOptionMenuItem.h 220 UIProcess/API/gtk/WebKitOptionMenuItemPrivate.h 215 221 UIProcess/API/gtk/WebKitPermissionRequest.cpp 216 222 UIProcess/API/gtk/WebKitPermissionRequest.h … … 223 229 UIProcess/API/gtk/WebKitPolicyDecision.h 224 230 UIProcess/API/gtk/WebKitPolicyDecisionPrivate.h 231 UIProcess/API/gtk/WebKitPopupMenu.cpp 225 232 UIProcess/API/gtk/WebKitPrintCustomWidget.cpp 226 233 UIProcess/API/gtk/WebKitPrintCustomWidget.h … … 561 568 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNotificationPermissionRequest.h 562 569 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitNotification.h 570 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitOptionMenu.h 571 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitOptionMenuItem.h 563 572 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPermissionRequest.h 564 573 ${WEBKIT2_DIR}/UIProcess/API/gtk/WebKitPlugin.h -
trunk/Source/WebKit2/UIProcess/API/gtk/PageClientImpl.cpp
r218064 r218325 38 38 #include "WebEventFactory.h" 39 39 #include "WebKitColorChooser.h" 40 #include "WebKitPopupMenu.h" 40 41 #include "WebKitWebViewBasePrivate.h" 41 42 #include "WebKitWebViewPrivate.h" 42 43 #include "WebPageProxy.h" 43 #include "WebPopupMenuProxyGtk.h"44 44 #include "WebProcessPool.h" 45 45 #include <WebCore/CairoUtilities.h> … … 207 207 RefPtr<WebPopupMenuProxy> PageClientImpl::createPopupMenuProxy(WebPageProxy& page) 208 208 { 209 return Web PopupMenuProxyGtk::create(m_viewWidget, page);209 return WebKitPopupMenu::create(m_viewWidget, page); 210 210 } 211 211 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.cpp
r218098 r218325 138 138 RUN_COLOR_CHOOSER, 139 139 140 SHOW_OPTION_MENU, 141 140 142 LAST_SIGNAL 141 143 }; … … 1884 1886 G_TYPE_BOOLEAN, 1, 1885 1887 WEBKIT_TYPE_COLOR_CHOOSER_REQUEST); 1888 1889 /** 1890 * WebKitWebView::show-option-menu: 1891 * @web_view: the #WebKitWebView on which the signal is emitted 1892 * @menu: the #WebKitOptionMenu 1893 * @event: the #GdkEvent that triggered the menu, or %NULL 1894 * @rectangle: the option element area 1895 * 1896 * This signal is emitted when a select element in @web_view needs to display a 1897 * dropdown menu. This signal can be used to show a custom menu, using @menu to get 1898 * the details of all items that should be displayed. The area of the element in the 1899 * #WebKitWebView is given as @rectangle parameter, it can be used to position the 1900 * menu. If this was triggered by a user interaction, like a mouse click, 1901 * @event parameter provides the #GdkEvent. 1902 * To handle this signal asynchronously you should keep a ref of the @menu. 1903 * 1904 * The default signal handler will pop up a #GtkMenu. 1905 * 1906 * Returns: %TRUE to stop other handlers from being invoked for the event. 1907 * %FALSE to propagate the event further. 1908 * 1909 * Since: 2.18. 1910 */ 1911 signals[SHOW_OPTION_MENU] = g_signal_new( 1912 "show-option-menu", 1913 G_TYPE_FROM_CLASS(webViewClass), 1914 G_SIGNAL_RUN_LAST, 1915 G_STRUCT_OFFSET(WebKitWebViewClass, show_option_menu), 1916 g_signal_accumulator_true_handled, nullptr, 1917 g_cclosure_marshal_generic, 1918 G_TYPE_BOOLEAN, 3, 1919 WEBKIT_TYPE_OPTION_MENU, 1920 GDK_TYPE_EVENT | G_SIGNAL_TYPE_STATIC_SCOPE, 1921 GDK_TYPE_RECTANGLE | G_SIGNAL_TYPE_STATIC_SCOPE); 1886 1922 } 1887 1923 … … 2211 2247 { 2212 2248 return webView->priv->websiteDataManager.get(); 2249 } 2250 2251 bool webkitWebViewShowOptionMenu(WebKitWebView* webView, const IntRect& rect, WebKitOptionMenu* menu, const GdkEvent* event) 2252 { 2253 GdkRectangle menuRect = rect; 2254 gboolean handled; 2255 g_signal_emit(webView, signals[SHOW_OPTION_MENU], 0, menu, event, &menuRect, &handled); 2256 return handled; 2213 2257 } 2214 2258 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebView.h
r216006 r218325 43 43 #include <webkit2/WebKitNavigationAction.h> 44 44 #include <webkit2/WebKitNotification.h> 45 #include <webkit2/WebKitOptionMenu.h> 45 46 #include <webkit2/WebKitPermissionRequest.h> 46 47 #include <webkit2/WebKitPolicyDecision.h> … … 250 251 gboolean (* run_color_chooser) (WebKitWebView *web_view, 251 252 WebKitColorChooserRequest *request); 253 gboolean (* show_option_menu) (WebKitWebView *web_view, 254 GdkRectangle *rectangle, 255 WebKitOptionMenu *menu); 252 256 253 257 void (*_webkit_reserved0) (void); 254 258 void (*_webkit_reserved1) (void); 255 259 void (*_webkit_reserved2) (void); 256 void (*_webkit_reserved3) (void);257 260 }; 258 261 -
trunk/Source/WebKit2/UIProcess/API/gtk/WebKitWebViewPrivate.h
r218098 r218325 35 35 #include "WebKitWebView.h" 36 36 #include "WebPageProxy.h" 37 #include <WebCore/IntRect.h> 37 38 #include <wtf/text/CString.h> 38 39 … … 73 74 void webkitWebViewRequestInstallMissingMediaPlugins(WebKitWebView*, WebKit::InstallMissingMediaPluginsPermissionRequest&); 74 75 WebKitWebsiteDataManager* webkitWebViewGetWebsiteDataManager(WebKitWebView*); 76 bool webkitWebViewShowOptionMenu(WebKitWebView*, const WebCore::IntRect&, WebKitOptionMenu*, const GdkEvent*); -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0-sections.txt
r217209 r218325 1177 1177 1178 1178 <SECTION> 1179 <FILE>WebKitOptionMenu</FILE> 1180 WebKitOptionMenu 1181 webkit_option_menu_get_n_items 1182 webkit_option_menu_get_item 1183 webkit_option_menu_select_item 1184 webkit_option_menu_activate_item 1185 webkit_option_menu_close 1186 1187 <SUBSECTION Standard> 1188 WebKitOptionMenuClass 1189 WEBKIT_TYPE_OPTION_MENU 1190 WEBKIT_OPTION_MENU 1191 WEBKIT_IS_OPTION_MENU 1192 WEBKIT_OPTION_MENU_CLASS 1193 WEBKIT_IS_OPTION_MENU_CLASS 1194 WEBKIT_OPTION_MENU_GET_CLASS 1195 1196 <SUBSECTION Private> 1197 WebKitOptionMenuPrivate 1198 webkit_option_menu_get_type 1199 </SECTION> 1200 1201 <SECTION> 1202 <FILE>WebKitOptionMenuItem</FILE> 1203 WebKitOptionMenuItem 1204 webkit_option_menu_item_copy 1205 webkit_option_menu_item_free 1206 webkit_option_menu_item_get_label 1207 webkit_option_menu_item_get_tooltip 1208 webkit_option_menu_item_is_group_label 1209 webkit_option_menu_item_is_group_child 1210 webkit_option_menu_item_is_enabled 1211 webkit_option_menu_item_is_selected 1212 1213 <SUBSECTION Standard> 1214 WEBKIT_TYPE_OPTION_MENU_ITEM 1215 1216 <SUBSECTION Private> 1217 webkit_option_menu_item_get_type 1218 </SECTION> 1219 1220 <SECTION> 1179 1221 <FILE>WebKitFormSubmissionRequest</FILE> 1180 1222 WebKitFormSubmissionRequest -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-4.0.types
r216006 r218325 37 37 webkit_print_custom_widget_get_type 38 38 webkit_automation_session_get_type 39 webkit_option_menu_get_type 40 webkit_option_menu_item_get_type -
trunk/Source/WebKit2/UIProcess/API/gtk/docs/webkit2gtk-docs.sgml
r216006 r218325 47 47 <xi:include href="xml/WebKitContextMenu.xml"/> 48 48 <xi:include href="xml/WebKitContextMenuItem.xml"/> 49 <xi:include href="xml/WebKitOptionMenu.xml"/> 50 <xi:include href="xml/WebKitOptionMenuItem.xml"/> 49 51 <xi:include href="xml/WebKitFormSubmissionRequest.xml"/> 50 52 <xi:include href="xml/WebKitSecurityManager.xml"/> -
trunk/Source/WebKit2/UIProcess/API/gtk/webkit2.h
r216006 r218325 58 58 #include <webkit2/WebKitNotification.h> 59 59 #include <webkit2/WebKitNotificationPermissionRequest.h> 60 #include <webkit2/WebKitOptionMenu.h> 61 #include <webkit2/WebKitOptionMenuItem.h> 60 62 #include <webkit2/WebKitPermissionRequest.h> 61 63 #include <webkit2/WebKitPlugin.h> -
trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.cpp
r215225 r218325 42 42 : WebPopupMenuProxy(client) 43 43 , m_webView(webView) 44 , m_popup(gtk_menu_new())45 44 , m_dismissMenuTimer(RunLoop::main(), this, &WebPopupMenuProxyGtk::dismissMenuTimerFired) 46 45 { 47 g_signal_connect(m_popup, "key-press-event", G_CALLBACK(keyPressEventCallback), this);48 g_signal_connect(m_popup, "unmap", G_CALLBACK(menuUnmappedCallback), this);49 46 } 50 47 … … 89 86 void WebPopupMenuProxyGtk::showPopupMenu(const IntRect& rect, TextDirection, double /* pageScaleFactor */, const Vector<WebPopupItem>& items, const PlatformPopupMenuData&, int32_t selectedIndex) 90 87 { 91 m_dismissMenuTimer.stop(); 88 ASSERT(!m_popup); 89 m_popup = gtk_menu_new(); 90 g_signal_connect(m_popup, "key-press-event", G_CALLBACK(keyPressEventCallback), this); 91 g_signal_connect(m_popup, "unmap", G_CALLBACK(menuUnmappedCallback), this); 92 92 93 93 populatePopupMenu(items); … … 179 179 void WebPopupMenuProxyGtk::hidePopupMenu() 180 180 { 181 if (!m_popup) 182 return; 183 181 184 gtk_menu_popdown(GTK_MENU(m_popup)); 182 185 resetTypeAheadFindState(); -
trunk/Source/WebKit2/UIProcess/gtk/WebPopupMenuProxyGtk.h
r202611 r218325 49 49 void cancelTracking() override; 50 50 51 pr ivate:51 protected: 52 52 WebPopupMenuProxyGtk(GtkWidget*, WebPopupMenuProxy::Client&); 53 53 54 GtkWidget* m_webView { nullptr }; 55 56 private: 54 57 void setCurrentlySelectedMenuItem(GtkWidget* item) { m_currentlySelectedMenuItem = item; } 55 58 GtkAction* createGtkActionForMenuItem(const WebPopupItem&, int itemIndex); … … 65 68 static void menuUnmappedCallback(GtkWidget*, WebPopupMenuProxyGtk*); 66 69 67 GtkWidget* m_webView { nullptr };68 70 GtkWidget* m_popup { nullptr }; 69 71 -
trunk/Tools/ChangeLog
r218320 r218325 1 2017-06-15 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 [GTK] Add API to allow overriding popup menus 4 https://bugs.webkit.org/show_bug.cgi?id=172905 5 6 Reviewed by Michael Catanzaro. 7 8 Add a unit test to check the new API. 9 10 * TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt: 11 * TestWebKitAPI/Tests/WebKit2Gtk/TestOptionMenu.cpp: Added. 12 (OptionMenuTest::OptionMenuTest): 13 (OptionMenuTest::~OptionMenuTest): 14 (OptionMenuTest::destroyMenu): 15 (OptionMenuTest::showOptionMenuCallback): 16 (OptionMenuTest::menuCloseCallback): 17 (OptionMenuTest::showOptionMenu): 18 (OptionMenuTest::clickAtPositionAndWaitUntilOptionMenuShown): 19 (OptionMenuTest::close): 20 (OptionMenuTest::activateItem): 21 (OptionMenuTest::selectItem): 22 (testOptionMenuSimple): 23 (testOptionMenuGroups): 24 (testOptionMenuActivate): 25 (testOptionMenuSelect): 26 (beforeAll): 27 (afterAll): 28 1 29 2017-06-15 Fujii Hironori <Hironori.Fujii@sony.com> 2 30 -
trunk/Tools/TestWebKitAPI/Tests/WebKit2Gtk/CMakeLists.txt
r216006 r218325 115 115 ADD_WK2_TEST(TestLoaderClient TestLoaderClient.cpp) 116 116 ADD_WK2_TEST(TestMultiprocess TestMultiprocess.cpp) 117 ADD_WK2_TEST(TestOptionMenu TestOptionMenu.cpp) 117 118 ADD_WK2_TEST(TestPrinting TestPrinting.cpp) 118 119 ADD_WK2_TEST(TestResources TestResources.cpp)
Note: See TracChangeset
for help on using the changeset viewer.