OLD | NEW |
---|---|
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 | 6 |
7 #import "chrome/browser/accessibility/browser_accessibility_cocoa.h" | 7 #import "chrome/browser/accessibility/browser_accessibility_cocoa.h" |
8 | 8 |
9 #include "app/l10n_util_mac.h" | 9 #include "app/l10n_util_mac.h" |
10 #include "base/string16.h" | 10 #include "base/string16.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
203 } | 203 } |
204 if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) { | 204 if ([attribute isEqualToString:NSAccessibilityTitleAttribute]) { |
205 return base::SysUTF16ToNSString(browserAccessibility_->name()); | 205 return base::SysUTF16ToNSString(browserAccessibility_->name()); |
206 } | 206 } |
207 if ([attribute isEqualToString:NSAccessibilityHelpAttribute]) { | 207 if ([attribute isEqualToString:NSAccessibilityHelpAttribute]) { |
208 return NSStringForWebAccessibilityAttribute( | 208 return NSStringForWebAccessibilityAttribute( |
209 browserAccessibility_->attributes(), | 209 browserAccessibility_->attributes(), |
210 WebAccessibility::ATTR_HELP); | 210 WebAccessibility::ATTR_HELP); |
211 } | 211 } |
212 if ([attribute isEqualToString:NSAccessibilityValueAttribute]) { | 212 if ([attribute isEqualToString:NSAccessibilityValueAttribute]) { |
213 // Webcore uses an attachmentView to get the below behavior. | |
Chris Guillory
2010/11/29 22:38:44
Nit: Capitalize the 'C' in WebCore (since the 'W'
| |
214 // We do not have any native views backing this object, so need | |
215 // to approximate Cocoa ax behavior best as we can. | |
213 if ([self role] == @"AXHeading") { | 216 if ([self role] == @"AXHeading") { |
214 NSString* headingLevel = | 217 NSString* headingLevel = |
215 NSStringForWebAccessibilityAttribute( | 218 NSStringForWebAccessibilityAttribute( |
216 browserAccessibility_->attributes(), | 219 browserAccessibility_->attributes(), |
217 WebAccessibility::ATTR_HTML_TAG); | 220 WebAccessibility::ATTR_HTML_TAG); |
218 if ([headingLevel length] >= 2) { | 221 if ([headingLevel length] >= 2) { |
219 return [NSNumber numberWithInt: | 222 return [NSNumber numberWithInt: |
220 [[headingLevel substringFromIndex:1] intValue]]; | 223 [[headingLevel substringFromIndex:1] intValue]]; |
221 } | 224 } |
222 } else if ([self role] == NSAccessibilityCheckBoxRole) { | 225 } else if ([self role] == NSAccessibilityCheckBoxRole) { |
223 return [NSNumber numberWithInt:GetState( | 226 return [NSNumber numberWithInt:GetState( |
224 browserAccessibility_, WebAccessibility::STATE_CHECKED) ? 1 : 0]; | 227 browserAccessibility_, WebAccessibility::STATE_CHECKED) ? 1 : 0]; |
228 } else if ([self role] == NSAccessibilityButtonRole) { | |
229 // Does not make sense for pure buttons. | |
Chris Guillory
2010/11/29 22:38:44
What does not make sense for pure buttons? AXValue
| |
230 return @""; | |
225 } else { | 231 } else { |
226 return base::SysUTF16ToNSString(browserAccessibility_->value()); | 232 return base::SysUTF16ToNSString(browserAccessibility_->value()); |
227 } | 233 } |
228 } | 234 } |
229 if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) { | 235 if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) { |
230 return [self roleDescription]; | 236 return [self roleDescription]; |
231 } | 237 } |
232 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { | 238 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { |
233 NSNumber* ret = [NSNumber numberWithBool: | 239 NSNumber* ret = [NSNumber numberWithBool: |
234 GetState(browserAccessibility_, WebAccessibility::STATE_FOCUSED)]; | 240 GetState(browserAccessibility_, WebAccessibility::STATE_FOCUSED)]; |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
460 | 466 |
461 - (NSUInteger)hash { | 467 - (NSUInteger)hash { |
462 // Potentially called during dealloc. | 468 // Potentially called during dealloc. |
463 if (!browserAccessibility_) | 469 if (!browserAccessibility_) |
464 return [super hash]; | 470 return [super hash]; |
465 return browserAccessibility_->renderer_id(); | 471 return browserAccessibility_->renderer_id(); |
466 } | 472 } |
467 | 473 |
468 @end | 474 @end |
469 | 475 |
OLD | NEW |