OLD | NEW |
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 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #import "base/mac/mac_util.h" | 9 #import "base/mac/mac_util.h" |
10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 | 133 |
134 if (node->GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && | 134 if (node->GetRole() == ui::AX_ROLE_LIST_BOX_OPTION && |
135 node->HasState(ui::AX_STATE_SELECTED) && | 135 node->HasState(ui::AX_STATE_SELECTED) && |
136 node->GetParent() && | 136 node->GetParent() && |
137 node->GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { | 137 node->GetParent()->GetRole() == ui::AX_ROLE_LIST_BOX) { |
138 node = node->GetParent(); | 138 node = node->GetParent(); |
139 SetFocus(*node); | 139 SetFocus(*node); |
140 } | 140 } |
141 } | 141 } |
142 | 142 |
143 auto native_node = node->ToBrowserAccessibilityCocoa(); | 143 auto native_node = ToBrowserAccessibilityCocoa(node); |
144 DCHECK(native_node); | 144 DCHECK(native_node); |
145 | 145 |
146 // Refer to |AXObjectCache::postPlatformNotification| in WebKit source code. | 146 // Refer to |AXObjectCache::postPlatformNotification| in WebKit source code. |
147 NSString* mac_notification; | 147 NSString* mac_notification; |
148 switch (event_type) { | 148 switch (event_type) { |
149 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: | 149 case ui::AX_EVENT_ACTIVEDESCENDANTCHANGED: |
150 if (node->GetRole() == ui::AX_ROLE_TREE) { | 150 if (node->GetRole() == ui::AX_ROLE_TREE) { |
151 mac_notification = NSAccessibilitySelectedRowsChangedNotification; | 151 mac_notification = NSAccessibilitySelectedRowsChangedNotification; |
152 } else if (node->GetRole() == ui::AX_ROLE_COMBO_BOX) { | 152 } else if (node->GetRole() == ui::AX_ROLE_COMBO_BOX) { |
153 // Even though the selected item in the combo box has changed, we don't | 153 // Even though the selected item in the combo box has changed, we don't |
(...skipping 26 matching lines...) Expand all Loading... |
180 } else { | 180 } else { |
181 mac_notification = NSAccessibilitySelectedChildrenChangedNotification; | 181 mac_notification = NSAccessibilitySelectedChildrenChangedNotification; |
182 } | 182 } |
183 break; | 183 break; |
184 case ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED: { | 184 case ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED: { |
185 mac_notification = NSAccessibilitySelectedTextChangedNotification; | 185 mac_notification = NSAccessibilitySelectedTextChangedNotification; |
186 // WebKit fires a notification both on the focused object and the root. | 186 // WebKit fires a notification both on the focused object and the root. |
187 BrowserAccessibility* focus = GetFocus(); | 187 BrowserAccessibility* focus = GetFocus(); |
188 if (!focus) | 188 if (!focus) |
189 break; | 189 break; |
190 NSAccessibilityPostNotification(focus->ToBrowserAccessibilityCocoa(), | 190 NSAccessibilityPostNotification(ToBrowserAccessibilityCocoa(focus), |
191 mac_notification); | 191 mac_notification); |
192 | 192 |
193 if (base::mac::IsOSElCapitanOrLater()) { | 193 if (base::mac::IsOSElCapitanOrLater()) { |
194 // |NSAccessibilityPostNotificationWithUserInfo| should be used on OS X | 194 // |NSAccessibilityPostNotificationWithUserInfo| should be used on OS X |
195 // 10.11 or later to notify Voiceover about text selection changes. This | 195 // 10.11 or later to notify Voiceover about text selection changes. This |
196 // API has been present on versions of OS X since 10.7 but doesn't | 196 // API has been present on versions of OS X since 10.7 but doesn't |
197 // appear to be needed by Voiceover before version 10.11. | 197 // appear to be needed by Voiceover before version 10.11. |
198 NSDictionary* user_info = | 198 NSDictionary* user_info = |
199 GetUserInfoForSelectedTextChangedNotification(); | 199 GetUserInfoForSelectedTextChangedNotification(); |
200 | 200 |
201 BrowserAccessibility* root = GetRoot(); | 201 BrowserAccessibility* root = GetRoot(); |
202 if (!root) | 202 if (!root) |
203 return; | 203 return; |
204 | 204 |
205 NSAccessibilityPostNotificationWithUserInfo( | 205 NSAccessibilityPostNotificationWithUserInfo( |
206 focus->ToBrowserAccessibilityCocoa(), mac_notification, user_info); | 206 ToBrowserAccessibilityCocoa(focus), mac_notification, user_info); |
207 NSAccessibilityPostNotificationWithUserInfo( | 207 NSAccessibilityPostNotificationWithUserInfo( |
208 root->ToBrowserAccessibilityCocoa(), mac_notification, user_info); | 208 ToBrowserAccessibilityCocoa(root), mac_notification, user_info); |
209 return; | 209 return; |
210 } | 210 } |
211 break; | 211 break; |
212 } | 212 } |
213 case ui::AX_EVENT_CHECKED_STATE_CHANGED: | 213 case ui::AX_EVENT_CHECKED_STATE_CHANGED: |
214 case ui::AX_EVENT_VALUE_CHANGED: | 214 case ui::AX_EVENT_VALUE_CHANGED: |
215 mac_notification = NSAccessibilityValueChangedNotification; | 215 mac_notification = NSAccessibilityValueChangedNotification; |
216 break; | 216 break; |
217 // TODO(nektar): Need to add an event for live region created. | 217 // TODO(nektar): Need to add an event for live region created. |
218 case ui::AX_EVENT_LIVE_REGION_CHANGED: | 218 case ui::AX_EVENT_LIVE_REGION_CHANGED: |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 [user_info | 311 [user_info |
312 setObject:[NSNumber numberWithInt:AXTextSelectionGranularityUnknown] | 312 setObject:[NSNumber numberWithInt:AXTextSelectionGranularityUnknown] |
313 forKey:NSAccessibilityTextSelectionGranularity]; | 313 forKey:NSAccessibilityTextSelectionGranularity]; |
314 [user_info setObject:[NSNumber numberWithBool:YES] | 314 [user_info setObject:[NSNumber numberWithBool:YES] |
315 forKey:NSAccessibilityTextSelectionChangedFocus]; | 315 forKey:NSAccessibilityTextSelectionChangedFocus]; |
316 | 316 |
317 int32_t focus_id = GetTreeData().sel_focus_object_id; | 317 int32_t focus_id = GetTreeData().sel_focus_object_id; |
318 BrowserAccessibility* focus_object = GetFromID(focus_id); | 318 BrowserAccessibility* focus_object = GetFromID(focus_id); |
319 if (focus_object) { | 319 if (focus_object) { |
320 focus_object = focus_object->GetClosestPlatformObject(); | 320 focus_object = focus_object->GetClosestPlatformObject(); |
321 auto native_focus_object = focus_object->ToBrowserAccessibilityCocoa(); | 321 auto native_focus_object = ToBrowserAccessibilityCocoa(focus_object); |
322 if (native_focus_object) { | 322 if (native_focus_object) { |
323 [user_info setObject:[native_focus_object selectedTextMarkerRange] | 323 [user_info setObject:[native_focus_object selectedTextMarkerRange] |
324 forKey:NSAccessibilitySelectedTextMarkerRangeAttribute]; | 324 forKey:NSAccessibilitySelectedTextMarkerRangeAttribute]; |
325 [user_info setObject:native_focus_object | 325 [user_info setObject:native_focus_object |
326 forKey:NSAccessibilityTextChangeElement]; | 326 forKey:NSAccessibilityTextChangeElement]; |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 return user_info; | 330 return user_info; |
331 } | 331 } |
332 | 332 |
333 } // namespace content | 333 } // namespace content |
OLD | NEW |