| 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 b80334f475aa788e6c092d9e9a05f4e02e93998f..53189cbf1d11b1b3d939ba9a763c3e296a22464e 100644
|
| --- a/content/browser/accessibility/browser_accessibility_android.cc
|
| +++ b/content/browser/accessibility/browser_accessibility_android.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "base/i18n/break_iterator.h"
|
| #include "base/strings/string_util.h"
|
| +#include "base/strings/stringprintf.h"
|
| #include "base/strings/utf_string_conversions.h"
|
| #include "content/browser/accessibility/browser_accessibility_manager_android.h"
|
| #include "content/common/accessibility_messages.h"
|
| @@ -76,6 +77,10 @@ bool BrowserAccessibilityAndroid::PlatformIsLeaf() const {
|
| if (HasFocusableChild())
|
| return false;
|
|
|
| + // Date and time controls should drop their children.
|
| + if (GetRole() == ui::AX_ROLE_DATE || GetRole() == ui::AX_ROLE_TIME)
|
| + return true;
|
| +
|
| // Headings with text can drop their children.
|
| base::string16 name = GetText();
|
| if (GetRole() == ui::AX_ROLE_HEADING && !name.empty())
|
| @@ -251,12 +256,15 @@ const char* BrowserAccessibilityAndroid::GetClassName() const {
|
| case ui::AX_ROLE_SLIDER:
|
| class_name = "android.widget.SeekBar";
|
| break;
|
| + case ui::AX_ROLE_COLOR_WELL:
|
| case ui::AX_ROLE_COMBO_BOX:
|
| + case ui::AX_ROLE_DATE:
|
| + case ui::AX_ROLE_POP_UP_BUTTON:
|
| + case ui::AX_ROLE_TIME:
|
| class_name = "android.widget.Spinner";
|
| break;
|
| case ui::AX_ROLE_BUTTON:
|
| case ui::AX_ROLE_MENU_BUTTON:
|
| - case ui::AX_ROLE_POP_UP_BUTTON:
|
| class_name = "android.widget.Button";
|
| break;
|
| case ui::AX_ROLE_CHECK_BOX:
|
| @@ -319,13 +327,29 @@ base::string16 BrowserAccessibilityAndroid::GetText() const {
|
| // name on Android, not 2 or 3 like on Windows or Mac.
|
|
|
| // First, always return the |value| attribute if this is an
|
| - // editable text field.
|
| - if (!value().empty() &&
|
| - (GetRole() == ui::AX_ROLE_EDITABLE_TEXT ||
|
| - GetRole() == ui::AX_ROLE_TEXT_AREA ||
|
| - GetRole() == ui::AX_ROLE_TEXT_FIELD ||
|
| - HasState(ui::AX_STATE_EDITABLE))) {
|
| - return base::UTF8ToUTF16(value());
|
| + // input field.
|
| + if (!value().empty()) {
|
| + if (HasState(ui::AX_STATE_EDITABLE))
|
| + return base::UTF8ToUTF16(value());
|
| +
|
| + switch (GetRole()) {
|
| + case ui::AX_ROLE_COMBO_BOX:
|
| + case ui::AX_ROLE_EDITABLE_TEXT:
|
| + case ui::AX_ROLE_POP_UP_BUTTON:
|
| + case ui::AX_ROLE_TEXT_AREA:
|
| + case ui::AX_ROLE_TEXT_FIELD:
|
| + return base::UTF8ToUTF16(value());
|
| + }
|
| + }
|
| +
|
| + // For color wells, the color is stored in separate attributes.
|
| + // Perhaps we could return color names in the future?
|
| + if (GetRole() == ui::AX_ROLE_COLOR_WELL) {
|
| + int red = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE_RED);
|
| + int green = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE_GREEN);
|
| + int blue = GetIntAttribute(ui::AX_ATTR_COLOR_VALUE_BLUE);
|
| + return base::UTF8ToUTF16(
|
| + base::StringPrintf("#%02X%02X%02X", red, green, blue));
|
| }
|
|
|
| // Always prefer visible text if this is a link. Sites sometimes add
|
| @@ -343,8 +367,17 @@ base::string16 BrowserAccessibilityAndroid::GetText() const {
|
| // Blink, making the platform-specific mapping to accessible text simpler.
|
| base::string16 description = GetString16Attribute(ui::AX_ATTR_DESCRIPTION);
|
| base::string16 help = GetString16Attribute(ui::AX_ATTR_HELP);
|
| +
|
| base::string16 placeholder;
|
| - GetHtmlAttribute("placeholder", &placeholder);
|
| + switch (GetRole()) {
|
| + case ui::AX_ROLE_DATE:
|
| + case ui::AX_ROLE_EDITABLE_TEXT:
|
| + case ui::AX_ROLE_TEXT_AREA:
|
| + case ui::AX_ROLE_TEXT_FIELD:
|
| + case ui::AX_ROLE_TIME:
|
| + GetHtmlAttribute("placeholder", &placeholder);
|
| + }
|
| +
|
| int title_elem_id = GetIntAttribute(
|
| ui::AX_ATTR_TITLE_UI_ELEMENT);
|
| base::string16 text;
|
| @@ -356,7 +389,7 @@ base::string16 BrowserAccessibilityAndroid::GetText() const {
|
| text = help;
|
| else if (!name().empty())
|
| text = base::UTF8ToUTF16(name());
|
| - else if (GetRole() == ui::AX_ROLE_TEXT_FIELD && !placeholder.empty())
|
| + else if (!placeholder.empty())
|
| text = placeholder;
|
| else if (!value().empty())
|
| text = base::UTF8ToUTF16(value());
|
|
|