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 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
527 return browserAccessibility_->manager() ? | 528 return browserAccessibility_->manager() ? |
528 browserAccessibility_->manager()->delegate() : | 529 browserAccessibility_->manager()->delegate() : |
529 nil; | 530 nil; |
530 } | 531 } |
531 | 532 |
532 - (NSPoint)pointInScreen:(NSPoint)origin | 533 - (NSPoint)pointInScreen:(NSPoint)origin |
533 size:(NSSize)size { | 534 size:(NSSize)size { |
534 if (!browserAccessibility_) | 535 if (!browserAccessibility_) |
535 return NSZeroPoint; | 536 return NSZeroPoint; |
536 | 537 |
537 gfx::Rect bounds(origin.x, origin.y, size.width, size.height); | 538 // Get the delegate for the topmost BrowserAccessibilityManager, because |
538 gfx::Point point = [self delegate]->AccessibilityOriginInScreen(bounds); | 539 // that's the only one that can convert points to their origin in the screen. |
539 return NSMakePoint(point.x(), point.y()); | 540 BrowserAccessibilityDelegate* delegate = GetDelegateFromRootManager(); |
| 541 if (delegate) { |
| 542 gfx::Rect bounds(origin.x, origin.y, size.width, size.height); |
| 543 gfx::Point point = delegate->AccessibilityOriginInScreen(bounds); |
| 544 return NSMakePoint(point.x(), point.y()); |
| 545 } else { |
| 546 return NSZeroPoint; |
| 547 } |
540 } | 548 } |
541 | 549 |
542 // Returns a string indicating the NSAccessibility role of this object. | 550 // Returns a string indicating the NSAccessibility role of this object. |
543 - (NSString*)role { | 551 - (NSString*)role { |
544 ui::AXRole role = [self internalRole]; | 552 ui::AXRole role = [self internalRole]; |
545 if (role == ui::AX_ROLE_CANVAS && | 553 if (role == ui::AX_ROLE_CANVAS && |
546 browserAccessibility_->GetBoolAttribute( | 554 browserAccessibility_->GetBoolAttribute( |
547 ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { | 555 ui::AX_ATTR_CANVAS_HAS_FALLBACK)) { |
548 return NSAccessibilityGroupRole; | 556 return NSAccessibilityGroupRole; |
549 } | 557 } |
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 if (!browserAccessibility_) | 1559 if (!browserAccessibility_) |
1552 return [super hash]; | 1560 return [super hash]; |
1553 return browserAccessibility_->GetId(); | 1561 return browserAccessibility_->GetId(); |
1554 } | 1562 } |
1555 | 1563 |
1556 - (BOOL)accessibilityShouldUseUniqueId { | 1564 - (BOOL)accessibilityShouldUseUniqueId { |
1557 return YES; | 1565 return YES; |
1558 } | 1566 } |
1559 | 1567 |
1560 @end | 1568 @end |
1561 | |
OLD | NEW |