Title: [243793] trunk/Source/WebKit
- Revision
- 243793
- Author
- [email protected]
- Date
- 2019-04-03 01:25:26 -0700 (Wed, 03 Apr 2019)
Log Message
Web Inspector: [GTK] Copy copies to nowhere
https://bugs.webkit.org/show_bug.cgi?id=181228
Reviewed by Michael Catanzaro.
The thing is that those items are actually submenu items, with options, for example in the case of Copy to copy
HTML, Text, XPath, etc. We are not correctly handling submenus when populating the context menu received from
the web process.
* UIProcess/gtk/WebContextMenuProxyGtk.cpp:
(WebKit::WebContextMenuProxyGtk::populateSubMenu): Helper to populate submenu items recursively.
(WebKit::WebContextMenuProxyGtk::populate): Handle submenu items.
* UIProcess/gtk/WebContextMenuProxyGtk.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (243792 => 243793)
--- trunk/Source/WebKit/ChangeLog 2019-04-03 06:23:51 UTC (rev 243792)
+++ trunk/Source/WebKit/ChangeLog 2019-04-03 08:25:26 UTC (rev 243793)
@@ -1,3 +1,19 @@
+2019-04-03 Carlos Garcia Campos <[email protected]>
+
+ Web Inspector: [GTK] Copy copies to nowhere
+ https://bugs.webkit.org/show_bug.cgi?id=181228
+
+ Reviewed by Michael Catanzaro.
+
+ The thing is that those items are actually submenu items, with options, for example in the case of Copy to copy
+ HTML, Text, XPath, etc. We are not correctly handling submenus when populating the context menu received from
+ the web process.
+
+ * UIProcess/gtk/WebContextMenuProxyGtk.cpp:
+ (WebKit::WebContextMenuProxyGtk::populateSubMenu): Helper to populate submenu items recursively.
+ (WebKit::WebContextMenuProxyGtk::populate): Handle submenu items.
+ * UIProcess/gtk/WebContextMenuProxyGtk.h:
+
2019-04-02 Wenson Hsieh <[email protected]>
[Cocoa] Add new API around WKWebpagePreferences in WKNavigationDelegate and WKWebViewConfiguration
Modified: trunk/Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.cpp (243792 => 243793)
--- trunk/Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.cpp 2019-04-03 06:23:51 UTC (rev 243792)
+++ trunk/Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.cpp 2019-04-03 08:25:26 UTC (rev 243793)
@@ -117,6 +117,18 @@
return menu;
}
+Vector<WebContextMenuItemGlib> WebContextMenuProxyGtk::populateSubMenu(const WebContextMenuItemData& subMenuItemData)
+{
+ Vector<WebContextMenuItemGlib> items;
+ for (const auto& itemData : subMenuItemData.submenu()) {
+ if (itemData.type() == SubmenuType)
+ items.append(WebContextMenuItemGlib(itemData, populateSubMenu(itemData)));
+ else
+ items.append(itemData);
+ }
+ return items;
+}
+
void WebContextMenuProxyGtk::populate(const Vector<WebContextMenuItemGlib>& items)
{
GRefPtr<GMenu> menu = buildMenu(items);
@@ -128,14 +140,25 @@
GRefPtr<GMenu> menu = adoptGRef(g_menu_new());
GMenu* sectionMenu = menu.get();
for (const auto& item : items) {
- if (item->data().type() == SeparatorType) {
+ switch (item->data().type()) {
+ case SeparatorType: {
GRefPtr<GMenu> section = adoptGRef(g_menu_new());
g_menu_append_section(menu.get(), nullptr, G_MENU_MODEL(section.get()));
sectionMenu = section.get();
- } else {
+ break;
+ }
+ case SubmenuType: {
+ WebContextMenuItemGlib menuitem(item->data(), populateSubMenu(item->data()));
+ append(sectionMenu, menuitem);
+ break;
+ }
+ case ActionType:
+ case CheckableActionType: {
WebContextMenuItemGlib menuitem(item->data());
append(sectionMenu, menuitem);
+ break;
}
+ }
}
gtk_menu_shell_bind_model(GTK_MENU_SHELL(m_menu), G_MENU_MODEL(menu.get()), nullptr, TRUE);
}
Modified: trunk/Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.h (243792 => 243793)
--- trunk/Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.h 2019-04-03 06:23:51 UTC (rev 243792)
+++ trunk/Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.h 2019-04-03 08:25:26 UTC (rev 243793)
@@ -59,6 +59,7 @@
void append(GMenu*, const WebContextMenuItemGlib&);
GRefPtr<GMenu> buildMenu(const Vector<WebContextMenuItemGlib>&);
void populate(const Vector<Ref<WebContextMenuItem>>&);
+ Vector<WebContextMenuItemGlib> populateSubMenu(const WebContextMenuItemData&);
static void menuPositionFunction(GtkMenu*, gint*, gint*, gboolean*, WebContextMenuProxyGtk*);
GtkWidget* m_webView;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes