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

Unified Diff: content/browser/accessibility/browser_accessibility_manager_mac.mm

Issue 2027683002: Reland of Uses the activedescendant_changed event received from Blink to fire the right focus event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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_manager_mac.mm
diff --git a/content/browser/accessibility/browser_accessibility_manager_mac.mm b/content/browser/accessibility/browser_accessibility_manager_mac.mm
index c389a5c2f3c96d4f0d3b4745e22d20898b596b1d..5fe7dde6a809ccc7181de3131dedd411c5d8783c 100644
--- a/content/browser/accessibility/browser_accessibility_manager_mac.mm
+++ b/content/browser/accessibility/browser_accessibility_manager_mac.mm
@@ -132,14 +132,20 @@
}
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.
- BrowserAccessibility* node = BrowserAccessibilityManager::GetFocus();
- if (node && node->GetRole() == ui::AX_ROLE_LIST_BOX)
- return node;
+ // 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;
+ }
// For other roles, follow the active descendant.
- return GetActiveDescendantFocus(node);
+ return GetActiveDescendant(focus);
}
void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent(
@@ -148,20 +154,6 @@
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);
@@ -178,7 +170,10 @@
// the combo box where the user might be typing.
mac_notification = NSAccessibilitySelectedChildrenChangedNotification;
} else {
- mac_notification = NSAccessibilityFocusedUIElementChangedNotification;
+ // In all other cases we should post
+ // |NSAccessibilityFocusedUIElementChangedNotification|, but this is
+ // handled elsewhere.
+ return;
}
break;
case ui::AX_EVENT_AUTOCORRECTION_OCCURED:

Powered by Google App Engine
This is Rietveld 408576698