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

Side by Side Diff: content/browser/accessibility/browser_accessibility_manager_mac.mm

Issue 1899823002: 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, 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" 5 #include "content/browser/accessibility/browser_accessibility_manager_mac.h"
6 6
7 #import "base/mac/mac_util.h" 7 #import "base/mac/mac_util.h"
8 #import "base/mac/sdk_forward_declarations.h" 8 #import "base/mac/sdk_forward_declarations.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 // For other roles, follow the active descendant. 138 // For other roles, follow the active descendant.
139 return GetActiveDescendantFocus(node); 139 return GetActiveDescendantFocus(node);
140 } 140 }
141 141
142 void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent( 142 void BrowserAccessibilityManagerMac::NotifyAccessibilityEvent(
143 ui::AXEvent event_type, 143 ui::AXEvent event_type,
144 BrowserAccessibility* node) { 144 BrowserAccessibility* node) {
145 if (!node->IsNative()) 145 if (!node->IsNative())
146 return; 146 return;
147 147
148 if (event_type == ui::AX_EVENT_FOCUS) {
149 BrowserAccessibility* active_descendant = GetActiveDescendantFocus(node);
150 if (active_descendant)
151 node = active_descendant;
152
153 if (node->GetRole() == ui::AX_ROLE_LIST_BOX_OPTION &&
dmazzoni 2016/04/18 18:27:04 Deleting this code will break list boxes on Mac. V
154 node->HasState(ui::AX_STATE_SELECTED) &&
155 node->GetParent() &&
156 node->GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) {
157 node = node->GetParent();
158 SetFocus(*node);
159 }
160 }
161
162 auto native_node = ToBrowserAccessibilityCocoa(node); 148 auto native_node = ToBrowserAccessibilityCocoa(node);
163 DCHECK(native_node); 149 DCHECK(native_node);
164 150
165 // Refer to |AXObjectCache::postPlatformNotification| in WebKit source code. 151 // Refer to |AXObjectCache::postPlatformNotification| in WebKit source code.
166 NSString* mac_notification; 152 NSString* mac_notification;
167 switch (event_type) { 153 switch (event_type) {
168 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: 154 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED:
169 if (node->GetRole() == ui::AX_ROLE_TREE) { 155 if (node->GetRole() == ui::AX_ROLE_TREE) {
170 mac_notification = NSAccessibilitySelectedRowsChangedNotification; 156 mac_notification = NSAccessibilitySelectedRowsChangedNotification;
171 } else if (node->GetRole() == ui::AX_ROLE_COMBO_BOX) { 157 } else if (node->GetRole() == ui::AX_ROLE_COMBO_BOX) {
172 // Even though the selected item in the combo box has changed, we don't 158 // Even though the selected item in the combo box has changed, we don't
173 // want to post a focus change because this will take the focus out of 159 // want to post a focus change because this will take the focus out of
174 // the combo box where the user might be typing. 160 // the combo box where the user might be typing.
175 mac_notification = NSAccessibilitySelectedChildrenChangedNotification; 161 mac_notification = NSAccessibilitySelectedChildrenChangedNotification;
176 } else { 162 } else {
177 mac_notification = NSAccessibilityFocusedUIElementChangedNotification; 163 mac_notification = NSAccessibilityFocusedUIElementChangedNotification;
164 BrowserAccessibility* focus = GetFocus();
165 if (!focus)
166 return;
167 native_node = ToBrowserAccessibilityCocoa(focus);
178 } 168 }
179 break; 169 break;
180 case ui::AX_EVENT_AUTOCORRECTION_OCCURED: 170 case ui::AX_EVENT_AUTOCORRECTION_OCCURED:
181 mac_notification = NSAccessibilityAutocorrectionOccurredNotification; 171 mac_notification = NSAccessibilityAutocorrectionOccurredNotification;
182 break; 172 break;
183 case ui::AX_EVENT_FOCUS: 173 case ui::AX_EVENT_FOCUS:
184 mac_notification = NSAccessibilityFocusedUIElementChangedNotification; 174 mac_notification = NSAccessibilityFocusedUIElementChangedNotification;
185 break; 175 break;
186 case ui::AX_EVENT_LAYOUT_COMPLETE: 176 case ui::AX_EVENT_LAYOUT_COMPLETE:
187 mac_notification = NSAccessibilityLayoutCompleteNotification; 177 mac_notification = NSAccessibilityLayoutCompleteNotification;
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 } 441 }
452 442
453 return @{ 443 return @{
454 NSAccessibilityTextStateChangeTypeKey : @(AXTextStateChangeTypeEdit), 444 NSAccessibilityTextStateChangeTypeKey : @(AXTextStateChangeTypeEdit),
455 NSAccessibilityTextChangeValues : changes, 445 NSAccessibilityTextChangeValues : changes,
456 NSAccessibilityTextChangeElement : native_node 446 NSAccessibilityTextChangeElement : native_node
457 }; 447 };
458 } 448 }
459 449
460 } // namespace content 450 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698