| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 NSString* const NSAccessibilityLayoutCompleteNotification = | 51 NSString* const NSAccessibilityLayoutCompleteNotification = |
| 52 @"AXLayoutComplete"; | 52 @"AXLayoutComplete"; |
| 53 NSString* const NSAccessibilityLoadCompleteNotification = | 53 NSString* const NSAccessibilityLoadCompleteNotification = |
| 54 @"AXLoadComplete"; | 54 @"AXLoadComplete"; |
| 55 NSString* const NSAccessibilityInvalidStatusChangedNotification = | 55 NSString* const NSAccessibilityInvalidStatusChangedNotification = |
| 56 @"AXInvalidStatusChanged"; | 56 @"AXInvalidStatusChanged"; |
| 57 NSString* const NSAccessibilityLiveRegionChangedNotification = | 57 NSString* const NSAccessibilityLiveRegionChangedNotification = |
| 58 @"AXLiveRegionChanged"; | 58 @"AXLiveRegionChanged"; |
| 59 NSString* const NSAccessibilityMenuItemSelectedNotification = | 59 NSString* const NSAccessibilityMenuItemSelectedNotification = |
| 60 @"AXMenuItemSelected"; | 60 @"AXMenuItemSelected"; |
| 61 |
| 62 // Attributes used for NSAccessibilitySelectedTextChangedNotification. |
| 61 NSString* const NSAccessibilityTextStateChangeTypeKey = | 63 NSString* const NSAccessibilityTextStateChangeTypeKey = |
| 62 @"AXTextStateChangeType"; | 64 @"AXTextStateChangeType"; |
| 63 NSString* const NSAccessibilityTextStateSyncKey = @"AXTextStateSync"; | 65 NSString* const NSAccessibilityTextStateSyncKey = @"AXTextStateSync"; |
| 64 NSString* const NSAccessibilityTextSelectionDirection = | 66 NSString* const NSAccessibilityTextSelectionDirection = |
| 65 @"AXTextSelectionDirection"; | 67 @"AXTextSelectionDirection"; |
| 66 NSString* const NSAccessibilityTextSelectionGranularity = | 68 NSString* const NSAccessibilityTextSelectionGranularity = |
| 67 @"AXTextSelectionGranularity"; | 69 @"AXTextSelectionGranularity"; |
| 68 NSString* const NSAccessibilityTextSelectionChangedFocus = | 70 NSString* const NSAccessibilityTextSelectionChangedFocus = |
| 69 @"AXTextSelectionChangedFocus"; | 71 @"AXTextSelectionChangedFocus"; |
| 70 NSString* const NSAccessibilityTextChangeElement = | 72 NSString* const NSAccessibilitySelectedTextMarkerRangeAttribute = |
| 71 @"AXAccessibilityTextChangeElement"; | 73 @"AXSelectedTextMarkerRange"; |
| 74 NSString* const NSAccessibilityTextChangeElement = @"AXTextChangeElement"; |
| 72 | 75 |
| 73 } // namespace | 76 } // namespace |
| 74 | 77 |
| 75 namespace content { | 78 namespace content { |
| 76 | 79 |
| 77 // static | 80 // static |
| 78 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( | 81 BrowserAccessibilityManager* BrowserAccessibilityManager::Create( |
| 79 const ui::AXTreeUpdate& initial_tree, | 82 const ui::AXTreeUpdate& initial_tree, |
| 80 BrowserAccessibilityDelegate* delegate, | 83 BrowserAccessibilityDelegate* delegate, |
| 81 BrowserAccessibilityFactory* factory) { | 84 BrowserAccessibilityFactory* factory) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 mac_notification = NSAccessibilitySelectedChildrenChangedNotification; | 181 mac_notification = NSAccessibilitySelectedChildrenChangedNotification; |
| 179 } | 182 } |
| 180 break; | 183 break; |
| 181 case ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED: { | 184 case ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED: { |
| 182 mac_notification = NSAccessibilitySelectedTextChangedNotification; | 185 mac_notification = NSAccessibilitySelectedTextChangedNotification; |
| 183 if (base::mac::IsOSElCapitanOrLater()) { | 186 if (base::mac::IsOSElCapitanOrLater()) { |
| 184 // |NSAccessibilityPostNotificationWithUserInfo| should be used on OS X | 187 // |NSAccessibilityPostNotificationWithUserInfo| should be used on OS X |
| 185 // 10.11 or later to notify Voiceover about text selection changes. This | 188 // 10.11 or later to notify Voiceover about text selection changes. This |
| 186 // API has been present on versions of OS X since 10.7 but doesn't | 189 // API has been present on versions of OS X since 10.7 but doesn't |
| 187 // appear to be needed by Voiceover before version 10.11. | 190 // appear to be needed by Voiceover before version 10.11. |
| 191 // WebKit fires a notification both on the focused object and the root. |
| 188 NSDictionary* user_info = | 192 NSDictionary* user_info = |
| 189 GetUserInfoForSelectedTextChangedNotification(); | 193 GetUserInfoForSelectedTextChangedNotification(); |
| 194 |
| 195 BrowserAccessibility* focus = GetFocus(); |
| 196 if (!focus) |
| 197 return; |
| 190 NSAccessibilityPostNotificationWithUserInfo( | 198 NSAccessibilityPostNotificationWithUserInfo( |
| 191 native_node, mac_notification, user_info); | 199 focus->ToBrowserAccessibilityCocoa(), mac_notification, user_info); |
| 200 |
| 201 BrowserAccessibility* root = GetRoot(); |
| 202 if (!root) |
| 203 return; |
| 204 NSAccessibilityPostNotificationWithUserInfo( |
| 205 root->ToBrowserAccessibilityCocoa(), mac_notification, user_info); |
| 192 return; | 206 return; |
| 193 } | 207 } |
| 194 break; | 208 break; |
| 195 } | 209 } |
| 196 case ui::AX_EVENT_CHECKED_STATE_CHANGED: | 210 case ui::AX_EVENT_CHECKED_STATE_CHANGED: |
| 197 case ui::AX_EVENT_VALUE_CHANGED: | 211 case ui::AX_EVENT_VALUE_CHANGED: |
| 198 mac_notification = NSAccessibilityValueChangedNotification; | 212 mac_notification = NSAccessibilityValueChangedNotification; |
| 199 break; | 213 break; |
| 200 // TODO(nektar): Need to add an event for live region created. | 214 // TODO(nektar): Need to add an event for live region created. |
| 201 case ui::AX_EVENT_LIVE_REGION_CHANGED: | 215 case ui::AX_EVENT_LIVE_REGION_CHANGED: |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 [user_info setObject:[NSNumber numberWithInt:AXTextStateChangeTypeUnknown] | 303 [user_info setObject:[NSNumber numberWithInt:AXTextStateChangeTypeUnknown] |
| 290 forKey:NSAccessibilityTextStateChangeTypeKey]; | 304 forKey:NSAccessibilityTextStateChangeTypeKey]; |
| 291 [user_info | 305 [user_info |
| 292 setObject:[NSNumber numberWithInt:AXTextSelectionDirectionUnknown] | 306 setObject:[NSNumber numberWithInt:AXTextSelectionDirectionUnknown] |
| 293 forKey:NSAccessibilityTextSelectionDirection]; | 307 forKey:NSAccessibilityTextSelectionDirection]; |
| 294 [user_info | 308 [user_info |
| 295 setObject:[NSNumber numberWithInt:AXTextSelectionGranularityUnknown] | 309 setObject:[NSNumber numberWithInt:AXTextSelectionGranularityUnknown] |
| 296 forKey:NSAccessibilityTextSelectionGranularity]; | 310 forKey:NSAccessibilityTextSelectionGranularity]; |
| 297 [user_info setObject:[NSNumber numberWithBool:YES] | 311 [user_info setObject:[NSNumber numberWithBool:YES] |
| 298 forKey:NSAccessibilityTextSelectionChangedFocus]; | 312 forKey:NSAccessibilityTextSelectionChangedFocus]; |
| 299 // TODO(nektar): Set selected text marker range. | |
| 300 | 313 |
| 301 int32_t focus_id = GetTreeData().sel_focus_object_id; | 314 int32_t focus_id = GetTreeData().sel_focus_object_id; |
| 302 BrowserAccessibility* focus_object = GetFromID(focus_id); | 315 BrowserAccessibility* focus_object = GetFromID(focus_id); |
| 303 if (focus_object) { | 316 if (focus_object) { |
| 304 focus_object = focus_object->GetClosestPlatformObject(); | 317 focus_object = focus_object->GetClosestPlatformObject(); |
| 305 auto native_focus_object = focus_object->ToBrowserAccessibilityCocoa(); | 318 auto native_focus_object = focus_object->ToBrowserAccessibilityCocoa(); |
| 306 if (native_focus_object) | 319 if (native_focus_object) { |
| 320 [user_info setObject:[native_focus_object selectedTextMarkerRange] |
| 321 forKey:NSAccessibilitySelectedTextMarkerRangeAttribute]; |
| 307 [user_info setObject:native_focus_object | 322 [user_info setObject:native_focus_object |
| 308 forKey:NSAccessibilityTextChangeElement]; | 323 forKey:NSAccessibilityTextChangeElement]; |
| 324 } |
| 309 } | 325 } |
| 310 | 326 |
| 311 return user_info; | 327 return user_info; |
| 312 } | 328 } |
| 313 | 329 |
| 314 } // namespace content | 330 } // namespace content |
| OLD | NEW |