Skip to content

Commit 449c1eb

Browse files
committed
[GTK] Misplaced right click menu on web page due to deprecated gtk_menu_popup()
https://bugs.webkit.org/show_bug.cgi?id=170553 Source/WebCore: Reviewed by Carlos Garcia Campos. * platform/gtk/GtkVersioning.h: Add replacements for GtkPopover functions which are no longet available in GTK4. (gtk_popover_menu_new): Added. (gtk_popover_bind_model): Added. (gtk_popover_set_relative_to): Added. Source/WebKit: Reviewed by Carlos Garcia Campos. Replace GtkMenuShell with a GtkPopoverMenu for context menus. The former is not available at all in GTK4, and the later allows for simplifying the positioning code: it is enough to provide a point in WebKitWebView widget where to place the popup, and GTK takes care of everything. This removes the custom positioning code (as it is not needed anymore), which did GdkScreen-relative calculations that GTK4 does not support. No new tests needed. * Shared/glib/WebContextMenuItemGlib.h: * UIProcess/API/glib/WebKitWebView.cpp: (contextMenuDismissed): Change parameter from GtkMenuShell to GtkMenuShell to GtkWidget. (webkitWebViewPopulateContextMenu): Connect to the GtkPopover::closed signal instead of GtkMenuShell::deactivate. * UIProcess/API/gtk/WebKitWebViewBase.cpp: (activeContextMenuClosed): Renamed from activeContextMenuUnmapped(), changed parameter from GtkMenuShell to GtkWidget, and compare with WebContextMenuProxyGtk::gtkWidget(). (activeContextMenuUnmapped): Renamed to activeContextMenuClosed(). (webkitWebViewBaseSetActiveContextMenuProxy): Connect to the GtkPopover::closed signal instead of GtkMenuShell::deactivate. (webkitWebViewBaseGetActiveContextMenuProxy): * UIProcess/API/gtk/WebKitWebViewBasePrivate.h: * UIProcess/API/gtk/WebKitWebViewGtk.cpp: * UIProcess/gtk/WebContextMenuProxyGtk.cpp: Arrange to use GtkPopoverMenu instead of GtkMenuShell. * UIProcess/gtk/WebContextMenuProxyGtk.cpp: (WebKit::WebContextMenuProxyGtk::populate): (WebKit::WebContextMenuProxyGtk::showContextMenuWithItems): Simplify using m_context.menuLocation() to obtain the location where to make the context menu popup next to, which allows removing the ::menuPositionFunction() callback as well. (WebKit::WebContextMenuProxyGtk::WebContextMenuProxyGtk): (WebKit::WebContextMenuProxyGtk::~WebContextMenuProxyGtk): * UIProcess/gtk/WebContextMenuProxyGtk.h: Remove declarations for ::menuPositionFunction() and ::m_popupPosition, which are now unneeded. (WebKit::WebContextMenuProxyGtk::gtkWidget const): Renamed from ::gtkMenu(), and made it return a GtkWidget. Tools: Minor adaptations needed in the API tests to account for the differences between GtkMenuShell and GtkPopoverMenu. Reviewed by Carlos Garcia Campos. * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp: (lookupWidgetsWalkChild): Added. (lookupWidgets): Added. Canonical link: https://commits.webkit.org/224079@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260889 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent bbc2f7a commit 449c1eb

12 files changed

Lines changed: 174 additions & 95 deletions

File tree

Source/WebCore/ChangeLog

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
2020-04-29 Adrian Perez de Castro <[email protected]>
2+
3+
[GTK] Misplaced right click menu on web page due to deprecated gtk_menu_popup()
4+
https://bugs.webkit.org/show_bug.cgi?id=170553
5+
6+
Reviewed by Carlos Garcia Campos.
7+
8+
* platform/gtk/GtkVersioning.h: Add replacements for GtkPopover functions which are no longet available in GTK4.
9+
(gtk_popover_menu_new): Added.
10+
(gtk_popover_bind_model): Added.
11+
(gtk_popover_set_relative_to): Added.
12+
113
2020-04-29 Philippe Normand <[email protected]>
214

315
[GStreamer] Switch to audiointerleave

Source/WebCore/platform/gtk/GtkVersioning.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,4 +151,20 @@ gdk_event_get_keycode(const GdkEvent* event, guint16* keycode)
151151
*keycode = gdk_key_event_get_keycode(const_cast<GdkEvent*>(event));
152152
return TRUE;
153153
}
154+
155+
static inline GtkWidget* gtk_popover_menu_new()
156+
{
157+
return gtk_popover_menu_new_from_model(nullptr);
158+
}
159+
160+
static inline void gtk_popover_bind_model(GtkPopover* popover, GMenuModel* model, const char*)
161+
{
162+
ASSERT(GTK_IS_POPOVER_MENU(popover));
163+
gtk_popover_menu_set_menu_model(GTK_POPOVER_MENU(popover), model);
164+
}
165+
166+
static inline void gtk_popover_set_relative_to(GtkPopover* popover, GtkWidget* parent)
167+
{
168+
gtk_widget_set_parent(GTK_WIDGET(popover), parent);
169+
}
154170
#endif // USE(GTK4)

Source/WebKit/ChangeLog

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,46 @@
1+
2020-04-29 Adrian Perez de Castro <[email protected]>
2+
3+
[GTK] Misplaced right click menu on web page due to deprecated gtk_menu_popup()
4+
https://bugs.webkit.org/show_bug.cgi?id=170553
5+
6+
Reviewed by Carlos Garcia Campos.
7+
8+
Replace GtkMenuShell with a GtkPopoverMenu for context menus. The former is not available
9+
at all in GTK4, and the later allows for simplifying the positioning code: it is enough
10+
to provide a point in WebKitWebView widget where to place the popup, and GTK takes care
11+
of everything. This removes the custom positioning code (as it is not needed anymore),
12+
which did GdkScreen-relative calculations that GTK4 does not support.
13+
14+
No new tests needed.
15+
16+
* Shared/glib/WebContextMenuItemGlib.h:
17+
* UIProcess/API/glib/WebKitWebView.cpp:
18+
(contextMenuDismissed): Change parameter from GtkMenuShell to GtkMenuShell to GtkWidget.
19+
(webkitWebViewPopulateContextMenu): Connect to the GtkPopover::closed signal instead of
20+
GtkMenuShell::deactivate.
21+
* UIProcess/API/gtk/WebKitWebViewBase.cpp:
22+
(activeContextMenuClosed): Renamed from activeContextMenuUnmapped(), changed parameter
23+
from GtkMenuShell to GtkWidget, and compare with WebContextMenuProxyGtk::gtkWidget().
24+
(activeContextMenuUnmapped): Renamed to activeContextMenuClosed().
25+
(webkitWebViewBaseSetActiveContextMenuProxy): Connect to the GtkPopover::closed signal
26+
instead of GtkMenuShell::deactivate.
27+
(webkitWebViewBaseGetActiveContextMenuProxy):
28+
* UIProcess/API/gtk/WebKitWebViewBasePrivate.h:
29+
* UIProcess/API/gtk/WebKitWebViewGtk.cpp:
30+
* UIProcess/gtk/WebContextMenuProxyGtk.cpp: Arrange to use GtkPopoverMenu instead of
31+
GtkMenuShell.
32+
* UIProcess/gtk/WebContextMenuProxyGtk.cpp:
33+
(WebKit::WebContextMenuProxyGtk::populate):
34+
(WebKit::WebContextMenuProxyGtk::showContextMenuWithItems): Simplify using
35+
m_context.menuLocation() to obtain the location where to make the context menu popup
36+
next to, which allows removing the ::menuPositionFunction() callback as well.
37+
(WebKit::WebContextMenuProxyGtk::WebContextMenuProxyGtk):
38+
(WebKit::WebContextMenuProxyGtk::~WebContextMenuProxyGtk):
39+
* UIProcess/gtk/WebContextMenuProxyGtk.h: Remove declarations for ::menuPositionFunction()
40+
and ::m_popupPosition, which are now unneeded.
41+
(WebKit::WebContextMenuProxyGtk::gtkWidget const): Renamed from ::gtkMenu(), and made it
42+
return a GtkWidget.
43+
144
2020-04-29 Commit Queue <[email protected]>
245

346
Unreviewed, reverting r260650.

Source/WebKit/Shared/glib/WebContextMenuItemGlib.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2015 Igalia S.L.
2+
* Copyright (C) 2015, 2020 Igalia S.L.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -29,10 +29,10 @@
2929
#include <wtf/glib/GRefPtr.h>
3030
#include <wtf/glib/GUniquePtr.h>
3131

32-
#if !USE(GTK4)
32+
#if PLATFORM(GTK) && !USE(GTK4)
3333
typedef struct _GtkAction GtkAction;
34+
#endif // PLATFORM(GTK) && !USE(GTK4)
3435
typedef struct _GAction GAction;
35-
#endif
3636

3737
namespace WebKit {
3838

Source/WebKit/UIProcess/API/glib/WebKitWebView.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
/*
2-
* Copyright (C) 2011 Igalia S.L.
32
* Portions Copyright (c) 2011 Motorola Mobility, Inc. All rights reserved.
43
* Copyright (C) 2014 Collabora Ltd.
5-
* Copyright (C) 2017 Igalia S.L.
4+
* Copyright (C) 2011, 2017, 2020 Igalia S.L.
65
*
76
* This library is free software; you can redistribute it and/or
87
* modify it under the terms of the GNU Library General Public
@@ -2580,16 +2579,13 @@ void webkitWebViewRunFileChooserRequest(WebKitWebView* webView, WebKitFileChoose
25802579
}
25812580

25822581
#if PLATFORM(GTK)
2583-
#if !USE(GTK4)
2584-
static void contextMenuDismissed(GtkMenuShell*, WebKitWebView* webView)
2582+
static void contextMenuDismissed(GtkWidget*, WebKitWebView* webView)
25852583
{
25862584
g_signal_emit(webView, signals[CONTEXT_MENU_DISMISSED], 0, NULL);
25872585
}
2588-
#endif
25892586

25902587
void webkitWebViewPopulateContextMenu(WebKitWebView* webView, const Vector<WebContextMenuItemData>& proposedMenu, const WebHitTestResultData& hitTestResultData, GVariant* userData)
25912588
{
2592-
#if !USE(GTK4)
25932589
WebKitWebViewBase* webViewBase = WEBKIT_WEB_VIEW_BASE(webView);
25942590
WebContextMenuProxyGtk* contextMenuProxy = webkitWebViewBaseGetActiveContextMenuProxy(webViewBase);
25952591
ASSERT(contextMenuProxy);
@@ -2609,11 +2605,10 @@ void webkitWebViewPopulateContextMenu(WebKitWebView* webView, const Vector<WebCo
26092605
webkitContextMenuPopulate(contextMenu.get(), contextMenuItems);
26102606
contextMenuProxy->populate(contextMenuItems);
26112607

2612-
g_signal_connect(contextMenuProxy->gtkMenu(), "deactivate", G_CALLBACK(contextMenuDismissed), webView);
2608+
g_signal_connect(contextMenuProxy->gtkWidget(), "closed", G_CALLBACK(contextMenuDismissed), webView);
26132609

26142610
// Clear the menu to make sure it's useless after signal emission.
26152611
webkit_context_menu_remove_all(contextMenu.get());
2616-
#endif
26172612
}
26182613
#elif PLATFORM(WPE)
26192614
void webkitWebViewPopulateContextMenu(WebKitWebView* webView, const Vector<WebContextMenuItemData>& proposedMenu, const WebHitTestResultData& hitTestResultData, GVariant* userData)

Source/WebKit/UIProcess/API/gtk/WebKitWebViewBase.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/*
22
* Copyright (C) 2010 Apple Inc. All rights reserved.
33
* Portions Copyright (c) 2010 Motorola Mobility, Inc. All rights reserved.
4-
* Copyright (C) 2011 Igalia S.L.
54
* Copyright (C) 2013 Gustavo Noronha Silva <[email protected]>.
5+
* Copyright (C) 2011, 2020 Igalia S.L.
66
*
77
* Redistribution and use in source and binary forms, with or without
88
* modification, are permitted provided that the following conditions
@@ -190,9 +190,7 @@ struct _WebKitWebViewBasePrivate {
190190
AttachmentSide inspectorAttachmentSide { AttachmentSide::Bottom };
191191
unsigned inspectorViewSize { 0 };
192192
GUniquePtr<GdkEvent> contextMenuEvent;
193-
#if !USE(GTK4)
194193
WebContextMenuProxyGtk* activeContextMenuProxy { nullptr };
195-
#endif
196194
InputMethodFilter inputMethodFilter;
197195
KeyBindingTranslator keyBindingTranslator;
198196
TouchEventsMap touchEvents;
@@ -1860,24 +1858,22 @@ void webkitWebViewBaseSetInspectorViewSize(WebKitWebViewBase* webkitWebViewBase,
18601858
gtk_widget_queue_resize_no_redraw(GTK_WIDGET(webkitWebViewBase));
18611859
}
18621860

1863-
#if !USE(GTK4)
1864-
static void activeContextMenuUnmapped(GtkMenu* menu, WebKitWebViewBase* webViewBase)
1861+
static void activeContextMenuClosed(GtkWidget* widget, WebKitWebViewBase* webViewBase)
18651862
{
1866-
if (webViewBase->priv->activeContextMenuProxy && webViewBase->priv->activeContextMenuProxy->gtkMenu() == menu)
1863+
if (webViewBase->priv->activeContextMenuProxy && webViewBase->priv->activeContextMenuProxy->gtkWidget() == widget)
18671864
webViewBase->priv->activeContextMenuProxy = nullptr;
18681865
}
18691866

18701867
void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase, WebContextMenuProxyGtk* contextMenuProxy)
18711868
{
18721869
webkitWebViewBase->priv->activeContextMenuProxy = contextMenuProxy;
1873-
g_signal_connect_object(contextMenuProxy->gtkMenu(), "unmap", G_CALLBACK(activeContextMenuUnmapped), webkitWebViewBase, static_cast<GConnectFlags>(0));
1870+
g_signal_connect_object(contextMenuProxy->gtkWidget(), "closed", G_CALLBACK(activeContextMenuClosed), webkitWebViewBase, static_cast<GConnectFlags>(0));
18741871
}
18751872

18761873
WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase* webkitWebViewBase)
18771874
{
18781875
return webkitWebViewBase->priv->activeContextMenuProxy;
18791876
}
1880-
#endif
18811877

18821878
GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase* webkitWebViewBase)
18831879
{

Source/WebKit/UIProcess/API/gtk/WebKitWebViewBasePrivate.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,8 @@ void webkitWebViewBaseEnterFullScreen(WebKitWebViewBase*);
5353
void webkitWebViewBaseExitFullScreen(WebKitWebViewBase*);
5454
bool webkitWebViewBaseIsFullScreen(WebKitWebViewBase*);
5555
void webkitWebViewBaseSetInspectorViewSize(WebKitWebViewBase*, unsigned size);
56-
#if !USE(GTK4)
5756
void webkitWebViewBaseSetActiveContextMenuProxy(WebKitWebViewBase*, WebKit::WebContextMenuProxyGtk*);
5857
WebKit::WebContextMenuProxyGtk* webkitWebViewBaseGetActiveContextMenuProxy(WebKitWebViewBase*);
59-
#endif
6058
GdkEvent* webkitWebViewBaseTakeContextMenuEvent(WebKitWebViewBase*);
6159
void webkitWebViewBaseSetInputMethodState(WebKitWebViewBase*, Optional<WebKit::InputMethodState>&&);
6260
void webkitWebViewBaseUpdateTextInputState(WebKitWebViewBase*);

Source/WebKit/UIProcess/API/gtk/WebKitWebViewGtk.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2017 Igalia S.L.
2+
* Copyright (C) 2017, 2020 Igalia S.L.
33
*
44
* This library is free software; you can redistribute it and/or
55
* modify it under the terms of the GNU Library General Public

Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.cpp

Lines changed: 11 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2011 Igalia S.L.
2+
* Copyright (C) 2011, 2020 Igalia S.L.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -47,7 +47,6 @@ static const char* gContextMenuItemGroup = "webkitContextMenu";
4747
namespace WebKit {
4848
using namespace WebCore;
4949

50-
#if !USE(GTK4)
5150
static void contextMenuItemActivatedCallback(GAction* action, GVariant*, WebPageProxy* page)
5251
{
5352
auto* stateType = g_action_get_state_type(action);
@@ -68,7 +67,7 @@ void WebContextMenuProxyGtk::append(GMenu* menu, const WebContextMenuItemGlib& m
6867
GRefPtr<GMenuItem> gMenuItem;
6968
GAction* action = menuItem.gAction();
7069
ASSERT(action);
71-
g_action_map_add_action(G_ACTION_MAP(gtk_widget_get_action_group(GTK_WIDGET(m_menu), gContextMenuItemGroup)), action);
70+
g_action_map_add_action(G_ACTION_MAP(m_actionGroup.get()), action);
7271

7372
switch (menuItem.type()) {
7473
case ActionType:
@@ -129,7 +128,7 @@ Vector<WebContextMenuItemGlib> WebContextMenuProxyGtk::populateSubMenu(const Web
129128
void WebContextMenuProxyGtk::populate(const Vector<WebContextMenuItemGlib>& items)
130129
{
131130
GRefPtr<GMenu> menu = buildMenu(items);
132-
gtk_menu_shell_bind_model(GTK_MENU_SHELL(m_menu), G_MENU_MODEL(menu.get()), nullptr, TRUE);
131+
gtk_popover_bind_model(m_menu, G_MENU_MODEL(menu.get()), nullptr);
133132
}
134133

135134
void WebContextMenuProxyGtk::populate(const Vector<Ref<WebContextMenuItem>>& items)
@@ -157,26 +156,22 @@ void WebContextMenuProxyGtk::populate(const Vector<Ref<WebContextMenuItem>>& ite
157156
}
158157
}
159158
}
160-
gtk_menu_shell_bind_model(GTK_MENU_SHELL(m_menu), G_MENU_MODEL(menu.get()), nullptr, TRUE);
159+
gtk_popover_bind_model(m_menu, G_MENU_MODEL(menu.get()), nullptr);
161160
}
162-
#endif
163161

164162
void WebContextMenuProxyGtk::show()
165163
{
166-
#if !USE(GTK4)
167164
Vector<Ref<WebContextMenuItem>> proposedAPIItems;
168165
for (auto& item : m_context.menuItems()) {
169166
if (item.action() != ContextMenuItemTagShareMenu)
170167
proposedAPIItems.append(WebContextMenuItem::create(item));
171168
}
172169

173170
m_page->contextMenuClient().getContextMenuFromProposedMenu(*m_page, WTFMove(proposedAPIItems), WebContextMenuListenerProxy::create(this).get(), m_context.webHitTestResultData(), m_page->process().transformHandlesToObjects(m_userData.object()).get());
174-
#endif
175171
}
176172

177173
void WebContextMenuProxyGtk::showContextMenuWithItems(Vector<Ref<WebContextMenuItem>>&& items)
178174
{
179-
#if !USE(GTK4)
180175
if (!items.isEmpty())
181176
populate(items);
182177

@@ -185,63 +180,35 @@ void WebContextMenuProxyGtk::showContextMenuWithItems(Vector<Ref<WebContextMenuI
185180
if (!childCount)
186181
return;
187182

188-
m_popupPosition = convertWidgetPointToScreenPoint(m_webView, m_context.menuLocation());
189-
190-
// Display menu initiated by right click (mouse button pressed = 3).
191-
NativeWebMouseEvent* mouseEvent = m_page->currentlyProcessedMouseDownEvent();
192-
const GdkEvent* event = mouseEvent ? mouseEvent->nativeEvent() : 0;
193-
gtk_menu_attach_to_widget(m_menu, GTK_WIDGET(m_webView), nullptr);
194-
gtk_menu_popup(m_menu, nullptr, nullptr, reinterpret_cast<GtkMenuPositionFunc>(menuPositionFunction), this, event ? event->button.button : 3, event ? event->button.time : GDK_CURRENT_TIME);
195-
#endif
183+
const GdkRectangle rect = { m_context.menuLocation().x(), m_context.menuLocation().y(), 1, 1 };
184+
gtk_popover_set_pointing_to(m_menu, &rect);
185+
gtk_popover_popup(m_menu);
196186
}
197187

198188
WebContextMenuProxyGtk::WebContextMenuProxyGtk(GtkWidget* webView, WebPageProxy& page, ContextMenuContextData&& context, const UserData& userData)
199189
: WebContextMenuProxy(WTFMove(context), userData)
200-
#if !USE(GTK4)
201190
, m_webView(webView)
202191
, m_page(&page)
203-
, m_menu(GTK_MENU(gtk_menu_new()))
204-
#endif
192+
, m_menu(GTK_POPOVER(gtk_popover_menu_new()))
205193
{
206-
#if !USE(GTK4)
194+
gtk_popover_set_position(m_menu, GTK_POS_BOTTOM);
195+
gtk_popover_set_relative_to(m_menu, m_webView);
207196
GRefPtr<GSimpleActionGroup> group = adoptGRef(g_simple_action_group_new());
208197
gtk_widget_insert_action_group(GTK_WIDGET(m_menu), gContextMenuItemGroup, G_ACTION_GROUP(group.get()));
209198
webkitWebViewBaseSetActiveContextMenuProxy(WEBKIT_WEB_VIEW_BASE(m_webView), this);
210-
#endif
211199
}
212200

213201
WebContextMenuProxyGtk::~WebContextMenuProxyGtk()
214202
{
215-
#if !USE(GTK4)
216-
gtk_menu_popdown(m_menu);
203+
gtk_popover_popdown(m_menu);
217204

218205
for (auto& handler : m_signalHandlers)
219206
g_signal_handler_disconnect(handler.value, handler.key);
220207
m_signalHandlers.clear();
221208

222209
gtk_widget_insert_action_group(GTK_WIDGET(m_menu), gContextMenuItemGroup, nullptr);
223210
gtk_widget_destroy(GTK_WIDGET(m_menu));
224-
#endif
225-
}
226-
227-
#if !USE(GTK4)
228-
void WebContextMenuProxyGtk::menuPositionFunction(GtkMenu* menu, gint* x, gint* y, gboolean* pushIn, WebContextMenuProxyGtk* popupMenu)
229-
{
230-
GtkRequisition menuSize;
231-
gtk_widget_get_preferred_size(GTK_WIDGET(menu), &menuSize, 0);
232-
233-
GdkScreen* screen = gtk_widget_get_screen(popupMenu->m_webView);
234-
*x = popupMenu->m_popupPosition.x();
235-
if ((*x + menuSize.width) >= gdk_screen_get_width(screen))
236-
*x -= menuSize.width;
237-
238-
*y = popupMenu->m_popupPosition.y();
239-
if ((*y + menuSize.height) >= gdk_screen_get_height(screen))
240-
*y -= menuSize.height;
241-
242-
*pushIn = FALSE;
243211
}
244-
#endif
245212

246213
} // namespace WebKit
247214
#endif // ENABLE(CONTEXT_MENUS)

Source/WebKit/UIProcess/gtk/WebContextMenuProxyGtk.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2011 Igalia S.L.
2+
* Copyright (C) 2011, 2020 Igalia S.L.
33
*
44
* Redistribution and use in source and binary forms, with or without
55
* modification, are permitted provided that the following conditions
@@ -29,6 +29,7 @@
2929

3030
#include "WebContextMenuItemGlib.h"
3131
#include "WebContextMenuProxy.h"
32+
#include <WebCore/GtkVersioning.h>
3233
#include <WebCore/IntPoint.h>
3334
#include <wtf/HashMap.h>
3435
#include <wtf/glib/GRefPtr.h>
@@ -49,28 +50,23 @@ class WebContextMenuProxyGtk : public WebContextMenuProxy {
4950
}
5051
~WebContextMenuProxyGtk();
5152

52-
#if !USE(GTK4)
5353
void populate(const Vector<WebContextMenuItemGlib>&);
54-
GtkMenu* gtkMenu() const { return m_menu; }
55-
#endif
54+
GtkWidget* gtkWidget() const { return GTK_WIDGET(m_menu); }
5655

5756
private:
5857
WebContextMenuProxyGtk(GtkWidget*, WebPageProxy&, ContextMenuContextData&&, const UserData&);
5958
void show() override;
6059
void showContextMenuWithItems(Vector<Ref<WebContextMenuItem>>&&) override;
61-
#if !USE(GTK4)
6260
void append(GMenu*, const WebContextMenuItemGlib&);
6361
GRefPtr<GMenu> buildMenu(const Vector<WebContextMenuItemGlib>&);
6462
void populate(const Vector<Ref<WebContextMenuItem>>&);
6563
Vector<WebContextMenuItemGlib> populateSubMenu(const WebContextMenuItemData&);
66-
static void menuPositionFunction(GtkMenu*, gint*, gint*, gboolean*, WebContextMenuProxyGtk*);
6764

6865
GtkWidget* m_webView;
6966
WebPageProxy* m_page;
70-
GtkMenu* m_menu;
71-
WebCore::IntPoint m_popupPosition;
67+
GtkPopover* m_menu;
7268
HashMap<unsigned long, void*> m_signalHandlers;
73-
#endif
69+
GRefPtr<GSimpleActionGroup> m_actionGroup { adoptGRef(g_simple_action_group_new()) };
7470
};
7571

7672

0 commit comments

Comments
 (0)