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

Unified 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 show attributes are writable if there is not callback provided to change its value. 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 side-by-side diff with in-line comments
Download patch
Index: ui/accessibility/platform/ax_platform_node_mac.mm
diff --git a/ui/accessibility/platform/ax_platform_node_mac.mm b/ui/accessibility/platform/ax_platform_node_mac.mm
index 79fa94904ba8d2fbd2fcb4f57b97db3fa7f8ca29..0df2bcf863259d1ec16f7896dc6ff5e253f2475d 100644
--- a/ui/accessibility/platform/ax_platform_node_mac.mm
+++ b/ui/accessibility/platform/ax_platform_node_mac.mm
@@ -349,8 +349,43 @@ void NotifyMacEvent(NSView* target, ui::AXEvent event_type) {
return axAttributes.autorelease();
}
-- (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute {
- return NO;
+- (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName {
+ // Allow certain attributes to be written via an accessibility client. A
+ // writable attribute will only appear as such if the accessibility element
+ // has a value set for that attribute.
+ 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.
+ [[NSMutableArray alloc] init]);
+
+ NSArray* const kWritableAttributes = @[
+ NSAccessibilitySelectedAttribute, NSAccessibilitySelectedChildrenAttribute,
+ NSAccessibilitySelectedTextAttribute,
+ 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.
+ NSAccessibilityVisibleCharacterRangeAttribute
+ ];
+
+ if (!ui::AXViewState::IsFlagSet(node_->GetData().state,
+ ui::AX_STATE_READ_ONLY)) {
+ 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
+ [axWritableAttributes addObject:NSAccessibilityValueAttribute];
tapted 2016/08/11 04:23:25 I think NSAccessibilityValueAttribute and NSAccess
Patti Lor 2016/08/12 01:57:42 Done.
+ [axWritableAttributes addObjectsFromArray:kWritableAttributes];
+ }
+
+ if (ui::AXViewState::IsFlagSet(node_->GetData().state,
+ ui::AX_STATE_FOCUSABLE))
+ [axWritableAttributes addObject:NSAccessibilityFocusedAttribute];
+
+ BOOL settable = [axWritableAttributes containsObject:attributeName];
+ 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!
+ return settable;
+}
+
+- (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute {
+ 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
+ [value isKindOfClass:[NSString class]])
+ node_->GetDelegate()->SetStringValue(base::SysNSStringToUTF16(value));
+
+ // TODO(patricialor): Plumb through all the other writable attributes as
+ // specified in accessibilityIsAttributeSettable.
}
- (id)accessibilityAttributeValue:(NSString*)attribute {

Powered by Google App Engine
This is Rietveld 408576698