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

Side by Side Diff: content/browser/accessibility/browser_accessibility_cocoa.mm

Issue 790003003: Exposed the invalid state of form controls to the accessibility APIs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Tried fixing Android unit tests. Created 5 years, 11 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 | content/browser/accessibility/browser_accessibility_win.cc » ('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) 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 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
384 return nil; 384 return nil;
385 } 385 }
386 386
387 // Returns whether or not this node should be ignored in the 387 // Returns whether or not this node should be ignored in the
388 // accessibility tree. 388 // accessibility tree.
389 - (BOOL)isIgnored { 389 - (BOOL)isIgnored {
390 return [[self role] isEqualToString:NSAccessibilityUnknownRole]; 390 return [[self role] isEqualToString:NSAccessibilityUnknownRole];
391 } 391 }
392 392
393 - (NSString*)invalid { 393 - (NSString*)invalid {
394 base::string16 invalidUTF; 394 int invalidState;
395 if (!browserAccessibility_->GetHtmlAttribute("aria-invalid", &invalidUTF)) 395 if (!browserAccessibility_->GetIntAttribute(
396 return NULL; 396 ui::AX_ATTR_INVALID_STATE, &invalidState))
397 NSString* invalid = base::SysUTF16ToNSString(invalidUTF);
398 if ([invalid isEqualToString:@"false"] ||
399 [invalid isEqualToString:@""]) {
400 return @"false"; 397 return @"false";
398
399 switch (invalidState) {
400 case ui::AX_INVALID_STATE_FALSE:
401 return @"false";
402 case ui::AX_INVALID_STATE_TRUE:
403 return @"true";
404 case ui::AX_INVALID_STATE_SPELLING:
405 return @"spelling";
406 case ui::AX_INVALID_STATE_GRAMMAR:
407 return @"grammar";
408 case ui::AX_INVALID_STATE_OTHER:
409 {
410 std::string ariaInvalidValue;
411 if (browserAccessibility_->GetStringAttribute(
412 ui::AX_ATTR_ARIA_INVALID_VALUE,
413 &ariaInvalidValue))
414 return base::SysUTF8ToNSString(ariaInvalidValue);
415 // Return @"true" since we cannot be more specific about the value.
416 return @"true";
417 }
418 default:
419 NOTREACHED();
401 } 420 }
402 return invalid; 421
422 return @"false";
403 } 423 }
404 424
405 - (NSString*)placeholder { 425 - (NSString*)placeholder {
406 return NSStringForStringAttribute( 426 return NSStringForStringAttribute(
407 browserAccessibility_, ui::AX_ATTR_PLACEHOLDER); 427 browserAccessibility_, ui::AX_ATTR_PLACEHOLDER);
408 } 428 }
409 429
410 - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute 430 - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute
411 addTo:(NSMutableArray*)outArray { 431 addTo:(NSMutableArray*)outArray {
412 const std::vector<int32>& attributeValues = 432 const std::vector<int32>& attributeValues =
(...skipping 1119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 return [super hash]; 1552 return [super hash];
1533 return browserAccessibility_->GetId(); 1553 return browserAccessibility_->GetId();
1534 } 1554 }
1535 1555
1536 - (BOOL)accessibilityShouldUseUniqueId { 1556 - (BOOL)accessibilityShouldUseUniqueId {
1537 return YES; 1557 return YES;
1538 } 1558 }
1539 1559
1540 @end 1560 @end
1541 1561
OLDNEW
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698