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 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 369 return axAttributes.autorelease(); | 369 return axAttributes.autorelease(); |
| 370 } | 370 } |
| 371 | 371 |
| 372 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName { | 372 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attributeName { |
| 373 // Allow certain attributes to be written via an accessibility client. A | 373 // Allow certain attributes to be written via an accessibility client. A |
| 374 // writable attribute will only appear as such if the accessibility element | 374 // writable attribute will only appear as such if the accessibility element |
| 375 // has a value set for that attribute. | 375 // has a value set for that attribute. |
| 376 if ([attributeName | 376 if ([attributeName |
| 377 isEqualToString:NSAccessibilitySelectedChildrenAttribute] || | 377 isEqualToString:NSAccessibilitySelectedChildrenAttribute] || |
| 378 [attributeName | 378 [attributeName |
| 379 isEqualToString:NSAccessibilitySelectedTextRangeAttribute] || | |
| 380 [attributeName | |
| 381 isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) { | 379 isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) { |
| 382 return NO; | 380 return NO; |
| 383 } | 381 } |
| 384 | 382 |
| 383 if ([attributeName | |
| 384 isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { | |
| 385 return YES; | |
| 386 } | |
| 387 | |
| 385 // Since tabs use the Radio Button role on Mac, the standard way to set them | 388 // Since tabs use the Radio Button role on Mac, the standard way to set them |
| 386 // is via the value attribute rather than the selected attribute. | 389 // is via the value attribute rather than the selected attribute. |
| 387 if ([attributeName isEqualToString:NSAccessibilityValueAttribute] && | 390 if ([attributeName isEqualToString:NSAccessibilityValueAttribute] && |
| 388 node_->GetData().role == ui::AX_ROLE_TAB) { | 391 node_->GetData().role == ui::AX_ROLE_TAB) { |
| 389 return !node_->GetData().HasStateFlag(ui::AX_STATE_SELECTED); | 392 return !node_->GetData().HasStateFlag(ui::AX_STATE_SELECTED); |
| 390 } | 393 } |
| 391 | 394 |
| 392 if ([attributeName isEqualToString:NSAccessibilityValueAttribute] || | 395 if ([attributeName isEqualToString:NSAccessibilityValueAttribute] || |
| 393 [attributeName isEqualToString:NSAccessibilitySelectedTextAttribute]) { | 396 [attributeName isEqualToString:NSAccessibilitySelectedTextAttribute]) { |
| 394 return !ui::AXNodeData::IsFlagSet(node_->GetData().state, | 397 return !ui::AXNodeData::IsFlagSet(node_->GetData().state, |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 409 ui::AXActionData data; | 412 ui::AXActionData data; |
| 410 | 413 |
| 411 // Check for attributes first. Only the |data.action| should be set here - any | 414 // Check for attributes first. Only the |data.action| should be set here - any |
| 412 // type-specific information, if needed, should be set below. | 415 // type-specific information, if needed, should be set below. |
| 413 if ([attribute isEqualToString:NSAccessibilityValueAttribute]) { | 416 if ([attribute isEqualToString:NSAccessibilityValueAttribute]) { |
| 414 data.action = node_->GetData().role == ui::AX_ROLE_TAB | 417 data.action = node_->GetData().role == ui::AX_ROLE_TAB |
| 415 ? ui::AX_ACTION_SET_SELECTION | 418 ? ui::AX_ACTION_SET_SELECTION |
| 416 : ui::AX_ACTION_SET_VALUE; | 419 : ui::AX_ACTION_SET_VALUE; |
| 417 } else if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]) { | 420 } else if ([attribute isEqualToString:NSAccessibilitySelectedTextAttribute]) { |
| 418 data.action = ui::AX_ACTION_REPLACE_SELECTED_TEXT; | 421 data.action = ui::AX_ACTION_REPLACE_SELECTED_TEXT; |
| 422 } else if ([attribute | |
| 423 isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { | |
| 424 data.action = ui::AX_ACTION_SET_SELECTION; | |
| 419 } else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { | 425 } else if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { |
| 420 if ([value isKindOfClass:[NSNumber class]]) { | 426 if ([value isKindOfClass:[NSNumber class]]) { |
| 421 data.action = | 427 data.action = |
| 422 [value boolValue] ? ui::AX_ACTION_FOCUS : ui::AX_ACTION_BLUR; | 428 [value boolValue] ? ui::AX_ACTION_FOCUS : ui::AX_ACTION_BLUR; |
| 423 } | 429 } |
| 424 } | 430 } |
| 425 | 431 |
| 426 // Set type-specific information as necessary for actions set above. | 432 // Set type-specific information as necessary for actions set above. |
| 427 if ([value isKindOfClass:[NSString class]]) | 433 if ([value isKindOfClass:[NSString class]]) { |
| 428 data.value = base::SysNSStringToUTF16(value); | 434 data.value = base::SysNSStringToUTF16(value); |
| 435 } else if ([value isKindOfClass:[NSValue class]]) { | |
| 436 NSRange range = [value rangeValue]; | |
|
tapted
2017/02/09 23:09:37
I think we should only do this if data.action == u
Patti Lor
2017/02/13 23:31:03
Done, thanks :)
| |
| 437 data.anchor_offset = range.location; | |
| 438 data.focus_offset = range.location + range.length; | |
| 439 } | |
| 429 | 440 |
| 430 if (data.action != ui::AX_ACTION_NONE) | 441 if (data.action != ui::AX_ACTION_NONE) |
| 431 node_->GetDelegate()->AccessibilityPerformAction(data); | 442 node_->GetDelegate()->AccessibilityPerformAction(data); |
| 432 | 443 |
| 433 // TODO(patricialor): Plumb through all the other writable attributes as | 444 // TODO(patricialor): Plumb through all the other writable attributes as |
| 434 // specified in accessibilityIsAttributeSettable. | 445 // specified in accessibilityIsAttributeSettable. |
| 435 } | 446 } |
| 436 | 447 |
| 437 - (id)accessibilityAttributeValue:(NSString*)attribute { | 448 - (id)accessibilityAttributeValue:(NSString*)attribute { |
| 438 SEL selector = NSSelectorFromString(attribute); | 449 SEL selector = NSSelectorFromString(attribute); |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 631 } | 642 } |
| 632 NotifyMacEvent(native_node_, event_type); | 643 NotifyMacEvent(native_node_, event_type); |
| 633 } | 644 } |
| 634 | 645 |
| 635 int AXPlatformNodeMac::GetIndexInParent() { | 646 int AXPlatformNodeMac::GetIndexInParent() { |
| 636 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 647 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
| 637 return -1; | 648 return -1; |
| 638 } | 649 } |
| 639 | 650 |
| 640 } // namespace ui | 651 } // namespace ui |
| OLD | NEW |