summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 18:27:34 +0000
committerctguil@chromium.org <ctguil@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-01 18:27:34 +0000
commit2cc800b06bfbdc34b49e25c059ac1da34d63eb61 (patch)
tree56401e75be35081faeddce3478f621b06e5c4be2 /views
parentc150956182eff7504a22fcf3a1a960a75f2bc593 (diff)
downloadchromium_src-2cc800b06bfbdc34b49e25c059ac1da34d63eb61.zip
chromium_src-2cc800b06bfbdc34b49e25c059ac1da34d63eb61.tar.gz
chromium_src-2cc800b06bfbdc34b49e25c059ac1da34d63eb61.tar.bz2
Remove mnemonic and add keyboard shortcut text to the accessible name of text buttons in the wrench menu.
Add breaks to GetAccessibleState switch statements. BUG=51738 TEST=Verify in NVDA and JAWS that text buttons are read without mnemonic and with keyboard shortcut. Review URL: http://codereview.chromium.org/3612001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61201 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-rw-r--r--views/controls/button/custom_button.cc3
-rw-r--r--views/controls/menu/menu_item_view.cc51
-rw-r--r--views/controls/menu/menu_item_view.h5
3 files changed, 38 insertions, 21 deletions
diff --git a/views/controls/button/custom_button.cc b/views/controls/button/custom_button.cc
index 4ab2fae..a1f4e62 100644
--- a/views/controls/button/custom_button.cc
+++ b/views/controls/button/custom_button.cc
@@ -58,10 +58,13 @@ AccessibilityTypes::State CustomButton::GetAccessibleState() {
switch (state_) {
case BS_HOT:
state = AccessibilityTypes::STATE_HOTTRACKED;
+ break;
case BS_PUSHED:
state = AccessibilityTypes::STATE_PRESSED;
+ break;
case BS_DISABLED:
state = AccessibilityTypes::STATE_UNAVAILABLE;
+ break;
case BS_NORMAL:
case BS_COUNT:
// No additional accessibility state set for this button state.
diff --git a/views/controls/menu/menu_item_view.cc b/views/controls/menu/menu_item_view.cc
index c903a0f..bd1fbaf 100644
--- a/views/controls/menu/menu_item_view.cc
+++ b/views/controls/menu/menu_item_view.cc
@@ -108,10 +108,12 @@ AccessibilityTypes::State MenuItemView::GetAccessibleState() {
switch (GetType()) {
case SUBMENU:
state |= AccessibilityTypes::STATE_HASPOPUP;
+ break;
case CHECKBOX:
case RADIO:
state |= GetDelegate()->IsItemChecked(GetCommand()) ?
AccessibilityTypes::STATE_CHECKED : 0;
+ break;
case NORMAL:
case SEPARATOR:
// No additional accessibility states currently for these menu states.
@@ -120,6 +122,33 @@ AccessibilityTypes::State MenuItemView::GetAccessibleState() {
return state;
}
+// static
+std::wstring MenuItemView::GetAccessibleNameForMenuItem(
+ const std::wstring& item_text, const std::wstring& accelerator_text) {
+ std::wstring accessible_name = item_text;
+
+ // Filter out the "&" for accessibility clients.
+ size_t index = 0;
+ while ((index = accessible_name.find(L"&", index)) != std::wstring::npos &&
+ index + 1 < accessible_name.length()) {
+ accessible_name.replace(index, accessible_name.length() - index,
+ accessible_name.substr(index + 1));
+
+ // Special case for "&&" (escaped for "&").
+ if (accessible_name[index] == '&')
+ ++index;
+ }
+
+ // Append accelerator text.
+ menus::Accelerator menu_accelerator;
+ if (!accelerator_text.empty()) {
+ accessible_name.append(L" ");
+ accessible_name.append(accelerator_text);
+ }
+
+ return accessible_name;
+}
+
void MenuItemView::RunMenuAt(gfx::NativeWindow parent,
MenuButton* button,
const gfx::Rect& bounds,
@@ -237,27 +266,7 @@ SubmenuView* MenuItemView::CreateSubmenu() {
void MenuItemView::SetTitle(const std::wstring& title) {
title_ = title;
- std::wstring accessible_title(title);
-
- // Filter out the "&" for accessibility clients.
- size_t index = 0;
- while ((index = accessible_title.find(L"&", index)) != std::wstring::npos &&
- index + 1 < accessible_title.length()) {
- accessible_title.replace(index, accessible_title.length() - index,
- accessible_title.substr(index + 1));
-
- // Special case for "&&" (escaped for "&").
- if (accessible_title[index] == '&')
- ++index;
- }
-
- if (!GetAcceleratorText().empty()) {
- std::wstring accelerator_text(L" ");
- accelerator_text.append(GetAcceleratorText());
- accessible_title.append(accelerator_text);
- }
-
- SetAccessibleName(accessible_title);
+ SetAccessibleName(GetAccessibleNameForMenuItem(title, GetAcceleratorText()));
}
void MenuItemView::SetSelected(bool selected) {
diff --git a/views/controls/menu/menu_item_view.h b/views/controls/menu/menu_item_view.h
index 0430e34..66540b7 100644
--- a/views/controls/menu/menu_item_view.h
+++ b/views/controls/menu/menu_item_view.h
@@ -98,6 +98,11 @@ class MenuItemView : public View {
// X-coordinate of where the label starts.
static int label_start() { return label_start_; }
+ // Returns the accessible name to be used with screen readers. Mnemonics are
+ // removed and the menu item accelerator text is appended.
+ static std::wstring GetAccessibleNameForMenuItem(
+ const std::wstring& item_text, const std::wstring& accelerator_text);
+
// Run methods. See description above class for details. Both Run methods take
// a rectangle, which is used to position the menu. |has_mnemonics| indicates
// whether the items have mnemonics. Mnemonics are identified by way of the