diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 07:05:20 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-09 07:05:20 +0000 |
commit | cd3e2d90d3030ad3e271098b15d2f60db13ba09a (patch) | |
tree | d3333f31da08d07237d6a1f1f66fd14fc2fdec55 /ui | |
parent | 45056077ba7064c4b539d95111d0f62b3755deb3 (diff) | |
download | chromium_src-cd3e2d90d3030ad3e271098b15d2f60db13ba09a.zip chromium_src-cd3e2d90d3030ad3e271098b15d2f60db13ba09a.tar.gz chromium_src-cd3e2d90d3030ad3e271098b15d2f60db13ba09a.tar.bz2 |
Add initial GTK web accessibility framework (third attempt).
Previous attempts to land this patch:
1. http://codereview.chromium.org/9839069/
2. http://codereview.chromium.org/10382013/
The previous attempts failed to land due to test failures and problems
depending on libatk with the official Linux build. The build is now resolved,
and the test failures have been fixed by adding an IsNative method to
BrowserAccessibility. Please look carefully at the IsNative calls in the
code; the rest is the same.
Original description:
This enables Linux desktop assistive technology such as the Orca screen
reader to access the web contents. Builds on the same accessibility stack
used by Mac & Windows already.
This change works with Orca now, but it's minimal: all that works is getting
the correct feedback when you tab through focusable links and controls in
a webpage. Future changes will add the rest of the support.
BUG=24585
TEST=Run Chrome on desktop Linux with Orca turned on, tab through links.
Review URL: https://chromiumcodereview.appspot.com/10382051
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135998 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui')
-rw-r--r-- | ui/gfx/gtk_preserve_window.cc | 27 | ||||
-rw-r--r-- | ui/gfx/gtk_preserve_window.h | 11 |
2 files changed, 37 insertions, 1 deletions
diff --git a/ui/gfx/gtk_preserve_window.cc b/ui/gfx/gtk_preserve_window.cc index da09570..8ea1c43 100644 --- a/ui/gfx/gtk_preserve_window.cc +++ b/ui/gfx/gtk_preserve_window.cc @@ -24,6 +24,10 @@ struct _GtkPreserveWindowPrivate { // Whether or not we delegate the resize of the GdkWindow // to someone else. gboolean delegate_resize; + + // Accessible factory and userdata. + AtkObject* (*accessible_factory)(void* userdata); + void* accessible_factory_userdata; }; G_DEFINE_TYPE(GtkPreserveWindow, gtk_preserve_window, GTK_TYPE_FIXED) @@ -33,12 +37,14 @@ static void gtk_preserve_window_realize(GtkWidget* widget); static void gtk_preserve_window_unrealize(GtkWidget* widget); static void gtk_preserve_window_size_allocate(GtkWidget* widget, GtkAllocation* allocation); +static AtkObject* gtk_preserve_window_get_accessible(GtkWidget* widget); static void gtk_preserve_window_class_init(GtkPreserveWindowClass *klass) { GtkWidgetClass* widget_class = reinterpret_cast<GtkWidgetClass*>(klass); widget_class->realize = gtk_preserve_window_realize; widget_class->unrealize = gtk_preserve_window_unrealize; widget_class->size_allocate = gtk_preserve_window_size_allocate; + widget_class->get_accessible = gtk_preserve_window_get_accessible; GtkObjectClass* object_class = reinterpret_cast<GtkObjectClass*>(klass); object_class->destroy = gtk_preserve_window_destroy; @@ -50,6 +56,8 @@ static void gtk_preserve_window_class_init(GtkPreserveWindowClass *klass) { static void gtk_preserve_window_init(GtkPreserveWindow* widget) { GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); priv->preserve_window = FALSE; + priv->accessible_factory = NULL; + priv->accessible_factory_userdata = NULL; // These widgets always have their own window. gtk_widget_set_has_window(GTK_WIDGET(widget), TRUE); @@ -234,4 +242,23 @@ void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, priv->delegate_resize = delegate; } +void gtk_preserve_window_set_accessible_factory( + GtkPreserveWindow* widget, + AtkObject* (*factory)(void* userdata), + gpointer userdata) { + GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); + priv->accessible_factory = factory; + priv->accessible_factory_userdata = userdata; +} + +AtkObject* gtk_preserve_window_get_accessible(GtkWidget* widget) { + GtkPreserveWindowPrivate* priv = GTK_PRESERVE_WINDOW_GET_PRIVATE(widget); + if (priv->accessible_factory) { + return priv->accessible_factory(priv->accessible_factory_userdata); + } else { + return GTK_WIDGET_CLASS(gtk_preserve_window_parent_class) + ->get_accessible(widget); + } +} + G_END_DECLS diff --git a/ui/gfx/gtk_preserve_window.h b/ui/gfx/gtk_preserve_window.h index 37657b3..0af5d7a 100644 --- a/ui/gfx/gtk_preserve_window.h +++ b/ui/gfx/gtk_preserve_window.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,6 +6,7 @@ #define UI_GFX_GTK_PRESERVE_WINDOW_H_ #pragma once +#include <atk/atk.h> #include <gdk/gdk.h> #include <gtk/gtk.h> @@ -61,6 +62,14 @@ void gtk_preserve_window_set_preserve(GtkPreserveWindow* widget, UI_EXPORT void gtk_preserve_window_delegate_resize(GtkPreserveWindow* widget, gboolean delegate); +// Provide a function to return an AtkObject* when calls to get_accessible +// are made on this widget. The parameter |userdata| will be passed to the +// factory function. +void gtk_preserve_window_set_accessible_factory( + GtkPreserveWindow* widget, + AtkObject* (*factory)(void* userdata), + gpointer userdata); + G_END_DECLS #endif // UI_GFX_GTK_PRESERVE_WINDOW_H_ |