| 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 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 5 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
| 6 | 6 |
| 7 #include <execinfo.h> | 7 #include <execinfo.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <string.h> | 10 #include <string.h> |
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 AXTextMarkerRef AXTextMarkerRangeCopyStartMarker( | 133 AXTextMarkerRef AXTextMarkerRangeCopyStartMarker( |
| 134 AXTextMarkerRangeRef text_marker_range); | 134 AXTextMarkerRangeRef text_marker_range); |
| 135 | 135 |
| 136 AXTextMarkerRef AXTextMarkerRangeCopyEndMarker( | 136 AXTextMarkerRef AXTextMarkerRangeCopyEndMarker( |
| 137 AXTextMarkerRangeRef text_marker_range); | 137 AXTextMarkerRangeRef text_marker_range); |
| 138 | 138 |
| 139 #endif // MAC_OS_X_VERSION_10_11 | 139 #endif // MAC_OS_X_VERSION_10_11 |
| 140 | 140 |
| 141 } // extern "C" | 141 } // extern "C" |
| 142 | 142 |
| 143 // to call |release| on it to transfer ownership of the position to the text | 143 // AXTextMarkerCreate copies from data buffer given to it. |
| 144 // marker object. | |
| 145 id CreateTextMarker(AXPlatformPositionInstance position) { | 144 id CreateTextMarker(AXPlatformPositionInstance position) { |
| 146 AXTextMarkerRef text_marker = AXTextMarkerCreate( | 145 AXTextMarkerRef text_marker = AXTextMarkerCreate( |
| 147 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(position.release()), | 146 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(position.get()), |
| 148 sizeof(AXPlatformPosition)); | 147 sizeof(AXPlatformPosition)); |
| 149 return static_cast<id>( | 148 return static_cast<id>( |
| 150 base::mac::CFTypeRefToNSObjectAutorelease(text_marker)); | 149 base::mac::CFTypeRefToNSObjectAutorelease(text_marker)); |
| 151 } | 150 } |
| 152 | 151 |
| 153 // |range| is destructed at the end of this method and ownership of its |anchor| | 152 // |range| is destructed at the end of this method. |anchor| and |focus| are |
| 154 // and |focus| are transfered to the marker range object. | 153 // copied into the individual text markers. |
| 155 id CreateTextMarkerRange(const AXPlatformRange range) { | 154 id CreateTextMarkerRange(const AXPlatformRange range) { |
| 156 AXTextMarkerRef start_marker = AXTextMarkerCreate( | 155 base::ScopedCFTypeRef<AXTextMarkerRef> start_marker(AXTextMarkerCreate( |
| 157 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(range.anchor()), | 156 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(range.anchor()), |
| 158 sizeof(AXPlatformPosition)); | 157 sizeof(AXPlatformPosition))); |
| 159 AXTextMarkerRef end_marker = AXTextMarkerCreate( | 158 base::ScopedCFTypeRef<AXTextMarkerRef> end_marker(AXTextMarkerCreate( |
| 160 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(range.focus()), | 159 kCFAllocatorDefault, reinterpret_cast<const UInt8*>(range.focus()), |
| 161 sizeof(AXPlatformPosition)); | 160 sizeof(AXPlatformPosition))); |
| 162 AXTextMarkerRangeRef marker_range = | 161 AXTextMarkerRangeRef marker_range = |
| 163 AXTextMarkerRangeCreate(kCFAllocatorDefault, start_marker, end_marker); | 162 AXTextMarkerRangeCreate(kCFAllocatorDefault, start_marker, end_marker); |
| 164 return static_cast<id>( | 163 return static_cast<id>( |
| 165 base::mac::CFTypeRefToNSObjectAutorelease(marker_range)); | 164 base::mac::CFTypeRefToNSObjectAutorelease(marker_range)); |
| 166 } | 165 } |
| 167 | 166 |
| 168 AXPlatformPositionInstance CreatePositionFromTextMarker( | 167 AXPlatformPositionInstance CreatePositionFromTextMarker( |
| 169 AXTextMarkerRef text_marker) { | 168 AXTextMarkerRef text_marker) { |
| 170 DCHECK(text_marker); | 169 DCHECK(text_marker); |
| 171 if (AXTextMarkerGetLength(text_marker) != sizeof(AXPlatformPosition)) | 170 if (AXTextMarkerGetLength(text_marker) != sizeof(AXPlatformPosition)) |
| (...skipping 2707 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2879 } | 2878 } |
| 2880 | 2879 |
| 2881 - (BOOL)accessibilityNotifiesWhenDestroyed { | 2880 - (BOOL)accessibilityNotifiesWhenDestroyed { |
| 2882 // Indicate that BrowserAccessibilityCocoa will post a notification when it's | 2881 // Indicate that BrowserAccessibilityCocoa will post a notification when it's |
| 2883 // destroyed (see -detach). This allows VoiceOver to do some internal things | 2882 // destroyed (see -detach). This allows VoiceOver to do some internal things |
| 2884 // more efficiently. | 2883 // more efficiently. |
| 2885 return YES; | 2884 return YES; |
| 2886 } | 2885 } |
| 2887 | 2886 |
| 2888 @end | 2887 @end |
| OLD | NEW |