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 |
| 11 #include <map> | 11 #include <map> |
| 12 | 12 |
| 13 #include "base/mac/foundation_util.h" | 13 #include "base/mac/foundation_util.h" |
| 14 #include "base/mac/scoped_cftyperef.h" | 14 #include "base/mac/scoped_cftyperef.h" |
| 15 #import "base/mac/sdk_forward_declarations.h" | |
| 15 #include "base/strings/string16.h" | 16 #include "base/strings/string16.h" |
| 16 #include "base/strings/sys_string_conversions.h" | 17 #include "base/strings/sys_string_conversions.h" |
| 17 #include "base/strings/utf_string_conversions.h" | 18 #include "base/strings/utf_string_conversions.h" |
| 18 #include "content/app/strings/grit/content_strings.h" | 19 #include "content/app/strings/grit/content_strings.h" |
| 19 #include "content/browser/accessibility/browser_accessibility_mac.h" | 20 #include "content/browser/accessibility/browser_accessibility_mac.h" |
| 20 #include "content/browser/accessibility/browser_accessibility_manager.h" | 21 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 21 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 22 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
| 22 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" | 23 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" |
| 23 #include "content/public/common/content_client.h" | 24 #include "content/public/common/content_client.h" |
| 24 #include "third_party/skia/include/core/SkColor.h" | 25 #include "third_party/skia/include/core/SkColor.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 100 int32_t node_id; | 101 int32_t node_id; |
| 101 int offset; | 102 int offset; |
| 102 ui::AXTextAffinity affinity; | 103 ui::AXTextAffinity affinity; |
| 103 }; | 104 }; |
| 104 | 105 |
| 105 // VoiceOver uses -1 to mean "no limit" for AXResultsLimit. | 106 // VoiceOver uses -1 to mean "no limit" for AXResultsLimit. |
| 106 const int kAXResultsLimitNoLimit = -1; | 107 const int kAXResultsLimitNoLimit = -1; |
| 107 | 108 |
| 108 extern "C" { | 109 extern "C" { |
| 109 | 110 |
| 110 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5, | |
| 111 // 10.6, and 10.7. It allows accessibility clients to observe events posted on | |
| 112 // this object. | |
| 113 void NSAccessibilityUnregisterUniqueIdForUIElement(id element); | |
| 114 | |
| 115 // The following are private accessibility APIs required for cursor navigation | 111 // The following are private accessibility APIs required for cursor navigation |
| 116 // and text selection. VoiceOver started relying on them in Mac OS X 10.11. | 112 // and text selection. VoiceOver started relying on them in Mac OS X 10.11. |
| 117 #if !defined(MAC_OS_X_VERSION_10_11) || \ | 113 #if !defined(MAC_OS_X_VERSION_10_11) || \ |
| 118 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 | 114 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 |
| 119 | 115 |
| 120 AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, | 116 AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, |
| 121 const UInt8* bytes, | 117 const UInt8* bytes, |
| 122 CFIndex length); | 118 CFIndex length); |
| 123 | 119 |
| 124 const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker); | 120 const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker); |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 596 dict = nil; | 592 dict = nil; |
| 597 } | 593 } |
| 598 | 594 |
| 599 - (instancetype)initWithObject:(BrowserAccessibility*)accessibility { | 595 - (instancetype)initWithObject:(BrowserAccessibility*)accessibility { |
| 600 if ((self = [super init])) | 596 if ((self = [super init])) |
| 601 browserAccessibility_ = accessibility; | 597 browserAccessibility_ = accessibility; |
| 602 return self; | 598 return self; |
| 603 } | 599 } |
| 604 | 600 |
| 605 - (void)detach { | 601 - (void)detach { |
| 606 if (browserAccessibility_) | 602 if (!browserAccessibility_) |
| 607 NSAccessibilityUnregisterUniqueIdForUIElement(self); | 603 return; |
| 604 NSAccessibilityPostNotification( | |
| 605 self, NSAccessibilityUIElementDestroyedNotification); | |
| 606 NSAccessibilityUnregisterUniqueIdForUIElement(self); | |
| 608 browserAccessibility_ = nullptr; | 607 browserAccessibility_ = nullptr; |
| 609 } | 608 } |
| 610 | 609 |
| 611 - (NSString*)accessKey { | 610 - (NSString*)accessKey { |
| 612 if (![self instanceActive]) | 611 if (![self instanceActive]) |
| 613 return nil; | 612 return nil; |
| 614 return NSStringForStringAttribute( | 613 return NSStringForStringAttribute( |
| 615 browserAccessibility_, ui::AX_ATTR_ACCESS_KEY); | 614 browserAccessibility_, ui::AX_ATTR_ACCESS_KEY); |
| 616 } | 615 } |
| 617 | 616 |
| (...skipping 2228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2846 return ([self hash] == [object hash]); | 2845 return ([self hash] == [object hash]); |
| 2847 } | 2846 } |
| 2848 | 2847 |
| 2849 - (NSUInteger)hash { | 2848 - (NSUInteger)hash { |
| 2850 // Potentially called during dealloc. | 2849 // Potentially called during dealloc. |
| 2851 if (![self instanceActive]) | 2850 if (![self instanceActive]) |
| 2852 return [super hash]; | 2851 return [super hash]; |
| 2853 return browserAccessibility_->GetId(); | 2852 return browserAccessibility_->GetId(); |
| 2854 } | 2853 } |
| 2855 | 2854 |
| 2855 - (BOOL)accessibilityNotifiesWhenDestroyed { | |
| 2856 return YES; | |
|
tapted
2016/09/26 05:19:17
Comment here why this is done? Reading the comment
Patti Lor
2016/09/28 00:29:14
Ah - I think this might actually not be needed (at
| |
| 2857 } | |
| 2858 | |
| 2856 - (BOOL)accessibilityShouldUseUniqueId { | 2859 - (BOOL)accessibilityShouldUseUniqueId { |
| 2857 return YES; | 2860 return YES; |
| 2858 } | 2861 } |
| 2859 | 2862 |
| 2860 @end | 2863 @end |
| OLD | NEW |