From deec83932392fbd23221d2467498076d2fc8da84 Mon Sep 17 00:00:00 2001 From: "mario@webkit.org" Date: Mon, 23 Jan 2012 14:45:23 +0000 Subject: [PATCH] [GTK] Refactor GTK's accessibilitity code to be more modular https://bugs.webkit.org/show_bug.cgi?id=76783 Reviewed by Martin Robinson. New files for the implementation of the AtkAction interface, containing the related code from WebKitAccessibleWrapperAtk.cpp. * accessibility/gtk/WebKitAccessibleInterfaceAction.cpp: Added. (core): (webkitAccessibleActionInterfaceInit): (webkitAccessibleActionDoAction): (webkitAccessibleActionGetNActions): (webkitAccessibleActionGetDescription): (webkitAccessibleActionGetKeybinding): (webkitAccessibleActionGetName): * accessibility/gtk/WebKitAccessibleInterfaceAction.h: Added. * accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove code related to the implementation of the AtkAction interface. Add new files to build files. * GNUmakefile.list.am: Add WebKitAccessibleInterfaceAction.[h|cpp]. * WebCore.gypi: Ditto. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105618 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 28 +++++++ Source/WebCore/GNUmakefile.list.am | 2 + Source/WebCore/WebCore.gypi | 2 + .../gtk/WebKitAccessibleInterfaceAction.cpp | 87 ++++++++++++++++++++++ .../gtk/WebKitAccessibleInterfaceAction.h | 34 +++++++++ .../gtk/WebKitAccessibleWrapperAtk.cpp | 50 +------------ 6 files changed, 155 insertions(+), 48 deletions(-) create mode 100644 Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.cpp create mode 100644 Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.h diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 1478e30..cff6371 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,31 @@ +2012-01-23 Mario Sanchez Prada + + [GTK] Refactor GTK's accessibilitity code to be more modular + https://bugs.webkit.org/show_bug.cgi?id=76783 + + Reviewed by Martin Robinson. + + New files for the implementation of the AtkAction interface, + containing the related code from WebKitAccessibleWrapperAtk.cpp. + + * accessibility/gtk/WebKitAccessibleInterfaceAction.cpp: Added. + (core): + (webkitAccessibleActionInterfaceInit): + (webkitAccessibleActionDoAction): + (webkitAccessibleActionGetNActions): + (webkitAccessibleActionGetDescription): + (webkitAccessibleActionGetKeybinding): + (webkitAccessibleActionGetName): + * accessibility/gtk/WebKitAccessibleInterfaceAction.h: Added. + + * accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove code + related to the implementation of the AtkAction interface. + + Add new files to build files. + + * GNUmakefile.list.am: Add WebKitAccessibleInterfaceAction.[h|cpp]. + * WebCore.gypi: Ditto. + 2012-01-23 Nikolas Zimmermann SVG animation repaint issue with image and dynamic clipPath diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am index ec7be25..01f3a81 100644 --- a/Source/WebCore/GNUmakefile.list.am +++ b/Source/WebCore/GNUmakefile.list.am @@ -4424,6 +4424,8 @@ webcoregtk_sources += \ Source/WebCore/accessibility/gtk/AXObjectCacheAtk.cpp \ Source/WebCore/accessibility/gtk/WebKitAccessibleHyperlink.h \ Source/WebCore/accessibility/gtk/WebKitAccessibleHyperlink.cpp \ + Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.cpp \ + Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.h \ Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp \ Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h \ Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp \ diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi index bfb5c61..e21fbb4 100644 --- a/Source/WebCore/WebCore.gypi +++ b/Source/WebCore/WebCore.gypi @@ -1768,6 +1768,8 @@ 'accessibility/gtk/AccessibilityObjectAtk.cpp', 'accessibility/gtk/WebKitAccessibleHyperlink.cpp', 'accessibility/gtk/WebKitAccessibleHyperlink.h', + 'accessibility/gtk/WebKitAccessibleInterfaceAction.cpp', + 'accessibility/gtk/WebKitAccessibleInterfaceAction.h', 'accessibility/gtk/WebKitAccessibleUtil.cpp', 'accessibility/gtk/WebKitAccessibleUtil.h', 'accessibility/gtk/WebKitAccessibleWrapperAtk.cpp', diff --git a/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.cpp b/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.cpp new file mode 100644 index 0000000..680f713 --- /dev/null +++ b/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.cpp @@ -0,0 +1,87 @@ +/* + * Copyright (C) 2008 Nuanti Ltd. + * Copyright (C) 2009 Jan Alonzo + * Copyright (C) 2012 Igalia S.L. + * + * Portions from Mozilla a11y, copyright as follows: + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is + * Sun Microsystems, Inc. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include "config.h" +#include "WebKitAccessibleInterfaceAction.h" + +#include "AccessibilityObject.h" +#include "NotImplemented.h" +#include "WebKitAccessibleUtil.h" +#include "WebKitAccessibleWrapperAtk.h" + +using namespace WebCore; + +static AccessibilityObject* core(AtkAction* action) +{ + if (!WEBKIT_IS_ACCESSIBLE(action)) + return 0; + + return webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(action)); +} + +void webkitAccessibleActionInterfaceInit(AtkActionIface* iface) +{ + iface->do_action = webkitAccessibleActionDoAction; + iface->get_n_actions = webkitAccessibleActionGetNActions; + iface->get_description = webkitAccessibleActionGetDescription; + iface->get_keybinding = webkitAccessibleActionGetKeybinding; + iface->get_name = webkitAccessibleActionGetName; +} + +gboolean webkitAccessibleActionDoAction(AtkAction* action, gint index) +{ + g_return_val_if_fail(!index, FALSE); + return core(action)->performDefaultAction(); +} + +gint webkitAccessibleActionGetNActions(AtkAction*) +{ + return 1; +} + +const gchar* webkitAccessibleActionGetDescription(AtkAction*, gint) +{ + // TODO: Need a way to provide/localize action descriptions. + notImplemented(); + return ""; +} + +const gchar* webkitAccessibleActionGetKeybinding(AtkAction* action, gint index) +{ + g_return_val_if_fail(!index, 0); + // FIXME: Construct a proper keybinding string. + return returnString(core(action)->accessKey().string()); +} + +const gchar* webkitAccessibleActionGetName(AtkAction* action, gint index) +{ + g_return_val_if_fail(!index, 0); + return returnString(core(action)->actionVerb()); +} diff --git a/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.h b/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.h new file mode 100644 index 0000000..73ca570 --- /dev/null +++ b/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.h @@ -0,0 +1,34 @@ +/* + * Copyright (C) 2008 Nuanti Ltd. + * Copyright (C) 2009 Jan Alonzo + * Copyright (C) 2012 Igalia S.L. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef WebKitAccessibleInterfaceAction_h +#define WebKitAccessibleInterfaceAction_h + +#include + +void webkitAccessibleActionInterfaceInit(AtkActionIface*); +gboolean webkitAccessibleActionDoAction(AtkAction*, gint index); +gint webkitAccessibleActionGetNActions(AtkAction*); +const gchar* webkitAccessibleActionGetDescription(AtkAction*, gint index); +const gchar* webkitAccessibleActionGetKeybinding(AtkAction*, gint index); +const gchar* webkitAccessibleActionGetName(AtkAction*, gint index); + +#endif // WebKitAccessibleInterfaceAction_h diff --git a/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp b/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp index fbc426d..eb83a14 100644 --- a/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp +++ b/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp @@ -63,6 +63,7 @@ #include "TextEncoding.h" #include "TextIterator.h" #include "WebKitAccessibleHyperlink.h" +#include "WebKitAccessibleInterfaceAction.h" #include "WebKitAccessibleUtil.h" #include "htmlediting.h" #include "visible_units.h" @@ -109,11 +110,6 @@ static AccessibilityObject* core(AtkObject* object) return core(WEBKIT_ACCESSIBLE(object)); } -static AccessibilityObject* core(AtkAction* action) -{ - return core(ATK_OBJECT(action)); -} - static AccessibilityObject* core(AtkSelection* selection) { return core(ATK_OBJECT(selection)); @@ -868,47 +864,6 @@ webkit_accessible_get_type(void) return type_volatile; } -static gboolean webkit_accessible_action_do_action(AtkAction* action, gint i) -{ - g_return_val_if_fail(!i, FALSE); - return core(action)->performDefaultAction(); -} - -static gint webkit_accessible_action_get_n_actions(AtkAction* action) -{ - return 1; -} - -static const gchar* webkit_accessible_action_get_description(AtkAction* action, gint i) -{ - g_return_val_if_fail(!i, 0); - // TODO: Need a way to provide/localize action descriptions. - notImplemented(); - return ""; -} - -static const gchar* webkit_accessible_action_get_keybinding(AtkAction* action, gint i) -{ - g_return_val_if_fail(!i, 0); - // FIXME: Construct a proper keybinding string. - return returnString(core(action)->accessKey().string()); -} - -static const gchar* webkit_accessible_action_get_name(AtkAction* action, gint i) -{ - g_return_val_if_fail(!i, 0); - return returnString(core(action)->actionVerb()); -} - -static void atk_action_interface_init(AtkActionIface* iface) -{ - iface->do_action = webkit_accessible_action_do_action; - iface->get_n_actions = webkit_accessible_action_get_n_actions; - iface->get_description = webkit_accessible_action_get_description; - iface->get_keybinding = webkit_accessible_action_get_keybinding; - iface->get_name = webkit_accessible_action_get_name; -} - // Selection (for controls) static AccessibilityObject* listObjectForSelection(AtkSelection* selection) @@ -2484,8 +2439,7 @@ static void atkValueInterfaceInit(AtkValueIface* iface) } static const GInterfaceInfo AtkInterfacesInitFunctions[] = { - {(GInterfaceInitFunc)atk_action_interface_init, - (GInterfaceFinalizeFunc) 0, 0}, + {reinterpret_cast(webkitAccessibleActionInterfaceInit), 0, 0}, {(GInterfaceInitFunc)atk_selection_interface_init, (GInterfaceFinalizeFunc) 0, 0}, {(GInterfaceInitFunc)atk_editable_text_interface_init, -- 2.7.4