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

Side by Side Diff: ui/accessibility/platform/ax_platform_node_mac.mm

Issue 976403004: MacViews: Fix accessibility hit tests, provide AXTitle (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20150303-MacViews-Disable-Touch-Tests
Patch Set: tweak comments Created 5 years, 9 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
« no previous file with comments | « no previous file | ui/views/cocoa/bridged_native_widget.mm » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "ui/accessibility/platform/ax_platform_node_mac.h" 5 #import "ui/accessibility/platform/ax_platform_node_mac.h"
6 6
7 #import <Cocoa/Cocoa.h> 7 #import <Cocoa/Cocoa.h>
8 8
9 #include "base/strings/sys_string_conversions.h" 9 #include "base/strings/sys_string_conversions.h"
10 #import "ui/accessibility/ax_node_data.h" 10 #import "ui/accessibility/ax_node_data.h"
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 - (NSString*)AXRole { 237 - (NSString*)AXRole {
238 if (!node_) 238 if (!node_)
239 return nil; 239 return nil;
240 return [[self class] nativeRoleFromAXRole:node_->GetData().role]; 240 return [[self class] nativeRoleFromAXRole:node_->GetData().role];
241 } 241 }
242 242
243 - (NSValue*)AXSize { 243 - (NSValue*)AXSize {
244 return [NSValue valueWithSize:self.boundsInScreen.size]; 244 return [NSValue valueWithSize:self.boundsInScreen.size];
245 } 245 }
246 246
247 - (NSString*)AXTitle {
248 std::string value;
249 if (node_->GetStringAttribute(ui::AX_ATTR_NAME, &value))
250 return base::SysUTF8ToNSString(value);
251 return nil;
252 }
253
247 // NSAccessibility informal protocol implementation. 254 // NSAccessibility informal protocol implementation.
248 255
249 - (BOOL)accessibilityIsIgnored { 256 - (BOOL)accessibilityIsIgnored {
250 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole]; 257 return [[self AXRole] isEqualToString:NSAccessibilityUnknownRole];
251 } 258 }
252 259
253 - (id)accessibilityHitTest:(NSPoint)point { 260 - (id)accessibilityHitTest:(NSPoint)point {
254 for (AXPlatformNodeCocoa* child in [self AXChildren]) { 261 for (AXPlatformNodeCocoa* child in [self AXChildren]) {
255 if (NSPointInRect(point, child.boundsInScreen)) 262 if (NSPointInRect(point, child.boundsInScreen))
256 return [child accessibilityHitTest:point]; 263 return [child accessibilityHitTest:point];
257 } 264 }
258 return NSAccessibilityUnignoredAncestor(self); 265 return NSAccessibilityUnignoredAncestor(self);
259 } 266 }
260 267
261 - (NSArray*)accessibilityActionNames { 268 - (NSArray*)accessibilityActionNames {
262 return nil; 269 return nil;
263 } 270 }
264 271
265 - (NSArray*)accessibilityAttributeNames { 272 - (NSArray*)accessibilityAttributeNames {
273 // These attributes are required on all accessibility objects.
266 return @[ 274 return @[
267 NSAccessibilityChildrenAttribute, 275 NSAccessibilityChildrenAttribute,
268 NSAccessibilityParentAttribute, 276 NSAccessibilityParentAttribute,
269 NSAccessibilityPositionAttribute, 277 NSAccessibilityPositionAttribute,
270 NSAccessibilityRoleAttribute, 278 NSAccessibilityRoleAttribute,
271 NSAccessibilitySizeAttribute, 279 NSAccessibilitySizeAttribute,
280
281 // Title is required for most elements. Cocoa asks for the value even if it
282 // is omitted here, but won't present it to accessibility APIs without this.
283 NSAccessibilityTitleAttribute,
272 ]; 284 ];
285 // TODO(tapted): Add additional attributes based on role.
273 } 286 }
274 287
275 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute { 288 - (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute {
276 return NO; 289 return NO;
277 } 290 }
278 291
279 - (id)accessibilityAttributeValue:(NSString*)attribute { 292 - (id)accessibilityAttributeValue:(NSString*)attribute {
280 SEL selector = NSSelectorFromString(attribute); 293 SEL selector = NSSelectorFromString(attribute);
281 if ([self respondsToSelector:selector]) 294 if ([self respondsToSelector:selector])
282 return [self performSelector:selector]; 295 return [self performSelector:selector];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 void AXPlatformNodeMac::NotifyAccessibilityEvent(ui::AXEvent event_type) { 329 void AXPlatformNodeMac::NotifyAccessibilityEvent(ui::AXEvent event_type) {
317 // TODO(dmazzoni): implement this. http://crbug.com/396137 330 // TODO(dmazzoni): implement this. http://crbug.com/396137
318 } 331 }
319 332
320 int AXPlatformNodeMac::GetIndexInParent() { 333 int AXPlatformNodeMac::GetIndexInParent() {
321 // TODO(dmazzoni): implement this. http://crbug.com/396137 334 // TODO(dmazzoni): implement this. http://crbug.com/396137
322 return -1; 335 return -1;
323 } 336 }
324 337
325 } // namespace ui 338 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/views/cocoa/bridged_native_widget.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698