Chromium Code Reviews| Index: content/browser/accessibility/browser_accessibility_android.cc |
| diff --git a/content/browser/accessibility/browser_accessibility_android.cc b/content/browser/accessibility/browser_accessibility_android.cc |
| index 8257c74a9212ccbe3b82b455dc3b9bd0aaa149f5..1adafbea4d7848e34e9045e5873f44b82fefbc92 100644 |
| --- a/content/browser/accessibility/browser_accessibility_android.cc |
| +++ b/content/browser/accessibility/browser_accessibility_android.cc |
| @@ -347,17 +347,8 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { |
| // First, always return the |value| attribute if this is an |
| // input field. |
| base::string16 value = GetValue(); |
| - if (!value.empty()) { |
| - if (HasState(ui::AX_STATE_EDITABLE)) |
| - return value; |
| - |
| - switch (GetRole()) { |
| - case ui::AX_ROLE_COMBO_BOX: |
| - case ui::AX_ROLE_POP_UP_BUTTON: |
| - case ui::AX_ROLE_TEXT_FIELD: |
| - return value; |
| - } |
| - } |
| + if (!value.empty() && ShouldExposeValueAsName()) |
|
David Tseng
2016/03/17 22:55:15
So, in the Android world, text is same as name?
W
|
| + return value; |
| // For color wells, the color is stored in separate attributes. |
| // Perhaps we could return color names in the future? |
|
David Tseng
2016/03/17 22:55:15
Unrelated; this begs to be made into a TODO with a
|
| @@ -371,13 +362,6 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { |
| } |
| base::string16 text = GetString16Attribute(ui::AX_ATTR_NAME); |
| - base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION); |
| - if (!description.empty()) { |
| - if (!text.empty()) |
| - text += base::ASCIIToUTF16(" "); |
| - text += description; |
| - } |
| - |
| if (text.empty()) |
| text = value; |
| @@ -415,6 +399,16 @@ base::string16 BrowserAccessibilityAndroid::GetText() const { |
| return text; |
| } |
| +base::string16 BrowserAccessibilityAndroid::GetDescription() const { |
| + // If we're returning the value as the main text, then return the |
| + // accessible name as the only accessible text. |
|
David Tseng
2016/03/17 22:55:15
Can you reword this last part? Accessible text or
|
| + base::string16 value = GetValue(); |
| + if (!value.empty() && ShouldExposeValueAsName()) |
|
David Tseng
2016/03/17 22:55:15
Can you move this non-empty value check into Shoul
|
| + return GetString16Attribute(ui::AX_ATTR_NAME); |
| + |
| + return GetString16Attribute(ui::AX_ATTR_DESCRIPTION); |
| +} |
| + |
| base::string16 BrowserAccessibilityAndroid::GetRoleDescription() const { |
| content::ContentClient* content_client = content::GetContentClient(); |
| @@ -1342,6 +1336,20 @@ bool BrowserAccessibilityAndroid::IsIframe() const { |
| GetRole() == ui::AX_ROLE_IFRAME_PRESENTATIONAL); |
| } |
| +bool BrowserAccessibilityAndroid::ShouldExposeValueAsName() const { |
| + if (HasState(ui::AX_STATE_EDITABLE)) |
| + return true; |
| + |
| + switch (GetRole()) { |
| + case ui::AX_ROLE_COMBO_BOX: |
| + case ui::AX_ROLE_POP_UP_BUTTON: |
| + case ui::AX_ROLE_TEXT_FIELD: |
| + return true; |
| + } |
| + |
| + return false; |
| +} |
| + |
| void BrowserAccessibilityAndroid::OnDataChanged() { |
| BrowserAccessibility::OnDataChanged(); |