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

Unified Diff: content/browser/accessibility/browser_accessibility_cocoa.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 Mac test 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
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_manager_mac.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/browser_accessibility_cocoa.mm
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm
index 7db4fc7fa29617bcb18363849b9908c754bcd916..227fe5475f38cbabc9cc7488f571abd70c136fcc 100644
--- a/content/browser/accessibility/browser_accessibility_cocoa.mm
+++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -761,35 +761,49 @@ NSDictionary* attributeToMethodNameMap = nil;
- (NSArray*)selectedChildren {
NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
-
BrowserAccessibilityManager* manager = browserAccessibility_->manager();
- BrowserAccessibility* focusedChild =
- manager->GetFocus(browserAccessibility_);
- if (focusedChild && focusedChild != browserAccessibility_) {
+ BrowserAccessibility* focusedChild = manager->GetFocus(browserAccessibility_);
+
+ // If it's not multiselectable, try to skip iterating over the
+ // children.
+ if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) {
// First try the focused child.
- [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()];
- } else {
+ if (focusedChild && focusedChild != browserAccessibility_) {
+ [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()];
+ return ret;
+ }
+
// Next try the active descendant.
int activeDescendantId;
if (browserAccessibility_->GetIntAttribute(
ui::AX_ATTR_ACTIVEDESCENDANT_ID, &activeDescendantId)) {
BrowserAccessibility* activeDescendant =
manager->GetFromID(activeDescendantId);
- if (activeDescendant)
+ if (activeDescendant) {
[ret addObject:activeDescendant->ToBrowserAccessibilityCocoa()];
- } else {
- // Otherwise return any children with the "selected" state, which
- // may come from aria-selected.
- uint32 childCount = browserAccessibility_->PlatformChildCount();
- for (uint32 index = 0; index < childCount; ++index) {
- BrowserAccessibility* child =
- browserAccessibility_->PlatformGetChild(index);
- if (child->HasState(ui::AX_STATE_SELECTED))
- [ret addObject:child->ToBrowserAccessibilityCocoa()];
+ return ret;
}
}
}
+ // If it's multiselectable or if the previous attempts failed,
+ // return any children with the "selected" state, which may
+ // come from aria-selected.
+ uint32 childCount = browserAccessibility_->PlatformChildCount();
+ for (uint32 index = 0; index < childCount; ++index) {
+ BrowserAccessibility* child =
+ browserAccessibility_->PlatformGetChild(index);
+ if (child->HasState(ui::AX_STATE_SELECTED))
+ [ret addObject:child->ToBrowserAccessibilityCocoa()];
+ }
+
+ // And if nothing's selected but one has focus, use the focused one.
+ if ([ret count] == 0 &&
+ focusedChild &&
+ focusedChild != browserAccessibility_) {
+ [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()];
+ }
+
return ret;
}
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_manager_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698