Diff
Modified: trunk/Source/WebCore/ChangeLog (105715 => 105716)
--- trunk/Source/WebCore/ChangeLog 2012-01-24 10:51:11 UTC (rev 105715)
+++ trunk/Source/WebCore/ChangeLog 2012-01-24 11:03:51 UTC (rev 105716)
@@ -1,3 +1,37 @@
+2012-01-24 Mario Sanchez Prada <[email protected]>
+
+ [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 AtkComponent interface,
+ containing the related code from WebKitAccessibleWrapperAtk.cpp.
+
+ * accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp: Added.
+ (core):
+ (atkToContents):
+ (webkitAccessibleComponentInterfaceInit):
+ (webkitAccessibleComponentRefAccessibleAtPoint):
+ (webkitAccessibleComponentGetExtents):
+ (webkitAccessibleComponentGrabFocus):
+ * accessibility/gtk/WebKitAccessibleInterfaceComponent.h: Added.
+
+ Move common function contentsToAtk() out from the wrapper to the
+ utility file, used from WebKitAccessibleInterfaceComponent.cpp.
+
+ * accessibility/gtk/WebKitAccessibleUtil.cpp:
+ (contentsRelativeToAtkCoordinateType): Taken from WebKitAccessibleWrapperAtk.cpp.
+ * accessibility/gtk/WebKitAccessibleUtil.h:
+ * accessibility/gtk/WebKitAccessibleWrapperAtk.cpp: Remove local
+ implementation of contentsToAtk, as well as all the code related
+ to the implementation of the AtkComponent interface.
+
+ Add new files to build files.
+
+ * GNUmakefile.list.am: Add WebKitAccessibleInterfaceComponent.[h|cpp].
+ * WebCore.gypi: Ditto.
+
2012-01-24 Kentaro Hara <[email protected]>
[Refactoring] Makes finish() of CodeGeneratorV8.pm empty
Modified: trunk/Source/WebCore/GNUmakefile.list.am (105715 => 105716)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-01-24 10:51:11 UTC (rev 105715)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-01-24 11:03:51 UTC (rev 105716)
@@ -4423,6 +4423,8 @@
Source/WebCore/accessibility/gtk/WebKitAccessibleHyperlink.cpp \
Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.cpp \
Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceAction.h \
+ Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp \
+ Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.h \
Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp \
Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h \
Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp \
Modified: trunk/Source/WebCore/WebCore.gypi (105715 => 105716)
--- trunk/Source/WebCore/WebCore.gypi 2012-01-24 10:51:11 UTC (rev 105715)
+++ trunk/Source/WebCore/WebCore.gypi 2012-01-24 11:03:51 UTC (rev 105716)
@@ -1347,6 +1347,8 @@
'accessibility/gtk/WebKitAccessibleHyperlink.h',
'accessibility/gtk/WebKitAccessibleInterfaceAction.cpp',
'accessibility/gtk/WebKitAccessibleInterfaceAction.h',
+ 'accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp',
+ 'accessibility/gtk/WebKitAccessibleInterfaceComponent.h',
'accessibility/gtk/WebKitAccessibleUtil.cpp',
'accessibility/gtk/WebKitAccessibleUtil.h',
'accessibility/gtk/WebKitAccessibleWrapperAtk.cpp',
Added: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp (0 => 105716)
--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp (rev 0)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.cpp 2012-01-24 11:03:51 UTC (rev 105716)
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2008 Nuanti Ltd.
+ * Copyright (C) 2009 Jan Alonzo
+ * Copyright (C) 2009, 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 "WebKitAccessibleInterfaceComponent.h"
+
+#include "AccessibilityObject.h"
+#include "FrameView.h"
+#include "IntRect.h"
+#include "WebKitAccessibleUtil.h"
+#include "WebKitAccessibleWrapperAtk.h"
+
+using namespace WebCore;
+
+static AccessibilityObject* core(AtkComponent* component)
+{
+ if (!WEBKIT_IS_ACCESSIBLE(component))
+ return 0;
+
+ return webkitAccessibleGetAccessibilityObject(WEBKIT_ACCESSIBLE(component));
+}
+
+static IntPoint atkToContents(AccessibilityObject* coreObject, AtkCoordType coordType, gint x, gint y)
+{
+ IntPoint pos(x, y);
+
+ FrameView* frameView = coreObject->documentFrameView();
+ if (frameView) {
+ switch (coordType) {
+ case ATK_XY_SCREEN:
+ return frameView->screenToContents(pos);
+ case ATK_XY_WINDOW:
+ return frameView->windowToContents(pos);
+ }
+ }
+
+ return pos;
+}
+
+void webkitAccessibleComponentInterfaceInit(AtkComponentIface* iface)
+{
+ iface->ref_accessible_at_point = webkitAccessibleComponentRefAccessibleAtPoint;
+ iface->get_extents = webkitAccessibleComponentGetExtents;
+ iface->grab_focus = webkitAccessibleComponentGrabFocus;
+}
+
+AtkObject* webkitAccessibleComponentRefAccessibleAtPoint(AtkComponent* component, gint x, gint y, AtkCoordType coordType)
+{
+ IntPoint pos = atkToContents(core(component), coordType, x, y);
+
+ AccessibilityObject* target = core(component)->accessibilityHitTest(pos);
+ if (!target)
+ return 0;
+ g_object_ref(target->wrapper());
+ return target->wrapper();
+}
+
+void webkitAccessibleComponentGetExtents(AtkComponent* component, gint* x, gint* y, gint* width, gint* height, AtkCoordType coordType)
+{
+ IntRect rect = core(component)->elementRect();
+ contentsRelativeToAtkCoordinateType(core(component), coordType, rect, x, y, width, height);
+}
+
+gboolean webkitAccessibleComponentGrabFocus(AtkComponent* component)
+{
+ core(component)->setFocused(true);
+ return core(component)->isFocused();
+}
Copied: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.h (from rev 105715, trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h) (0 => 105716)
--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.h (rev 0)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleInterfaceComponent.h 2012-01-24 11:03:51 UTC (rev 105716)
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2008 Nuanti Ltd.
+ * Copyright (C) 2009 Jan Alonzo
+ * Copyright (C) 2009, 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 WebKitAccessibleInterfaceComponent_h
+#define WebKitAccessibleInterfaceComponent_h
+
+#include <atk/atk.h>
+
+void webkitAccessibleComponentInterfaceInit(AtkComponentIface*);
+AtkObject* webkitAccessibleComponentRefAccessibleAtPoint(AtkComponent*, gint x, gint y, AtkCoordType);
+void webkitAccessibleComponentGetExtents(AtkComponent*, gint* x, gint* y, gint* width, gint* height, AtkCoordType);
+gboolean webkitAccessibleComponentGrabFocus(AtkComponent*);
+
+#endif // WebKitAccessibleInterfaceComponent_h
Modified: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp (105715 => 105716)
--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp 2012-01-24 10:51:11 UTC (rev 105715)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.cpp 2012-01-24 11:03:51 UTC (rev 105716)
@@ -31,9 +31,40 @@
#include "config.h"
#include "WebKitAccessibleUtil.h"
+#include "AccessibilityObject.h"
+#include "FrameView.h"
+#include "IntRect.h"
+
#include <wtf/text/AtomicString.h>
#include <wtf/text/CString.h>
+using namespace WebCore;
+
+void contentsRelativeToAtkCoordinateType(AccessibilityObject* coreObject, AtkCoordType coordType, IntRect rect, gint* x, gint* y, gint* width, gint* height)
+{
+ FrameView* frameView = coreObject->documentFrameView();
+
+ if (frameView) {
+ switch (coordType) {
+ case ATK_XY_WINDOW:
+ rect = frameView->contentsToWindow(rect);
+ break;
+ case ATK_XY_SCREEN:
+ rect = frameView->contentsToScreen(rect);
+ break;
+ }
+ }
+
+ if (x)
+ *x = rect.x();
+ if (y)
+ *y = rect.y();
+ if (width)
+ *width = rect.width();
+ if (height)
+ *height = rect.height();
+}
+
// Used to provide const char* returns.
const char* returnString(const String& str)
{
Modified: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h (105715 => 105716)
--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h 2012-01-24 10:51:11 UTC (rev 105715)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleUtil.h 2012-01-24 11:03:51 UTC (rev 105716)
@@ -22,9 +22,16 @@
#ifndef WebKitAccessibleUtil_h
#define WebKitAccessibleUtil_h
+#include <atk/atk.h>
#include <wtf/text/WTFString.h>
-// Returns a const char* pointing to a statically allocated string.
+namespace WebCore {
+class AccessibilityObject;
+class IntRect;
+}
+
+void contentsRelativeToAtkCoordinateType(WebCore::AccessibilityObject*, AtkCoordType, WebCore::IntRect, gint* x, gint* y, gint* width = 0, gint* height = 0);
+
const char* returnString(const String&);
#endif // WebKitAccessibleUtil_h
Modified: trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp (105715 => 105716)
--- trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp 2012-01-24 10:51:11 UTC (rev 105715)
+++ trunk/Source/WebCore/accessibility/gtk/WebKitAccessibleWrapperAtk.cpp 2012-01-24 11:03:51 UTC (rev 105716)
@@ -64,6 +64,7 @@
#include "TextIterator.h"
#include "WebKitAccessibleHyperlink.h"
#include "WebKitAccessibleInterfaceAction.h"
+#include "WebKitAccessibleInterfaceComponent.h"
#include "WebKitAccessibleUtil.h"
#include "htmlediting.h"
#include "visible_units.h"
@@ -125,11 +126,6 @@
return core(ATK_OBJECT(text));
}
-static AccessibilityObject* core(AtkComponent* component)
-{
- return core(ATK_OBJECT(component));
-}
-
static AccessibilityObject* core(AtkImage* image)
{
return core(ATK_OBJECT(image));
@@ -1940,84 +1936,12 @@
iface->paste_text = webkit_accessible_editable_text_paste_text;
}
-static void contentsToAtk(AccessibilityObject* coreObject, AtkCoordType coordType, IntRect rect, gint* x, gint* y, gint* width = 0, gint* height = 0)
-{
- FrameView* frameView = coreObject->documentFrameView();
-
- if (frameView) {
- switch (coordType) {
- case ATK_XY_WINDOW:
- rect = frameView->contentsToWindow(rect);
- break;
- case ATK_XY_SCREEN:
- rect = frameView->contentsToScreen(rect);
- break;
- }
- }
-
- if (x)
- *x = rect.x();
- if (y)
- *y = rect.y();
- if (width)
- *width = rect.width();
- if (height)
- *height = rect.height();
-}
-
-static IntPoint atkToContents(AccessibilityObject* coreObject, AtkCoordType coordType, gint x, gint y)
-{
- IntPoint pos(x, y);
-
- FrameView* frameView = coreObject->documentFrameView();
- if (frameView) {
- switch (coordType) {
- case ATK_XY_SCREEN:
- return frameView->screenToContents(pos);
- case ATK_XY_WINDOW:
- return frameView->windowToContents(pos);
- }
- }
-
- return pos;
-}
-
-static AtkObject* webkit_accessible_component_ref_accessible_at_point(AtkComponent* component, gint x, gint y, AtkCoordType coordType)
-{
- IntPoint pos = atkToContents(core(component), coordType, x, y);
-
- AccessibilityObject* target = core(component)->accessibilityHitTest(pos);
- if (!target)
- return 0;
- g_object_ref(target->wrapper());
- return target->wrapper();
-}
-
-static void webkit_accessible_component_get_extents(AtkComponent* component, gint* x, gint* y, gint* width, gint* height, AtkCoordType coordType)
-{
- IntRect rect = core(component)->elementRect();
- contentsToAtk(core(component), coordType, rect, x, y, width, height);
-}
-
-static gboolean webkit_accessible_component_grab_focus(AtkComponent* component)
-{
- core(component)->setFocused(true);
- return core(component)->isFocused();
-}
-
-static void atk_component_interface_init(AtkComponentIface* iface)
-{
- iface->ref_accessible_at_point = webkit_accessible_component_ref_accessible_at_point;
- iface->get_extents = webkit_accessible_component_get_extents;
- iface->grab_focus = webkit_accessible_component_grab_focus;
-}
-
// Image
static void webkit_accessible_image_get_image_position(AtkImage* image, gint* x, gint* y, AtkCoordType coordType)
{
IntRect rect = core(image)->elementRect();
- contentsToAtk(core(image), coordType, rect, x, y);
+ contentsRelativeToAtkCoordinateType(core(image), coordType, rect, x, y);
}
static const gchar* webkit_accessible_image_get_image_description(AtkImage* image)
@@ -2446,8 +2370,7 @@
(GInterfaceFinalizeFunc) 0, 0},
{(GInterfaceInitFunc)atk_text_interface_init,
(GInterfaceFinalizeFunc) 0, 0},
- {(GInterfaceInitFunc)atk_component_interface_init,
- (GInterfaceFinalizeFunc) 0, 0},
+ {reinterpret_cast<GInterfaceInitFunc>(webkitAccessibleComponentInterfaceInit), 0, 0},
{(GInterfaceInitFunc)atk_image_interface_init,
(GInterfaceFinalizeFunc) 0, 0},
{(GInterfaceInitFunc)atk_table_interface_init,