⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 259799 in webkit


Ignore:
Timestamp:
Apr 9, 2020, 7:48:31 AM (6 years ago)
Author:
Claudio Saavedra
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):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r259789 r259799  
     12020-04-09  Claudio Saavedra  <csaavedra@igalia.com>
     2
     3        [GTK] Clean-up use of deprecated GtkAction
     4        https://bugs.webkit.org/show_bug.cgi?id=210273
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        GtkAction is deprecated, however we use it because it's exposed
     9        in the public API. Guard deprecated API usage to remove warnings and
     10        update docs to not suggest using the deprecated API.
     11
     12        * Shared/API/glib/WebKitContextMenuItem.cpp:
     13        * Shared/glib/WebContextMenuItemGlib.cpp:
     14        (WebKit::WebContextMenuItemGlib::buildActionName const):
     15        (WebKit::WebContextMenuItemGlib::createActionIfNeeded):
     16
    1172020-04-09  David Kilzer  <ddkilzer@apple.com>
    218
  • trunk/Source/WebKit/Shared/API/glib/WebKitContextMenuItem.cpp

    r248846 r259799  
    181181 * when a menu item created with a %WEBKIT_CONTEXT_MENU_ACTION_STOP is
    182182 * activated the action associated will be handled by WebKit and the current
    183  * load operation will be stopped. You can get the #GtkAction of a
     183 * load operation will be stopped. You can get the #GAction of a
    184184 * #WebKitContextMenuItem created with a #WebKitContextMenuAction with
    185  * webkit_context_menu_item_get_action() and connect to #GtkAction::activate signal
    186  * to be notified when the item is activated. But you can't prevent the associated
     185 * webkit_context_menu_item_get_gaction() and connect to the #GSimpleAction::activate signal
     186 * to be notified when the item is activated, but you can't prevent the associated
    187187 * action from being performed.
    188188 *
  • trunk/Source/WebKit/Shared/glib/WebContextMenuItemGlib.cpp

    r246374 r259799  
    7979
    8080#if PLATFORM(GTK)
     81ALLOW_DEPRECATED_DECLARATIONS_BEGIN
    8182WebContextMenuItemGlib::WebContextMenuItemGlib(GtkAction* action)
    8283    : 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)
     
    8687    g_object_set_data_full(G_OBJECT(m_gAction.get()), "webkit-gtk-action", g_object_ref(m_gtkAction), g_object_unref);
    8788}
     89ALLOW_DEPRECATED_DECLARATIONS_END
    8890#endif
    8991
     
    9597{
    9698#if PLATFORM(GTK)
     99ALLOW_DEPRECATED_DECLARATIONS_BEGIN
    97100    if (m_gtkAction)
    98101        return GUniquePtr<char>(g_strdup(gtk_action_get_name(m_gtkAction)));
     102ALLOW_DEPRECATED_DECLARATIONS_END
    99103#endif
    100104
     
    118122
    119123#if PLATFORM(GTK)
     124ALLOW_DEPRECATED_DECLARATIONS_BEGIN
    120125    // Create the GtkAction for backwards compatibility only.
    121126    if (!m_gtkAction) {
     
    130135
    131136    g_signal_connect_object(m_gAction.get(), "activate", G_CALLBACK(gtk_action_activate), m_gtkAction, G_CONNECT_SWAPPED);
     137ALLOW_DEPRECATED_DECLARATIONS_END
    132138#endif
    133139}
  • trunk/Tools/ChangeLog

    r259787 r259799  
     12020-04-09  Claudio Saavedra  <csaavedra@igalia.com>
     2
     3        [GTK] Clean-up use of deprecated GtkAction
     4        https://bugs.webkit.org/show_bug.cgi?id=210273
     5
     6        Reviewed by Carlos Garcia Campos.
     7
     8        GtkAction is deprecated so remove usage of it in the
     9        context menu API tests and guard its API usage when
     10        we still need to use it to test the deprecated WebKitGTK+ API
     11        exposing GtkAction.
     12
     13        * TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp:
     14        (testContextMenuPopulateMenu):
     15
    1162020-04-09  Aakash Jain  <aakash_jain@apple.com>
    217
  • trunk/Tools/TestWebKitAPI/Tests/WebKitGtk/TestContextMenu.cpp

    r247901 r259799  
    113113    }
    114114
    115     void checkActionState(GtkAction* action, unsigned state)
    116     {
    117         if (state & Visible)
    118             g_assert_true(gtk_action_get_visible(action));
     115    void checkActionState(GAction* action, unsigned state)
     116    {
     117        if (state & Enabled)
     118            g_assert_true(g_action_get_enabled(action));
    119119        else
    120             g_assert_false(gtk_action_get_visible(action));
    121 
    122         if (state & Enabled)
    123             g_assert_true(gtk_action_get_sensitive(action));
    124         else
    125             g_assert_false(gtk_action_get_sensitive(action));
    126 
    127         if (GTK_IS_TOGGLE_ACTION(action)) {
     120            g_assert_false(g_action_get_enabled(action));
     121
     122        const GVariantType* type = g_action_get_state_type(action);
     123        if (type && g_variant_type_equal(type, G_VARIANT_TYPE_BOOLEAN)) {
     124            GRefPtr<GVariant> actionState = adoptGRef(g_action_get_state(action));
    128125            if (state & Checked)
    129                 g_assert_true(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
     126                g_assert_true(g_variant_get_boolean(actionState.get()));
    130127            else
    131                 g_assert_false(gtk_toggle_action_get_active(GTK_TOGGLE_ACTION(action)));
     128                g_assert_false(g_variant_get_boolean(actionState.get()));
    132129        }
    133130    }
     
    151148        g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, stockAction);
    152149
    153         checkActionState(action, state);
     150        checkActionState(gAction, state);
    154151
    155152        return g_list_next(items);
     
    167164        GtkAction* action = webkit_context_menu_item_get_action(item);
    168165        g_assert_true(GTK_IS_ACTION(action));
    169         G_GNUC_END_IGNORE_DEPRECATIONS;
    170166
    171167        GAction* gAction = webkit_context_menu_item_get_gaction(item);
     
    182178        g_assert_cmpint(webkit_context_menu_item_get_stock_action(item), ==, WEBKIT_CONTEXT_MENU_ACTION_CUSTOM);
    183179        g_assert_cmpstr(gtk_action_get_label(action), ==, label);
    184 
    185         checkActionState(action, state);
     180        G_GNUC_END_IGNORE_DEPRECATIONS;
     181
     182        checkActionState(gAction, state);
    186183
    187184        return g_list_next(items);
     
    205202        g_assert_true(G_IS_ACTION(gAction));
    206203
    207         checkActionState(action, state);
     204        checkActionState(gAction, state);
    208205
    209206        WebKitContextMenu* subMenu = webkit_context_menu_item_get_submenu(item);
     
    656653    test->waitUntilLoadFinished();
    657654
     655    G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
    658656    // Create a custom menu item.
    659657    GRefPtr<GtkAction> action = adoptGRef(gtk_action_new("WebKitGTKCustomAction", "Custom _Action", nullptr, nullptr));
     
    671669    g_assert_false(test->m_activated);
    672670    g_assert_true(test->m_toggled);
     671    G_GNUC_END_IGNORE_DEPRECATIONS;
    673672
    674673    // Create a custom menu item using GAction.
Note: See TracChangeset for help on using the changeset viewer.