Index: content/browser/accessibility/browser_accessibility_manager_mac.mm |
diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm |
index 5fe7dde6a809ccc7181de3131dedd411c5d8783c..c389a5c2f3c96d4f0d3b4745e22d20898b596b1d 100644 |
--- a/content/browser/accessibility/browser_accessibility_manager_mac.mm |
+++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm |
@@ -132,20 +132,14 @@ |
} |
BrowserAccessibility* BrowserAccessibilityManagerMac::GetFocus() { |
- BrowserAccessibility* focus = BrowserAccessibilityManager::GetFocus(); |
- |
// On Mac, list boxes should always get focus on the whole list, otherwise |
// information about the number of selected items will never be reported. |
- // For editable combo boxes, focus should stay on the combo box so the user |
- // will not be taken out of the combo box while typing. |
- if (focus && (focus->GetRole() == ui::AX_ROLE_LIST_BOX || |
- (focus->GetRole() == ui::AX_ROLE_COMBO_BOX && |
- focus->HasState(ui::AX_STATE_EDITABLE)))) { |
- return focus; |
- } |
+ BrowserAccessibility* node = BrowserAccessibilityManager::GetFocus(); |
+ if (node && node->GetRole() == ui::AX_ROLE_LIST_BOX) |
+ return node; |
// For other roles, follow the active descendant. |
- return GetActiveDescendant(focus); |
+ return GetActiveDescendantFocus(node); |
} |
void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( |
@@ -154,6 +148,20 @@ |
BrowserAccessibility* node) { |
if (!node->IsNative()) |
return; |
+ |
+ if (event_type == ui::AX_EVENT_FOCUS) { |
+ BrowserAccessibility* active_descendant = GetActiveDescendantFocus(node); |
+ if (active_descendant) |
+ node = active_descendant; |
+ |
+ if (node->GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && |
+ node->HasState(ui::AX_STATE_SELECTED) && |
+ node->GetParent() && |
+ node->GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { |
+ node = node->GetParent(); |
+ SetFocus(*node); |
+ } |
+ } |
auto native_node = ToBrowserAccessibilityCocoa(node); |
DCHECK(native_node); |
@@ -170,10 +178,7 @@ |
// the combo box where the user might be typing. |
mac_notification = NSAccessibilitySelectedChildrenChangedNotification; |
} else { |
- // In all other cases we should post |
- // |NSAccessibilityFocusedUIElementChangedNotification|, but this is |
- // handled elsewhere. |
- return; |
+ mac_notification = NSAccessibilityFocusedUIElementChangedNotification; |
} |
break; |
case ui::AX_EVENT_AUTOCORRECTION_OCCURED: |