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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
274 return gfx::ScreenRectToNSRect(node_->GetBoundsInScreen()); | 274 return gfx::ScreenRectToNSRect(node_->GetBoundsInScreen()); |
275 } | 275 } |
276 | 276 |
277 - (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute { | 277 - (NSString*)getStringAttribute:(ui::AXStringAttribute)attribute { |
278 std::string attributeValue; | 278 std::string attributeValue; |
279 if (node_->GetStringAttribute(attribute, &attributeValue)) | 279 if (node_->GetStringAttribute(attribute, &attributeValue)) |
280 return base::SysUTF8ToNSString(attributeValue); | 280 return base::SysUTF8ToNSString(attributeValue); |
281 return nil; | 281 return nil; |
282 } | 282 } |
283 | 283 |
| 284 - (ui::AXPlatformNodeBase*)getNode { |
| 285 return node_; |
| 286 } |
| 287 |
284 // NSAccessibility informal protocol implementation. | 288 // NSAccessibility informal protocol implementation. |
285 | 289 |
286 - (BOOL)accessibilityIsIgnored { | 290 - (BOOL)accessibilityIsIgnored { |
287 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole] || | 291 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole] || |
288 node_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE); | 292 node_->GetData().HasStateFlag(ui::AX_STATE_INVISIBLE); |
289 } | 293 } |
290 | 294 |
291 - (id)accessibilityHitTest:(NSPoint)point { | 295 - (id)accessibilityHitTest:(NSPoint)point { |
292 for (AXPlatformNodeCocoa* child in [self AXChildren]) { | 296 for (AXPlatformNodeCocoa* child in [self AXChildren]) { |
293 if (NSPointInRect(point, child.boundsInScreen)) | 297 if (![child accessibilityIsIgnored] && |
| 298 NSPointInRect(point, [child boundsInScreen])) |
294 return [child accessibilityHitTest:point]; | 299 return [child accessibilityHitTest:point]; |
295 } | 300 } |
296 return NSAccessibilityUnignoredAncestor(self); | 301 return NSAccessibilityUnignoredAncestor(self); |
297 } | 302 } |
298 | 303 |
299 - (BOOL)accessibilityNotifiesWhenDestroyed { | 304 - (BOOL)accessibilityNotifiesWhenDestroyed { |
300 return YES; | 305 return YES; |
301 } | 306 } |
302 | 307 |
303 - (id)accessibilityFocusedUIElement { | 308 - (id)accessibilityFocusedUIElement { |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 | 616 |
612 namespace ui { | 617 namespace ui { |
613 | 618 |
614 // static | 619 // static |
615 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) { | 620 AXPlatformNode* AXPlatformNode::Create(AXPlatformNodeDelegate* delegate) { |
616 AXPlatformNodeBase* node = new AXPlatformNodeMac(); | 621 AXPlatformNodeBase* node = new AXPlatformNodeMac(); |
617 node->Init(delegate); | 622 node->Init(delegate); |
618 return node; | 623 return node; |
619 } | 624 } |
620 | 625 |
| 626 // static |
| 627 AX_EXPORT AXPlatformNode* AXPlatformNode::FromNativeViewAccessible( |
| 628 gfx::NativeViewAccessible accessible) { |
| 629 if ([accessible isKindOfClass:[AXPlatformNodeCocoa class]]) |
| 630 return [accessible getNode]; |
| 631 return nullptr; |
| 632 } |
| 633 |
621 AXPlatformNodeMac::AXPlatformNodeMac() { | 634 AXPlatformNodeMac::AXPlatformNodeMac() { |
622 } | 635 } |
623 | 636 |
624 AXPlatformNodeMac::~AXPlatformNodeMac() { | 637 AXPlatformNodeMac::~AXPlatformNodeMac() { |
625 } | 638 } |
626 | 639 |
627 void AXPlatformNodeMac::Destroy() { | 640 void AXPlatformNodeMac::Destroy() { |
628 if (native_node_) | 641 if (native_node_) |
629 [native_node_ detach]; | 642 [native_node_ detach]; |
630 AXPlatformNodeBase::Destroy(); | 643 AXPlatformNodeBase::Destroy(); |
(...skipping 22 matching lines...) Expand all Loading... |
653 } | 666 } |
654 NotifyMacEvent(native_node_, event_type); | 667 NotifyMacEvent(native_node_, event_type); |
655 } | 668 } |
656 | 669 |
657 int AXPlatformNodeMac::GetIndexInParent() { | 670 int AXPlatformNodeMac::GetIndexInParent() { |
658 // TODO(dmazzoni): implement this. http://crbug.com/396137 | 671 // TODO(dmazzoni): implement this. http://crbug.com/396137 |
659 return -1; | 672 return -1; |
660 } | 673 } |
661 | 674 |
662 } // namespace ui | 675 } // namespace ui |
OLD | NEW |