summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 05:45:33 +0000
committerajwong@chromium.org <ajwong@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-16 05:45:33 +0000
commit791199c674cd1aa2997e39079e33681596866fc8 (patch)
tree9d8837dfd5273300585ef082c993b4a7fe1ed976 /views
parent0546c189a55fb6043b69a99cae098e00758a4cb5 (diff)
downloadchromium_src-791199c674cd1aa2997e39079e33681596866fc8.zip
chromium_src-791199c674cd1aa2997e39079e33681596866fc8.tar.gz
chromium_src-791199c674cd1aa2997e39079e33681596866fc8.tar.bz2
Reapply r41640.
Original patch by thiago.farina@gmail.com Revision r41640 was reverted in r41676 because it looked like it might have been responsible for Interactive UI test failures in linux and windows. However, reverting didn't fix, so I'm reapplying it. Review URL: http://codereview.chromium.org/982004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41683 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/accessibility/accessibility_types.h2
-rw-r--r--views/accessibility/view_accessibility.cc4
-rw-r--r--views/controls/combobox/combobox.cc21
-rw-r--r--views/controls/combobox/combobox.h10
-rw-r--r--views/controls/link.cc15
-rw-r--r--views/controls/link.h8
6 files changed, 57 insertions, 3 deletions
diff --git a/views/accessibility/accessibility_types.h b/views/accessibility/accessibility_types.h
index e3bdfae..cc92d0c 100644
--- a/views/accessibility/accessibility_types.h
+++ b/views/accessibility/accessibility_types.h
@@ -25,8 +25,10 @@ class AccessibilityTypes {
ROLE_BUTTONMENU,
ROLE_CHECKBUTTON,
ROLE_CLIENT,
+ ROLE_COMBOBOX,
ROLE_GRAPHIC,
ROLE_GROUPING,
+ ROLE_LINK,
ROLE_PAGETAB,
ROLE_PAGETABLIST,
ROLE_PUSHBUTTON,
diff --git a/views/accessibility/view_accessibility.cc b/views/accessibility/view_accessibility.cc
index f6c83eb..f8bf516 100644
--- a/views/accessibility/view_accessibility.cc
+++ b/views/accessibility/view_accessibility.cc
@@ -676,10 +676,14 @@ long ViewAccessibility::MSAARole(AccessibilityTypes::Role role) {
return ROLE_SYSTEM_BUTTONMENU;
case AccessibilityTypes::ROLE_CHECKBUTTON:
return ROLE_SYSTEM_CHECKBUTTON;
+ case AccessibilityTypes::ROLE_COMBOBOX:
+ return ROLE_SYSTEM_COMBOBOX;
case AccessibilityTypes::ROLE_GRAPHIC:
return ROLE_SYSTEM_GRAPHIC;
case AccessibilityTypes::ROLE_GROUPING:
return ROLE_SYSTEM_GROUPING;
+ case AccessibilityTypes::ROLE_LINK:
+ return ROLE_SYSTEM_LINK;
case AccessibilityTypes::ROLE_PAGETAB:
return ROLE_SYSTEM_PAGETAB;
case AccessibilityTypes::ROLE_PAGETABLIST:
diff --git a/views/controls/combobox/combobox.cc b/views/controls/combobox/combobox.cc
index 290c141..2edfcd9 100644
--- a/views/controls/combobox/combobox.cc
+++ b/views/controls/combobox/combobox.cc
@@ -85,6 +85,27 @@ void Combobox::PaintFocusBorder(gfx::Canvas* canvas) {
View::PaintFocusBorder(canvas);
}
+bool Combobox::GetAccessibleName(std::wstring* name) {
+ DCHECK(name);
+
+ if (!accessible_name_.empty()) {
+ *name = accessible_name_;
+ return true;
+ }
+ return false;
+}
+
+bool Combobox::GetAccessibleRole(AccessibilityTypes::Role* role) {
+ DCHECK(role);
+
+ *role = AccessibilityTypes::ROLE_COMBOBOX;
+ return true;
+}
+
+void Combobox::SetAccessibleName(const std::wstring& name) {
+ accessible_name_.assign(name);
+}
+
void Combobox::Focus() {
// Forward the focus to the wrapper.
if (native_wrapper_)
diff --git a/views/controls/combobox/combobox.h b/views/controls/combobox/combobox.h
index 1380051..fdf5f8e 100644
--- a/views/controls/combobox/combobox.h
+++ b/views/controls/combobox/combobox.h
@@ -5,6 +5,8 @@
#ifndef VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
#define VIEWS_CONTROLS_COMBOBOX_COMBOBOX_H_
+#include <string>
+
#include "views/view.h"
class ComboboxModel;
@@ -40,7 +42,7 @@ class Combobox : public View {
void ModelChanged();
// Gets/Sets the selected item.
- int selected_item() const { return selected_item_; };
+ int selected_item() const { return selected_item_; }
void SetSelectedItem(int index);
// Called when the combo box's selection is changed by the user.
@@ -55,6 +57,9 @@ class Combobox : public View {
virtual void SetEnabled(bool enabled);
virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e);
virtual void PaintFocusBorder(gfx::Canvas* canvas);
+ virtual bool GetAccessibleName(std::wstring* name);
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual void SetAccessibleName(const std::wstring& name);
protected:
virtual void Focus();
@@ -75,6 +80,9 @@ class Combobox : public View {
// The current selection.
int selected_item_;
+ // The accessible name of this control.
+ std::wstring accessible_name_;
+
DISALLOW_COPY_AND_ASSIGN(Combobox);
};
diff --git a/views/controls/link.cc b/views/controls/link.cc
index e83c0cd..80172e2 100644
--- a/views/controls/link.cc
+++ b/views/controls/link.cc
@@ -51,7 +51,6 @@ void GetColors(const SkColor* background_color, // NULL means "use default"
*normal_color = kNormalColor;
}
}
-
}
namespace views {
@@ -145,6 +144,20 @@ bool Link::SkipDefaultKeyEventProcessing(const KeyEvent& e) {
(e.GetKeyCode() == base::VKEY_RETURN);
}
+bool Link::GetAccessibleRole(AccessibilityTypes::Role* role) {
+ DCHECK(role);
+
+ *role = AccessibilityTypes::ROLE_LINK;
+ return true;
+}
+
+bool Link::GetAccessibleName(std::wstring* name) {
+ DCHECK(name);
+
+ *name = GetText();
+ return !name->empty();
+}
+
void Link::SetFont(const gfx::Font& font) {
Label::SetFont(font);
ValidateStyle();
diff --git a/views/controls/link.h b/views/controls/link.h
index 8c281e3..4ef7af3 100644
--- a/views/controls/link.h
+++ b/views/controls/link.h
@@ -5,6 +5,8 @@
#ifndef VIEWS_CONTROLS_LINK_H_
#define VIEWS_CONTROLS_LINK_H_
+#include <string>
+
#include "views/controls/label.h"
namespace views {
@@ -33,7 +35,7 @@ class LinkController {
class Link : public Label {
public:
Link();
- Link(const std::wstring& title);
+ explicit Link(const std::wstring& title);
virtual ~Link();
void SetController(LinkController* controller);
@@ -47,6 +49,10 @@ class Link : public Label {
virtual bool OnKeyPressed(const KeyEvent& e);
virtual bool SkipDefaultKeyEventProcessing(const KeyEvent& e);
+ // Accessibility accessors, overridden from View:
+ virtual bool GetAccessibleRole(AccessibilityTypes::Role* role);
+ virtual bool GetAccessibleName(std::wstring* name);
+
virtual void SetFont(const gfx::Font& font);
// Set whether the link is enabled.