- Revision
- 259799
- Author
- csaave...@igalia.com
- Date
- 2020-04-09 07:48:31 -0700 (Thu, 09 Apr 2020)
Log Message
[GTK] Clean-up use of deprecated GtkAction
https://bugs.webkit.org/show_bug.cgi?id=210273
Reviewed by Carlos Garcia Campos.
Source/WebKit:
GtkAction is deprecated, however we use it because it's exposed
in the public API. Guard deprecated API usage to remove warnings and
update docs to not suggest using the deprecated API.
* Shared/API/glib/WebKitContextMenuItem.cpp:
* Shared/glib/WebContextMenuItemGlib.cpp:
(WebKit::WebContextMenuItemGlib::buildActionName const):
(WebKit::WebContextMenuItemGlib::createActionIfNeeded):
Tools:
GtkAction is deprecated so remove usage of it in the
context menu API tests and guard its API usage when
we still need to use it to test the deprecated WebKitGTK+ API
exposing GtkAction.
* TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
(testContextMenuPopulateMenu):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (259798 => 259799)
--- trunk/Source/WebKit/ChangeLog 2020-04-09 14:20:59 UTC (rev 259798)
+++ trunk/Source/WebKit/ChangeLog 2020-04-09 14:48:31 UTC (rev 259799)
@@ -1,3 +1,19 @@
+2020-04-09 Claudio Saavedra <csaave...@igalia.com>
+
+ [GTK] Clean-up use of deprecated GtkAction
+ https://bugs.webkit.org/show_bug.cgi?id=210273
+
+ Reviewed by Carlos Garcia Campos.
+
+ GtkAction is deprecated, however we use it because it's exposed
+ in the public API. Guard deprecated API usage to remove warnings and
+ update docs to not suggest using the deprecated API.
+
+ * Shared/API/glib/WebKitContextMenuItem.cpp:
+ * Shared/glib/WebContextMenuItemGlib.cpp:
+ (WebKit::WebContextMenuItemGlib::buildActionName const):
+ (WebKit::WebContextMenuItemGlib::createActionIfNeeded):
+
2020-04-09 David Kilzer <ddkil...@apple.com>
UserData::decode should add bounds checks
Modified: trunk/Source/WebKit/Shared/API/glib/WebKitContextMenuItem.cpp (259798 => 259799)
--- trunk/Source/WebKit/Shared/API/glib/WebKitContextMenuItem.cpp 2020-04-09 14:20:59 UTC (rev 259798)
+++ trunk/Source/WebKit/Shared/API/glib/WebKitContextMenuItem.cpp 2020-04-09 14:48:31 UTC (rev 259799)
@@ -180,10 +180,10 @@
* Stock actions are handled automatically by WebKit so that, for example,
* when a menu item created with a %WEBKIT_CONTEXT_MENU_ACTION_STOP is
* activated the action associated will be handled by WebKit and the current
- * load operation will be stopped. You can get the #GtkAction of a
+ * load operation will be stopped. You can get the #GAction of a
* #WebKitContextMenuItem created with a #WebKitContextMenuAction with
- * webkit_context_menu_item_get_action() and connect to #GtkAction::activate signal
- * to be notified when the item is activated. But you can't prevent the associated
+ * webkit_context_menu_item_get_gaction() and connect to the #GSimpleAction::activate signal
+ * to be notified when the item is activated, but you can't prevent the associated
* action from being performed.
*
* Returns: the newly created #WebKitContextMenuItem object.
Modified: trunk/Source/WebKit/Shared/glib/WebContextMenuItemGlib.cpp (259798 => 259799)
--- trunk/Source/WebKit/Shared/glib/WebContextMenuItemGlib.cpp 2020-04-09 14:20:59 UTC (rev 259798)
+++ trunk/Source/WebKit/Shared/glib/WebContextMenuItemGlib.cpp 2020-04-09 14:48:31 UTC (rev 259799)
@@ -78,6 +78,7 @@
}
#if PLATFORM(GTK)
+ALLOW_DEPRECATED_DECLARATIONS_BEGIN
WebContextMenuItemGlib::WebContextMenuItemGlib(GtkAction* action)
: WebContextMenuItemData(GTK_IS_TOGGLE_ACTION(action) ? CheckableActionType : ActionType, ContextMenuItemBaseApplicationTag, String::fromUTF8(gtk_action_get_label(action)), gtk_action_get_sensitive(action), GTK_IS_TOGGLE_ACTION(action) ? gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)) : false)
{
@@ -85,6 +86,7 @@
createActionIfNeeded();
g_object_set_data_full(G_OBJECT(m_gAction.get()), "webkit-gtk-action", g_object_ref(m_gtkAction), g_object_unref);
}
+ALLOW_DEPRECATED_DECLARATIONS_END
#endif
WebContextMenuItemGlib::~WebContextMenuItemGlib()
@@ -94,8 +96,10 @@
GUniquePtr<char> WebContextMenuItemGlib::buildActionName() const
{
#if PLATFORM(GTK)
+ALLOW_DEPRECATED_DECLARATIONS_BEGIN
if (m_gtkAction)
return GUniquePtr<char>(g_strdup(gtk_action_get_name(m_gtkAction)));
+ALLOW_DEPRECATED_DECLARATIONS_END
#endif
static uint64_t actionID = 0;
@@ -117,6 +121,7 @@
}
#if PLATFORM(GTK)
+ALLOW_DEPRECATED_DECLARATIONS_BEGIN
// Create the GtkAction for backwards compatibility only.
if (!m_gtkAction) {
if (type() == CheckableActionType) {
@@ -129,6 +134,7 @@
}
g_signal_connect_object(m_gAction.get(), "activate", G_CALLBACK(gtk_action_activate), m_gtkAction, G_CONNECT_SWAPPED);
+ALLOW_DEPRECATED_DECLARATIONS_END
#endif
}
Modified: trunk/Tools/ChangeLog (259798 => 259799)
--- trunk/Tools/ChangeLog 2020-04-09 14:20:59 UTC (rev 259798)
+++ trunk/Tools/ChangeLog 2020-04-09 14:48:31 UTC (rev 259799)
@@ -1,3 +1,18 @@
+2020-04-09 Claudio Saavedra <csaave...@igalia.com>
+
+ [GTK] Clean-up use of deprecated GtkAction
+ https://bugs.webkit.org/show_bug.cgi?id=210273
+
+ Reviewed by Carlos Garcia Campos.
+
+ GtkAction is deprecated so remove usage of it in the
+ context menu API tests and guard its API usage when
+ we still need to use it to test the deprecated WebKitGTK+ API
+ exposing GtkAction.
+
+ * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
+ (testContextMenuPopulateMenu):
+
2020-04-09 Aakash Jain <aakash_j...@apple.com>
[ews] rename CompileWebKitToT to CompileWebKitWithoutPatch
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp (259798 => 259799)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp 2020-04-09 14:20:59 UTC (rev 259798)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp 2020-04-09 14:48:31 UTC (rev 259799)
@@ -112,23 +112,20 @@
return 0;
}
- void checkActionState(GtkAction* action, unsigned state)
+ void checkActionState(GAction* action, unsigned state)
{
- if (state & Visible)
- g_assert_true(gtk_action_get_visible(action));
- else
- g_assert_false(gtk_action_get_visible(action));
-
if (state & Enabled)
- g_assert_true(gtk_action_get_sensitive(action));
+ g_assert_true(g_action_get_enabled(action));
else
- g_assert_false(gtk_action_get_sensitive(action));
+ g_assert_false(g_action_get_enabled(action));
- if (GTK_IS_TOGGLE_ACTION(action)) {
+ const GVariantType* type = g_action_get_state_type(action);
+ if (type && g_variant_type_equal(type, G_VARIANT_TYPE_BOOLEAN)) {
+ GRefPtr<GVariant> actionState = adoptGRef(g_action_get_state(action));
if (state & Checked)
- g_assert_true(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
+ g_assert_true(g_variant_get_boolean(actionState.get()));
else
- g_assert_false(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
+ g_assert_false(g_variant_get_boolean(actionState.get()));
}
}
@@ -150,7 +147,7 @@
g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, stockAction);
- checkActionState(action, state);
+ checkActionState(gAction, state);
return g_list_next(items);
}
@@ -166,7 +163,6 @@
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
GtkAction* action = ""
g_assert_true(GTK_IS_ACTION(action));
- G_GNUC_END_IGNORE_DEPRECATIONS;
GAction* gAction = webkit_context_menu_item_get_gaction(item);
g_assert_true(G_IS_ACTION(gAction));
@@ -181,8 +177,9 @@
g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, WEBKIT_CONTEXT_MENU_ACTION_CUSTOM);
g_assert_cmpstr(gtk_action_get_label(action), ==, label);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
- checkActionState(action, state);
+ checkActionState(gAction, state);
return g_list_next(items);
}
@@ -204,7 +201,7 @@
GAction* gAction = webkit_context_menu_item_get_gaction(item);
g_assert_true(G_IS_ACTION(gAction));
- checkActionState(action, state);
+ checkActionState(gAction, state);
WebKitContextMenu* subMenu = webkit_context_menu_item_get_submenu(item);
g_assert_true(WEBKIT_IS_CONTEXT_MENU(subMenu));
@@ -655,6 +652,7 @@
test->loadHtml("<html><body>WebKitGTK Context menu tests</body></html>", "file:///");
test->waitUntilLoadFinished();
+ G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
// Create a custom menu item.
GRefPtr<GtkAction> action = "" "Custom _Action", nullptr, nullptr));
test->setAction(action.get());
@@ -670,6 +668,7 @@
test->toggleCustomMenuItemAndWaitUntilToggled(gtk_action_get_label(toggleAction.get()));
g_assert_false(test->m_activated);
g_assert_true(test->m_toggled);
+ G_GNUC_END_IGNORE_DEPRECATIONS;
// Create a custom menu item using GAction.
GRefPtr<GAction> gAction = adoptGRef(G_ACTION(g_simple_action_new("WebKitGTKCustomGAction", nullptr)));