OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/accessibility/browser_accessibility_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_win.h" |
6 | 6 |
7 #include <UIAutomationClient.h> | 7 #include <UIAutomationClient.h> |
8 #include <UIAutomationCoreApi.h> | 8 #include <UIAutomationCoreApi.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { | 431 HRESULT BrowserAccessibilityWin::accDoDefaultAction(VARIANT var_id) { |
432 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); | 432 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_DO_DEFAULT_ACTION); |
433 if (!instance_active()) | 433 if (!instance_active()) |
434 return E_FAIL; | 434 return E_FAIL; |
435 | 435 |
436 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); | 436 BrowserAccessibilityWin* target = GetTargetFromChildID(var_id); |
437 if (!target) | 437 if (!target) |
438 return E_INVALIDARG; | 438 return E_INVALIDARG; |
439 | 439 |
440 // Return an error if it's not clickable. | 440 // Return an error if it's not clickable. |
441 if (!target->HasIntAttribute(ui::AX_ATTR_ACTION)) | 441 if (!target->HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB)) |
442 return DISP_E_MEMBERNOTFOUND; | 442 return DISP_E_MEMBERNOTFOUND; |
443 | 443 |
444 manager_->DoDefaultAction(*target); | 444 manager_->DoDefaultAction(*target); |
445 return S_OK; | 445 return S_OK; |
446 } | 446 } |
447 | 447 |
448 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, | 448 STDMETHODIMP BrowserAccessibilityWin::accHitTest(LONG x_left, |
449 LONG y_top, | 449 LONG y_top, |
450 VARIANT* child) { | 450 VARIANT* child) { |
451 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); | 451 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); |
(...skipping 2253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2705 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2705 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
2706 if (!instance_active()) | 2706 if (!instance_active()) |
2707 return E_FAIL; | 2707 return E_FAIL; |
2708 | 2708 |
2709 if (!n_actions) | 2709 if (!n_actions) |
2710 return E_INVALIDARG; | 2710 return E_INVALIDARG; |
2711 | 2711 |
2712 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| | 2712 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| |
2713 // to work properly because the |IAccessibleHyperlink| interface inherits from | 2713 // to work properly because the |IAccessibleHyperlink| interface inherits from |
2714 // |IAccessibleAction|. | 2714 // |IAccessibleAction|. |
2715 if (IsHyperlink() || HasIntAttribute(ui::AX_ATTR_ACTION)) { | 2715 if (IsHyperlink() || HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB)) { |
2716 *n_actions = 1; | 2716 *n_actions = 1; |
2717 } else { | 2717 } else { |
2718 *n_actions = 0; | 2718 *n_actions = 0; |
2719 } | 2719 } |
2720 | 2720 |
2721 return S_OK; | 2721 return S_OK; |
2722 } | 2722 } |
2723 | 2723 |
2724 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { | 2724 STDMETHODIMP BrowserAccessibilityWin::doAction(long action_index) { |
2725 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); | 2725 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); |
2726 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2726 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
2727 if (!instance_active()) | 2727 if (!instance_active()) |
2728 return E_FAIL; | 2728 return E_FAIL; |
2729 | 2729 |
2730 if (!HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) | 2730 if (!HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB) || action_index != 0) |
2731 return E_INVALIDARG; | 2731 return E_INVALIDARG; |
2732 | 2732 |
2733 manager_->DoDefaultAction(*this); | 2733 manager_->DoDefaultAction(*this); |
2734 return S_OK; | 2734 return S_OK; |
2735 } | 2735 } |
2736 | 2736 |
2737 STDMETHODIMP | 2737 STDMETHODIMP |
2738 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { | 2738 BrowserAccessibilityWin::get_description(long action_index, BSTR* description) { |
2739 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); | 2739 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); |
2740 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2740 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
(...skipping 12 matching lines...) Expand all Loading... | |
2753 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { | 2753 STDMETHODIMP BrowserAccessibilityWin::get_name(long action_index, BSTR* name) { |
2754 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); | 2754 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); |
2755 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2755 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
2756 if (!instance_active()) | 2756 if (!instance_active()) |
2757 return E_FAIL; | 2757 return E_FAIL; |
2758 | 2758 |
2759 if (!name) | 2759 if (!name) |
2760 return E_INVALIDARG; | 2760 return E_INVALIDARG; |
2761 | 2761 |
2762 int action; | 2762 int action; |
2763 if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) { | 2763 if (!GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action) || |
2764 action_index != 0) { | |
2764 *name = nullptr; | 2765 *name = nullptr; |
2765 return E_INVALIDARG; | 2766 return E_INVALIDARG; |
2766 } | 2767 } |
2767 | 2768 |
2768 base::string16 action_verb = | 2769 base::string16 action_verb = ui::ActionToUnlocalizedString( |
2769 ui::ActionToUnlocalizedString(static_cast<ui::AXSupportedAction>(action)); | 2770 static_cast<ui::AXDefaultActionVerb>(action)); |
2770 if (action_verb.empty() || action_verb == L"none") { | 2771 if (action_verb.empty() || action_verb == L"none") { |
2771 *name = nullptr; | 2772 *name = nullptr; |
2772 return S_FALSE; | 2773 return S_FALSE; |
2773 } | 2774 } |
2774 | 2775 |
2775 *name = SysAllocString(action_verb.c_str()); | 2776 *name = SysAllocString(action_verb.c_str()); |
2776 DCHECK(name); | 2777 DCHECK(name); |
2777 return S_OK; | 2778 return S_OK; |
2778 } | 2779 } |
2779 | 2780 |
2780 STDMETHODIMP | 2781 STDMETHODIMP |
2781 BrowserAccessibilityWin::get_localizedName(long action_index, | 2782 BrowserAccessibilityWin::get_localizedName(long action_index, |
2782 BSTR* localized_name) { | 2783 BSTR* localized_name) { |
2783 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); | 2784 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); |
2784 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2785 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
2785 if (!instance_active()) | 2786 if (!instance_active()) |
2786 return E_FAIL; | 2787 return E_FAIL; |
2787 | 2788 |
2788 if (!localized_name) | 2789 if (!localized_name) |
2789 return E_INVALIDARG; | 2790 return E_INVALIDARG; |
2790 | 2791 |
2791 int action; | 2792 int action; |
2792 if (!GetIntAttribute(ui::AX_ATTR_ACTION, &action) || action_index != 0) { | 2793 if (!GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action) || |
2794 action_index != 0) { | |
2793 *localized_name = nullptr; | 2795 *localized_name = nullptr; |
2794 return E_INVALIDARG; | 2796 return E_INVALIDARG; |
2795 } | 2797 } |
2796 | 2798 |
2797 base::string16 action_verb = | 2799 base::string16 action_verb = |
2798 ui::ActionToString(static_cast<ui::AXSupportedAction>(action)); | 2800 ui::ActionToString(static_cast<ui::AXDefaultActionVerb>(action)); |
dmazzoni
2017/05/12 03:08:58
And this one should be ActionVerbToLocalizedString
Patti Lor
2017/05/15 06:03:42
Done.
| |
2799 if (action_verb.empty()) { | 2801 if (action_verb.empty()) { |
2800 *localized_name = nullptr; | 2802 *localized_name = nullptr; |
2801 return S_FALSE; | 2803 return S_FALSE; |
2802 } | 2804 } |
2803 | 2805 |
2804 *localized_name = SysAllocString(action_verb.c_str()); | 2806 *localized_name = SysAllocString(action_verb.c_str()); |
2805 DCHECK(localized_name); | 2807 DCHECK(localized_name); |
2806 return S_OK; | 2808 return S_OK; |
2807 } | 2809 } |
2808 | 2810 |
(...skipping 2836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5645 return static_cast<BrowserAccessibilityWin*>(obj); | 5647 return static_cast<BrowserAccessibilityWin*>(obj); |
5646 } | 5648 } |
5647 | 5649 |
5648 const BrowserAccessibilityWin* | 5650 const BrowserAccessibilityWin* |
5649 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { | 5651 ToBrowserAccessibilityWin(const BrowserAccessibility* obj) { |
5650 DCHECK(!obj || obj->IsNative()); | 5652 DCHECK(!obj || obj->IsNative()); |
5651 return static_cast<const BrowserAccessibilityWin*>(obj); | 5653 return static_cast<const BrowserAccessibilityWin*>(obj); |
5652 } | 5654 } |
5653 | 5655 |
5654 } // namespace content | 5656 } // namespace content |
OLD | NEW |