| 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" |
| 11 #include "base/strings/sys_string_conversions.h" | 11 #include "base/strings/sys_string_conversions.h" |
| 12 #include "ui/accessibility/ax_node_data.h" | 12 #include "ui/accessibility/ax_node_data.h" |
| 13 #include "ui/accessibility/ax_view_state.h" | |
| 14 #include "ui/accessibility/platform/ax_platform_node_delegate.h" | 13 #include "ui/accessibility/platform/ax_platform_node_delegate.h" |
| 15 #import "ui/gfx/mac/coordinate_conversion.h" | 14 #import "ui/gfx/mac/coordinate_conversion.h" |
| 16 | 15 |
| 17 namespace { | 16 namespace { |
| 18 | 17 |
| 19 struct RoleMapEntry { | 18 struct RoleMapEntry { |
| 20 ui::AXRole value; | 19 ui::AXRole value; |
| 21 NSString* nativeValue; | 20 NSString* nativeValue; |
| 22 }; | 21 }; |
| 23 | 22 |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 [attributeName | 375 [attributeName |
| 377 isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) { | 376 isEqualToString:NSAccessibilityVisibleCharacterRangeAttribute]) { |
| 378 return NO; | 377 return NO; |
| 379 } | 378 } |
| 380 | 379 |
| 381 if ([attributeName isEqualToString:NSAccessibilityValueAttribute] || | 380 if ([attributeName isEqualToString:NSAccessibilityValueAttribute] || |
| 382 [attributeName isEqualToString:NSAccessibilitySelectedTextAttribute]) | 381 [attributeName isEqualToString:NSAccessibilitySelectedTextAttribute]) |
| 383 return node_->GetDelegate()->CanSetStringValue(); | 382 return node_->GetDelegate()->CanSetStringValue(); |
| 384 | 383 |
| 385 if ([attributeName isEqualToString:NSAccessibilityFocusedAttribute]) { | 384 if ([attributeName isEqualToString:NSAccessibilityFocusedAttribute]) { |
| 386 if (ui::AXViewState::IsFlagSet(node_->GetData().state, | 385 if (ui::AXNodeData::IsFlagSet(node_->GetData().state, |
| 387 ui::AX_STATE_FOCUSABLE)) | 386 ui::AX_STATE_FOCUSABLE)) |
| 388 return NO; | 387 return NO; |
| 389 } | 388 } |
| 390 | 389 |
| 391 // TODO(patricialor): Add callbacks for updating the above attributes except | 390 // TODO(patricialor): Add callbacks for updating the above attributes except |
| 392 // NSAccessibilityValueAttribute and return YES. | 391 // NSAccessibilityValueAttribute and return YES. |
| 393 return NO; | 392 return NO; |
| 394 } | 393 } |
| 395 | 394 |
| 396 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { | 395 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { |
| 397 if ([attribute isEqualToString:NSAccessibilityValueAttribute] && | 396 if ([attribute isEqualToString:NSAccessibilityValueAttribute] && |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 - (NSString*)AXRole { | 438 - (NSString*)AXRole { |
| 440 if (!node_) | 439 if (!node_) |
| 441 return nil; | 440 return nil; |
| 442 return [[self class] nativeRoleFromAXRole:node_->GetData().role]; | 441 return [[self class] nativeRoleFromAXRole:node_->GetData().role]; |
| 443 } | 442 } |
| 444 | 443 |
| 445 - (NSString*)AXSubrole { | 444 - (NSString*)AXSubrole { |
| 446 ui::AXRole role = node_->GetData().role; | 445 ui::AXRole role = node_->GetData().role; |
| 447 switch (role) { | 446 switch (role) { |
| 448 case ui::AX_ROLE_TEXT_FIELD: | 447 case ui::AX_ROLE_TEXT_FIELD: |
| 449 if (ui::AXViewState::IsFlagSet(node_->GetData().state, | 448 if (ui::AXNodeData::IsFlagSet(node_->GetData().state, |
| 450 ui::AX_STATE_PROTECTED)) | 449 ui::AX_STATE_PROTECTED)) |
| 451 return NSAccessibilitySecureTextFieldSubrole; | 450 return NSAccessibilitySecureTextFieldSubrole; |
| 452 break; | 451 break; |
| 453 default: | 452 default: |
| 454 break; | 453 break; |
| 455 } | 454 } |
| 456 return [AXPlatformNodeCocoa nativeSubroleFromAXRole:role]; | 455 return [AXPlatformNodeCocoa nativeSubroleFromAXRole:role]; |
| 457 } | 456 } |
| 458 | 457 |
| 459 - (NSString*)AXRoleDescription { | 458 - (NSString*)AXRoleDescription { |
| 460 return NSAccessibilityRoleDescription([self AXRole], [self AXSubrole]); | 459 return NSAccessibilityRoleDescription([self AXRole], [self AXSubrole]); |
| 461 } | 460 } |
| 462 | 461 |
| 463 - (NSValue*)AXSize { | 462 - (NSValue*)AXSize { |
| 464 return [NSValue valueWithSize:self.boundsInScreen.size]; | 463 return [NSValue valueWithSize:self.boundsInScreen.size]; |
| 465 } | 464 } |
| 466 | 465 |
| 467 - (NSString*)AXTitle { | 466 - (NSString*)AXTitle { |
| 468 return [self getStringAttribute:ui::AX_ATTR_NAME]; | 467 return [self getStringAttribute:ui::AX_ATTR_NAME]; |
| 469 } | 468 } |
| 470 | 469 |
| 471 - (NSString*)AXValue { | 470 - (NSString*)AXValue { |
| 472 return [self getStringAttribute:ui::AX_ATTR_VALUE]; | 471 return [self getStringAttribute:ui::AX_ATTR_VALUE]; |
| 473 } | 472 } |
| 474 | 473 |
| 475 - (NSValue*)AXEnabled { | 474 - (NSValue*)AXEnabled { |
| 476 return [NSNumber | 475 return [NSNumber |
| 477 numberWithBool:!ui::AXViewState::IsFlagSet(node_->GetData().state, | 476 numberWithBool:!ui::AXNodeData::IsFlagSet(node_->GetData().state, |
| 478 ui::AX_STATE_DISABLED)]; | 477 ui::AX_STATE_DISABLED)]; |
| 479 } | 478 } |
| 480 | 479 |
| 481 - (NSValue*)AXFocused { | 480 - (NSValue*)AXFocused { |
| 482 if (ui::AXViewState::IsFlagSet(node_->GetData().state, | 481 if (ui::AXNodeData::IsFlagSet(node_->GetData().state, |
| 483 ui::AX_STATE_FOCUSABLE)) | 482 ui::AX_STATE_FOCUSABLE)) |
| 484 return [NSNumber numberWithBool:(node_->GetDelegate()->GetFocus() == | 483 return [NSNumber numberWithBool:(node_->GetDelegate()->GetFocus() == |
| 485 node_->GetNativeViewAccessible())]; | 484 node_->GetNativeViewAccessible())]; |
| 486 return [NSNumber numberWithBool:NO]; | 485 return [NSNumber numberWithBool:NO]; |
| 487 } | 486 } |
| 488 | 487 |
| 489 - (NSString*)AXHelp { | 488 - (NSString*)AXHelp { |
| 490 return [self getStringAttribute:ui::AX_ATTR_DESCRIPTION]; | 489 return [self getStringAttribute:ui::AX_ATTR_DESCRIPTION]; |
| 491 } | 490 } |
| 492 | 491 |
| 493 - (NSWindow*)AXTopLevelUIElement { | 492 - (NSWindow*)AXTopLevelUIElement { |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 } | 584 } |
| 586 NotifyMacEvent(native_node_, event_type); | 585 NotifyMacEvent(native_node_, event_type); |
| 587 } | 586 } |
| 588 | 587 |
| 589 int AXPlatformNodeMac::GetIndexInParent() { | 588 int AXPlatformNodeMac::GetIndexInParent() { |
| 590 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 589 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
| 591 return -1; | 590 return -1; |
| 592 } | 591 } |
| 593 | 592 |
| 594 } // namespace ui | 593 } // namespace ui |
| OLD | NEW |