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 |
(...skipping 1473 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1484 // that backs this object. | 1484 // that backs this object. |
1485 - (void)accessibilityPerformAction:(NSString*)action { | 1485 - (void)accessibilityPerformAction:(NSString*)action { |
1486 if (!browserAccessibility_) | 1486 if (!browserAccessibility_) |
1487 return; | 1487 return; |
1488 | 1488 |
1489 // TODO(dmazzoni): Support more actions. | 1489 // TODO(dmazzoni): Support more actions. |
1490 if ([action isEqualToString:NSAccessibilityPressAction]) { | 1490 if ([action isEqualToString:NSAccessibilityPressAction]) { |
1491 [self delegate]->AccessibilityDoDefaultAction( | 1491 [self delegate]->AccessibilityDoDefaultAction( |
1492 browserAccessibility_->GetId()); | 1492 browserAccessibility_->GetId()); |
1493 } else if ([action isEqualToString:NSAccessibilityShowMenuAction]) { | 1493 } else if ([action isEqualToString:NSAccessibilityShowMenuAction]) { |
1494 [self delegate]->AccessibilityShowMenu(browserAccessibility_->GetId()); | 1494 NSPoint objOrigin = [self origin]; |
| 1495 NSSize size = [[self size] sizeValue]; |
| 1496 gfx::Point origin = [self delegate]->AccessibilityOriginInScreen( |
| 1497 gfx::Rect(objOrigin.x, objOrigin.y, size.width, size.height)); |
| 1498 origin.set_x(origin.x() + size.width / 2); |
| 1499 origin.set_y(origin.y() + size.width / 2); |
| 1500 [self delegate]->AccessibilityShowMenu(origin); |
1495 } | 1501 } |
1496 } | 1502 } |
1497 | 1503 |
1498 // Returns the description of the given action. | 1504 // Returns the description of the given action. |
1499 - (NSString*)accessibilityActionDescription:(NSString*)action { | 1505 - (NSString*)accessibilityActionDescription:(NSString*)action { |
1500 if (!browserAccessibility_) | 1506 if (!browserAccessibility_) |
1501 return nil; | 1507 return nil; |
1502 | 1508 |
1503 return NSAccessibilityActionDescription(action); | 1509 return NSAccessibilityActionDescription(action); |
1504 } | 1510 } |
1505 | 1511 |
1506 // Sets an override value for a specific accessibility attribute. | 1512 // Sets an override value for a specific accessibility attribute. |
1507 // This class does not support this. | 1513 // This class does not support this. |
1508 - (BOOL)accessibilitySetOverrideValue:(id)value | 1514 - (BOOL)accessibilitySetOverrideValue:(id)value |
1509 forAttribute:(NSString*)attribute { | 1515 forAttribute:(NSString*)attribute { |
1510 return NO; | 1516 return NO; |
1511 } | 1517 } |
1512 | 1518 |
1513 // Sets the value for an accessibility attribute via the accessibility API. | 1519 // Sets the value for an accessibility attribute via the accessibility API. |
1514 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { | 1520 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { |
1515 if (!browserAccessibility_) | 1521 if (!browserAccessibility_) |
1516 return; | 1522 return; |
1517 | 1523 |
1518 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { | 1524 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { |
| 1525 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
1519 NSNumber* focusedNumber = value; | 1526 NSNumber* focusedNumber = value; |
1520 BOOL focused = [focusedNumber intValue]; | 1527 BOOL focused = [focusedNumber intValue]; |
1521 if (focused) | 1528 if (focused) |
1522 [self delegate]->AccessibilitySetFocus(browserAccessibility_->GetId()); | 1529 manager->SetFocus(browserAccessibility_, true); |
1523 } | 1530 } |
1524 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { | 1531 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { |
1525 NSRange range = [(NSValue*)value rangeValue]; | 1532 NSRange range = [(NSValue*)value rangeValue]; |
1526 [self delegate]->AccessibilitySetTextSelection( | 1533 [self delegate]->AccessibilitySetTextSelection( |
1527 browserAccessibility_->GetId(), | 1534 browserAccessibility_->GetId(), |
1528 range.location, range.location + range.length); | 1535 range.location, range.location + range.length); |
1529 } | 1536 } |
1530 } | 1537 } |
1531 | 1538 |
1532 // Returns the deepest accessibility child that should not be ignored. | 1539 // Returns the deepest accessibility child that should not be ignored. |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1570 return [super hash]; | 1577 return [super hash]; |
1571 return browserAccessibility_->GetId(); | 1578 return browserAccessibility_->GetId(); |
1572 } | 1579 } |
1573 | 1580 |
1574 - (BOOL)accessibilityShouldUseUniqueId { | 1581 - (BOOL)accessibilityShouldUseUniqueId { |
1575 return YES; | 1582 return YES; |
1576 } | 1583 } |
1577 | 1584 |
1578 @end | 1585 @end |
1579 | 1586 |
OLD | NEW |