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

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 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_cocoa.mm
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm
index 9781913557fe81c12b348564a5b04615cdbf4cb2..0a4f606ce3549942b79362cb47bc979f5da8f8b3 100644
--- a/content/browser/accessibility/browser_accessibility_cocoa.mm
+++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -758,34 +758,42 @@ NSDictionary* attributeToMethodNameMap = nil;
- (NSArray*)selectedChildren {
NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease];
- BrowserAccessibilityManager* manager = browserAccessibility_->manager();
- BrowserAccessibility* focusedChild =
- manager->GetFocus(browserAccessibility_);
- if (focusedChild && focusedChild != 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 {
+ BrowserAccessibilityManager* manager = browserAccessibility_->manager();
+ BrowserAccessibility* focusedChild =
+ manager->GetFocus(browserAccessibility_);
+ 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()];
+ }
+
return ret;
}

Powered by Google App Engine
This is Rietveld 408576698