OLD | NEW |
1 // Copyright (c) 2017 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2017 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_com_win.h" | 5 #include "content/browser/accessibility/browser_accessibility_com_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 return E_FAIL; | 431 return E_FAIL; |
432 | 432 |
433 auto* manager = Manager(); | 433 auto* manager = Manager(); |
434 if (!manager) | 434 if (!manager) |
435 return E_FAIL; | 435 return E_FAIL; |
436 | 436 |
437 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); | 437 BrowserAccessibilityComWin* target = GetTargetFromChildID(var_id); |
438 if (!target) | 438 if (!target) |
439 return E_INVALIDARG; | 439 return E_INVALIDARG; |
440 | 440 |
441 // Return an error if it's not clickable. | 441 // Return an error if it hasn't got a custom action verb to describe what |
442 if (!target->owner()->HasIntAttribute(ui::AX_ATTR_ACTION)) | 442 // happens on click. |
| 443 if (!target->owner()->HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB)) |
443 return DISP_E_MEMBERNOTFOUND; | 444 return DISP_E_MEMBERNOTFOUND; |
444 | 445 |
445 manager->DoDefaultAction(*target->owner()); | 446 manager->DoDefaultAction(*target->owner()); |
446 return S_OK; | 447 return S_OK; |
447 } | 448 } |
448 | 449 |
449 STDMETHODIMP BrowserAccessibilityComWin::accHitTest(LONG x_left, | 450 STDMETHODIMP BrowserAccessibilityComWin::accHitTest(LONG x_left, |
450 LONG y_top, | 451 LONG y_top, |
451 VARIANT* child) { | 452 VARIANT* child) { |
452 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); | 453 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_ACC_HIT_TEST); |
(...skipping 2299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2752 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2753 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
2753 if (!owner()) | 2754 if (!owner()) |
2754 return E_FAIL; | 2755 return E_FAIL; |
2755 | 2756 |
2756 if (!n_actions) | 2757 if (!n_actions) |
2757 return E_INVALIDARG; | 2758 return E_INVALIDARG; |
2758 | 2759 |
2759 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| | 2760 // |IsHyperlink| is required for |IAccessibleHyperlink::anchor/anchorTarget| |
2760 // to work properly because the |IAccessibleHyperlink| interface inherits from | 2761 // to work properly because the |IAccessibleHyperlink| interface inherits from |
2761 // |IAccessibleAction|. | 2762 // |IAccessibleAction|. |
2762 if (IsHyperlink() || owner()->HasIntAttribute(ui::AX_ATTR_ACTION)) { | 2763 if (IsHyperlink() || |
| 2764 owner()->HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB)) { |
2763 *n_actions = 1; | 2765 *n_actions = 1; |
2764 } else { | 2766 } else { |
2765 *n_actions = 0; | 2767 *n_actions = 0; |
2766 } | 2768 } |
2767 | 2769 |
2768 return S_OK; | 2770 return S_OK; |
2769 } | 2771 } |
2770 | 2772 |
2771 STDMETHODIMP BrowserAccessibilityComWin::doAction(long action_index) { | 2773 STDMETHODIMP BrowserAccessibilityComWin::doAction(long action_index) { |
2772 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); | 2774 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_DO_ACTION); |
2773 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2775 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
2774 if (!owner()) | 2776 if (!owner()) |
2775 return E_FAIL; | 2777 return E_FAIL; |
2776 | 2778 |
2777 if (!owner()->HasIntAttribute(ui::AX_ATTR_ACTION) || action_index != 0) | 2779 if (!owner()->HasIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB) || |
| 2780 action_index != 0) |
2778 return E_INVALIDARG; | 2781 return E_INVALIDARG; |
2779 | 2782 |
2780 Manager()->DoDefaultAction(*owner()); | 2783 Manager()->DoDefaultAction(*owner()); |
2781 return S_OK; | 2784 return S_OK; |
2782 } | 2785 } |
2783 | 2786 |
2784 STDMETHODIMP | 2787 STDMETHODIMP |
2785 BrowserAccessibilityComWin::get_description(long action_index, | 2788 BrowserAccessibilityComWin::get_description(long action_index, |
2786 BSTR* description) { | 2789 BSTR* description) { |
2787 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); | 2790 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_IAACTION_GET_DESCRIPTION); |
(...skipping 14 matching lines...) Expand all Loading... |
2802 BSTR* name) { | 2805 BSTR* name) { |
2803 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); | 2806 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_NAME); |
2804 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2807 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
2805 if (!owner()) | 2808 if (!owner()) |
2806 return E_FAIL; | 2809 return E_FAIL; |
2807 | 2810 |
2808 if (!name) | 2811 if (!name) |
2809 return E_INVALIDARG; | 2812 return E_INVALIDARG; |
2810 | 2813 |
2811 int action; | 2814 int action; |
2812 if (!owner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || | 2815 if (!owner()->GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action) || |
2813 action_index != 0) { | 2816 action_index != 0) { |
2814 *name = nullptr; | 2817 *name = nullptr; |
2815 return E_INVALIDARG; | 2818 return E_INVALIDARG; |
2816 } | 2819 } |
2817 | 2820 |
2818 base::string16 action_verb = | 2821 base::string16 action_verb = ui::ActionVerbToUnlocalizedString( |
2819 ui::ActionToUnlocalizedString(static_cast<ui::AXSupportedAction>(action)); | 2822 static_cast<ui::AXDefaultActionVerb>(action)); |
2820 if (action_verb.empty() || action_verb == L"none") { | 2823 if (action_verb.empty() || action_verb == L"none") { |
2821 *name = nullptr; | 2824 *name = nullptr; |
2822 return S_FALSE; | 2825 return S_FALSE; |
2823 } | 2826 } |
2824 | 2827 |
2825 *name = SysAllocString(action_verb.c_str()); | 2828 *name = SysAllocString(action_verb.c_str()); |
2826 DCHECK(name); | 2829 DCHECK(name); |
2827 return S_OK; | 2830 return S_OK; |
2828 } | 2831 } |
2829 | 2832 |
2830 STDMETHODIMP | 2833 STDMETHODIMP |
2831 BrowserAccessibilityComWin::get_localizedName(long action_index, | 2834 BrowserAccessibilityComWin::get_localizedName(long action_index, |
2832 BSTR* localized_name) { | 2835 BSTR* localized_name) { |
2833 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); | 2836 WIN_ACCESSIBILITY_API_HISTOGRAM(UMA_API_GET_LOCALIZED_NAME); |
2834 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); | 2837 AddAccessibilityModeFlags(kScreenReaderAndHTMLAccessibilityModes); |
2835 if (!owner()) | 2838 if (!owner()) |
2836 return E_FAIL; | 2839 return E_FAIL; |
2837 | 2840 |
2838 if (!localized_name) | 2841 if (!localized_name) |
2839 return E_INVALIDARG; | 2842 return E_INVALIDARG; |
2840 | 2843 |
2841 int action; | 2844 int action; |
2842 if (!owner()->GetIntAttribute(ui::AX_ATTR_ACTION, &action) || | 2845 if (!owner()->GetIntAttribute(ui::AX_ATTR_DEFAULT_ACTION_VERB, &action) || |
2843 action_index != 0) { | 2846 action_index != 0) { |
2844 *localized_name = nullptr; | 2847 *localized_name = nullptr; |
2845 return E_INVALIDARG; | 2848 return E_INVALIDARG; |
2846 } | 2849 } |
2847 | 2850 |
2848 base::string16 action_verb = | 2851 base::string16 action_verb = ui::ActionVerbToLocalizedString( |
2849 ui::ActionToString(static_cast<ui::AXSupportedAction>(action)); | 2852 static_cast<ui::AXDefaultActionVerb>(action)); |
2850 if (action_verb.empty()) { | 2853 if (action_verb.empty()) { |
2851 *localized_name = nullptr; | 2854 *localized_name = nullptr; |
2852 return S_FALSE; | 2855 return S_FALSE; |
2853 } | 2856 } |
2854 | 2857 |
2855 *localized_name = SysAllocString(action_verb.c_str()); | 2858 *localized_name = SysAllocString(action_verb.c_str()); |
2856 DCHECK(localized_name); | 2859 DCHECK(localized_name); |
2857 return S_OK; | 2860 return S_OK; |
2858 } | 2861 } |
2859 | 2862 |
(...skipping 2868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5728 | 5731 |
5729 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( | 5732 BrowserAccessibilityComWin* ToBrowserAccessibilityComWin( |
5730 BrowserAccessibility* obj) { | 5733 BrowserAccessibility* obj) { |
5731 if (!obj || !obj->IsNative()) | 5734 if (!obj || !obj->IsNative()) |
5732 return nullptr; | 5735 return nullptr; |
5733 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); | 5736 auto* result = static_cast<BrowserAccessibilityWin*>(obj)->GetCOM(); |
5734 return result; | 5737 return result; |
5735 } | 5738 } |
5736 | 5739 |
5737 } // namespace content | 5740 } // namespace content |
OLD | NEW |