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

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: Fixed BrowserAccessibilityCocoa::AXInvalid. Created 6 years 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
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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 return nil; 383 return nil;
384 } 384 }
385 385
386 // Returns whether or not this node should be ignored in the 386 // Returns whether or not this node should be ignored in the
387 // accessibility tree. 387 // accessibility tree.
388 - (BOOL)isIgnored { 388 - (BOOL)isIgnored {
389 return [[self role] isEqualToString:NSAccessibilityUnknownRole]; 389 return [[self role] isEqualToString:NSAccessibilityUnknownRole];
390 } 390 }
391 391
392 - (NSString*)invalid { 392 - (NSString*)invalid {
393 base::string16 invalidUTF; 393 int invalidState;
394 if (!browserAccessibility_->GetHtmlAttribute("aria-invalid", &invalidUTF)) 394 if (!browserAccessibility_->GetIntAttribute(
395 return NULL; 395 ui::AX_ATTR_INVALID_STATE, &invalidState))
396 NSString* invalid = base::SysUTF16ToNSString(invalidUTF);
397 if ([invalid isEqualToString:@"false"] ||
398 [invalid isEqualToString:@""]) {
399 return @"false"; 396 return @"false";
397
398 switch (invalidState) {
399 case ui::AX_INVALID_STATE_FALSE:
400 return @"false";
401 case ui::AX_INVALID_STATE_TRUE:
402 return @"true";
403 case ui::AX_INVALID_STATE_SPELLING:
404 return @"spelling";
405 case ui::AX_INVALID_STATE_GRAMMAR:
406 return @"grammar";
407 case ui::AX_INVALID_STATE_OTHER:
408 {
409 std::string ariaInvalidValue;
410 if (browserAccessibility_->GetStringAttribute(
411 ui::AX_ATTR_ARIA_INVALID_VALUE,
412 &ariaInvalidValue))
413 return base::SysUTF8ToNSString(ariaInvalidValue);
dmazzoni 2014/12/19 17:30:33 nit: this line should be indented 2 spaces less
414 // Return @"true" since we cannot be more specific about the value.
415 return @"true";
416 }
417 default:
418 NOTREACHED();
400 } 419 }
401 return invalid; 420
421 return @"false";
402 } 422 }
403 423
404 - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute 424 - (void)addLinkedUIElementsFromAttribute:(ui::AXIntListAttribute)attribute
405 addTo:(NSMutableArray*)outArray { 425 addTo:(NSMutableArray*)outArray {
406 const std::vector<int32>& attributeValues = 426 const std::vector<int32>& attributeValues =
407 browserAccessibility_->GetIntListAttribute(attribute); 427 browserAccessibility_->GetIntListAttribute(attribute);
408 for (size_t i = 0; i < attributeValues.size(); ++i) { 428 for (size_t i = 0; i < attributeValues.size(); ++i) {
409 BrowserAccessibility* element = 429 BrowserAccessibility* element =
410 browserAccessibility_->manager()->GetFromID(attributeValues[i]); 430 browserAccessibility_->manager()->GetFromID(attributeValues[i]);
411 if (element) 431 if (element)
(...skipping 1098 matching lines...) Expand 10 before | Expand all | Expand 10 after
1510 return [super hash]; 1530 return [super hash];
1511 return browserAccessibility_->GetId(); 1531 return browserAccessibility_->GetId();
1512 } 1532 }
1513 1533
1514 - (BOOL)accessibilityShouldUseUniqueId { 1534 - (BOOL)accessibilityShouldUseUniqueId {
1515 return YES; 1535 return YES;
1516 } 1536 }
1517 1537
1518 @end 1538 @end
1519 1539
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698