diff options
author | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-06 15:25:00 +0000 |
---|---|---|
committer | dmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-06 15:25:00 +0000 |
commit | 075d97d34cd147da28f536c5d4e4b6bea1bfef43 (patch) | |
tree | 72d594b1681035d0efd34b6c854ee77dcd2cb6b2 /ui/gfx | |
parent | 0944741242d9ed32323b06a8026a62b89de2a9bf (diff) | |
download | chromium_src-075d97d34cd147da28f536c5d4e4b6bea1bfef43.zip chromium_src-075d97d34cd147da28f536c5d4e4b6bea1bfef43.tar.gz chromium_src-075d97d34cd147da28f536c5d4e4b6bea1bfef43.tar.bz2 |
Add initial GTK web accessibility framework (new with valgrind fix).
This is the same as http://codereview.chromium.org/9839069/ which was
landed but reverted due to a valgrind failure in content_unittests.
The valgrind failure was because browser_accessibility_manager_unittest.cc
is constructing its own subclass of BrowserAccessibility (for testing),
but BrowserAccessibilityManagerGtk was assuming that any BrowserAccessibility
could be static_casted to a BrowserAccessibilityGtk. I fixed this by
making ToBrowserAccessibilityGtk() a virtual method with a default impl that
returns NULL.
Original change:
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.
TBR=darin,sky
Review URL: https://chromiumcodereview.appspot.com/10381010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135593 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/gfx')
-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_ |