| 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 d77d60d807df37b81a29a06f654076daa7f39529..14fb2e39852645879e85e0253aed453e3cf84710 100644
|
| --- a/content/browser/accessibility/browser_accessibility_win.cc
|
| +++ b/content/browser/accessibility/browser_accessibility_win.cc
|
| @@ -421,7 +421,7 @@ HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) {
|
| return E_INVALIDARG;
|
|
|
| // Return an error if it's not clickable.
|
| - if (!target->HasStringAttribute(ui::AX_ATTR_ACTION))
|
| + if (!target->HasIntAttribute(ui::AX_ATTR_ACTION))
|
| return DISP_E_MEMBERNOTFOUND;
|
|
|
| manager()->DoDefaultAction(*target);
|
| @@ -577,8 +577,7 @@ STDMETHODIMP BrowserAccessibilityWin::get_accDefaultAction(VARIANT var_id,
|
| if (!target)
|
| return E_INVALIDARG;
|
|
|
| - return target->GetStringAttributeAsBstr(
|
| - ui::AX_ATTR_ACTION, def_action);
|
| + return target->get_localizedName(0, def_action);
|
| }
|
|
|
| STDMETHODIMP BrowserAccessibilityWin::get_accDescription(VARIANT var_id,
|
| @@ -2839,7 +2838,7 @@ STDMETHODIMP BrowserAccessibilityWin::nActions(long* n_actions) {
|
| // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget|
|
| // to work properly because the |IAccessibleHyperlink| interface inherits from
|
| // |IAccessibleAction|.
|
| - if (IsHyperlink() || HasStringAttribute(ui::AX_ATTR_ACTION)) {
|
| + if (IsHyperlink() || HasIntAttribute(ui::AX_ATTR_ACTION)) {
|
| *n_actions = 1;
|
| } else {
|
| *n_actions = 0;
|
| @@ -2853,7 +2852,7 @@ STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) {
|
| if (!instance_active())
|
| return E_FAIL;
|
|
|
| - if (!HasStringAttribute(ui::AX_ATTR_ACTION) || action_index != 0)
|
| + if (!HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0)
|
| return E_INVALIDARG;
|
|
|
| manager()->DoDefaultAction(*this);
|
| @@ -2882,13 +2881,19 @@ STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) {
|
| if (!name)
|
| return E_INVALIDARG;
|
|
|
| - base::string16 action_verb;
|
| - if (!GetString16Attribute(ui::AX_ATTR_ACTION, &action_verb) ||
|
| - action_index != 0) {
|
| + int action;
|
| + if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) {
|
| *name = nullptr;
|
| return E_INVALIDARG;
|
| }
|
|
|
| + base::string16 action_verb =
|
| + ActionToUnlocalizedString(static_cast<ui::AXSupportedAction>(action));
|
| + if (action_verb.empty() || action_verb == L"None") {
|
| + *name = nullptr;
|
| + return S_FALSE;
|
| + }
|
| +
|
| *name = SysAllocString(action_verb.c_str());
|
| DCHECK(name);
|
| return S_OK;
|
| @@ -2898,7 +2903,28 @@ STDMETHODIMP
|
| BrowserAccessibilityWin::get_localizedName(long action_index,
|
| BSTR* localized_name) {
|
| WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME);
|
| - return E_NOTIMPL;
|
| + if (!instance_active())
|
| + return E_FAIL;
|
| +
|
| + if (!localized_name)
|
| + return E_INVALIDARG;
|
| +
|
| + int action;
|
| + if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) {
|
| + *localized_name = nullptr;
|
| + return E_INVALIDARG;
|
| + }
|
| +
|
| + base::string16 action_verb =
|
| + ui::ActionToString(static_cast<ui::AXSupportedAction>(action));
|
| + if (action_verb.empty()) {
|
| + *localized_name = nullptr;
|
| + return S_FALSE;
|
| + }
|
| +
|
| + *localized_name = SysAllocString(action_verb.c_str());
|
| + DCHECK(localized_name);
|
| + return S_OK;
|
| }
|
|
|
| //
|
| @@ -4026,6 +4052,29 @@ void BrowserAccessibilityWin::OnLocationChanged() {
|
| FireNativeEvent(EVENT_OBJECT_LOCATIONCHANGE);
|
| }
|
|
|
| +// Some APIs need to return non-localized action names.
|
| +// Returns only "click" for now because this is the only action that makes NVDA
|
| +// recognize that an object is interactive.
|
| +// static
|
| +base::string16 BrowserAccessibilityWin::ActionToUnlocalizedString(
|
| + ui::AXSupportedAction supported_action) {
|
| + switch (supported_action) {
|
| + case ui::AX_SUPPORTED_ACTION_NONE:
|
| + return L"None";
|
| + case ui::AX_SUPPORTED_ACTION_ACTIVATE:
|
| + case ui::AX_SUPPORTED_ACTION_CHECK:
|
| + case ui::AX_SUPPORTED_ACTION_CLICK:
|
| + case ui::AX_SUPPORTED_ACTION_JUMP:
|
| + case ui::AX_SUPPORTED_ACTION_OPEN:
|
| + case ui::AX_SUPPORTED_ACTION_PRESS:
|
| + case ui::AX_SUPPORTED_ACTION_SELECT:
|
| + case ui::AX_SUPPORTED_ACTION_UNCHECK:
|
| + return L"click";
|
| + }
|
| + NOTREACHED();
|
| + return base::string16();
|
| +}
|
| +
|
| std::vector<base::string16> BrowserAccessibilityWin::ComputeTextAttributes()
|
| const {
|
| std::vector<base::string16> attributes;
|
|
|