| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 NSAccessibilitySubroleAttribute, | 298 NSAccessibilitySubroleAttribute, |
| 299 | 299 |
| 300 // Title is required for most elements. Cocoa asks for the value even if it | 300 // Title is required for most elements. Cocoa asks for the value even if it |
| 301 // is omitted here, but won't present it to accessibility APIs without this. | 301 // is omitted here, but won't present it to accessibility APIs without this. |
| 302 NSAccessibilityTitleAttribute, | 302 NSAccessibilityTitleAttribute, |
| 303 | 303 |
| 304 // Attributes which are not required, but are general to all roles. | 304 // Attributes which are not required, but are general to all roles. |
| 305 NSAccessibilityRoleDescriptionAttribute, | 305 NSAccessibilityRoleDescriptionAttribute, |
| 306 NSAccessibilityEnabledAttribute, | 306 NSAccessibilityEnabledAttribute, |
| 307 NSAccessibilityFocusedAttribute, | 307 NSAccessibilityFocusedAttribute, |
| 308 NSAccessibilityHelpAttribute, |
| 309 NSAccessibilityTopLevelUIElementAttribute, |
| 310 NSAccessibilityWindowAttribute, |
| 308 ]; | 311 ]; |
| 309 | 312 |
| 310 // Attributes required for user-editable controls. | 313 // Attributes required for user-editable controls. |
| 311 NSArray* const kValueAttributes = @[ NSAccessibilityValueAttribute ]; | 314 NSArray* const kValueAttributes = @[ NSAccessibilityValueAttribute ]; |
| 312 | 315 |
| 313 // Attributes required for textfields. | 316 // Attributes required for textfields. |
| 314 NSArray* const kTextfieldAttributes = @[ | 317 NSArray* const kTextfieldAttributes = @[ |
| 315 NSAccessibilityInsertionPointLineNumberAttribute, | 318 NSAccessibilityInsertionPointLineNumberAttribute, |
| 316 NSAccessibilityNumberOfCharactersAttribute, | 319 NSAccessibilityNumberOfCharactersAttribute, |
| 317 NSAccessibilityPlaceholderValueAttribute, | 320 NSAccessibilityPlaceholderValueAttribute, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 ui::AX_STATE_PROTECTED)) | 396 ui::AX_STATE_PROTECTED)) |
| 394 return NSAccessibilitySecureTextFieldSubrole; | 397 return NSAccessibilitySecureTextFieldSubrole; |
| 395 break; | 398 break; |
| 396 default: | 399 default: |
| 397 break; | 400 break; |
| 398 } | 401 } |
| 399 return [AXPlatformNodeCocoa nativeSubroleFromAXRole:role]; | 402 return [AXPlatformNodeCocoa nativeSubroleFromAXRole:role]; |
| 400 } | 403 } |
| 401 | 404 |
| 402 - (NSString*)AXRoleDescription { | 405 - (NSString*)AXRoleDescription { |
| 403 NSString* description = [self getStringAttribute:ui::AX_ATTR_DESCRIPTION]; | 406 return NSAccessibilityRoleDescription([self AXRole], [self AXSubrole]); |
| 404 if (!description) | |
| 405 return NSAccessibilityRoleDescription([self AXRole], [self AXSubrole]); | |
| 406 return description; | |
| 407 } | 407 } |
| 408 | 408 |
| 409 - (NSValue*)AXSize { | 409 - (NSValue*)AXSize { |
| 410 return [NSValue valueWithSize:self.boundsInScreen.size]; | 410 return [NSValue valueWithSize:self.boundsInScreen.size]; |
| 411 } | 411 } |
| 412 | 412 |
| 413 - (NSString*)AXTitle { | 413 - (NSString*)AXTitle { |
| 414 return [self getStringAttribute:ui::AX_ATTR_NAME]; | 414 return [self getStringAttribute:ui::AX_ATTR_NAME]; |
| 415 } | 415 } |
| 416 | 416 |
| 417 - (NSString*)AXValue { | 417 - (NSString*)AXValue { |
| 418 return [self getStringAttribute:ui::AX_ATTR_VALUE]; | 418 return [self getStringAttribute:ui::AX_ATTR_VALUE]; |
| 419 } | 419 } |
| 420 | 420 |
| 421 - (NSValue*)AXEnabled { | 421 - (NSValue*)AXEnabled { |
| 422 return [NSNumber | 422 return [NSNumber |
| 423 numberWithBool:!ui::AXViewState::IsFlagSet(node_->GetData().state, | 423 numberWithBool:!ui::AXViewState::IsFlagSet(node_->GetData().state, |
| 424 ui::AX_STATE_DISABLED)]; | 424 ui::AX_STATE_DISABLED)]; |
| 425 } | 425 } |
| 426 | 426 |
| 427 - (NSValue*)AXFocused { | 427 - (NSValue*)AXFocused { |
| 428 if (ui::AXViewState::IsFlagSet(node_->GetData().state, | 428 if (ui::AXViewState::IsFlagSet(node_->GetData().state, |
| 429 ui::AX_STATE_FOCUSABLE)) | 429 ui::AX_STATE_FOCUSABLE)) |
| 430 return [NSNumber numberWithBool:(node_->GetDelegate()->GetFocus() == | 430 return [NSNumber numberWithBool:(node_->GetDelegate()->GetFocus() == |
| 431 node_->GetNativeViewAccessible())]; | 431 node_->GetNativeViewAccessible())]; |
| 432 return [NSNumber numberWithBool:NO]; | 432 return [NSNumber numberWithBool:NO]; |
| 433 } | 433 } |
| 434 | 434 |
| 435 - (NSString*)AXHelp { |
| 436 return [self getStringAttribute:ui::AX_ATTR_DESCRIPTION]; |
| 437 } |
| 438 |
| 439 - (NSWindow*)AXTopLevelUIElement { |
| 440 return [self AXWindow]; |
| 441 } |
| 442 |
| 443 - (NSWindow*)AXWindow { |
| 444 return node_->GetDelegate()->GetTopLevelWidget(); |
| 445 } |
| 446 |
| 435 // Textfield-specific NSAccessibility attributes. | 447 // Textfield-specific NSAccessibility attributes. |
| 436 | 448 |
| 437 - (NSNumber*)AXInsertionPointLineNumber { | 449 - (NSNumber*)AXInsertionPointLineNumber { |
| 438 // Multiline is not supported on views. | 450 // Multiline is not supported on views. |
| 439 return [NSNumber numberWithInteger:0]; | 451 return [NSNumber numberWithInteger:0]; |
| 440 } | 452 } |
| 441 | 453 |
| 442 - (NSNumber*)AXNumberOfCharacters { | 454 - (NSNumber*)AXNumberOfCharacters { |
| 443 return [NSNumber numberWithInteger:[[self AXValue] length]]; | 455 return [NSNumber numberWithInteger:[[self AXValue] length]]; |
| 444 } | 456 } |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 } | 532 } |
| 521 NotifyMacEvent(target, event_type); | 533 NotifyMacEvent(target, event_type); |
| 522 } | 534 } |
| 523 | 535 |
| 524 int AXPlatformNodeMac::GetIndexInParent() { | 536 int AXPlatformNodeMac::GetIndexInParent() { |
| 525 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 537 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
| 526 return -1; | 538 return -1; |
| 527 } | 539 } |
| 528 | 540 |
| 529 } // namespace ui | 541 } // namespace ui |
| OLD | NEW |