Module: wine Branch: master Commit: 46b78c5d6dd0acdca8361815bc45d6e57849f169 URL: https://gitlab.winehq.org/wine/wine/-/commit/46b78c5d6dd0acdca8361815bc45d6e...
Author: Connor McAdams cmcadams@codeweavers.com Date: Wed Aug 30 10:56:52 2023 -0400
uiautomationcore: Don't return oleacc proxy IAccessibles from GetIAccessible for MSAA providers.
Signed-off-by: Connor McAdams cmcadams@codeweavers.com
---
dlls/uiautomationcore/tests/uiautomation.c | 7 +++++++ dlls/uiautomationcore/uia_provider.c | 27 ++++++++++++++++++++------- 2 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/dlls/uiautomationcore/tests/uiautomation.c b/dlls/uiautomationcore/tests/uiautomation.c index d4da880c038..ec2e7e31d6b 100644 --- a/dlls/uiautomationcore/tests/uiautomation.c +++ b/dlls/uiautomationcore/tests/uiautomation.c @@ -3473,6 +3473,12 @@ static void test_uia_prov_from_acc_fragment_root(HWND hwnd) ok(!!elroot, "elroot == NULL\n"); CHECK_CALLED(winproc_GETOBJECT_CLIENT);
+ /* + * ILegacyIAccessibleProvider::GetIAccessible returns a NULL + * IAccessible if the provider represents an oleacc proxy. + */ + check_msaa_prov_acc(elroot, NULL, CHILDID_SELF); + /* * Returns a provider from get_HostRawElementProvider without having * to query the HWND. @@ -3494,6 +3500,7 @@ static void test_uia_prov_from_acc_fragment_root(HWND hwnd) IRawElementProviderFragment_Release(elfrag2); ok(hr == S_OK, "Unexpected hr %#lx.\n", hr); ok(!!elroot2, "elroot2 == NULL\n"); + check_msaa_prov_acc(elroot2, NULL, CHILDID_SELF); CHECK_CALLED(winproc_GETOBJECT_CLIENT);
ok(!iface_cmp((IUnknown *)elroot, (IUnknown *)elroot2), "elroot2 == elroot\n"); diff --git a/dlls/uiautomationcore/uia_provider.c b/dlls/uiautomationcore/uia_provider.c index cb945796f50..729dc7ab2c5 100644 --- a/dlls/uiautomationcore/uia_provider.c +++ b/dlls/uiautomationcore/uia_provider.c @@ -84,6 +84,21 @@ static IAccessible *msaa_acc_da_unwrap(IAccessible *acc) return acc; }
+static BOOL msaa_acc_is_oleacc_proxy(IAccessible *acc) +{ + IUnknown *unk; + HRESULT hr; + + hr = msaa_acc_get_service(acc, &IIS_IsOleaccProxy, &IID_IUnknown, (void **)&unk); + if (SUCCEEDED(hr) && unk) + { + IUnknown_Release(unk); + return TRUE; + } + + return FALSE; +} + /* * Compare role, state, child count, and location properties of the two * IAccessibles. If all four are successfully retrieved and are equal, this is @@ -1103,10 +1118,11 @@ static HRESULT WINAPI msaa_acc_provider_GetIAccessible(ILegacyIAccessibleProvide
TRACE("%p, %p\n", iface, out_acc);
- IAccessible_AddRef(msaa_prov->acc); - *out_acc = msaa_prov->acc; + *out_acc = NULL; + if (msaa_acc_is_oleacc_proxy(msaa_prov->acc)) + return S_OK;
- return S_OK; + return IAccessible_QueryInterface(msaa_prov->acc, &IID_IAccessible, (void **)out_acc); }
static HRESULT WINAPI msaa_acc_provider_get_ChildId(ILegacyIAccessibleProvider *iface, int *out_cid) @@ -1252,7 +1268,6 @@ HRESULT WINAPI UiaProviderFromIAccessible(IAccessible *acc, LONG child_id, DWORD IRawElementProviderSimple **elprov) { HWND hwnd = NULL; - IUnknown *unk; HRESULT hr;
TRACE("(%p, %ld, %#lx, %p)\n", acc, child_id, flags, elprov); @@ -1271,11 +1286,9 @@ HRESULT WINAPI UiaProviderFromIAccessible(IAccessible *acc, LONG child_id, DWORD return E_NOTIMPL; }
- hr = msaa_acc_get_service(acc, &IIS_IsOleaccProxy, &IID_IUnknown, (void **)&unk); - if (SUCCEEDED(hr) && unk) + if (msaa_acc_is_oleacc_proxy(acc)) { WARN("Cannot wrap an oleacc proxy IAccessible!\n"); - IUnknown_Release(unk); return E_INVALIDARG; }