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 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 case ui::AX_ROLE_TOGGLE_BUTTON: | 342 case ui::AX_ROLE_TOGGLE_BUTTON: |
| 343 [axAttributes addObjectsFromArray:kValueAttributes]; | 343 [axAttributes addObjectsFromArray:kValueAttributes]; |
| 344 break; | 344 break; |
| 345 // TODO(tapted): Add additional attributes based on role. | 345 // TODO(tapted): Add additional attributes based on role. |
| 346 default: | 346 default: |
| 347 break; | 347 break; |
| 348 } | 348 } |
| 349 return axAttributes.autorelease(); | 349 return axAttributes.autorelease(); |
| 350 } | 350 } |
| 351 | 351 |
| 352 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute { | 352 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName { |
| 353 return NO; | 353 // Allow certain attributes to be written via an accessibility client. A |
| 354 // writable attribute will only appear as such if the accessibility element | |
| 355 // has a value set for that attribute. | |
| 356 base::scoped_nsobject<NSMutableArray> axWritableAttributes( | |
|
tapted
2016/08/11 04:23:25
I don't think we need this array unless it's used
Patti Lor
2016/08/12 01:57:42
Done.
| |
| 357 [[NSMutableArray alloc] init]); | |
| 358 | |
| 359 NSArray* const kWritableAttributes = @[ | |
| 360 NSAccessibilitySelectedAttribute, NSAccessibilitySelectedChildrenAttribute, | |
| 361 NSAccessibilitySelectedTextAttribute, | |
| 362 NSAccessibilitySelectedTextRangeAttribute, | |
|
tapted
2016/08/11 04:23:25
I think the TextRange should be settable on ReadOn
Patti Lor
2016/08/12 01:57:42
Done.
| |
| 363 NSAccessibilityVisibleCharacterRangeAttribute | |
| 364 ]; | |
| 365 | |
| 366 if (!ui::AXViewState::IsFlagSet(node_->GetData().state, | |
| 367 ui::AX_STATE_READ_ONLY)) { | |
| 368 if (node_->GetDelegate()->CanSetStringValue()) | |
|
tapted
2016/08/11 04:23:25
We already call node_->GetData().state a bunch her
Patti Lor
2016/08/12 01:57:42
The naming is a bit confusing - it's not actually
tapted
2016/08/12 03:50:52
Ah I see. I guess it would be necessary to update
| |
| 369 [axWritableAttributes addObject:NSAccessibilityValueAttribute]; | |
|
tapted
2016/08/11 04:23:25
I think NSAccessibilityValueAttribute and NSAccess
Patti Lor
2016/08/12 01:57:42
Done.
| |
| 370 [axWritableAttributes addObjectsFromArray:kWritableAttributes]; | |
| 371 } | |
| 372 | |
| 373 if (ui::AXViewState::IsFlagSet(node_->GetData().state, | |
| 374 ui::AX_STATE_FOCUSABLE)) | |
| 375 [axWritableAttributes addObject:NSAccessibilityFocusedAttribute]; | |
| 376 | |
| 377 BOOL settable = [axWritableAttributes containsObject:attributeName]; | |
| 378 axWritableAttributes.autorelease(); | |
|
tapted
2016/08/11 04:23:25
(usually we only do scoped_nsobject::autorelease()
Patti Lor
2016/08/12 01:57:42
Done, thanks for the FYI!
| |
| 379 return settable; | |
| 380 } | |
| 381 | |
| 382 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { | |
| 383 if ([attribute isEqualToString:NSAccessibilityValueAttribute] && | |
|
tapted
2016/08/11 04:23:25
Does NSAccessibilitySelectedTextAttribute already
Patti Lor
2016/08/12 01:57:42
Yep, writing NSAccessibilitySelectedTextAttribute
tapted
2016/08/12 03:50:52
sorta - I guess the question is whether the callba
| |
| 384 [value isKindOfClass:[NSString class]]) | |
| 385 node_->GetDelegate()->SetStringValue(base::SysNSStringToUTF16(value)); | |
| 386 | |
| 387 // TODO(patricialor): Plumb through all the other writable attributes as | |
| 388 // specified in accessibilityIsAttributeSettable. | |
| 354 } | 389 } |
| 355 | 390 |
| 356 - (id)accessibilityAttributeValue:(NSString*)attribute { | 391 - (id)accessibilityAttributeValue:(NSString*)attribute { |
| 357 SEL selector = NSSelectorFromString(attribute); | 392 SEL selector = NSSelectorFromString(attribute); |
| 358 if ([self respondsToSelector:selector]) | 393 if ([self respondsToSelector:selector]) |
| 359 return [self performSelector:selector]; | 394 return [self performSelector:selector]; |
| 360 return nil; | 395 return nil; |
| 361 } | 396 } |
| 362 | 397 |
| 363 // NSAccessibility attributes. | 398 // NSAccessibility attributes. |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 532 } | 567 } |
| 533 NotifyMacEvent(target, event_type); | 568 NotifyMacEvent(target, event_type); |
| 534 } | 569 } |
| 535 | 570 |
| 536 int AXPlatformNodeMac::GetIndexInParent() { | 571 int AXPlatformNodeMac::GetIndexInParent() { |
| 537 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 572 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
| 538 return -1; | 573 return -1; |
| 539 } | 574 } |
| 540 | 575 |
| 541 } // namespace ui | 576 } // namespace ui |
| OLD | NEW |