Chromium Code Reviews| 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 #define _ATL_DEBUG_QI | |
|
dmazzoni
2012/04/04 06:02:00
Delete this before checking in?
ananta
2012/04/04 19:23:00
Done.
| |
| 5 #include "ui/views/accessibility/native_view_accessibility_win.h" | 6 #include "ui/views/accessibility/native_view_accessibility_win.h" |
| 6 | 7 |
| 7 #include <atlbase.h> | 8 #include <atlbase.h> |
| 8 #include <atlcom.h> | 9 #include <atlcom.h> |
| 9 | 10 |
| 11 #include <UIAutomationClient.h> | |
|
dmazzoni
2012/04/04 06:02:00
Nit: group above
ananta
2012/04/04 19:23:00
Done.
| |
| 10 #include <vector> | 12 #include <vector> |
| 11 | 13 |
| 14 #include "base/win/windows_version.h" | |
| 12 #include "third_party/iaccessible2/ia2_api_all.h" | 15 #include "third_party/iaccessible2/ia2_api_all.h" |
| 13 #include "ui/base/accessibility/accessible_text_utils.h" | 16 #include "ui/base/accessibility/accessible_text_utils.h" |
| 14 #include "ui/base/accessibility/accessible_view_state.h" | 17 #include "ui/base/accessibility/accessible_view_state.h" |
| 15 #include "ui/base/view_prop.h" | 18 #include "ui/base/view_prop.h" |
| 16 #include "ui/base/win/atl_module.h" | 19 #include "ui/base/win/atl_module.h" |
| 17 #include "ui/views/widget/native_widget_win.h" | 20 #include "ui/views/widget/native_widget_win.h" |
| 18 #include "ui/views/widget/widget.h" | 21 #include "ui/views/widget/widget.h" |
| 19 | 22 |
| 20 using ui::AccessibilityTypes; | 23 using ui::AccessibilityTypes; |
| 21 | 24 |
| (...skipping 755 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 777 | 780 |
| 778 // | 781 // |
| 779 // IServiceProvider methods. | 782 // IServiceProvider methods. |
| 780 // | 783 // |
| 781 | 784 |
| 782 STDMETHODIMP NativeViewAccessibilityWin::QueryService( | 785 STDMETHODIMP NativeViewAccessibilityWin::QueryService( |
| 783 REFGUID guidService, REFIID riid, void** object) { | 786 REFGUID guidService, REFIID riid, void** object) { |
| 784 if (!view_) | 787 if (!view_) |
| 785 return E_FAIL; | 788 return E_FAIL; |
| 786 | 789 |
| 787 if (guidService == IID_IAccessible || | 790 if (riid == IID_IAccessible || |
| 788 guidService == IID_IAccessible2 || | 791 riid == IID_IAccessible2 || |
| 789 guidService == IID_IAccessibleText) { | 792 riid == IID_IAccessibleText) { |
| 793 return QueryInterface(riid, object); | |
| 794 } | |
| 795 | |
| 796 // We only support the IAccessibleEx interface on Windows 8 and above. This | |
| 797 // is needed for the On screen Keyboard to show up in metro mode, when the | |
| 798 // user taps an editable region in the window. | |
| 799 // All methods in the IAccessibleEx interface are unimplemented. | |
| 800 if (riid == IID_IAccessibleEx && | |
| 801 base::win::GetVersion() >= base::win::VERSION_WIN8) { | |
| 790 return QueryInterface(riid, object); | 802 return QueryInterface(riid, object); |
| 791 } | 803 } |
| 792 | 804 |
| 793 *object = NULL; | 805 *object = NULL; |
| 794 return E_FAIL; | 806 return E_FAIL; |
| 795 } | 807 } |
| 796 | 808 |
| 809 STDMETHODIMP NativeViewAccessibilityWin::GetPatternProvider( | |
| 810 PATTERNID id, IUnknown** provider) { | |
| 811 DVLOG(1) << "In Function: " | |
| 812 << __FUNCTION__ | |
| 813 << " for pattern id: " | |
| 814 << id; | |
| 815 if (id == UIA_ValuePatternId || id == UIA_TextPatternId) { | |
| 816 ui::AccessibleViewState state; | |
| 817 view_->GetAccessibleState(&state); | |
| 818 long role = MSAARole(state.role); | |
| 819 | |
| 820 if (role == ROLE_SYSTEM_TEXT) { | |
| 821 DVLOG(1) << "Returning UIA text provider"; | |
| 822 ui::UIATextProvider::CreateTextProvider(true, provider); | |
| 823 return S_OK; | |
| 824 } | |
| 825 } | |
| 826 return E_NOTIMPL; | |
| 827 } | |
| 828 | |
| 829 STDMETHODIMP NativeViewAccessibilityWin::GetPropertyValue(PROPERTYID id, | |
| 830 VARIANT* ret) { | |
| 831 DVLOG(1) << "In Function: " | |
| 832 << __FUNCTION__ | |
| 833 << " for property id: " | |
| 834 << id; | |
| 835 if (id == UIA_ControlTypePropertyId) { | |
| 836 ui::AccessibleViewState state; | |
| 837 view_->GetAccessibleState(&state); | |
| 838 long role = MSAARole(state.role); | |
| 839 if (role == ROLE_SYSTEM_TEXT) { | |
| 840 V_VT(ret) = VT_I4; | |
| 841 ret->lVal = UIA_EditControlTypeId; | |
| 842 DVLOG(1) << "Returning Edit control type"; | |
| 843 } else { | |
| 844 DVLOG(1) << "Returning empty control type"; | |
| 845 V_VT(ret) = VT_EMPTY; | |
| 846 } | |
| 847 } else { | |
| 848 V_VT(ret) = VT_EMPTY; | |
| 849 } | |
| 850 return S_OK; | |
| 851 } | |
| 852 | |
| 797 // | 853 // |
| 798 // Static methods. | 854 // Static methods. |
| 799 // | 855 // |
| 800 | 856 |
| 801 int32 NativeViewAccessibilityWin::MSAAEvent(AccessibilityTypes::Event event) { | 857 int32 NativeViewAccessibilityWin::MSAAEvent(AccessibilityTypes::Event event) { |
| 802 switch (event) { | 858 switch (event) { |
| 803 case AccessibilityTypes::EVENT_ALERT: | 859 case AccessibilityTypes::EVENT_ALERT: |
| 804 return EVENT_SYSTEM_ALERT; | 860 return EVENT_SYSTEM_ALERT; |
| 805 case AccessibilityTypes::EVENT_FOCUS: | 861 case AccessibilityTypes::EVENT_FOCUS: |
| 806 return EVENT_OBJECT_FOCUS; | 862 return EVENT_OBJECT_FOCUS; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1027 const string16& text, | 1083 const string16& text, |
| 1028 IA2TextBoundaryType ia2_boundary, | 1084 IA2TextBoundaryType ia2_boundary, |
| 1029 LONG start_offset, | 1085 LONG start_offset, |
| 1030 ui::TextBoundaryDirection direction) { | 1086 ui::TextBoundaryDirection direction) { |
| 1031 HandleSpecialTextOffset(text, &start_offset); | 1087 HandleSpecialTextOffset(text, &start_offset); |
| 1032 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); | 1088 ui::TextBoundaryType boundary = IA2TextBoundaryToTextBoundary(ia2_boundary); |
| 1033 std::vector<int32> line_breaks; | 1089 std::vector<int32> line_breaks; |
| 1034 return ui::FindAccessibleTextBoundary( | 1090 return ui::FindAccessibleTextBoundary( |
| 1035 text, line_breaks, boundary, start_offset, direction); | 1091 text, line_breaks, boundary, start_offset, direction); |
| 1036 } | 1092 } |
| OLD | NEW |