Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility_win.cc |
| diff --git a/content/browser/accessibility/browser_accessibility_win.cc b/content/browser/accessibility/browser_accessibility_win.cc |
| index b269a07b49a38e6e3eb430d08196c962a02a5315..2946b7f67e5fe93eb30f5e7b7afd4a712cc6eb0c 100644 |
| --- a/content/browser/accessibility/browser_accessibility_win.cc |
| +++ b/content/browser/accessibility/browser_accessibility_win.cc |
| @@ -2979,6 +2979,42 @@ void BrowserAccessibilityWin::OnDataChanged() { |
| } |
| } |
| + // Expose invalid state for form controls and elements with aria-invalid. |
| + int invalidState; |
|
dmazzoni
2014/12/19 17:30:33
nit: invalid_state (c++ files in Chromium are like
|
| + if (GetIntAttribute(ui::AX_ATTR_INVALID_STATE, &invalidState)) { |
| + // TODO(nektar): Handle the possibility of having multiple aria-invalid |
| + // attributes defined, e.g., "invalid:spelling,grammar". |
| + switch (invalidState) { |
| + case ui::AX_INVALID_STATE_NONE: |
| + break; |
| + case ui::AX_INVALID_STATE_FALSE: |
| + ia2_attributes_.push_back(L"invalid:false"); |
| + break; |
| + case ui::AX_INVALID_STATE_TRUE: |
| + ia2_attributes_.push_back(L"invalid:true"); |
| + break; |
| + case ui::AX_INVALID_STATE_SPELLING: |
| + ia2_attributes_.push_back(L"invalid:spelling"); |
| + break; |
| + case ui::AX_INVALID_STATE_GRAMMAR: |
| + ia2_attributes_.push_back(L"invalid:grammar"); |
| + break; |
| + case ui::AX_INVALID_STATE_OTHER: |
| + { |
| + base::string16 ariaInvalidValue; |
| + if (GetString16Attribute(ui::AX_ATTR_ARIA_INVALID_VALUE, |
|
dmazzoni
2014/12/19 17:30:33
nit: you need braces for both the "if" and "else"
|
| + &ariaInvalidValue)) |
| + ia2_attributes_.push_back(L"invalid:" + ariaInvalidValue); |
|
dmazzoni
2014/12/19 17:30:33
nit: indent 2 less
|
| + else |
| + // Set the attribute to L"true", since we cannot be more specific. |
| + ia2_attributes_.push_back(L"invalid:true"); |
|
dmazzoni
2014/12/19 17:30:33
nit: indent 2 less
|
| + } |
| + break; |
| + default: |
| + NOTREACHED(); |
| + } |
| + } |
| + |
| // The calculation of the accessible name of an element has been |
| // standardized in the HTML to Platform Accessibility APIs Implementation |
| // Guide (http://www.w3.org/TR/html-aapi/). In order to return the |
| @@ -3285,16 +3321,22 @@ void BrowserAccessibilityWin::HandleSpecialTextOffset( |
| ui::TextBoundaryType BrowserAccessibilityWin::IA2TextBoundaryToTextBoundary( |
| IA2TextBoundaryType ia2_boundary) { |
| switch(ia2_boundary) { |
| - case IA2_TEXT_BOUNDARY_CHAR: return ui::CHAR_BOUNDARY; |
| - case IA2_TEXT_BOUNDARY_WORD: return ui::WORD_BOUNDARY; |
| - case IA2_TEXT_BOUNDARY_LINE: return ui::LINE_BOUNDARY; |
| - case IA2_TEXT_BOUNDARY_SENTENCE: return ui::SENTENCE_BOUNDARY; |
| - case IA2_TEXT_BOUNDARY_PARAGRAPH: return ui::PARAGRAPH_BOUNDARY; |
| - case IA2_TEXT_BOUNDARY_ALL: return ui::ALL_BOUNDARY; |
| + case IA2_TEXT_BOUNDARY_CHAR: |
| + return ui::CHAR_BOUNDARY; |
| + case IA2_TEXT_BOUNDARY_WORD: |
| + return ui::WORD_BOUNDARY; |
| + case IA2_TEXT_BOUNDARY_LINE: |
| + return ui::LINE_BOUNDARY; |
| + case IA2_TEXT_BOUNDARY_SENTENCE: |
| + return ui::SENTENCE_BOUNDARY; |
| + case IA2_TEXT_BOUNDARY_PARAGRAPH: |
| + return ui::PARAGRAPH_BOUNDARY; |
| + case IA2_TEXT_BOUNDARY_ALL: |
| + return ui::ALL_BOUNDARY; |
| default: |
| NOTREACHED(); |
| - return ui::CHAR_BOUNDARY; |
| } |
| + return ui::CHAR_BOUNDARY; |
| } |
| LONG BrowserAccessibilityWin::FindBoundary( |
| @@ -3335,6 +3377,9 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| ia_state_ |= STATE_SYSTEM_HOTTRACKED; |
| if (HasState(ui::AX_STATE_INDETERMINATE)) |
| ia_state_ |= STATE_SYSTEM_INDETERMINATE; |
| + if (HasIntAttribute(ui::AX_ATTR_INVALID_STATE) && |
| + GetIntAttribute(ui::AX_ATTR_INVALID_STATE) != ui::AX_INVALID_STATE_FALSE) |
| + ia2_state_ |= IA2_STATE_INVALID_ENTRY; |
|
dmazzoni
2014/12/19 17:30:34
nit: indent 2 less
|
| if (HasState(ui::AX_STATE_INVISIBLE)) |
| ia_state_ |= STATE_SYSTEM_INVISIBLE; |
| if (HasState(ui::AX_STATE_LINKED)) |
| @@ -3373,10 +3418,6 @@ void BrowserAccessibilityWin::InitRoleAndState() { |
| if (!HasState(ui::AX_STATE_READ_ONLY)) |
| ia2_state_ |= IA2_STATE_EDITABLE; |
| - base::string16 invalid; |
| - if (GetHtmlAttribute("aria-invalid", &invalid)) |
| - ia2_state_ |= IA2_STATE_INVALID_ENTRY; |
| - |
| if (GetBoolAttribute(ui::AX_ATTR_BUTTON_MIXED)) |
| ia_state_ |= STATE_SYSTEM_MIXED; |