diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 23:28:26 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-05-02 23:28:26 +0000 |
commit | 3afdea6a3782f47a7aec4e6a5d3048fd84db42da (patch) | |
tree | 0a93910df5129533908141b8d5dedf26f1bbb120 /content/browser/accessibility | |
parent | 28a0c07009e60fadc9cf454e782c583cf5621627 (diff) | |
download | chromium_src-3afdea6a3782f47a7aec4e6a5d3048fd84db42da.zip chromium_src-3afdea6a3782f47a7aec4e6a5d3048fd84db42da.tar.gz chromium_src-3afdea6a3782f47a7aec4e6a5d3048fd84db42da.tar.bz2 |
Revert 135020 - Add initial GTK web accessibility framework.
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
Review URL: http://codereview.chromium.org/9839069
TBR=dmazzoni@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10316010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@135027 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/accessibility')
17 files changed, 55 insertions, 604 deletions
diff --git a/content/browser/accessibility/browser_accessibility.cc b/content/browser/accessibility/browser_accessibility.cc index 7705e55..4f81569 100644 --- a/content/browser/accessibility/browser_accessibility.cc +++ b/content/browser/accessibility/browser_accessibility.cc @@ -15,9 +15,9 @@ typedef WebAccessibility::FloatAttribute FloatAttribute; typedef WebAccessibility::IntAttribute IntAttribute; typedef WebAccessibility::StringAttribute StringAttribute; -#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOOLKIT_GTK) -// We have implementations of BrowserAccessibility on Win, Mac, -// and GTK. If we have anything else, just instantiate the base class. +#if (defined(OS_POSIX) && !defined(OS_MACOSX)) || defined(USE_AURA) +// There's no OS-specific implementation of BrowserAccessibilityManager +// on Unix, so just instantiate the base class. // static BrowserAccessibility* BrowserAccessibility::Create() { return new BrowserAccessibility(); diff --git a/content/browser/accessibility/browser_accessibility.h b/content/browser/accessibility/browser_accessibility.h index 4bd703b..0fbb3eb 100644 --- a/content/browser/accessibility/browser_accessibility.h +++ b/content/browser/accessibility/browser_accessibility.h @@ -20,8 +20,6 @@ class BrowserAccessibilityManager; @class BrowserAccessibilityCocoa; #elif defined(OS_WIN) class BrowserAccessibilityWin; -#elif defined(TOOLKIT_GTK) -class BrowserAccessibilityGtk; #endif using webkit_glue::WebAccessibility; @@ -190,11 +188,9 @@ class CONTENT_EXPORT BrowserAccessibility { int32 ref_count() const { return ref_count_; } #if defined(OS_MACOSX) && __OBJC__ - BrowserAccessibilityCocoa* ToBrowserAccessibilityCocoa(); + BrowserAccessibilityCocoa* toBrowserAccessibilityCocoa(); #elif defined(OS_WIN) - BrowserAccessibilityWin* ToBrowserAccessibilityWin(); -#elif defined(TOOLKIT_GTK) - BrowserAccessibilityGtk* ToBrowserAccessibilityGtk(); + BrowserAccessibilityWin* toBrowserAccessibilityWin(); #endif // Retrieve the value of a bool attribute from the bool attribute diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm index edc0cbb..b282cad 100644 --- a/content/browser/accessibility/browser_accessibility_cocoa.mm +++ b/content/browser/accessibility/browser_accessibility_cocoa.mm @@ -343,7 +343,7 @@ NSDictionary* attributeToMethodNameMap = nil; index < browserAccessibility_->child_count(); ++index) { BrowserAccessibilityCocoa* child = - browserAccessibility_->GetChild(index)->ToBrowserAccessibilityCocoa(); + browserAccessibility_->GetChild(index)->toBrowserAccessibilityCocoa(); if ([child isIgnored]) [children_ addObjectsFromArray:[child children]]; else @@ -362,7 +362,7 @@ NSDictionary* attributeToMethodNameMap = nil; // a DCHECK in the future. if (child) { BrowserAccessibilityCocoa* child_cocoa = - child->ToBrowserAccessibilityCocoa(); + child->toBrowserAccessibilityCocoa(); [children_ addObject:child_cocoa]; } } @@ -374,7 +374,7 @@ NSDictionary* attributeToMethodNameMap = nil; if (![self isIgnored]) { children_.reset(); } else { - [browserAccessibility_->parent()->ToBrowserAccessibilityCocoa() + [browserAccessibility_->parent()->toBrowserAccessibilityCocoa() childrenChanged]; } } @@ -488,7 +488,7 @@ NSDictionary* attributeToMethodNameMap = nil; // A nil parent means we're the root. if (browserAccessibility_->parent()) { return NSAccessibilityUnignoredAncestor( - browserAccessibility_->parent()->ToBrowserAccessibilityCocoa()); + browserAccessibility_->parent()->toBrowserAccessibilityCocoa()); } else { // Hook back up to RenderWidgetHostViewCocoa. return browserAccessibility_->manager()->GetParentView(); @@ -632,7 +632,7 @@ NSDictionary* attributeToMethodNameMap = nil; BrowserAccessibility* titleElement = browserAccessibility_->manager()->GetFromRendererID(titleElementId); if (titleElement) - return titleElement->ToBrowserAccessibilityCocoa(); + return titleElement->toBrowserAccessibilityCocoa(); } return nil; } diff --git a/content/browser/accessibility/browser_accessibility_gtk.cc b/content/browser/accessibility/browser_accessibility_gtk.cc deleted file mode 100644 index cb94b00..0000000 --- a/content/browser/accessibility/browser_accessibility_gtk.cc +++ /dev/null @@ -1,343 +0,0 @@ -// 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. - -#include "content/browser/accessibility/browser_accessibility_gtk.h" - -#include "base/utf_string_conversions.h" -#include "content/browser/accessibility/browser_accessibility_manager_gtk.h" -#include "content/common/accessibility_messages.h" - -#include <gtk/gtk.h> - -using webkit_glue::WebAccessibility; - -// The maximum length of an autogenerated unique type name string, -// generated from the 16-bit interface mask from an AtkObject. -// 30 is enough for the prefix "WAIType" + 5 hex chars (max) */ -static const int kWAITypeNameLen = 30; - -static gpointer browser_accessibility_parent_class = NULL; - -static BrowserAccessibilityGtk* ToBrowserAccessibilityGtk( - BrowserAccessibilityAtk* atk_object) { - if (!atk_object) - return NULL; - - return atk_object->m_object; -} - -static BrowserAccessibilityGtk* ToBrowserAccessibilityGtk( - AtkObject* atk_object) { - if (!IS_BROWSER_ACCESSIBILITY(atk_object)) - return NULL; - - return ToBrowserAccessibilityGtk(BROWSER_ACCESSIBILITY(atk_object)); -} - -static const gchar* browser_accessibility_get_name(AtkObject* atk_object) { - BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); - return obj->atk_acc_name().c_str(); -} - -static const gchar* browser_accessibility_get_description( - AtkObject* atk_object) { - BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); - string16 description; - obj->GetStringAttribute(WebAccessibility::ATTR_DESCRIPTION, &description); - return UTF16ToUTF8(description).c_str(); -} - -static AtkObject* browser_accessibility_get_parent(AtkObject* atk_object) { - BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); - if (obj->parent()) - return obj->parent()->ToBrowserAccessibilityGtk()->GetAtkObject(); - else - return gtk_widget_get_accessible(obj->manager()->GetParentView()); -} - -static gint browser_accessibility_get_n_children(AtkObject* atk_object) { - BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); - return obj->children().size(); -} - -static AtkObject* browser_accessibility_ref_child( - AtkObject* atk_object, gint index) { - BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); - AtkObject* result = - obj->children()[index]->ToBrowserAccessibilityGtk()->GetAtkObject(); - g_object_ref(result); - return result; -} - -static gint browser_accessibility_get_index_in_parent(AtkObject* atk_object) { - BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); - return obj->index_in_parent(); -} - -static AtkAttributeSet* browser_accessibility_get_attributes( - AtkObject* atk_object) { - return NULL; -} - -static AtkRole browser_accessibility_get_role(AtkObject* atk_object) { - BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); - return obj->atk_role(); -} - -static AtkStateSet* browser_accessibility_ref_state_set(AtkObject* atk_object) { - BrowserAccessibilityGtk* obj = ToBrowserAccessibilityGtk(atk_object); - AtkStateSet* state_set = - ATK_OBJECT_CLASS(browser_accessibility_parent_class)-> - ref_state_set(atk_object); - int32 state = obj->state(); - - if ((state >> WebAccessibility::STATE_FOCUSABLE) & 1) - atk_state_set_add_state(state_set, ATK_STATE_FOCUSABLE); - if (obj->manager()->GetFocus(NULL) == obj) - atk_state_set_add_state(state_set, ATK_STATE_FOCUSED); - - return state_set; -} - -static AtkRelationSet* browser_accessibility_ref_relation_set( - AtkObject* atk_object) { - AtkRelationSet* relation_set = - ATK_OBJECT_CLASS(browser_accessibility_parent_class) - ->ref_relation_set(atk_object); - return relation_set; -} - -static void browser_accessibility_init(AtkObject* atk_object, gpointer data) { - if (ATK_OBJECT_CLASS(browser_accessibility_parent_class)->initialize) { - ATK_OBJECT_CLASS(browser_accessibility_parent_class)->initialize( - atk_object, data); - } - - BROWSER_ACCESSIBILITY(atk_object)->m_object = - reinterpret_cast<BrowserAccessibilityGtk*>(data); -} - -static void browser_accessibility_finalize(GObject* atk_object) { - G_OBJECT_CLASS(browser_accessibility_parent_class)->finalize(atk_object); -} - -static void browser_accessibility_class_init(AtkObjectClass* klass) { - GObjectClass* gobject_class = G_OBJECT_CLASS(klass); - browser_accessibility_parent_class = g_type_class_peek_parent(klass); - - gobject_class->finalize = browser_accessibility_finalize; - klass->initialize = browser_accessibility_init; - klass->get_name = browser_accessibility_get_name; - klass->get_description = browser_accessibility_get_description; - klass->get_parent = browser_accessibility_get_parent; - klass->get_n_children = browser_accessibility_get_n_children; - klass->ref_child = browser_accessibility_ref_child; - klass->get_role = browser_accessibility_get_role; - klass->ref_state_set = browser_accessibility_ref_state_set; - klass->get_index_in_parent = browser_accessibility_get_index_in_parent; - klass->get_attributes = browser_accessibility_get_attributes; - klass->ref_relation_set = browser_accessibility_ref_relation_set; -} - -GType browser_accessibility_get_type() { - static volatile gsize type_volatile = 0; - - if (g_once_init_enter(&type_volatile)) { - static const GTypeInfo tinfo = { - sizeof(BrowserAccessibilityAtkClass), - (GBaseInitFunc) 0, - (GBaseFinalizeFunc) 0, - (GClassInitFunc) browser_accessibility_class_init, - (GClassFinalizeFunc) 0, - 0, /* class data */ - sizeof(BrowserAccessibilityAtk), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) 0, - 0 /* value table */ - }; - - GType type = g_type_register_static( - ATK_TYPE_OBJECT, "BrowserAccessibility", &tinfo, GTypeFlags(0)); - g_once_init_leave(&type_volatile, type); - } - - return type_volatile; -} - -static guint16 GetInterfaceMaskFromObject(BrowserAccessibilityGtk* obj) { - return 0; -} - -static const char* GetUniqueAccessibilityTypeName(guint16 interface_mask) -{ - static char name[kWAITypeNameLen + 1]; - - sprintf(name, "WAIType%x", interface_mask); - name[kWAITypeNameLen] = '\0'; - - return name; -} - -static const GInterfaceInfo AtkInterfacesInitFunctions[] = { -}; - -enum WAIType { - WAI_ACTION, - WAI_SELECTION, - WAI_EDITABLE_TEXT, - WAI_TEXT, - WAI_COMPONENT, - WAI_IMAGE, - WAI_TABLE, - WAI_HYPERTEXT, - WAI_HYPERLINK, - WAI_DOCUMENT, - WAI_VALUE, -}; - -static GType GetAtkInterfaceTypeFromWAIType(WAIType type) { - switch (type) { - case WAI_ACTION: - return ATK_TYPE_ACTION; - case WAI_SELECTION: - return ATK_TYPE_SELECTION; - case WAI_EDITABLE_TEXT: - return ATK_TYPE_EDITABLE_TEXT; - case WAI_TEXT: - return ATK_TYPE_TEXT; - case WAI_COMPONENT: - return ATK_TYPE_COMPONENT; - case WAI_IMAGE: - return ATK_TYPE_IMAGE; - case WAI_TABLE: - return ATK_TYPE_TABLE; - case WAI_HYPERTEXT: - return ATK_TYPE_HYPERTEXT; - case WAI_HYPERLINK: - return ATK_TYPE_HYPERLINK_IMPL; - case WAI_DOCUMENT: - return ATK_TYPE_DOCUMENT; - case WAI_VALUE: - return ATK_TYPE_VALUE; - } - - return G_TYPE_INVALID; -} - -static GType GetAccessibilityTypeFromObject(BrowserAccessibilityGtk* obj) { - static const GTypeInfo type_info = { - sizeof(BrowserAccessibilityAtkClass), - (GBaseInitFunc) 0, - (GBaseFinalizeFunc) 0, - (GClassInitFunc) 0, - (GClassFinalizeFunc) 0, - 0, /* class data */ - sizeof(BrowserAccessibilityAtk), /* instance size */ - 0, /* nb preallocs */ - (GInstanceInitFunc) 0, - 0 /* value table */ - }; - - guint16 interface_mask = GetInterfaceMaskFromObject(obj); - const char* atk_type_name = GetUniqueAccessibilityTypeName(interface_mask); - GType type = g_type_from_name(atk_type_name); - if (type) - return type; - - type = g_type_register_static(BROWSER_ACCESSIBILITY_TYPE, - atk_type_name, - &type_info, - GTypeFlags(0)); - for (guint i = 0; i < G_N_ELEMENTS(AtkInterfacesInitFunctions); i++) { - if (interface_mask & (1 << i)) { - g_type_add_interface_static( - type, - GetAtkInterfaceTypeFromWAIType(static_cast<WAIType>(i)), - &AtkInterfacesInitFunctions[i]); - } - } - - return type; -} - -BrowserAccessibilityAtk* browser_accessibility_new( - BrowserAccessibilityGtk* obj) { - GType type = GetAccessibilityTypeFromObject(obj); - AtkObject* atk_object = static_cast<AtkObject*>(g_object_new(type, 0)); - - atk_object_initialize(atk_object, obj); - - return BROWSER_ACCESSIBILITY(atk_object); -} - -void browser_accessibility_detach(BrowserAccessibilityAtk* atk_object) { -} - -// static -BrowserAccessibility* BrowserAccessibility::Create() { - return new BrowserAccessibilityGtk(); -} - -BrowserAccessibilityGtk* BrowserAccessibility::ToBrowserAccessibilityGtk() { - return static_cast<BrowserAccessibilityGtk*>(this); -} - -BrowserAccessibilityGtk::BrowserAccessibilityGtk() { - atk_object_ = ATK_OBJECT(browser_accessibility_new(this)); -} - -BrowserAccessibilityGtk::~BrowserAccessibilityGtk() { - browser_accessibility_detach(BROWSER_ACCESSIBILITY(atk_object_)); -} - -AtkObject* BrowserAccessibilityGtk::GetAtkObject() const { - if (!G_IS_OBJECT(atk_object_)) - return NULL; - return atk_object_; -} - -void BrowserAccessibilityGtk::PreInitialize() { - BrowserAccessibility::PreInitialize(); - InitRoleAndState(); - - if (this->parent()) { - atk_object_set_parent( - atk_object_, - this->parent()->ToBrowserAccessibilityGtk()->GetAtkObject()); - } -} - -void BrowserAccessibilityGtk::InitRoleAndState() { - atk_acc_name_ = UTF16ToUTF8(name()).c_str(); - - switch(role_) { - case WebAccessibility::ROLE_BUTTON: - atk_role_ = ATK_ROLE_PUSH_BUTTON; - break; - case WebAccessibility::ROLE_CHECKBOX: - atk_role_ = ATK_ROLE_CHECK_BOX; - break; - case WebAccessibility::ROLE_COMBO_BOX: - atk_role_ = ATK_ROLE_COMBO_BOX; - break; - case WebAccessibility::ROLE_LINK: - atk_role_ = ATK_ROLE_LINK; - break; - case WebAccessibility::ROLE_RADIO_BUTTON: - atk_role_ = ATK_ROLE_RADIO_BUTTON; - break; - case WebAccessibility::ROLE_TEXTAREA: - atk_role_ = ATK_ROLE_ENTRY; - break; - case WebAccessibility::ROLE_TEXT_FIELD: - atk_role_ = ATK_ROLE_ENTRY; - break; - case WebAccessibility::ROLE_WEBCORE_LINK: - atk_role_ = ATK_ROLE_LINK; - break; - default: - atk_role_ = ATK_ROLE_UNKNOWN; - break; - } -} diff --git a/content/browser/accessibility/browser_accessibility_gtk.h b/content/browser/accessibility/browser_accessibility_gtk.h deleted file mode 100644 index 13b1058..0000000 --- a/content/browser/accessibility/browser_accessibility_gtk.h +++ /dev/null @@ -1,92 +0,0 @@ -// 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. - -#ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_GTK_H_ -#define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_GTK_H_ -#pragma once - -#include "base/compiler_specific.h" -#include "content/browser/accessibility/browser_accessibility.h" -#include "webkit/glue/webaccessibility.h" - -#include <atk/atk.h> - -using webkit_glue::WebAccessibility; - -class BrowserAccessibilityGtk; -class BrowserAccessibilityManagerGtk; - -G_BEGIN_DECLS - -#define BROWSER_ACCESSIBILITY_TYPE (browser_accessibility_get_type()) -#define BROWSER_ACCESSIBILITY(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST( \ - (obj), BROWSER_ACCESSIBILITY_TYPE, BrowserAccessibilityAtk)) -#define BROWSER_ACCESSIBILITY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_CAST( \ - (klass), BROWSER_ACCESSIBILITY_TYPE, BrowserAccessibilityAtkClass)) -#define IS_BROWSER_ACCESSIBILITY(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE((obj), BROWSER_ACCESSIBILITY_TYPE)) -#define IS_BROWSER_ACCESSIBILITY_CLASS(klass) \ - (G_TYPE_CHECK_CLASS_TYPE((klass), BROWSER_ACCESSIBILITY_TYPE)) -#define BROWSER_ACCESSIBILITY_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS( \ - (obj), BROWSER_ACCESSIBILITY_TYPE, BrowserAccessibilityAtkClass)) - -typedef struct _BrowserAccessibilityAtk BrowserAccessibilityAtk; -typedef struct _BrowserAccessibilityAtkClass BrowserAccessibilityAtkClass; - -struct _BrowserAccessibilityAtk { - AtkObject parent; - BrowserAccessibilityGtk* m_object; -}; - -struct _BrowserAccessibilityAtkClass { - AtkObjectClass parent_class; -}; - -GType browser_accessibility_get_type (void) G_GNUC_CONST; - -BrowserAccessibilityAtk* browser_accessibility_new( - BrowserAccessibilityGtk* object); - -BrowserAccessibilityGtk* browser_accessibility_get_object( - BrowserAccessibilityAtk* atk_object); - -void browser_accessibility_detach (BrowserAccessibilityAtk* atk_object); - -AtkObject* browser_accessibility_get_focused_element( - BrowserAccessibilityAtk* atk_object); - -G_END_DECLS - -class BrowserAccessibilityGtk : public BrowserAccessibility { - public: - BrowserAccessibilityGtk(); - - virtual ~BrowserAccessibilityGtk(); - - AtkObject* GetAtkObject() const; - - AtkRole atk_role() { return atk_role_; } - const std::string& atk_acc_name() { return atk_acc_name_; } - - // BrowserAccessibility methods. - virtual void PreInitialize() OVERRIDE; - - private: - virtual void InitRoleAndState(); - - // Give BrowserAccessibility::Create access to our constructor. - friend class BrowserAccessibility; - - AtkObject* atk_object_; - AtkRole atk_role_; - std::string atk_acc_name_; - - private: - DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityGtk); -}; - -#endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_GTK_H_ diff --git a/content/browser/accessibility/browser_accessibility_mac.mm b/content/browser/accessibility/browser_accessibility_mac.mm index aa0c9d7..6a209d8 100644 --- a/content/browser/accessibility/browser_accessibility_mac.mm +++ b/content/browser/accessibility/browser_accessibility_mac.mm @@ -53,7 +53,7 @@ void BrowserAccessibilityMac::DetachTree( BrowserAccessibility::DetachTree(nodes); } -BrowserAccessibilityCocoa* BrowserAccessibility::ToBrowserAccessibilityCocoa() { +BrowserAccessibilityCocoa* BrowserAccessibility::toBrowserAccessibilityCocoa() { return static_cast<BrowserAccessibilityMac*>(this)-> native_view(); } diff --git a/content/browser/accessibility/browser_accessibility_mac_unittest.mm b/content/browser/accessibility/browser_accessibility_mac_unittest.mm index 0e1a73e..bb80935 100644 --- a/content/browser/accessibility/browser_accessibility_mac_unittest.mm +++ b/content/browser/accessibility/browser_accessibility_mac_unittest.mm @@ -77,7 +77,7 @@ class BrowserAccessibilityTest : public ui::CocoaTest { delegate_.reset([[MockAccessibilityDelegate alloc] init]); manager_.reset( BrowserAccessibilityManager::Create(delegate_, root, NULL)); - accessibility_.reset([manager_->GetRoot()->ToBrowserAccessibilityCocoa() + accessibility_.reset([manager_->GetRoot()->toBrowserAccessibilityCocoa() retain]); } diff --git a/content/browser/accessibility/browser_accessibility_manager.cc b/content/browser/accessibility/browser_accessibility_manager.cc index 7893acf..9c5329d 100644 --- a/content/browser/accessibility/browser_accessibility_manager.cc +++ b/content/browser/accessibility/browser_accessibility_manager.cc @@ -21,9 +21,9 @@ BrowserAccessibility* BrowserAccessibilityFactory::Create() { // static int32 BrowserAccessibilityManager::next_child_id_ = -1; -#if defined(OS_POSIX) && !defined(OS_MACOSX) && !defined(TOOLKIT_GTK) -// We have implementations of BrowserAccessibilityManager on Win, Mac, -// and GTK. If we have anything else, just instantiate the base class. +#if (defined(OS_POSIX) && !defined(OS_MACOSX)) || defined(USE_AURA) +// There's no OS-specific implementation of BrowserAccessibilityManager +// on Unix, so just instantiate the base class. // static BrowserAccessibilityManager* BrowserAccessibilityManager::Create( gfx::NativeView parent_view, diff --git a/content/browser/accessibility/browser_accessibility_manager.h b/content/browser/accessibility/browser_accessibility_manager.h index 7e1757b..8b2d7fd 100644 --- a/content/browser/accessibility/browser_accessibility_manager.h +++ b/content/browser/accessibility/browser_accessibility_manager.h @@ -133,7 +133,7 @@ class CONTENT_EXPORT BrowserAccessibilityManager { gfx::NativeView GetParentView(); #if defined(OS_WIN) - BrowserAccessibilityManagerWin* ToBrowserAccessibilityManagerWin(); + BrowserAccessibilityManagerWin* toBrowserAccessibilityManagerWin(); #endif // Return the object that has focus, if it's a descandant of the diff --git a/content/browser/accessibility/browser_accessibility_manager_gtk.cc b/content/browser/accessibility/browser_accessibility_manager_gtk.cc deleted file mode 100644 index 5a855c4..0000000 --- a/content/browser/accessibility/browser_accessibility_manager_gtk.cc +++ /dev/null @@ -1,69 +0,0 @@ -// 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. - -#include "content/browser/accessibility/browser_accessibility_manager_gtk.h" - -#include "content/browser/accessibility/browser_accessibility_gtk.h" -#include "content/common/accessibility_messages.h" - -using webkit_glue::WebAccessibility; - -// static -BrowserAccessibilityManager* BrowserAccessibilityManager::Create( - gfx::NativeView parent_view, - const WebAccessibility& src, - BrowserAccessibilityDelegate* delegate, - BrowserAccessibilityFactory* factory) { - return new BrowserAccessibilityManagerGtk( - parent_view, - src, - delegate, - factory); -} - -BrowserAccessibilityManagerGtk::BrowserAccessibilityManagerGtk( - GtkWidget* parent_view, - const WebAccessibility& src, - BrowserAccessibilityDelegate* delegate, - BrowserAccessibilityFactory* factory) - : BrowserAccessibilityManager(parent_view, src, delegate, factory) { -} - -BrowserAccessibilityManagerGtk::~BrowserAccessibilityManagerGtk() { -} - -void BrowserAccessibilityManagerGtk::NotifyAccessibilityEvent( - int type, - BrowserAccessibility* node) { - AtkObject* atk_object = node->ToBrowserAccessibilityGtk()->GetAtkObject(); - - switch (type) { - case AccessibilityNotificationChildrenChanged: - RecursivelySendChildrenChanged(GetRoot()->ToBrowserAccessibilityGtk()); - break; - case AccessibilityNotificationFocusChanged: - // Note: atk_focus_tracker_notify may be deprecated in the future; - // follow this bug for the replacement: - // https://bugzilla.gnome.org/show_bug.cgi?id=649575#c4 - g_signal_emit_by_name(atk_object, "focus-event", true); - atk_focus_tracker_notify(atk_object); - break; - default: - break; - } -} - -void BrowserAccessibilityManagerGtk::RecursivelySendChildrenChanged( - BrowserAccessibilityGtk* node) { - AtkObject* atkObject = node->ToBrowserAccessibilityGtk()->GetAtkObject(); - for (unsigned int i = 0; i < node->children().size(); ++i) { - BrowserAccessibilityGtk* child = - node->children()[i]->ToBrowserAccessibilityGtk(); - g_signal_emit_by_name(atkObject, - "children-changed::add", - i, - child->GetAtkObject()); - RecursivelySendChildrenChanged(child); - } -} diff --git a/content/browser/accessibility/browser_accessibility_manager_gtk.h b/content/browser/accessibility/browser_accessibility_manager_gtk.h deleted file mode 100644 index 4de6678..0000000 --- a/content/browser/accessibility/browser_accessibility_manager_gtk.h +++ /dev/null @@ -1,41 +0,0 @@ -// 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. - -#ifndef CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_GTK_H_ -#define CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_GTK_H_ -#pragma once - -#include "content/browser/accessibility/browser_accessibility_manager.h" -#include "webkit/glue/webaccessibility.h" - -class BrowserAccessibilityGtk; -struct ViewHostMsg_AccessibilityNotification_Params; - -using webkit_glue::WebAccessibility; - -// Manages a tree of BrowserAccessibilityGtk objects. -class BrowserAccessibilityManagerGtk : public BrowserAccessibilityManager { - public: - virtual ~BrowserAccessibilityManagerGtk(); - - // BrowserAccessibilityManager methods - virtual void NotifyAccessibilityEvent(int type, BrowserAccessibility* node) - OVERRIDE; - - private: - BrowserAccessibilityManagerGtk( - GtkWidget* parent_window, - const WebAccessibility& src, - BrowserAccessibilityDelegate* delegate, - BrowserAccessibilityFactory* factory); - - void RecursivelySendChildrenChanged(BrowserAccessibilityGtk* node); - - // Give BrowserAccessibilityManager::Create access to our constructor. - friend class BrowserAccessibilityManager; - - DISALLOW_COPY_AND_ASSIGN(BrowserAccessibilityManagerGtk); -}; - -#endif // CONTENT_BROWSER_ACCESSIBILITY_BROWSER_ACCESSIBILITY_MANAGER_GTK_H_ diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm index 4131244..92da9d5 100644 --- a/content/browser/accessibility/browser_accessibility_manager_mac.mm +++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm @@ -98,7 +98,7 @@ void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( event_id = NSAccessibilityValueChangedNotification; break; } - BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa(); + BrowserAccessibilityCocoa* native_node = node->toBrowserAccessibilityCocoa(); DCHECK(native_node); NSAccessibilityPostNotification(native_node, event_id); } diff --git a/content/browser/accessibility/browser_accessibility_manager_win.cc b/content/browser/accessibility/browser_accessibility_manager_win.cc index d5c85e5..2670ee1 100644 --- a/content/browser/accessibility/browser_accessibility_manager_win.cc +++ b/content/browser/accessibility/browser_accessibility_manager_win.cc @@ -23,7 +23,7 @@ BrowserAccessibilityManager* BrowserAccessibilityManager::Create( } BrowserAccessibilityManagerWin* -BrowserAccessibilityManager::ToBrowserAccessibilityManagerWin() { +BrowserAccessibilityManager::toBrowserAccessibilityManagerWin() { return static_cast<BrowserAccessibilityManagerWin*>(this); } diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc index d185460..4f53ecc 100644 --- a/content/browser/accessibility/browser_accessibility_win.cc +++ b/content/browser/accessibility/browser_accessibility_win.cc @@ -135,7 +135,7 @@ STDMETHODIMP BrowserAccessibilityRelation::get_target( return E_FAIL; *target = static_cast<IAccessible*>( - result->ToBrowserAccessibilityWin()->NewReference()); + result->toBrowserAccessibilityWin()->NewReference()); return S_OK; } @@ -176,7 +176,7 @@ BrowserAccessibility* BrowserAccessibility::Create() { return instance->NewReference(); } -BrowserAccessibilityWin* BrowserAccessibility::ToBrowserAccessibilityWin() { +BrowserAccessibilityWin* BrowserAccessibility::toBrowserAccessibilityWin() { return static_cast<BrowserAccessibilityWin*>(this); } @@ -238,7 +238,7 @@ STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, child->lVal = CHILDID_SELF; } else { child->vt = VT_DISPATCH; - child->pdispVal = result->ToBrowserAccessibilityWin()->NewReference(); + child->pdispVal = result->toBrowserAccessibilityWin()->NewReference(); } return S_OK; } @@ -307,7 +307,7 @@ STDMETHODIMP BrowserAccessibilityWin::accNavigate( } end->vt = VT_DISPATCH; - end->pdispVal = result->ToBrowserAccessibilityWin()->NewReference(); + end->pdispVal = result->toBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -465,11 +465,11 @@ STDMETHODIMP BrowserAccessibilityWin::get_accParent(IDispatch** disp_parent) { if (!disp_parent) return E_INVALIDARG; - IAccessible* parent = parent_->ToBrowserAccessibilityWin(); + IAccessible* parent = parent_->toBrowserAccessibilityWin(); if (parent == NULL) { // This happens if we're the root of the tree; // return the IAccessible for the window. - parent = manager_->ToBrowserAccessibilityManagerWin()-> + parent = manager_->toBrowserAccessibilityManagerWin()-> GetParentWindowIAccessible(); } @@ -566,7 +566,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) { selected->vt = VT_DISPATCH; selected->pdispVal = - children_[i]->ToBrowserAccessibilityWin()->NewReference(); + children_[i]->toBrowserAccessibilityWin()->NewReference(); return S_OK; } } @@ -581,7 +581,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accSelection(VARIANT* selected) { if (children_[i]->HasState(WebAccessibility::STATE_SELECTED)) { enum_variant->ItemAt(index)->vt = VT_DISPATCH; enum_variant->ItemAt(index)->pdispVal = - children_[i]->ToBrowserAccessibilityWin()->NewReference(); + children_[i]->toBrowserAccessibilityWin()->NewReference(); ++index; } } @@ -1073,7 +1073,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnIndex( int cell_id = unique_cell_ids_[cell_index]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); int col_index; if (cell && cell->GetIntAttribute( @@ -1180,7 +1180,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowDescription( for (int i = 0; i < columns; ++i) { int cell_id = cell_ids_[row * columns + i]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) { if (cell->name_.size() > 0) { *description = SysAllocString(cell->name_.c_str()); @@ -1219,7 +1219,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowExtentAt( int cell_id = cell_ids_[row * columns + column]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); int rowspan; if (cell && cell->GetIntAttribute( @@ -1256,7 +1256,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowIndex( int cell_id = unique_cell_ids_[cell_index]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); int cell_row_index; if (cell && cell->GetIntAttribute( @@ -1389,7 +1389,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowColumnExtentsAtIndex( int cell_id = unique_cell_ids_[index]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); int rowspan; int colspan; if (cell && @@ -1527,7 +1527,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( for (int i = 0; i < rows; ++i) { int cell_id = table->cell_ids()[i * columns + column]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) (*n_column_header_cells)++; } @@ -1538,7 +1538,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_columnHeaderCells( for (int i = 0; i < rows; ++i) { int cell_id = table->cell_ids()[i * columns + column]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); if (cell && cell->role_ == WebAccessibility::ROLE_COLUMN_HEADER) { (*cell_accessibles)[index] = static_cast<IAccessible*>(cell->NewReference()); @@ -1625,7 +1625,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( for (int i = 0; i < columns; ++i) { int cell_id = table->cell_ids()[row * columns + i]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) (*n_row_header_cells)++; } @@ -1636,7 +1636,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_rowHeaderCells( for (int i = 0; i < columns; ++i) { int cell_id = table->cell_ids()[row * columns + i]; BrowserAccessibilityWin* cell = - manager_->GetFromRendererID(cell_id)->ToBrowserAccessibilityWin(); + manager_->GetFromRendererID(cell_id)->toBrowserAccessibilityWin(); if (cell && cell->role_ == WebAccessibility::ROLE_ROW_HEADER) { (*cell_accessibles)[index] = static_cast<IAccessible*>(cell->NewReference()); @@ -1737,7 +1737,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_table( } *table = static_cast<IAccessibleTable*>( - find_table->ToBrowserAccessibilityWin()->NewReference()); + find_table->toBrowserAccessibilityWin()->NewReference()); return S_OK; } @@ -2095,7 +2095,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_hyperlink( } BrowserAccessibilityWin* child = - children_[hyperlinks_[index]]->ToBrowserAccessibilityWin(); + children_[hyperlinks_[index]]->toBrowserAccessibilityWin(); *hyperlink = static_cast<IAccessibleHyperlink*>(child->NewReference()); return S_OK; } @@ -2397,7 +2397,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_parentNode(ISimpleDOMNode** node) { if (!node) return E_INVALIDARG; - *node = parent_->ToBrowserAccessibilityWin()->NewReference(); + *node = parent_->toBrowserAccessibilityWin()->NewReference(); return S_OK; } @@ -2409,7 +2409,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_firstChild(ISimpleDOMNode** node) { return E_INVALIDARG; if (children_.size()) { - *node = children_[0]->ToBrowserAccessibilityWin()->NewReference(); + *node = children_[0]->toBrowserAccessibilityWin()->NewReference(); return S_OK; } else { *node = NULL; @@ -2425,7 +2425,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_lastChild(ISimpleDOMNode** node) { return E_INVALIDARG; if (children_.size()) { - *node = children_[children_.size() - 1]->ToBrowserAccessibilityWin()-> + *node = children_[children_.size() - 1]->toBrowserAccessibilityWin()-> NewReference(); return S_OK; } else { @@ -2444,7 +2444,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_previousSibling( if (parent_ && index_in_parent_ > 0) { *node = parent_->children()[index_in_parent_ - 1]-> - ToBrowserAccessibilityWin()->NewReference(); + toBrowserAccessibilityWin()->NewReference(); return S_OK; } else { *node = NULL; @@ -2463,7 +2463,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_nextSibling(ISimpleDOMNode** node) { index_in_parent_ >= 0 && index_in_parent_ < static_cast<int>(parent_->children().size()) - 1) { *node = parent_->children()[index_in_parent_ + 1]-> - ToBrowserAccessibilityWin()->NewReference(); + toBrowserAccessibilityWin()->NewReference(); return S_OK; } else { *node = NULL; @@ -2481,7 +2481,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_childAt( return E_INVALIDARG; if (child_index < children_.size()) { - *node = children_[child_index]->ToBrowserAccessibilityWin()->NewReference(); + *node = children_[child_index]->toBrowserAccessibilityWin()->NewReference(); return S_OK; } else { *node = NULL; @@ -2848,9 +2848,9 @@ BrowserAccessibilityWin* BrowserAccessibilityWin::GetTargetFromChildID( return this; if (child_id >= 1 && child_id <= static_cast<LONG>(children_.size())) - return children_[child_id - 1]->ToBrowserAccessibilityWin(); + return children_[child_id - 1]->toBrowserAccessibilityWin(); - return manager_->GetFromChildID(child_id)->ToBrowserAccessibilityWin(); + return manager_->GetFromChildID(child_id)->toBrowserAccessibilityWin(); } HRESULT BrowserAccessibilityWin::GetStringAttributeAsBstr( @@ -2944,7 +2944,7 @@ LONG BrowserAccessibilityWin::FindBoundary( BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromRendererID( int32 renderer_id) { - return manager_->GetFromRendererID(renderer_id)->ToBrowserAccessibilityWin(); + return manager_->GetFromRendererID(renderer_id)->toBrowserAccessibilityWin(); } void BrowserAccessibilityWin::InitRoleAndState() { diff --git a/content/browser/accessibility/browser_accessibility_win_unittest.cc b/content/browser/accessibility/browser_accessibility_win_unittest.cc index 7841d4b..4afcd27 100644 --- a/content/browser/accessibility/browser_accessibility_win_unittest.cc +++ b/content/browser/accessibility/browser_accessibility_win_unittest.cc @@ -115,7 +115,7 @@ TEST_F(BrowserAccessibilityTest, TestNoLeaks) { new CountedBrowserAccessibilityFactory()); ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); IAccessible* root_accessible = - manager->GetRoot()->ToBrowserAccessibilityWin(); + manager->GetRoot()->toBrowserAccessibilityWin(); IDispatch* root_iaccessible = NULL; IDispatch* child1_iaccessible = NULL; VARIANT var_child; @@ -170,7 +170,7 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChange) { // Query for the text IAccessible and verify that it returns "old text" as its // value. base::win::ScopedComPtr<IDispatch> text_dispatch; - HRESULT hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild( + HRESULT hr = manager->GetRoot()->toBrowserAccessibilityWin()->get_accChild( CreateI4Variant(1), text_dispatch.Receive()); ASSERT_EQ(S_OK, hr); @@ -199,7 +199,7 @@ TEST_F(BrowserAccessibilityTest, TestChildrenChange) { // Query for the text IAccessible and verify that it now returns "new text" // as its value. - hr = manager->GetRoot()->ToBrowserAccessibilityWin()->get_accChild( + hr = manager->GetRoot()->toBrowserAccessibilityWin()->get_accChild( CreateI4Variant(1), text_dispatch.Receive()); ASSERT_EQ(S_OK, hr); @@ -297,9 +297,9 @@ TEST_F(BrowserAccessibilityTest, TestTextBoundaries) { ASSERT_EQ(2, CountedBrowserAccessibility::global_obj_count_); BrowserAccessibilityWin* root_obj = - manager->GetRoot()->ToBrowserAccessibilityWin(); + manager->GetRoot()->toBrowserAccessibilityWin(); BrowserAccessibilityWin* text1_obj = - root_obj->GetChild(0)->ToBrowserAccessibilityWin(); + root_obj->GetChild(0)->toBrowserAccessibilityWin(); BSTR text; long start; @@ -393,7 +393,7 @@ TEST_F(BrowserAccessibilityTest, TestSimpleHypertext) { ASSERT_EQ(3, CountedBrowserAccessibility::global_obj_count_); BrowserAccessibilityWin* root_obj = - manager->GetRoot()->ToBrowserAccessibilityWin(); + manager->GetRoot()->toBrowserAccessibilityWin(); BSTR text; @@ -477,7 +477,7 @@ TEST_F(BrowserAccessibilityTest, TestComplexHypertext) { ASSERT_EQ(7, CountedBrowserAccessibility::global_obj_count_); BrowserAccessibilityWin* root_obj = - manager->GetRoot()->ToBrowserAccessibilityWin(); + manager->GetRoot()->toBrowserAccessibilityWin(); BSTR text; diff --git a/content/browser/accessibility/dump_accessibility_tree_helper_mac.mm b/content/browser/accessibility/dump_accessibility_tree_helper_mac.mm index 04b72e0..50c40cd 100644 --- a/content/browser/accessibility/dump_accessibility_tree_helper_mac.mm +++ b/content/browser/accessibility/dump_accessibility_tree_helper_mac.mm @@ -15,7 +15,7 @@ void DumpAccessibilityTreeHelper::Initialize() {} string16 DumpAccessibilityTreeHelper::ToString(BrowserAccessibility* node, char* prefix) { - BrowserAccessibilityCocoa* cocoa_node = node->ToBrowserAccessibilityCocoa(); + BrowserAccessibilityCocoa* cocoa_node = node->toBrowserAccessibilityCocoa(); NSString* dump = [NSString stringWithFormat:@"%s%@ " "subrole=%@ " diff --git a/content/browser/accessibility/dump_accessibility_tree_helper_win.cc b/content/browser/accessibility/dump_accessibility_tree_helper_win.cc index f1d2c80..a567b2b 100644 --- a/content/browser/accessibility/dump_accessibility_tree_helper_win.cc +++ b/content/browser/accessibility/dump_accessibility_tree_helper_win.cc @@ -197,7 +197,7 @@ string16 DumpAccessibilityTreeHelper::ToString( if (role_string_map.empty()) Initialize(); - BrowserAccessibilityWin* acc_obj = node->ToBrowserAccessibilityWin(); + BrowserAccessibilityWin* acc_obj = node->toBrowserAccessibilityWin(); string16 state; std::map<int32, string16>::iterator it; |