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
3 // found in the LICENSE file.
4 #include "ui/base/win/accessibility_misc_utils.h"
6 #include "base/logging.h"
7 #include "ui/base/win/atl_module.h"
12 // UIA TextProvider implementation.
13 UIATextProvider::UIATextProvider()
16 UIATextProvider::~UIATextProvider() {
20 bool UIATextProvider::CreateTextProvider(const string16
& value
,
22 IUnknown
** provider
) {
23 // Make sure ATL is initialized in this module.
24 ui::win::CreateATLModuleIfNeeded();
26 CComObject
<UIATextProvider
>* text_provider
= NULL
;
27 HRESULT hr
= CComObject
<UIATextProvider
>::CreateInstance(&text_provider
);
29 DCHECK(text_provider
);
30 text_provider
->set_editable(editable
);
31 text_provider
->set_value(value
);
32 text_provider
->AddRef();
33 *provider
= static_cast<ITextProvider
*>(text_provider
);
39 STDMETHODIMP
UIATextProvider::get_IsReadOnly(BOOL
* read_only
) {
40 *read_only
= !editable_
;
45 // IValueProvider methods.
48 STDMETHODIMP
UIATextProvider::SetValue(const wchar_t* val
) {
52 STDMETHODIMP
UIATextProvider::get_Value(BSTR
* value
) {
53 *value
= SysAllocString(value_
.c_str());
58 // ITextProvider methods.
61 STDMETHODIMP
UIATextProvider::GetSelection(SAFEARRAY
** ret
) {
65 STDMETHODIMP
UIATextProvider::GetVisibleRanges(SAFEARRAY
** ret
) {
69 STDMETHODIMP
UIATextProvider::RangeFromChild(IRawElementProviderSimple
* child
,
70 ITextRangeProvider
** ret
) {
74 STDMETHODIMP
UIATextProvider::RangeFromPoint(struct UiaPoint point
,
75 ITextRangeProvider
** ret
) {
79 STDMETHODIMP
UIATextProvider::get_DocumentRange(ITextRangeProvider
** ret
) {
83 STDMETHODIMP
UIATextProvider::get_SupportedTextSelection(
84 enum SupportedTextSelection
* ret
) {