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

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: Get rid of array, move READ_ONLY checks to callback. 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 if (!ui::AXViewState::IsFlagSet(node_->GetData().state,
364 ui::AX_STATE_READ_ONLY))
365 // TODO(patricialor): Move READ_ONLY check to callbacks.
366 return YES;
tapted 2016/08/12 03:50:52 There might be some specific semantics of ui::AX_S
Patti Lor 2016/08/12 05:16:54 Thanks, didn't know that! Acking this and the next
367 }
368
369 if ([attributeName isEqualToString:NSAccessibilityValueAttribute] ||
370 [attributeName isEqualToString:NSAccessibilitySelectedTextAttribute]) {
371 if (node_->GetDelegate()->CanSetStringValue())
tapted 2016/08/12 03:50:52 perhaps just `return node_->GetDelegate()->CanSetS
Patti Lor 2016/08/12 05:16:54 Acknowledged.
372 return YES;
373 }
374
375 if ([attributeName isEqualToString:NSAccessibilityFocusedAttribute]) {
376 if (ui::AXViewState::IsFlagSet(node_->GetData().state,
tapted 2016/08/12 03:50:52 same here - just return the function result
Patti Lor 2016/08/12 05:16:54 Acknowledged.
377 ui::AX_STATE_FOCUSABLE))
378 return YES;
379 }
380
381 // TODO(patricialor): Add callbacks for updating the above attributes except
382 // NSAccessibilityValueAttribute.
353 return NO; 383 return NO;
354 } 384 }
355 385
386 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute {
387 if ([attribute isEqualToString:NSAccessibilityValueAttribute] &&
388 [value isKindOfClass:[NSString class]])
389 node_->GetDelegate()->SetStringValue(base::SysNSStringToUTF16(value));
390
391 // TODO(patricialor): Plumb through all the other writable attributes as
tapted 2016/08/12 03:50:52 It might be wrong to already return `YES` for the
Patti Lor 2016/08/12 05:16:54 Done.
392 // specified in accessibilityIsAttributeSettable.
393 }
394
356 - (id)accessibilityAttributeValue:(NSString*)attribute { 395 - (id)accessibilityAttributeValue:(NSString*)attribute {
357 SEL selector = NSSelectorFromString(attribute); 396 SEL selector = NSSelectorFromString(attribute);
358 if ([self respondsToSelector:selector]) 397 if ([self respondsToSelector:selector])
359 return [self performSelector:selector]; 398 return [self performSelector:selector];
360 return nil; 399 return nil;
361 } 400 }
362 401
363 // NSAccessibility attributes. 402 // NSAccessibility attributes.
364 403
365 - (NSArray*)AXChildren { 404 - (NSArray*)AXChildren {
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 571 }
533 NotifyMacEvent(target, event_type); 572 NotifyMacEvent(target, event_type);
534 } 573 }
535 574
536 int AXPlatformNodeMac::GetIndexInParent() { 575 int AXPlatformNodeMac::GetIndexInParent() {
537 // TODO(dmazzoni): implement this. http://crbug.com/396137 576 // TODO(dmazzoni): implement this. http://crbug.com/396137
538 return -1; 577 return -1;
539 } 578 }
540 579
541 } // namespace ui 580 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698