OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <execinfo.h> | 5 #include <execinfo.h> |
6 | 6 |
7 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 7 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
15 #include "content/app/strings/grit/content_strings.h" | 15 #include "content/app/strings/grit/content_strings.h" |
16 #include "content/browser/accessibility/browser_accessibility_manager.h" | 16 #include "content/browser/accessibility/browser_accessibility_manager.h" |
17 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" | 17 #include "content/browser/accessibility/browser_accessibility_manager_mac.h" |
18 #include "content/public/common/content_client.h" | 18 #include "content/public/common/content_client.h" |
19 #import "ui/accessibility/platform/ax_platform_node_mac.h" | 19 #import "ui/accessibility/platform/ax_platform_node_mac.h" |
20 | 20 |
21 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5, | 21 // See http://openradar.appspot.com/9896491. This SPI has been tested on 10.5, |
22 // 10.6, and 10.7. It allows accessibility clients to observe events posted on | 22 // 10.6, and 10.7. It allows accessibility clients to observe events posted on |
23 // this object. | 23 // this object. |
24 extern "C" void NSAccessibilityUnregisterUniqueIdForUIElement(id element); | 24 extern "C" void NSAccessibilityUnregisterUniqueIdForUIElement(id element); |
25 | 25 |
26 using ui::AXNodeData; | 26 using ui::AXNodeData; |
27 using content::BrowserAccessibility; | 27 using content::BrowserAccessibility; |
| 28 using content::BrowserAccessibilityDelegate; |
28 using content::BrowserAccessibilityManager; | 29 using content::BrowserAccessibilityManager; |
29 using content::BrowserAccessibilityManagerMac; | 30 using content::BrowserAccessibilityManagerMac; |
30 using content::ContentClient; | 31 using content::ContentClient; |
31 typedef ui::AXStringAttribute StringAttribute; | 32 typedef ui::AXStringAttribute StringAttribute; |
32 | 33 |
33 namespace { | 34 namespace { |
34 | 35 |
35 // Returns an autoreleased copy of the AXNodeData's attribute. | 36 // Returns an autoreleased copy of the AXNodeData's attribute. |
36 NSString* NSStringForStringAttribute( | 37 NSString* NSStringForStringAttribute( |
37 BrowserAccessibility* browserAccessibility, | 38 BrowserAccessibility* browserAccessibility, |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 return browserAccessibility_->manager() ? | 502 return browserAccessibility_->manager() ? |
502 browserAccessibility_->manager()->delegate() : | 503 browserAccessibility_->manager()->delegate() : |
503 nil; | 504 nil; |
504 } | 505 } |
505 | 506 |
506 - (NSPoint)pointInScreen:(NSPoint)origin | 507 - (NSPoint)pointInScreen:(NSPoint)origin |
507 size:(NSSize)size { | 508 size:(NSSize)size { |
508 if (!browserAccessibility_) | 509 if (!browserAccessibility_) |
509 return NSZeroPoint; | 510 return NSZeroPoint; |
510 | 511 |
511 gfx::Rect bounds(origin.x, origin.y, size.width, size.height); | 512 // Get the delegate for the topmost BrowserAccessibilityManager, because |
512 gfx::Point point = [self delegate]->AccessibilityOriginInScreen(bounds); | 513 // that's the only one that can convert points to their origin in the screen. |
513 return NSMakePoint(point.x(), point.y()); | 514 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
| 515 BrowserAccessibility* root = manager->GetRoot(); |
| 516 while (root->GetParent()) |
| 517 root = root->GetParent()->manager()->GetRoot(); |
| 518 manager = root->manager(); |
| 519 BrowserAccessibilityDelegate* delegate = manager->delegate(); |
| 520 |
| 521 if (delegate) { |
| 522 gfx::Rect bounds(origin.x, origin.y, size.width, size.height); |
| 523 gfx::Point point = delegate->AccessibilityOriginInScreen(bounds); |
| 524 return NSMakePoint(point.x(), point.y()); |
| 525 } else { |
| 526 return NSZeroPoint; |
| 527 } |
514 } | 528 } |
515 | 529 |
516 // Returns a string indicating the NSAccessibility role of this object. | 530 // Returns a string indicating the NSAccessibility role of this object. |
517 - (NSString*)role { | 531 - (NSString*)role { |
518 ui::AXRole role = [self internalRole]; | 532 ui::AXRole role = [self internalRole]; |
519 if (role == ui::AX_ROLE_CANVAS && | 533 if (role == ui::AX_ROLE_CANVAS && |
520 browserAccessibility_->GetBoolAttribute( | 534 browserAccessibility_->GetBoolAttribute( |
521 ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { | 535 ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { |
522 return NSAccessibilityGroupRole; | 536 return NSAccessibilityGroupRole; |
523 } | 537 } |
(...skipping 994 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1518 return [super hash]; | 1532 return [super hash]; |
1519 return browserAccessibility_->GetId(); | 1533 return browserAccessibility_->GetId(); |
1520 } | 1534 } |
1521 | 1535 |
1522 - (BOOL)accessibilityShouldUseUniqueId { | 1536 - (BOOL)accessibilityShouldUseUniqueId { |
1523 return YES; | 1537 return YES; |
1524 } | 1538 } |
1525 | 1539 |
1526 @end | 1540 @end |
1527 | 1541 |
OLD | NEW |