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 "base/bind.h" | 7 #include "base/bind.h" |
8 #import "base/mac/mac_util.h" | 8 #import "base/mac/mac_util.h" |
9 #import "base/mac/scoped_nsobject.h" | 9 #import "base/mac/scoped_nsobject.h" |
10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 } else { | 215 } else { |
216 mac_notification = NSAccessibilitySelectedChildrenChangedNotification; | 216 mac_notification = NSAccessibilitySelectedChildrenChangedNotification; |
217 } | 217 } |
218 break; | 218 break; |
219 case ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED: { | 219 case ui::AX_EVENT_DOCUMENT_SELECTION_CHANGED: { |
220 mac_notification = NSAccessibilitySelectedTextChangedNotification; | 220 mac_notification = NSAccessibilitySelectedTextChangedNotification; |
221 // WebKit fires a notification both on the focused object and the root. | 221 // WebKit fires a notification both on the focused object and the root. |
222 BrowserAccessibility* focus = GetFocus(); | 222 BrowserAccessibility* focus = GetFocus(); |
223 if (!focus) | 223 if (!focus) |
224 break; // Just fire a notification on the root. | 224 break; // Just fire a notification on the root. |
225 NSAccessibilityPostNotification(ToBrowserAccessibilityCocoa(focus), | |
226 mac_notification); | |
227 | 225 |
228 if (base::mac::IsAtLeastOS10_11()) { | 226 if (base::mac::IsAtLeastOS10_11()) { |
229 // |NSAccessibilityPostNotificationWithUserInfo| should be used on OS X | 227 // |NSAccessibilityPostNotificationWithUserInfo| should be used on OS X |
230 // 10.11 or later to notify Voiceover about text selection changes. This | 228 // 10.11 or later to notify Voiceover about text selection changes. This |
231 // API has been present on versions of OS X since 10.7 but doesn't | 229 // API has been present on versions of OS X since 10.7 but doesn't |
232 // appear to be needed by Voiceover before version 10.11. | 230 // appear to be needed by Voiceover before version 10.11. |
233 NSDictionary* user_info = | 231 NSDictionary* user_info = |
234 GetUserInfoForSelectedTextChangedNotification(); | 232 GetUserInfoForSelectedTextChangedNotification(); |
235 | 233 |
236 BrowserAccessibility* root = GetRoot(); | 234 BrowserAccessibility* root = GetRoot(); |
237 if (!root) | 235 if (!root) |
238 return; | 236 return; |
239 | 237 |
240 NSAccessibilityPostNotificationWithUserInfo( | 238 NSAccessibilityPostNotificationWithUserInfo( |
241 ToBrowserAccessibilityCocoa(focus), mac_notification, user_info); | 239 ToBrowserAccessibilityCocoa(focus), mac_notification, user_info); |
242 NSAccessibilityPostNotificationWithUserInfo( | 240 NSAccessibilityPostNotificationWithUserInfo( |
243 ToBrowserAccessibilityCocoa(root), mac_notification, user_info); | 241 ToBrowserAccessibilityCocoa(root), mac_notification, user_info); |
244 return; | 242 return; |
| 243 } else { |
| 244 NSAccessibilityPostNotification(ToBrowserAccessibilityCocoa(focus), |
| 245 mac_notification); |
245 } | 246 } |
246 break; | 247 break; |
247 } | 248 } |
248 case ui::AX_EVENT_CHECKED_STATE_CHANGED: | 249 case ui::AX_EVENT_CHECKED_STATE_CHANGED: |
249 mac_notification = NSAccessibilityValueChangedNotification; | 250 mac_notification = NSAccessibilityValueChangedNotification; |
250 break; | 251 break; |
251 case ui::AX_EVENT_VALUE_CHANGED: | 252 case ui::AX_EVENT_VALUE_CHANGED: |
252 mac_notification = NSAccessibilityValueChangedNotification; | 253 mac_notification = NSAccessibilityValueChangedNotification; |
253 if (base::mac::IsAtLeastOS10_11() && text_edits_.size()) { | 254 if (base::mac::IsAtLeastOS10_11() && text_edits_.size()) { |
254 // It seems that we don't need to distinguish between deleted and | 255 // It seems that we don't need to distinguish between deleted and |
(...skipping 26 matching lines...) Expand all Loading... |
281 native_node, NSAccessibilityLiveRegionCreatedNotification); | 282 native_node, NSAccessibilityLiveRegionCreatedNotification); |
282 // Voiceover requires a live region changed notification to actually | 283 // Voiceover requires a live region changed notification to actually |
283 // announce the live region. | 284 // announce the live region. |
284 NotifyAccessibilityEvent(BrowserAccessibilityEvent::FromTreeChange, | 285 NotifyAccessibilityEvent(BrowserAccessibilityEvent::FromTreeChange, |
285 ui::AX_EVENT_LIVE_REGION_CHANGED, node); | 286 ui::AX_EVENT_LIVE_REGION_CHANGED, node); |
286 return; | 287 return; |
287 case ui::AX_EVENT_LIVE_REGION_CHANGED: { | 288 case ui::AX_EVENT_LIVE_REGION_CHANGED: { |
288 // Voiceover seems to drop live region changed notifications if they come | 289 // Voiceover seems to drop live region changed notifications if they come |
289 // too soon after a live region created notification. | 290 // too soon after a live region created notification. |
290 // TODO(nektar): Limit the number of changed notifications as well. | 291 // TODO(nektar): Limit the number of changed notifications as well. |
| 292 |
| 293 if (never_suppress_or_delay_events_for_testing_) { |
| 294 NSAccessibilityPostNotification( |
| 295 native_node, NSAccessibilityLiveRegionChangedNotification); |
| 296 return; |
| 297 } |
| 298 |
291 base::scoped_nsobject<BrowserAccessibilityCocoa> retained_node( | 299 base::scoped_nsobject<BrowserAccessibilityCocoa> retained_node( |
292 [native_node retain]); | 300 [native_node retain]); |
293 BrowserThread::PostDelayedTask( | 301 BrowserThread::PostDelayedTask( |
294 BrowserThread::UI, FROM_HERE, | 302 BrowserThread::UI, FROM_HERE, |
295 base::Bind( | 303 base::Bind( |
296 [](base::scoped_nsobject<BrowserAccessibilityCocoa> node) { | 304 [](base::scoped_nsobject<BrowserAccessibilityCocoa> node) { |
297 if (node && [node instanceActive]) { | 305 if (node && [node instanceActive]) { |
298 NSAccessibilityPostNotification( | 306 NSAccessibilityPostNotification( |
299 node, NSAccessibilityLiveRegionChangedNotification); | 307 node, NSAccessibilityLiveRegionChangedNotification); |
300 } | 308 } |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 NSAccessibilityTextChangeValues : changes, | 486 NSAccessibilityTextChangeValues : changes, |
479 NSAccessibilityTextChangeElement : native_node | 487 NSAccessibilityTextChangeElement : native_node |
480 }; | 488 }; |
481 } | 489 } |
482 | 490 |
483 NSView* BrowserAccessibilityManagerMac::GetParentView() { | 491 NSView* BrowserAccessibilityManagerMac::GetParentView() { |
484 return delegate() ? delegate()->AccessibilityGetAcceleratedWidget() : nullptr; | 492 return delegate() ? delegate()->AccessibilityGetAcceleratedWidget() : nullptr; |
485 } | 493 } |
486 | 494 |
487 } // namespace content | 495 } // namespace content |
OLD | NEW |