Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: chrome/browser/cocoa/browser_accessibility.mm

Issue 3200001: Hookup role descriptions for webkit specific strings. Only doing this for ac... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | webkit/glue/webkit_strings.grd » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "chrome/browser/cocoa/browser_accessibility.h" 7 #import "chrome/browser/cocoa/browser_accessibility.h"
8 8
9 #include "app/l10n_util_mac.h"
9 #include "base/string16.h" 10 #include "base/string16.h"
10 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
11 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h" 12 #include "chrome/browser/renderer_host/render_widget_host_view_mac.h"
13 #include "grit/webkit_strings.h"
12 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h" 14 #include "third_party/WebKit/WebKit/chromium/public/WebRect.h"
13 15
14 using webkit_glue::WebAccessibility; 16 using webkit_glue::WebAccessibility;
15 17
16 namespace { 18 namespace {
17 19
18 // Returns an autoreleased copy of the WebAccessibility's attribute. 20 // Returns an autoreleased copy of the WebAccessibility's attribute.
19 NSString* NSStringForWebAccessibilityAttribute( 21 NSString* NSStringForWebAccessibilityAttribute(
20 const std::map<int32, string16>& attributes, 22 const std::map<int32, string16>& attributes,
21 WebAccessibility::Attribute attribute) { 23 WebAccessibility::Attribute attribute) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 const size_t numRoles = sizeof(roles) / sizeof(roles[0]); 123 const size_t numRoles = sizeof(roles) / sizeof(roles[0]);
122 for (size_t i = 0; i < numRoles; ++i) { 124 for (size_t i = 0; i < numRoles; ++i) {
123 if (roles[i].value == value) { 125 if (roles[i].value == value) {
124 role = roles[i].string; 126 role = roles[i].string;
125 break; 127 break;
126 } 128 }
127 } 129 }
128 return role; 130 return role;
129 } 131 }
130 132
133 // Returns a string indicating the role description of this object.
134 - (NSString*)roleDescription {
135 // The following descriptions are specific to webkit.
136 if ([[self role] isEqualToString:@"AXWebArea"])
137 return l10n_util::GetNSString(IDS_AX_ROLE_WEB_AREA);
138
139 if ([[self role] isEqualToString:@"NSAccessibilityLinkRole"])
140 return l10n_util::GetNSString(IDS_AX_ROLE_LINK);
141
142 if ([[self role] isEqualToString:@"AXHeading"])
143 return l10n_util::GetNSString(IDS_AX_ROLE_HEADING);
144
145 return NSAccessibilityRoleDescription([self role], nil);
146 }
147
131 // Returns the size of this object. 148 // Returns the size of this object.
132 - (NSSize)size { 149 - (NSSize)size {
133 return NSMakeSize(webAccessibility_.location.width, 150 return NSMakeSize(webAccessibility_.location.width,
134 webAccessibility_.location.height); 151 webAccessibility_.location.height);
135 } 152 }
136 153
137 // Returns the accessibility value for the given attribute. If the value isn't 154 // Returns the accessibility value for the given attribute. If the value isn't
138 // supported this will return nil. 155 // supported this will return nil.
139 - (id)accessibilityAttributeValue:(NSString*)attribute { 156 - (id)accessibilityAttributeValue:(NSString*)attribute {
140 if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) { 157 if ([attribute isEqualToString:NSAccessibilityRoleAttribute]) {
(...skipping 25 matching lines...) Expand all
166 return base::SysUTF16ToNSString(webAccessibility_.name); 183 return base::SysUTF16ToNSString(webAccessibility_.name);
167 } 184 }
168 if ([attribute isEqualToString:NSAccessibilityHelpAttribute]) { 185 if ([attribute isEqualToString:NSAccessibilityHelpAttribute]) {
169 return NSStringForWebAccessibilityAttribute(webAccessibility_.attributes, 186 return NSStringForWebAccessibilityAttribute(webAccessibility_.attributes,
170 WebAccessibility::ATTR_HELP); 187 WebAccessibility::ATTR_HELP);
171 } 188 }
172 if ([attribute isEqualToString:NSAccessibilityValueAttribute]) { 189 if ([attribute isEqualToString:NSAccessibilityValueAttribute]) {
173 return base::SysUTF16ToNSString(webAccessibility_.value); 190 return base::SysUTF16ToNSString(webAccessibility_.value);
174 } 191 }
175 if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) { 192 if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute]) {
176 return NSAccessibilityRoleDescription([self role], nil); 193 return [self roleDescription];
177 } 194 }
178 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) { 195 if ([attribute isEqualToString:NSAccessibilityFocusedAttribute]) {
179 NSNumber* ret = [NSNumber numberWithBool: 196 NSNumber* ret = [NSNumber numberWithBool:
180 GetState(webAccessibility_, WebAccessibility::STATE_FOCUSED)]; 197 GetState(webAccessibility_, WebAccessibility::STATE_FOCUSED)];
181 return ret; 198 return ret;
182 } 199 }
183 if ([attribute isEqualToString:NSAccessibilityEnabledAttribute] || 200 if ([attribute isEqualToString:NSAccessibilityEnabledAttribute] ||
184 [attribute isEqualToString:@"AXVisited"] || 201 [attribute isEqualToString:@"AXVisited"] ||
185 [attribute isEqualToString:@"AXLoaded"]) { 202 [attribute isEqualToString:@"AXLoaded"]) {
186 return [NSNumber numberWithBool:YES]; 203 return [NSNumber numberWithBool:YES];
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 return NO; 352 return NO;
336 return ([self hash] == [object hash]); 353 return ([self hash] == [object hash]);
337 } 354 }
338 355
339 - (NSUInteger)hash { 356 - (NSUInteger)hash {
340 return webAccessibility_.id; 357 return webAccessibility_.id;
341 } 358 }
342 359
343 @end 360 @end
344 361
OLDNEW
« no previous file with comments | « no previous file | webkit/glue/webkit_strings.grd » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698