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 657 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
668 } | 668 } |
669 | 669 |
670 - (NSNumber*)expanded { | 670 - (NSNumber*)expanded { |
671 return [NSNumber numberWithBool: | 671 return [NSNumber numberWithBool: |
672 GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; | 672 GetState(browserAccessibility_, ui::AX_STATE_EXPANDED)]; |
673 } | 673 } |
674 | 674 |
675 - (NSNumber*)focused { | 675 - (NSNumber*)focused { |
676 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 676 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
677 NSNumber* ret = [NSNumber numberWithBool: | 677 NSNumber* ret = [NSNumber numberWithBool: |
678 manager->GetFocus(NULL) == browserAccessibility_]; | 678 manager->GetFocus() == browserAccessibility_]; |
679 return ret; | 679 return ret; |
680 } | 680 } |
681 | 681 |
682 - (NSNumber*)grabbed { | 682 - (NSNumber*)grabbed { |
683 std::string grabbed; | 683 std::string grabbed; |
684 if (browserAccessibility_->GetHtmlAttribute("aria-grabbed", &grabbed) && | 684 if (browserAccessibility_->GetHtmlAttribute("aria-grabbed", &grabbed) && |
685 grabbed == "true") | 685 grabbed == "true") |
686 return [NSNumber numberWithBool:YES]; | 686 return [NSNumber numberWithBool:YES]; |
687 | 687 |
688 return [NSNumber numberWithBool:NO]; | 688 return [NSNumber numberWithBool:NO]; |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1125 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()]; | 1125 [ret addObject:rowElement->ToBrowserAccessibilityCocoa()]; |
1126 } | 1126 } |
1127 } | 1127 } |
1128 | 1128 |
1129 return ret; | 1129 return ret; |
1130 } | 1130 } |
1131 | 1131 |
1132 - (NSArray*)selectedChildren { | 1132 - (NSArray*)selectedChildren { |
1133 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; | 1133 NSMutableArray* ret = [[[NSMutableArray alloc] init] autorelease]; |
1134 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 1134 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
1135 BrowserAccessibility* focusedChild = manager->GetFocus(browserAccessibility_); | 1135 BrowserAccessibility* focusedChild = manager->GetFocus(); |
1136 if (!focusedChild->IsDescendantOf(browserAccessibility_)) | |
1137 focusedChild = nullptr; | |
1136 | 1138 |
1137 // If it's not multiselectable, try to skip iterating over the | 1139 // If it's not multiselectable, try to skip iterating over the |
1138 // children. | 1140 // children. |
1139 if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) { | 1141 if (!GetState(browserAccessibility_, ui::AX_STATE_MULTISELECTABLE)) { |
1140 // First try the focused child. | 1142 // First try the focused child. |
1141 if (focusedChild && focusedChild != browserAccessibility_) { | 1143 if (focusedChild && focusedChild != browserAccessibility_) { |
1142 [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()]; | 1144 [ret addObject:focusedChild->ToBrowserAccessibilityCocoa()]; |
1143 return ret; | 1145 return ret; |
1144 } | 1146 } |
1145 | 1147 |
(...skipping 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2025 // Sets the value for an accessibility attribute via the accessibility API. | 2027 // Sets the value for an accessibility attribute via the accessibility API. |
2026 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { | 2028 - (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute { |
2027 if (!browserAccessibility_) | 2029 if (!browserAccessibility_) |
2028 return; | 2030 return; |
2029 | 2031 |
2030 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { | 2032 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { |
2031 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); | 2033 BrowserAccessibilityManager* manager = browserAccessibility_->manager(); |
2032 NSNumber* focusedNumber = value; | 2034 NSNumber* focusedNumber = value; |
2033 BOOL focused = [focusedNumber intValue]; | 2035 BOOL focused = [focusedNumber intValue]; |
2034 if (focused) | 2036 if (focused) |
2035 manager->SetFocus(browserAccessibility_, true); | 2037 manager->SetFocus(*browserAccessibility_); |
David Tseng
2016/01/28 02:00:56
Btw, how does someone clear focus and is browserAc
dmazzoni
2016/01/30 00:02:41
Yes, browserAccessibility_ is non-null because Bro
| |
2036 } | 2038 } |
2037 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { | 2039 if ([attribute isEqualToString:NSAccessibilitySelectedTextRangeAttribute]) { |
2038 NSRange range = [(NSValue*)value rangeValue]; | 2040 NSRange range = [(NSValue*)value rangeValue]; |
2039 [self delegate]->AccessibilitySetSelection( | 2041 [self delegate]->AccessibilitySetSelection( |
2040 browserAccessibility_->GetId(), range.location, | 2042 browserAccessibility_->GetId(), range.location, |
2041 browserAccessibility_->GetId(), range.location + range.length); | 2043 browserAccessibility_->GetId(), range.location + range.length); |
2042 } | 2044 } |
2043 } | 2045 } |
2044 | 2046 |
2045 // Returns the deepest accessibility child that should not be ignored. | 2047 // Returns the deepest accessibility child that should not be ignored. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2082 if (!browserAccessibility_) | 2084 if (!browserAccessibility_) |
2083 return [super hash]; | 2085 return [super hash]; |
2084 return browserAccessibility_->GetId(); | 2086 return browserAccessibility_->GetId(); |
2085 } | 2087 } |
2086 | 2088 |
2087 - (BOOL)accessibilityShouldUseUniqueId { | 2089 - (BOOL)accessibilityShouldUseUniqueId { |
2088 return YES; | 2090 return YES; |
2089 } | 2091 } |
2090 | 2092 |
2091 @end | 2093 @end |
OLD | NEW |