Chromium Code Reviews| 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 <execinfo.h> | 5 #include <execinfo.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 9 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
| 10 | 10 |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 int32_t node_id; | 99 int32_t node_id; |
| 100 int offset; | 100 int offset; |
| 101 ui::AXTextAffinity affinity; | 101 ui::AXTextAffinity affinity; |
| 102 }; | 102 }; |
| 103 | 103 |
| 104 // VoiceOver uses -1 to mean "no limit" for AXResultsLimit. | 104 // VoiceOver uses -1 to mean "no limit" for AXResultsLimit. |
| 105 const int kAXResultsLimitNoLimit = -1; | 105 const int kAXResultsLimitNoLimit = -1; |
| 106 | 106 |
| 107 extern "C" { | 107 extern "C" { |
| 108 | 108 |
| 109 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5, | |
| 110 // 10.6, and 10.7. It allows accessibility clients to observe events posted on | |
| 111 // this object. | |
| 112 void NSAccessibilityUnregisterUniqueIdForUIElement(id element); | |
| 113 | |
| 114 // The following are private accessibility APIs required for cursor navigation | 109 // The following are private accessibility APIs required for cursor navigation |
| 115 // and text selection. VoiceOver started relying on them in Mac OS X 10.11. | 110 // and text selection. VoiceOver started relying on them in Mac OS X 10.11. |
| 116 #if !defined(MAC_OS_X_VERSION_10_11) || \ | 111 #if !defined(MAC_OS_X_VERSION_10_11) || \ |
| 117 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 | 112 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 |
| 118 | 113 |
| 119 AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, | 114 AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, |
| 120 const UInt8* bytes, | 115 const UInt8* bytes, |
| 121 CFIndex length); | 116 CFIndex length); |
| 122 | 117 |
| 123 const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker); | 118 const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 dict = nil; | 598 dict = nil; |
| 604 } | 599 } |
| 605 | 600 |
| 606 - (instancetype)initWithObject:(BrowserAccessibility*)accessibility { | 601 - (instancetype)initWithObject:(BrowserAccessibility*)accessibility { |
| 607 if ((self = [super init])) | 602 if ((self = [super init])) |
| 608 browserAccessibility_ = accessibility; | 603 browserAccessibility_ = accessibility; |
| 609 return self; | 604 return self; |
| 610 } | 605 } |
| 611 | 606 |
| 612 - (void)detach { | 607 - (void)detach { |
| 613 if (browserAccessibility_) | 608 if (!browserAccessibility_) |
| 614 NSAccessibilityUnregisterUniqueIdForUIElement(self); | 609 return; |
| 610 NSAccessibilityPostNotification( | |
| 611 self, NSAccessibilityUIElementDestroyedNotification); | |
| 615 browserAccessibility_ = nullptr; | 612 browserAccessibility_ = nullptr; |
| 616 } | 613 } |
| 617 | 614 |
| 618 - (NSString*)accessKey { | 615 - (NSString*)accessKey { |
| 619 if (![self instanceActive]) | 616 if (![self instanceActive]) |
| 620 return nil; | 617 return nil; |
| 621 return NSStringForStringAttribute( | 618 return NSStringForStringAttribute( |
| 622 browserAccessibility_, ui::AX_ATTR_ACCESS_KEY); | 619 browserAccessibility_, ui::AX_ATTR_ACCESS_KEY); |
| 623 } | 620 } |
| 624 | 621 |
| (...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2873 return ([self hash] == [object hash]); | 2870 return ([self hash] == [object hash]); |
| 2874 } | 2871 } |
| 2875 | 2872 |
| 2876 - (NSUInteger)hash { | 2873 - (NSUInteger)hash { |
| 2877 // Potentially called during dealloc. | 2874 // Potentially called during dealloc. |
| 2878 if (![self instanceActive]) | 2875 if (![self instanceActive]) |
| 2879 return [super hash]; | 2876 return [super hash]; |
| 2880 return browserAccessibility_->GetId(); | 2877 return browserAccessibility_->GetId(); |
| 2881 } | 2878 } |
| 2882 | 2879 |
| 2883 - (BOOL)accessibilityShouldUseUniqueId { | 2880 - (BOOL)accessibilityNotifiesWhenDestroyed { |
| 2881 // Indicate that BrowserAccessibilityCocoa will post a notification when it's | |
| 2882 // destroyed (see - detach). This allows VoiceOver to do some internal | |
|
tapted
2016/10/04 08:17:39
nit: -detach (no space)
Patti Lor
2016/10/05 05:47:23
Done.
| |
| 2883 // things more efficiently. | |
| 2884 return YES; | 2884 return YES; |
| 2885 } | 2885 } |
| 2886 | 2886 |
| 2887 @end | 2887 @end |
| OLD | NEW |