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

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

Issue 2024053003: Revert 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 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:

Powered by Google App Engine
This is Rietveld 408576698