Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "ui/accessibility/platform/ax_platform_node_mac.h" | 5 #import "ui/accessibility/platform/ax_platform_node_mac.h" |
| 6 | 6 |
| 7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
| 8 | 8 |
| 9 #include "base/strings/sys_string_conversions.h" | 9 #include "base/strings/sys_string_conversions.h" |
| 10 #import "ui/accessibility/ax_node_data.h" | 10 #import "ui/accessibility/ax_node_data.h" |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 237 - (NSString*)AXRole { | 237 - (NSString*)AXRole { |
| 238 if (!node_) | 238 if (!node_) |
| 239 return nil; | 239 return nil; |
| 240 return [[self class] nativeRoleFromAXRole:node_->GetData().role]; | 240 return [[self class] nativeRoleFromAXRole:node_->GetData().role]; |
| 241 } | 241 } |
| 242 | 242 |
| 243 - (NSValue*)AXSize { | 243 - (NSValue*)AXSize { |
| 244 return [NSValue valueWithSize:self.boundsInScreen.size]; | 244 return [NSValue valueWithSize:self.boundsInScreen.size]; |
| 245 } | 245 } |
| 246 | 246 |
| 247 - (NSString*)AXTitle { | |
| 248 std::string value; | |
| 249 if (node_->GetStringAttribute(ui::AX_ATTR_NAME, &value)) | |
| 250 return base::SysUTF8ToNSString(value); | |
| 251 return nil; | |
| 252 } | |
| 253 | |
| 247 // NSAccessibility informal protocol implementation. | 254 // NSAccessibility informal protocol implementation. |
| 248 | 255 |
| 249 - (BOOL)accessibilityIsIgnored { | 256 - (BOOL)accessibilityIsIgnored { |
| 250 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole]; | 257 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole]; |
| 251 } | 258 } |
| 252 | 259 |
| 253 - (id)accessibilityHitTest:(NSPoint)point { | 260 - (id)accessibilityHitTest:(NSPoint)point { |
| 254 for (AXPlatformNodeCocoa* child in [self AXChildren]) { | 261 for (AXPlatformNodeCocoa* child in [self AXChildren]) { |
| 255 if (NSPointInRect(point, child.boundsInScreen)) | 262 if (NSPointInRect(point, child.boundsInScreen)) |
| 256 return [child accessibilityHitTest:point]; | 263 return [child accessibilityHitTest:point]; |
| 257 } | 264 } |
| 258 return NSAccessibilityUnignoredAncestor(self); | 265 return NSAccessibilityUnignoredAncestor(self); |
| 259 } | 266 } |
| 260 | 267 |
| 261 - (NSArray*)accessibilityActionNames { | 268 - (NSArray*)accessibilityActionNames { |
| 262 return nil; | 269 return nil; |
| 263 } | 270 } |
| 264 | 271 |
| 265 - (NSArray*)accessibilityAttributeNames { | 272 - (NSArray*)accessibilityAttributeNames { |
| 266 return @[ | 273 return @[ |
| 267 NSAccessibilityChildrenAttribute, | 274 NSAccessibilityChildrenAttribute, |
| 268 NSAccessibilityParentAttribute, | 275 NSAccessibilityParentAttribute, |
| 269 NSAccessibilityPositionAttribute, | 276 NSAccessibilityPositionAttribute, |
| 270 NSAccessibilityRoleAttribute, | 277 NSAccessibilityRoleAttribute, |
| 271 NSAccessibilitySizeAttribute, | 278 NSAccessibilitySizeAttribute, |
| 279 | |
| 280 // Always add title. Cocoa asks for it regardless of it appearing in here, | |
|
dmazzoni
2015/03/06 07:58:01
Rather than a comment for "title", I'd maybe just
tapted
2015/03/06 11:01:18
Done. Added the comment at top.
The comment on Ti
| |
| 281 // most things should have it, and it's OK to return nil. | |
| 282 NSAccessibilityTitleAttribute, | |
| 272 ]; | 283 ]; |
| 284 // TODO(tapted): Add additional attributes based on role. | |
| 273 } | 285 } |
| 274 | 286 |
| 275 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute { | 287 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute { |
| 276 return NO; | 288 return NO; |
| 277 } | 289 } |
| 278 | 290 |
| 279 - (id)accessibilityAttributeValue:(NSString*)attribute { | 291 - (id)accessibilityAttributeValue:(NSString*)attribute { |
| 280 SEL selector = NSSelectorFromString(attribute); | 292 SEL selector = NSSelectorFromString(attribute); |
| 281 if ([self respondsToSelector:selector]) | 293 if ([self respondsToSelector:selector]) |
| 282 return [self performSelector:selector]; | 294 return [self performSelector:selector]; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 void AXPlatformNodeMac::NotifyAccessibilityEvent(ui::AXEvent event_type) { | 328 void AXPlatformNodeMac::NotifyAccessibilityEvent(ui::AXEvent event_type) { |
| 317 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 329 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
| 318 } | 330 } |
| 319 | 331 |
| 320 int AXPlatformNodeMac::GetIndexInParent() { | 332 int AXPlatformNodeMac::GetIndexInParent() { |
| 321 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 333 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
| 322 return -1; | 334 return -1; |
| 323 } | 335 } |
| 324 | 336 |
| 325 } // namespace ui | 337 } // namespace ui |
| OLD | NEW |