Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #ifndef UI_BASE_ACCESSIBILITY_ACCESSIBLE_TEXT_UTILS_H_ | 5 #ifndef UI_BASE_ACCESSIBILITY_ACCESSIBLE_TEXT_UTILS_H_ |
| 6 #define UI_BASE_ACCESSIBILITY_ACCESSIBLE_TEXT_UTILS_H_ | 6 #define UI_BASE_ACCESSIBILITY_ACCESSIBLE_TEXT_UTILS_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/string16.h" | 12 #include "base/string16.h" |
| 13 #include "ui/base/ui_export.h" | 13 #include "ui/base/ui_export.h" |
| 14 | 14 |
| 15 #if defined(OS_WIN) | |
| 16 #include <atlbase.h> | |
| 17 #include <atlcom.h> | |
| 18 #include <UIAutomationCore.h> | |
| 19 #endif // OS_WIN | |
| 20 | |
| 15 namespace ui { | 21 namespace ui { |
| 16 | 22 |
| 17 // Boundaries that can be passed to FindAccessibleTextBoundary, | 23 // Boundaries that can be passed to FindAccessibleTextBoundary, |
| 18 // representing various visual boundaries in (potentially multi-line) | 24 // representing various visual boundaries in (potentially multi-line) |
| 19 // text. This is used by assistive technology in order to, for example, | 25 // text. This is used by assistive technology in order to, for example, |
| 20 // retrieve the nearest word to the cursor, or retrieve all of the | 26 // retrieve the nearest word to the cursor, or retrieve all of the |
| 21 // text from the current cursor position to the end of the line. | 27 // text from the current cursor position to the end of the line. |
| 22 // These should be self-explanatory; "line" here refers to the visual | 28 // These should be self-explanatory; "line" here refers to the visual |
| 23 // line as currently displayed (possibly affected by wrapping). | 29 // line as currently displayed (possibly affected by wrapping). |
| 24 enum UI_EXPORT TextBoundaryType { | 30 enum UI_EXPORT TextBoundaryType { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 43 // (depending on |direction|) from the given |start_offset| until the | 49 // (depending on |direction|) from the given |start_offset| until the |
| 44 // given boundary is found, and return the offset of that boundary, | 50 // given boundary is found, and return the offset of that boundary, |
| 45 // using the vector of line break character offsets in |line_breaks|. | 51 // using the vector of line break character offsets in |line_breaks|. |
| 46 size_t UI_EXPORT FindAccessibleTextBoundary( | 52 size_t UI_EXPORT FindAccessibleTextBoundary( |
| 47 const string16& text, | 53 const string16& text, |
| 48 const std::vector<int>& line_breaks, | 54 const std::vector<int>& line_breaks, |
| 49 TextBoundaryType boundary, | 55 TextBoundaryType boundary, |
| 50 size_t start_offset, | 56 size_t start_offset, |
| 51 TextBoundaryDirection direction); | 57 TextBoundaryDirection direction); |
| 52 | 58 |
| 59 #if defined(OS_WIN) | |
| 60 // UIA Text provider implementation for edit controls. | |
| 61 class UI_EXPORT UIATextProvider | |
|
dmazzoni
2012/04/04 06:02:00
After looking at this, I think a better place for
ananta
2012/04/04 19:23:00
Done. Moved the class to the new files accessibili
| |
| 62 : public CComObjectRootEx<CComMultiThreadModel>, | |
| 63 public IValueProvider, | |
| 64 public ITextProvider { | |
| 65 public: | |
| 66 BEGIN_COM_MAP(UIATextProvider) | |
| 67 COM_INTERFACE_ENTRY2(IUnknown, ITextProvider) | |
| 68 COM_INTERFACE_ENTRY(IValueProvider) | |
| 69 COM_INTERFACE_ENTRY(ITextProvider) | |
| 70 END_COM_MAP() | |
| 71 | |
| 72 UIATextProvider(); | |
| 73 | |
| 74 // Creates an instance of the UIATextProvider class. | |
| 75 // Returns true on success | |
| 76 static bool CreateTextProvider(bool editable, IUnknown** provider); | |
| 77 | |
| 78 void set_editable(bool editable) { | |
| 79 editable_ = editable; | |
| 80 } | |
| 81 | |
| 82 // IValueProvider methods. | |
| 83 STDMETHOD(get_IsReadOnly)(BOOL* read_only); | |
| 84 | |
| 85 // IValueProvider methods not implemented. | |
| 86 STDMETHOD(SetValue)(const wchar_t* val) { | |
| 87 return E_NOTIMPL; | |
| 88 } | |
| 89 | |
| 90 STDMETHOD(get_Value)(BSTR* value) { | |
| 91 return E_NOTIMPL; | |
| 92 } | |
| 93 | |
| 94 // ITextProvider methods not implemented. | |
| 95 STDMETHOD(GetSelection)(SAFEARRAY** ret) { | |
| 96 return E_NOTIMPL; | |
| 97 } | |
| 98 | |
| 99 STDMETHOD(GetVisibleRanges)(SAFEARRAY** ret) { | |
| 100 return E_NOTIMPL; | |
| 101 } | |
| 102 | |
| 103 STDMETHOD(RangeFromChild)(IRawElementProviderSimple* child, | |
| 104 ITextRangeProvider** ret) { | |
| 105 return E_NOTIMPL; | |
| 106 } | |
| 107 | |
| 108 STDMETHOD(RangeFromPoint)(struct UiaPoint point, | |
| 109 ITextRangeProvider** ret) { | |
| 110 return E_NOTIMPL; | |
| 111 } | |
| 112 | |
| 113 STDMETHOD(get_DocumentRange)(ITextRangeProvider** ret) { | |
| 114 return E_NOTIMPL; | |
| 115 } | |
| 116 | |
| 117 STDMETHOD(get_SupportedTextSelection)(enum SupportedTextSelection* ret) { | |
| 118 return E_NOTIMPL; | |
| 119 } | |
| 120 | |
| 121 private: | |
| 122 bool editable_; | |
| 123 }; | |
| 124 #endif // OS_WIN | |
| 125 | |
| 53 } // namespace ui | 126 } // namespace ui |
| 54 | 127 |
| 55 #endif // UI_BASE_ACCESSIBILITY_ACCESSIBLE_TEXT_UTILS_H_ | 128 #endif // UI_BASE_ACCESSIBILITY_ACCESSIBLE_TEXT_UTILS_H_ |
| OLD | NEW |