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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_mac.mm

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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
6 6
7 #import "base/logging.h" 7 #import "base/logging.h"
8 #import "content/browser/accessibility/browser_accessibility_cocoa.h" 8 #import "content/browser/accessibility/browser_accessibility_cocoa.h"
9 #import "content/browser/accessibility/browser_accessibility_mac.h" 9 #import "content/browser/accessibility/browser_accessibility_mac.h"
10 #include "content/common/accessibility_messages.h" 10 #include "content/common/accessibility_messages.h"
(...skipping 26 matching lines...) Expand all
37 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA; 37 empty_document.role = ui::AX_ROLE_ROOT_WEB_AREA;
38 empty_document.state = 38 empty_document.state =
39 1 << ui::AX_STATE_READ_ONLY; 39 1 << ui::AX_STATE_READ_ONLY;
40 ui::AXTreeUpdate update; 40 ui::AXTreeUpdate update;
41 update.nodes.push_back(empty_document); 41 update.nodes.push_back(empty_document);
42 return update; 42 return update;
43 } 43 }
44 44
45 BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus( 45 BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus(
46 BrowserAccessibility* root) { 46 BrowserAccessibility* root) {
47 BrowserAccessibility* node = GetActiveDescendantFocus(root); 47 // On Mac, list boxes should always get focus on the whole list, otherwise
48 return node; 48 // information about the number of selected items will never be reported.
49 BrowserAccessibility* node = BrowserAccessibilityManager::GetFocus(root);
50 if (node && node->GetRole() == ui::AX_ROLE_LIST_BOX)
51 return node;
52
53 // For other roles, follow the active descendant.
54 return GetActiveDescendantFocus(root);
49 } 55 }
50 56
51 void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( 57 void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent(
52 ui::AXEvent event_type, 58 ui::AXEvent event_type,
53 BrowserAccessibility* node) { 59 BrowserAccessibility* node) {
54 if (!node->IsNative()) 60 if (!node->IsNative())
55 return; 61 return;
56 62
63 if (event_type == ui::AX_EVENT_FOCUS &&
64 node->GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
65 node->GetParent() &&
66 node->GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) {
je_julie(Not used) 2015/04/06 10:31:48 For this condition, how about extending IsListBoxO
67 node = node->GetParent();
68 SetFocus(node, false);
69 }
70
57 // Refer to AXObjectCache.mm (webkit). 71 // Refer to AXObjectCache.mm (webkit).
58 NSString* event_id = @""; 72 NSString* event_id = @"";
59 switch (event_type) { 73 switch (event_type) {
60 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: 74 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED:
61 if (node->GetRole() == ui::AX_ROLE_TREE) { 75 if (node->GetRole() == ui::AX_ROLE_TREE) {
62 event_id = NSAccessibilitySelectedRowsChangedNotification; 76 event_id = NSAccessibilitySelectedRowsChangedNotification;
63 } else { 77 } else {
64 event_id = NSAccessibilityFocusedUIElementChangedNotification; 78 event_id = NSAccessibilityFocusedUIElementChangedNotification;
65 BrowserAccessibility* active_descendant_focus = 79 BrowserAccessibility* active_descendant_focus =
66 GetActiveDescendantFocus(GetRoot()); 80 GetActiveDescendantFocus(GetRoot());
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 case ui::AX_EVENT_MENU_LIST_ITEM_SELECTED: 146 case ui::AX_EVENT_MENU_LIST_ITEM_SELECTED:
133 // Not used on Mac. 147 // Not used on Mac.
134 return; 148 return;
135 case ui::AX_EVENT_TEXT_CHANGED: 149 case ui::AX_EVENT_TEXT_CHANGED:
136 // Not used on Mac. 150 // Not used on Mac.
137 return; 151 return;
138 default: 152 default:
139 LOG(WARNING) << "Unknown accessibility event: " << event_type; 153 LOG(WARNING) << "Unknown accessibility event: " << event_type;
140 return; 154 return;
141 } 155 }
156
142 BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa(); 157 BrowserAccessibilityCocoa* native_node = node->ToBrowserAccessibilityCocoa();
143 DCHECK(native_node); 158 DCHECK(native_node);
144 NSAccessibilityPostNotification(native_node, event_id); 159 NSAccessibilityPostNotification(native_node, event_id);
145 } 160 }
146 161
147 void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished( 162 void BrowserAccessibilityManagerMac::OnAtomicUpdateFinished(
148 bool root_changed, const std::vector<ui::AXTreeDelegate::Change>& changes) { 163 bool root_changed, const std::vector<ui::AXTreeDelegate::Change>& changes) {
149 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes); 164 BrowserAccessibilityManager::OnAtomicUpdateFinished(root_changed, changes);
150 165
151 bool created_live_region = false; 166 bool created_live_region = false;
(...skipping 15 matching lines...) Expand all
167 // page for live regions once. By recreating the NSAccessibility 182 // page for live regions once. By recreating the NSAccessibility
168 // object for the root of the tree, we force VoiceOver to clear out its 183 // object for the root of the tree, we force VoiceOver to clear out its
169 // internal state and find newly-added live regions this time. 184 // internal state and find newly-added live regions this time.
170 BrowserAccessibilityMac* root = 185 BrowserAccessibilityMac* root =
171 static_cast<BrowserAccessibilityMac*>(GetRoot()); 186 static_cast<BrowserAccessibilityMac*>(GetRoot());
172 root->RecreateNativeObject(); 187 root->RecreateNativeObject();
173 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, root); 188 NotifyAccessibilityEvent(ui::AX_EVENT_CHILDREN_CHANGED, root);
174 } 189 }
175 190
176 } // namespace content 191 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698