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" | |
|
tapted
2016/09/28 01:03:19
nit: remove?
Patti Lor
2016/10/04 05:45:14
Done.
| |
| 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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 99 int32_t node_id; | 100 int32_t node_id; |
| 100 int offset; | 101 int offset; |
| 101 ui::AXTextAffinity affinity; | 102 ui::AXTextAffinity affinity; |
| 102 }; | 103 }; |
| 103 | 104 |
| 104 // VoiceOver uses -1 to mean "no limit" for AXResultsLimit. | 105 // VoiceOver uses -1 to mean "no limit" for AXResultsLimit. |
| 105 const int kAXResultsLimitNoLimit = -1; | 106 const int kAXResultsLimitNoLimit = -1; |
| 106 | 107 |
| 107 extern "C" { | 108 extern "C" { |
| 108 | 109 |
| 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 | 110 // 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. | 111 // and text selection. VoiceOver started relying on them in Mac OS X 10.11. |
| 116 #if !defined(MAC_OS_X_VERSION_10_11) || \ | 112 #if !defined(MAC_OS_X_VERSION_10_11) || \ |
| 117 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 | 113 MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_11 |
| 118 | 114 |
| 119 AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, | 115 AXTextMarkerRef AXTextMarkerCreate(CFAllocatorRef allocator, |
| 120 const UInt8* bytes, | 116 const UInt8* bytes, |
| 121 CFIndex length); | 117 CFIndex length); |
| 122 | 118 |
| 123 const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker); | 119 const UInt8* AXTextMarkerGetBytePtr(AXTextMarkerRef text_marker); |
| (...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 603 dict = nil; | 599 dict = nil; |
| 604 } | 600 } |
| 605 | 601 |
| 606 - (instancetype)initWithObject:(BrowserAccessibility*)accessibility { | 602 - (instancetype)initWithObject:(BrowserAccessibility*)accessibility { |
| 607 if ((self = [super init])) | 603 if ((self = [super init])) |
| 608 browserAccessibility_ = accessibility; | 604 browserAccessibility_ = accessibility; |
| 609 return self; | 605 return self; |
| 610 } | 606 } |
| 611 | 607 |
| 612 - (void)detach { | 608 - (void)detach { |
| 613 if (browserAccessibility_) | 609 if (!browserAccessibility_) |
| 614 NSAccessibilityUnregisterUniqueIdForUIElement(self); | 610 return; |
| 611 NSAccessibilityPostNotification( | |
| 612 self, NSAccessibilityUIElementDestroyedNotification); | |
| 615 browserAccessibility_ = nullptr; | 613 browserAccessibility_ = nullptr; |
| 616 } | 614 } |
| 617 | 615 |
| 618 - (NSString*)accessKey { | 616 - (NSString*)accessKey { |
| 619 if (![self instanceActive]) | 617 if (![self instanceActive]) |
| 620 return nil; | 618 return nil; |
| 621 return NSStringForStringAttribute( | 619 return NSStringForStringAttribute( |
| 622 browserAccessibility_, ui::AX_ATTR_ACCESS_KEY); | 620 browserAccessibility_, ui::AX_ATTR_ACCESS_KEY); |
| 623 } | 621 } |
| 624 | 622 |
| (...skipping 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2873 return ([self hash] == [object hash]); | 2871 return ([self hash] == [object hash]); |
| 2874 } | 2872 } |
| 2875 | 2873 |
| 2876 - (NSUInteger)hash { | 2874 - (NSUInteger)hash { |
| 2877 // Potentially called during dealloc. | 2875 // Potentially called during dealloc. |
| 2878 if (![self instanceActive]) | 2876 if (![self instanceActive]) |
| 2879 return [super hash]; | 2877 return [super hash]; |
| 2880 return browserAccessibility_->GetId(); | 2878 return browserAccessibility_->GetId(); |
| 2881 } | 2879 } |
| 2882 | 2880 |
| 2883 - (BOOL)accessibilityShouldUseUniqueId { | 2881 - (BOOL)accessibilityNotifiesWhenDestroyed { |
| 2882 // Indicate that BrowserAccessibilityCocoa will post a notification when it's | |
| 2883 // destroyed (see - detach). This allows VoiceOver to do some internal | |
| 2884 // things more efficiently. | |
|
tapted
2016/09/28 01:03:19
Yeah it would be awesome if we can drop the privat
Patti Lor
2016/10/04 05:45:14
The decision to delete the private API stuff here
| |
| 2884 return YES; | 2885 return YES; |
| 2885 } | 2886 } |
| 2886 | 2887 |
| 2887 @end | 2888 @end |
| OLD | NEW |