Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(182)

Unified Diff: content/browser/accessibility/browser_accessibility_win.cc

Issue 1057083002: Fix menu list and list box screen reader accessibility. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix on Mac too Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: content/browser/accessibility/browser_accessibility_win.cc
diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc
index 5c318b29e1c7de1041fc3a12a90404645cc80052..fc566807d1ef290ee834661b88c08895c1aa4827 100644
--- a/content/browser/accessibility/browser_accessibility_win.cc
+++ b/content/browser/accessibility/browser_accessibility_win.cc
@@ -903,9 +903,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_groupPosition(
if (!group_level || !similar_items_in_group || !position_in_group)
return E_INVALIDARG;
- if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
- GetParent() &&
- GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) {
+ if (IsListBoxOptionOrMenuListOption()) {
*group_level = 0;
*similar_items_in_group = GetParent()->PlatformChildCount();
*position_in_group = GetIndexInParent() + 1;
@@ -2996,13 +2994,13 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() {
IntAttributeToIA2(ui::AX_ATTR_HIERARCHICAL_LEVEL, "level");
// Expose the set size and position in set for listbox options.
- if (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
- GetParent() &&
- GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) {
+ if (IsListBoxOptionOrMenuListOption()) {
win_attributes_->ia2_attributes.push_back(
L"setsize:" + base::IntToString16(GetParent()->PlatformChildCount()));
win_attributes_->ia2_attributes.push_back(
- L"setsize:" + base::IntToString16(GetIndexInParent() + 1));
+ L"posinset:" + base::IntToString16(GetIndexInParent() + 1));
+ win_attributes_->ia2_attributes.push_back(
+ L"tag:option");
}
if (ia_role() == ROLE_SYSTEM_CHECKBUTTON ||
@@ -3184,9 +3182,9 @@ void BrowserAccessibilityWin::UpdateStep1ComputeWinAttributes() {
// WebKit stores the main accessible text in the "value" - swap it so
// that it's the "name".
if (name.empty() &&
- (GetRole() == ui::AX_ROLE_LIST_BOX_OPTION ||
- GetRole() == ui::AX_ROLE_STATIC_TEXT ||
- GetRole() == ui::AX_ROLE_LIST_MARKER)) {
+ (GetRole() == ui::AX_ROLE_STATIC_TEXT ||
+ GetRole() == ui::AX_ROLE_LIST_MARKER ||
+ IsListBoxOptionOrMenuListOption())) {
base::string16 tmp = value;
value = name;
name = tmp;
@@ -3303,10 +3301,22 @@ void BrowserAccessibilityWin::UpdateStep3FireEvents(bool is_subtree_creation) {
bool is_selected_now = (ia_state() & STATE_SYSTEM_SELECTED) != 0;
bool was_selected_before =
(old_win_attributes_->ia_state & STATE_SYSTEM_SELECTED) != 0;
- if (is_selected_now && !was_selected_before) {
- manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, this);
- } else if (!is_selected_now && was_selected_before) {
- manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, this);
+ if (is_selected_now || was_selected_before) {
+ bool multiselect = false;
+ if (GetParent() && GetParent()->HasState(ui::AX_STATE_MULTISELECTABLE))
+ multiselect = true;
+
+ if (multiselect) {
je_julie(Not used) 2015/04/06 10:31:48 Do we need this variable? it doesn't seem to be us
+ // In a multi-select box, fire SELECTIONADD and SELECTIONREMOVE events.
+ if (is_selected_now && !was_selected_before) {
+ manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONADD, this);
+ } else if (!is_selected_now && was_selected_before) {
+ manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTIONREMOVE, this);
+ }
+ } else if (is_selected_now && !was_selected_before) {
+ // In a single-select box, only fire SELECTION events.
+ manager->MaybeCallNotifyWinEvent(EVENT_OBJECT_SELECTION, this);
+ }
}
// Fire an event if this container object has scrolled.
@@ -3466,7 +3476,7 @@ base::string16 BrowserAccessibilityWin::GetValueText() {
}
base::string16 BrowserAccessibilityWin::TextForIAccessibleText() {
- if (IsEditableText())
+ if (IsEditableText() || GetRole() == ui::AX_ROLE_MENU_LIST_OPTION)
return value();
return (GetRole() == ui::AX_ROLE_STATIC_TEXT) ? name() : hypertext();
}
@@ -3592,6 +3602,26 @@ BrowserAccessibilityWin* BrowserAccessibilityWin::GetFromID(int32 id) {
return manager()->GetFromID(id)->ToBrowserAccessibilityWin();
}
+bool BrowserAccessibilityWin::IsListBoxOptionOrMenuListOption() {
+ if (!GetParent())
+ return false;
+
+ int32 role = GetRole();
+ int32 parent_role = GetParent()->GetRole();
+
+ if (role == ui::AX_ROLE_LIST_BOX_OPTION &&
+ parent_role == ui::AX_ROLE_LIST_BOX) {
+ return true;
+ }
+
+ if (role == ui::AX_ROLE_MENU_LIST_OPTION &&
+ parent_role == ui::AX_ROLE_MENU_LIST_POPUP) {
+ return true;
+ }
+
+ return false;
+}
+
void BrowserAccessibilityWin::InitRoleAndState() {
int32 ia_role = 0;
int32 ia_state = 0;
@@ -3914,10 +3944,12 @@ void BrowserAccessibilityWin::InitRoleAndState() {
ia2_role = IA2_ROLE_RADIO_MENU_ITEM;
break;
case ui::AX_ROLE_MENU_LIST_POPUP:
- ia_role = ROLE_SYSTEM_CLIENT;
+ ia_role = ROLE_SYSTEM_LIST;
+ ia2_state &= ~(IA2_STATE_EDITABLE);
break;
case ui::AX_ROLE_MENU_LIST_OPTION:
ia_role = ROLE_SYSTEM_LISTITEM;
+ ia2_state &= ~(IA2_STATE_EDITABLE);
if (ia_state & STATE_SYSTEM_SELECTABLE) {
ia_state |= STATE_SYSTEM_FOCUSABLE;
if (HasState(ui::AX_STATE_FOCUSED))

Powered by Google App Engine
This is Rietveld 408576698