Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Side by Side Diff: ui/accessibility/platform/ax_platform_node_mac.mm

Issue 2230093002: MacViews a11y: Allow accessibility clients to set the AXValue on some controls. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't say attributes are settable until implemented. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 // 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 if ([attributeName isEqualToString:NSAccessibilitySelectedAttribute] ||
357 [attributeName
358 isEqualToString:NSAccessibilitySelectedChildrenAttribute] ||
359 [attributeName
360 isEqualToString:NSAccessibilitySelectedTextRangeAttribute] ||
361 [attributeName
362 isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) {
363 return NO;
364 }
365
366 if ([attributeName isEqualToString:NSAccessibilityValueAttribute])
367 return node_->GetDelegate()->CanSetStringValue();
368 // TODO(patricialor): Implement and merge with conditional for value above.
369 if ([attributeName isEqualToString:NSAccessibilitySelectedTextAttribute])
370 return NO;
371
372 if ([attributeName isEqualToString:NSAccessibilityFocusedAttribute]) {
373 if (ui::AXViewState::IsFlagSet(node_->GetData().state,
374 ui::AX_STATE_FOCUSABLE))
375 return NO;
376 }
377
378 // TODO(patricialor): Add callbacks for updating the above attributes except
379 // NSAccessibilityValueAttribute and return YES.
353 return NO; 380 return NO;
354 } 381 }
355 382
383 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute {
384 if ([attribute isEqualToString:NSAccessibilityValueAttribute] &&
385 [value isKindOfClass:[NSString class]])
386 node_->GetDelegate()->SetStringValue(base::SysNSStringToUTF16(value));
387
388 // TODO(patricialor): Plumb through all the other writable attributes as
389 // specified in accessibilityIsAttributeSettable.
390 }
391
356 - (id)accessibilityAttributeValue:(NSString*)attribute { 392 - (id)accessibilityAttributeValue:(NSString*)attribute {
357 SEL selector = NSSelectorFromString(attribute); 393 SEL selector = NSSelectorFromString(attribute);
358 if ([self respondsToSelector:selector]) 394 if ([self respondsToSelector:selector])
359 return [self performSelector:selector]; 395 return [self performSelector:selector];
360 return nil; 396 return nil;
361 } 397 }
362 398
363 // NSAccessibility attributes. 399 // NSAccessibility attributes.
364 400
365 - (NSArray*)AXChildren { 401 - (NSArray*)AXChildren {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 568 }
533 NotifyMacEvent(target, event_type); 569 NotifyMacEvent(target, event_type);
534 } 570 }
535 571
536 int AXPlatformNodeMac::GetIndexInParent() { 572 int AXPlatformNodeMac::GetIndexInParent() {
537 // TODO(dmazzoni): implement this. http://crbug.com/396137 573 // TODO(dmazzoni): implement this. http://crbug.com/396137
538 return -1; 574 return -1;
539 } 575 }
540 576
541 } // namespace ui 577 } // namespace ui
OLDNEW
« no previous file with comments | « ui/accessibility/platform/ax_platform_node_delegate.h ('k') | ui/accessibility/platform/test_ax_node_wrapper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698