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 #include <stddef.h> | 6 #include <stddef.h> |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #import "content/browser/accessibility/browser_accessibility_cocoa.h" | 9 #import "content/browser/accessibility/browser_accessibility_cocoa.h" |
10 | 10 |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
672 } | 672 } |
673 | 673 |
674 - (NSNumber*)expanded { | 674 - (NSNumber*)expanded { |
675 return [NSNumber numberWithBool: | 675 return [NSNumber numberWithBool: |
676 GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; | 676 GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; |
677 } | 677 } |
678 | 678 |
679 - (NSNumber*)focused { | 679 - (NSNumber*)focused { |
680 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 680 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
681 NSNumber* ret = [NSNumber numberWithBool: | 681 NSNumber* ret = [NSNumber numberWithBool: |
682 manager->GetFocus(NULL) == browserAccessibility_]; | 682 manager->GetFocus() == browserAccessibility_]; |
683 return ret; | 683 return ret; |
684 } | 684 } |
685 | 685 |
686 - (NSNumber*)grabbed { | 686 - (NSNumber*)grabbed { |
687 std::string grabbed; | 687 std::string grabbed; |
688 if (browserAccessibility_->GetHtmlAttribute("aria-grabbed", &grabbed) && | 688 if (browserAccessibility_->GetHtmlAttribute("aria-grabbed", &grabbed) && |
689 grabbed == "true") | 689 grabbed == "true") |
690 return [NSNumber numberWithBool:YES]; | 690 return [NSNumber numberWithBool:YES]; |
691 | 691 |
692 return [NSNumber numberWithBool:NO]; | 692 return [NSNumber numberWithBool:NO]; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1129 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()]; | 1129 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()]; |
1130 } | 1130 } |
1131 } | 1131 } |
1132 | 1132 |
1133 return ret; | 1133 return ret; |
1134 } | 1134 } |
1135 | 1135 |
1136 - (NSArray*)selectedChildren { | 1136 - (NSArray*)selectedChildren { |
1137 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 1137 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
1138 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 1138 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
1139 BrowserAccessibility* focusedChild = manager->GetFocus(browserAccessibility_); | 1139 BrowserAccessibility* focusedChild = manager->GetFocus(); |
| 1140 if (!focusedChild->IsDescendantOf(browserAccessibility_)) |
| 1141 focusedChild = nullptr; |
1140 | 1142 |
1141 // If it's not multiselectable, try to skip iterating over the | 1143 // If it's not multiselectable, try to skip iterating over the |
1142 // children. | 1144 // children. |
1143 if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) { | 1145 if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) { |
1144 // First try the focused child. | 1146 // First try the focused child. |
1145 if (focusedChild && focusedChild != browserAccessibility_) { | 1147 if (focusedChild && focusedChild != browserAccessibility_) { |
1146 [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()]; | 1148 [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()]; |
1147 return ret; | 1149 return ret; |
1148 } | 1150 } |
1149 | 1151 |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2029 // Sets the value for an accessibility attribute via the accessibility API. | 2031 // Sets the value for an accessibility attribute via the accessibility API. |
2030 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { | 2032 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { |
2031 if (!browserAccessibility_) | 2033 if (!browserAccessibility_) |
2032 return; | 2034 return; |
2033 | 2035 |
2034 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { | 2036 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { |
2035 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 2037 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
2036 NSNumber* focusedNumber = value; | 2038 NSNumber* focusedNumber = value; |
2037 BOOL focused = [focusedNumber intValue]; | 2039 BOOL focused = [focusedNumber intValue]; |
2038 if (focused) | 2040 if (focused) |
2039 manager->SetFocus(browserAccessibility_, true); | 2041 manager->SetFocus(*browserAccessibility_); |
2040 } | 2042 } |
2041 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { | 2043 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { |
2042 NSRange range = [(NSValue*)value rangeValue]; | 2044 NSRange range = [(NSValue*)value rangeValue]; |
2043 [self delegate]->AccessibilitySetSelection( | 2045 [self delegate]->AccessibilitySetSelection( |
2044 browserAccessibility_->GetId(), range.location, | 2046 browserAccessibility_->GetId(), range.location, |
2045 browserAccessibility_->GetId(), range.location + range.length); | 2047 browserAccessibility_->GetId(), range.location + range.length); |
2046 } | 2048 } |
2047 } | 2049 } |
2048 | 2050 |
2049 // Returns the deepest accessibility child that should not be ignored. | 2051 // Returns the deepest accessibility child that should not be ignored. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2086 if (!browserAccessibility_) | 2088 if (!browserAccessibility_) |
2087 return [super hash]; | 2089 return [super hash]; |
2088 return browserAccessibility_->GetId(); | 2090 return browserAccessibility_->GetId(); |
2089 } | 2091 } |
2090 | 2092 |
2091 - (BOOL)accessibilityShouldUseUniqueId { | 2093 - (BOOL)accessibilityShouldUseUniqueId { |
2092 return YES; | 2094 return YES; |
2093 } | 2095 } |
2094 | 2096 |
2095 @end | 2097 @end |
OLD | NEW |