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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/accessibility/browser_accessibility_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/accessibility/browser_accessibility_cocoa.mm
diff --git a/content/browser/accessibility/browser_accessibility_cocoa.mm b/content/browser/accessibility/browser_accessibility_cocoa.mm
index 06b17ccdb8a4d6bc87095e847adcdfe6705974a0..1b720658e242816b88432d9b22c9c6afb2ac7cf8 100644
--- a/content/browser/accessibility/browser_accessibility_cocoa.mm
+++ b/content/browser/accessibility/browser_accessibility_cocoa.mm
@@ -391,15 +391,35 @@ NSDictionary* attributeToMethodNameMap = nil;
}
- (NSString*)invalid {
- base::string16 invalidUTF;
- if (!browserAccessibility_->GetHtmlAttribute("aria-invalid", &invalidUTF))
- return NULL;
- NSString* invalid = base::SysUTF16ToNSString(invalidUTF);
- if ([invalid isEqualToString:@"false"] ||
- [invalid isEqualToString:@""]) {
+ int invalidState;
+ if (!browserAccessibility_->GetIntAttribute(
+ ui::AX_ATTR_INVALID_STATE, &invalidState))
return @"false";
+
+ switch (invalidState) {
+ case ui::AX_INVALID_STATE_FALSE:
+ return @"false";
+ case ui::AX_INVALID_STATE_TRUE:
+ return @"true";
+ case ui::AX_INVALID_STATE_SPELLING:
+ return @"spelling";
+ case ui::AX_INVALID_STATE_GRAMMAR:
+ return @"grammar";
+ case ui::AX_INVALID_STATE_OTHER:
+ {
+ std::string ariaInvalidValue;
+ if (browserAccessibility_->GetStringAttribute(
+ ui::AX_ATTR_ARIA_INVALID_VALUE,
+ &ariaInvalidValue))
+ return base::SysUTF8ToNSString(ariaInvalidValue);
+ // Return @"true" since we cannot be more specific about the value.
+ return @"true";
+ }
+ default:
+ NOTREACHED();
}
- return invalid;
+
+ return @"false";
}
- (NSString*)placeholder {
« 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