2 * Copyright 2022 Connor McAdams for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #include "uiautomation.h"
22 #include "uia_classes.h"
23 #include "wine/list.h"
24 #include "wine/heap.h"
26 extern HMODULE huia_module DECLSPEC_HIDDEN
;
32 PROP_TYPE_PATTERN_PROP
,
36 * HUIANODEs that have an associated HWND are able to pull data from up to 4
37 * different providers:
39 * - Override providers are used to override values from all other providers.
40 * - Main providers are the base provider for an HUIANODE.
41 * - Nonclient providers are used to represent the nonclient area of the HWND.
42 * - HWND providers are used to represent data from the HWND as a whole, such
43 * as the bounding box.
45 * When a property is requested from the node, each provider is queried in
46 * descending order starting with the override provider until either one
47 * returns a property or there are no more providers to query.
49 enum uia_node_prov_type
{
58 IWineUiaNode IWineUiaNode_iface
;
61 IWineUiaProvider
*prov
[PROV_TYPE_COUNT
];
62 DWORD git_cookie
[PROV_TYPE_COUNT
];
70 int creator_prov_type
;
71 struct list prov_thread_list_entry
;
72 struct list node_map_list_entry
;
73 struct uia_provider_thread_map_entry
*map
;
76 static inline struct uia_node
*impl_from_IWineUiaNode(IWineUiaNode
*iface
)
78 return CONTAINING_RECORD(iface
, struct uia_node
, IWineUiaNode_iface
);
82 IWineUiaProvider IWineUiaProvider_iface
;
85 IRawElementProviderSimple
*elprov
;
86 BOOL return_nested_node
;
87 BOOL parent_check_ran
;
91 static inline struct uia_provider
*impl_from_IWineUiaProvider(IWineUiaProvider
*iface
)
93 return CONTAINING_RECORD(iface
, struct uia_provider
, IWineUiaProvider_iface
);
98 IWineUiaEvent IWineUiaEvent_iface
;
101 SAFEARRAY
*runtime_id
;
105 IRawElementProviderAdviseEvents
**event_advisers
;
106 int event_advisers_count
;
107 SIZE_T event_advisers_arr_size
;
109 UiaEventCallback
*cback
;
112 static inline void variant_init_bool(VARIANT
*v
, BOOL val
)
115 V_BOOL(v
) = val
? VARIANT_TRUE
: VARIANT_FALSE
;
118 static inline void variant_init_i4(VARIANT
*v
, int val
)
124 static inline BOOL
uia_array_reserve(void **elements
, SIZE_T
*capacity
, SIZE_T count
, SIZE_T size
)
126 SIZE_T max_capacity
, new_capacity
;
129 if (count
<= *capacity
)
132 max_capacity
= ~(SIZE_T
)0 / size
;
133 if (count
> max_capacity
)
136 new_capacity
= max(1, *capacity
);
137 while (new_capacity
< count
&& new_capacity
<= max_capacity
/ 2)
139 if (new_capacity
< count
)
140 new_capacity
= count
;
143 new_elements
= heap_alloc_zero(new_capacity
* size
);
145 new_elements
= HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, *elements
, new_capacity
* size
);
149 *elements
= new_elements
;
150 *capacity
= new_capacity
;
155 int get_node_provider_type_at_idx(struct uia_node
*node
, int idx
) DECLSPEC_HIDDEN
;
156 HRESULT
attach_event_to_uia_node(HUIANODE node
, struct uia_event
*event
) DECLSPEC_HIDDEN
;
157 HRESULT
create_uia_node_from_elprov(IRawElementProviderSimple
*elprov
, HUIANODE
*out_node
,
158 BOOL get_hwnd_providers
) DECLSPEC_HIDDEN
;
160 /* uia_com_client.c */
161 HRESULT
create_uia_iface(IUnknown
**iface
, BOOL is_cui8
) DECLSPEC_HIDDEN
;
164 HRESULT
uia_event_add_provider_event_adviser(IRawElementProviderAdviseEvents
*advise_events
,
165 struct uia_event
*event
) DECLSPEC_HIDDEN
;
168 const struct uia_prop_info
*uia_prop_info_from_id(PROPERTYID prop_id
) DECLSPEC_HIDDEN
;
169 const struct uia_event_info
*uia_event_info_from_id(EVENTID event_id
) DECLSPEC_HIDDEN
;
170 const struct uia_pattern_info
*uia_pattern_info_from_id(PATTERNID pattern_id
) DECLSPEC_HIDDEN
;
171 const struct uia_control_type_info
*uia_control_type_info_from_id(CONTROLTYPEID control_type_id
) DECLSPEC_HIDDEN
;
174 HRESULT
create_base_hwnd_provider(HWND hwnd
, IRawElementProviderSimple
**elprov
) DECLSPEC_HIDDEN
;
175 void uia_stop_provider_thread(void) DECLSPEC_HIDDEN
;
176 void uia_provider_thread_remove_node(HUIANODE node
) DECLSPEC_HIDDEN
;
177 LRESULT
uia_lresult_from_node(HUIANODE huianode
) DECLSPEC_HIDDEN
;
178 HRESULT
create_msaa_provider(IAccessible
*acc
, long child_id
, HWND hwnd
, BOOL known_root_acc
,
179 IRawElementProviderSimple
**elprov
) DECLSPEC_HIDDEN
;
182 HRESULT
get_safearray_dim_bounds(SAFEARRAY
*sa
, UINT dim
, LONG
*lbound
, LONG
*elems
) DECLSPEC_HIDDEN
;
183 HRESULT
get_safearray_bounds(SAFEARRAY
*sa
, LONG
*lbound
, LONG
*elems
) DECLSPEC_HIDDEN
;
184 int uia_compare_safearrays(SAFEARRAY
*sa1
, SAFEARRAY
*sa2
, int prop_type
) DECLSPEC_HIDDEN
;