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 #include "base/strings/string16.h" | 15 #include "base/strings/string16.h" |
16 #include "base/strings/sys_string_conversions.h" | 16 #include "base/strings/sys_string_conversions.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "content/app/strings/grit/content_strings.h" | 18 #include "content/app/strings/grit/content_strings.h" |
19 #include "content/browser/accessibility/browser_accessibility_mac.h" | 19 #include "content/browser/accessibility/browser_accessibility_mac.h" |
20 #include "content/browser/accessibility/browser_accessibility_manager.h" | 20 #include "content/browser/accessibility/browser_accessibility_manager.h" |
21 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 21 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
22 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" | 22 #include "content/browser/accessibility/one_shot_accessibility_tree_search.h" |
23 #include "content/public/common/content_client.h" | 23 #include "content/public/common/content_client.h" |
24 #include "third_party/skia/include/core/SkColor.h" | 24 #include "third_party/skia/include/core/SkColor.h" |
25 #include "ui/accessibility/ax_position.h" | |
26 #include "ui/accessibility/ax_range.h" | |
25 #import "ui/accessibility/platform/ax_platform_node_mac.h" | 27 #import "ui/accessibility/platform/ax_platform_node_mac.h" |
26 | 28 |
27 using content::AXTreeIDRegistry; | 29 using content::AXTreeIDRegistry; |
28 using content::AccessibilityMatchPredicate; | 30 using content::AccessibilityMatchPredicate; |
29 using content::BrowserAccessibility; | 31 using content::BrowserAccessibility; |
30 using content::BrowserAccessibilityDelegate; | 32 using content::BrowserAccessibilityDelegate; |
31 using content::BrowserAccessibilityManager; | 33 using content::BrowserAccessibilityManager; |
32 using content::BrowserAccessibilityManagerMac; | 34 using content::BrowserAccessibilityManagerMac; |
33 using content::ContentClient; | 35 using content::ContentClient; |
34 using content::OneShotAccessibilityTreeSearch; | 36 using content::OneShotAccessibilityTreeSearch; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
87 @"AXTextMarkerRangeForUnorderedTextMarkers"; | 89 @"AXTextMarkerRangeForUnorderedTextMarkers"; |
88 NSString* const NSAccessibilityIndexForChildUIElementParameterizedAttribute = | 90 NSString* const NSAccessibilityIndexForChildUIElementParameterizedAttribute = |
89 @"AXIndexForChildUIElement"; | 91 @"AXIndexForChildUIElement"; |
90 | 92 |
91 // Actions. | 93 // Actions. |
92 NSString* const NSAccessibilityScrollToVisibleAction = @"AXScrollToVisible"; | 94 NSString* const NSAccessibilityScrollToVisibleAction = @"AXScrollToVisible"; |
93 | 95 |
94 // A mapping from an accessibility attribute to its method name. | 96 // A mapping from an accessibility attribute to its method name. |
95 NSDictionary* attributeToMethodNameMap = nil; | 97 NSDictionary* attributeToMethodNameMap = nil; |
96 | 98 |
97 struct AXTextMarkerData { | |
98 AXTreeIDRegistry::AXTreeID tree_id; | |
99 int32_t node_id; | |
100 int offset; | |
101 ui::AXTextAffinity affinity; | |
102 }; | |
103 | |
104 // VoiceOver uses -1 to mean "no limit" for AXResultsLimit. | 99 // VoiceOver uses -1 to mean "no limit" for AXResultsLimit. |
105 const int kAXResultsLimitNoLimit = -1; | 100 const int kAXResultsLimitNoLimit = -1; |
106 | 101 |
107 extern "C" { | 102 extern "C" { |
108 | 103 |
109 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5, | 104 // 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 | 105 // 10.6, and 10.7. It allows accessibility clients to observe events posted on |
111 // this object. | 106 // this object. |
112 void NSAccessibilityUnregisterUniqueIdForUIElement(id element); | 107 void NSAccessibilityUnregisterUniqueIdForUIElement(id element); |
113 | 108 |
(...skipping 18 matching lines...) Expand all Loading... | |
132 AXTextMarkerRef AXTextMarkerRangeCopyEndMarker( | 127 AXTextMarkerRef AXTextMarkerRangeCopyEndMarker( |
133 AXTextMarkerRangeRef text_marker_range); | 128 AXTextMarkerRangeRef text_marker_range); |
134 | 129 |
135 #endif // MAC_OS_X_VERSION_10_11 | 130 #endif // MAC_OS_X_VERSION_10_11 |
136 | 131 |
137 } // extern "C" | 132 } // extern "C" |
138 | 133 |
139 id CreateTextMarker(const BrowserAccessibility& object, | 134 id CreateTextMarker(const BrowserAccessibility& object, |
140 int offset, | 135 int offset, |
141 ui::AXTextAffinity affinity) { | 136 ui::AXTextAffinity affinity) { |
142 AXTextMarkerData marker_data; | 137 if (!object.instance_active()) |
dmazzoni
2016/10/03 18:22:51
I think you should finish updating this file befor
| |
143 marker_data.tree_id = object.manager() ? object.manager()->ax_tree_id() : -1; | 138 return nil; |
144 marker_data.node_id = object.GetId(); | 139 |
145 marker_data.offset = offset; | 140 const auto manager = object.manager(); |
146 marker_data.affinity = affinity; | 141 DCHECK(manager); |
142 AXPosition marker_data = AXPlatformPosition::CreateTextPosition(manager->ax_tr ee_id(), object.node_id(), offset); | |
dmazzoni
2016/10/03 18:22:51
Where is AXPlatformPosition::CreateTextPosition de
| |
143 marker_data.set_affinity(affinity); | |
dmazzoni
2016/10/03 18:22:51
Don't you need an object of type AXPlatformPositio
| |
147 return (id)base::mac::CFTypeRefToNSObjectAutorelease(AXTextMarkerCreate( | 144 return (id)base::mac::CFTypeRefToNSObjectAutorelease(AXTextMarkerCreate( |
148 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(&marker_data), | 145 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(&marker_data), |
149 sizeof(marker_data))); | 146 sizeof(marker_data))); |
150 } | 147 } |
151 | 148 |
152 id CreateTextMarkerRange(const BrowserAccessibility& start_object, | 149 id CreateTextMarkerRange(const BrowserAccessibility& start_object, |
153 int start_offset, | 150 int start_offset, |
154 ui::AXTextAffinity start_affinity, | 151 ui::AXTextAffinity start_affinity, |
155 const BrowserAccessibility& end_object, | 152 const BrowserAccessibility& end_object, |
156 int end_offset, | 153 int end_offset, |
(...skipping 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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)accessibilityShouldUseUniqueId { |
2884 return YES; | 2881 return YES; |
2885 } | 2882 } |
2886 | 2883 |
2887 @end | 2884 @end |
OLD | NEW |