summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-19 18:50:40 +0000
committerctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-19 18:50:40 +0000
commit684a099f95bd2bac4aa7b82c1c3e4023dbc9c40d (patch)
treeb69ce6e21ac58f125c99d8f7c242397699b33cfd /views
parent9f95844be9cc61d2bf2eaee75080e0da8c4e7c67 (diff)
downloadchromium_src-684a099f95bd2bac4aa7b82c1c3e4023dbc9c40d.zip
chromium_src-684a099f95bd2bac4aa7b82c1c3e4023dbc9c40d.tar.gz
chromium_src-684a099f95bd2bac4aa7b82c1c3e4023dbc9c40d.tar.bz2
views: Add accessibility support to the Textfield control.
BUG=9619 TEST=open AccExplorer.exe, open bookmarks manager dialog, point it to the search Textfield (edit box) and see it if has the correct information for role (editable text), name (the label within it's connected) and state (read only). Review URL: http://codereview.chromium.org/1058002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42128 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/textfield/textfield.cc36
-rw-r--r--views/controls/textfield/textfield.h13
2 files changed, 47 insertions, 2 deletions
diff --git a/views/controls/textfield/textfield.cc b/views/controls/textfield/textfield.cc
index b650530..7f7251b 100644
--- a/views/controls/textfield/textfield.cc
+++ b/views/controls/textfield/textfield.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -227,6 +227,40 @@ void Textfield::PaintFocusBorder(gfx::Canvas* canvas) {
View::PaintFocusBorder(canvas);
}
+bool Textfield::GetAccessibleRole(AccessibilityTypes::Role* role) {
+ DCHECK(role);
+ if (!role)
+ return false;
+
+ *role = AccessibilityTypes::ROLE_TEXT;
+ return true;
+}
+
+bool Textfield::GetAccessibleName(std::wstring* name) {
+ DCHECK(name);
+ if (!name)
+ return false;
+
+ if (!accessible_name_.empty()) {
+ *name = accessible_name_;
+ return true;
+ }
+ return false;
+}
+
+bool Textfield::GetAccessibleState(AccessibilityTypes::State* state) {
+ DCHECK(state);
+ if (!state)
+ return false;
+
+ *state = AccessibilityTypes::STATE_READONLY;
+ return true;
+}
+
+void Textfield::SetAccessibleName(const std::wstring& name) {
+ accessible_name_.assign(name);
+}
+
void Textfield::SetEnabled(bool enabled) {
View::SetEnabled(enabled);
if (native_wrapper_)
diff --git a/views/controls/textfield/textfield.h b/views/controls/textfield/textfield.h
index bccd07e..b20f9ec 100644
--- a/views/controls/textfield/textfield.h
+++ b/views/controls/textfield/textfield.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -9,6 +9,8 @@
#include <gdk/gdk.h>
#endif
+#include <string>
+
#include "app/gfx/font.h"
#include "base/basictypes.h"
#include "base/keyboard_codes.h"
@@ -202,6 +204,12 @@ class Textfield : public View {
virtual void SetEnabled(bool enabled);
virtual void PaintFocusBorder(gfx::Canvas* canvas);
+ // Accessibility accessors, overridden from View:
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual bool GetAccessibleName(std::wstring* name);
+ virtual bool GetAccessibleState(AccessibilityTypes::State* state);
+ virtual void SetAccessibleName(const std::wstring& name);
+
protected:
virtual void Focus();
virtual void ViewHierarchyChanged(bool is_add, View* parent, View* child);
@@ -262,6 +270,9 @@ class Textfield : public View {
// NativeControlWin.
bool initialized_;
+ // The storage string for the accessibility name associated with this control.
+ std::wstring accessible_name_;
+
DISALLOW_COPY_AND_ASSIGN(Textfield);
};