| 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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 475 - (NSString*)orientation { | 475 - (NSString*)orientation { |
| 476 if (GetState(browserAccessibility_, ui::AX_STATE_VERTICAL)) | 476 if (GetState(browserAccessibility_, ui::AX_STATE_VERTICAL)) |
| 477 return NSAccessibilityVerticalOrientationValue; | 477 return NSAccessibilityVerticalOrientationValue; |
| 478 else if (GetState(browserAccessibility_, ui::AX_STATE_HORIZONTAL)) | 478 else if (GetState(browserAccessibility_, ui::AX_STATE_HORIZONTAL)) |
| 479 return NSAccessibilityHorizontalOrientationValue; | 479 return NSAccessibilityHorizontalOrientationValue; |
| 480 | 480 |
| 481 return @""; | 481 return @""; |
| 482 } | 482 } |
| 483 | 483 |
| 484 - (NSNumber*)numberOfCharacters { | 484 - (NSNumber*)numberOfCharacters { |
| 485 return [NSNumber numberWithInt:browserAccessibility_->value().length()]; | 485 std::string value = browserAccessibility_->GetStringAttribute( |
| 486 ui::AX_ATTR_VALUE); |
| 487 return [NSNumber numberWithInt:value.size()]; |
| 486 } | 488 } |
| 487 | 489 |
| 488 // The origin of this accessibility object in the page's document. | 490 // The origin of this accessibility object in the page's document. |
| 489 // This is relative to webkit's top-left origin, not Cocoa's | 491 // This is relative to webkit's top-left origin, not Cocoa's |
| 490 // bottom-left origin. | 492 // bottom-left origin. |
| 491 - (NSPoint)origin { | 493 - (NSPoint)origin { |
| 492 gfx::Rect bounds = browserAccessibility_->GetLocalBoundsRect(); | 494 gfx::Rect bounds = browserAccessibility_->GetLocalBoundsRect(); |
| 493 return NSMakePoint(bounds.x(), bounds.y()); | 495 return NSMakePoint(bounds.x(), bounds.y()); |
| 494 } | 496 } |
| 495 | 497 |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 return NSStringForStringAttribute( | 913 return NSStringForStringAttribute( |
| 912 browserAccessibility_, ui::AX_ATTR_VALUE); | 914 browserAccessibility_, ui::AX_ATTR_VALUE); |
| 913 } | 915 } |
| 914 | 916 |
| 915 - (NSString*)valueDescription { | 917 - (NSString*)valueDescription { |
| 916 return NSStringForStringAttribute( | 918 return NSStringForStringAttribute( |
| 917 browserAccessibility_, ui::AX_ATTR_VALUE); | 919 browserAccessibility_, ui::AX_ATTR_VALUE); |
| 918 } | 920 } |
| 919 | 921 |
| 920 - (NSValue*)visibleCharacterRange { | 922 - (NSValue*)visibleCharacterRange { |
| 921 return [NSValue valueWithRange: | 923 std::string value = browserAccessibility_->GetStringAttribute( |
| 922 NSMakeRange(0, browserAccessibility_->value().length())]; | 924 ui::AX_ATTR_VALUE); |
| 925 return [NSValue valueWithRange:NSMakeRange(0, value.size())]; |
| 923 } | 926 } |
| 924 | 927 |
| 925 - (NSArray*)visibleCells { | 928 - (NSArray*)visibleCells { |
| 926 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 929 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
| 927 const std::vector<int32>& uniqueCellIds = | 930 const std::vector<int32>& uniqueCellIds = |
| 928 browserAccessibility_->GetIntListAttribute( | 931 browserAccessibility_->GetIntListAttribute( |
| 929 ui::AX_ATTR_UNIQUE_CELL_IDS); | 932 ui::AX_ATTR_UNIQUE_CELL_IDS); |
| 930 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { | 933 for (size_t i = 0; i < uniqueCellIds.size(); ++i) { |
| 931 int id = uniqueCellIds[i]; | 934 int id = uniqueCellIds[i]; |
| 932 BrowserAccessibility* cell = | 935 BrowserAccessibility* cell = |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1026 // Returns the accessibility value for the given attribute and parameter. If the | 1029 // Returns the accessibility value for the given attribute and parameter. If the |
| 1027 // value isn't supported this will return nil. | 1030 // value isn't supported this will return nil. |
| 1028 - (id)accessibilityAttributeValue:(NSString*)attribute | 1031 - (id)accessibilityAttributeValue:(NSString*)attribute |
| 1029 forParameter:(id)parameter { | 1032 forParameter:(id)parameter { |
| 1030 if (!browserAccessibility_) | 1033 if (!browserAccessibility_) |
| 1031 return nil; | 1034 return nil; |
| 1032 | 1035 |
| 1033 const std::vector<int32>& line_breaks = | 1036 const std::vector<int32>& line_breaks = |
| 1034 browserAccessibility_->GetIntListAttribute( | 1037 browserAccessibility_->GetIntListAttribute( |
| 1035 ui::AX_ATTR_LINE_BREAKS); | 1038 ui::AX_ATTR_LINE_BREAKS); |
| 1036 int len = static_cast<int>(browserAccessibility_->value().size()); | 1039 std::string value = browserAccessibility_->GetStringAttribute( |
| 1040 ui::AX_ATTR_VALUE); |
| 1041 int len = static_cast<int>(value.size()); |
| 1037 | 1042 |
| 1038 if ([attribute isEqualToString: | 1043 if ([attribute isEqualToString: |
| 1039 NSAccessibilityStringForRangeParameterizedAttribute]) { | 1044 NSAccessibilityStringForRangeParameterizedAttribute]) { |
| 1040 NSRange range = [(NSValue*)parameter rangeValue]; | 1045 NSRange range = [(NSValue*)parameter rangeValue]; |
| 1041 std::string value = browserAccessibility_->GetStringAttribute( | 1046 std::string value = browserAccessibility_->GetStringAttribute( |
| 1042 ui::AX_ATTR_VALUE); | 1047 ui::AX_ATTR_VALUE); |
| 1043 return base::SysUTF8ToNSString(value.substr(range.location, range.length)); | 1048 return base::SysUTF8ToNSString(value.substr(range.location, range.length)); |
| 1044 } | 1049 } |
| 1045 | 1050 |
| 1046 if ([attribute isEqualToString: | 1051 if ([attribute isEqualToString: |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1560 if (!browserAccessibility_) | 1565 if (!browserAccessibility_) |
| 1561 return [super hash]; | 1566 return [super hash]; |
| 1562 return browserAccessibility_->GetId(); | 1567 return browserAccessibility_->GetId(); |
| 1563 } | 1568 } |
| 1564 | 1569 |
| 1565 - (BOOL)accessibilityShouldUseUniqueId { | 1570 - (BOOL)accessibilityShouldUseUniqueId { |
| 1566 return YES; | 1571 return YES; |
| 1567 } | 1572 } |
| 1568 | 1573 |
| 1569 @end | 1574 @end |
| OLD | NEW |