Bug 1841943: Remove broken LazyInstantiator code to resolve a fake root accessible. r=nlapre

The code previously called DefWindowProc to get a system generated client IAccessible. However, DefWindowProc doesn't do this and I'm fairly sure it never has.
Even if we use CreateStdAccessibleObject instead:

1. We crash in LazyInstantiator's destructor because we try to call into mWeakMsaaRoot, which doesn't exist in this case.
2. We crash when some clients call us because AddRef and Release assume that we've transplanted our ref count into mRealRootUnk, but we don't do that in the case of a fake root.
3. We don't (and can't) aggregate the fake root COM object, so QueryInterface would be asymmetric. This may well cause obscure crashes/leaks.

We could fix all of these issues, but since this has clearly never been used or relied upon, we should just remove it.
We already have stub implementations for key methods and the others will just fail as they always have.
There should be no visible change with this patch.

Differential Revision: https://phabricator.services.mozilla.com/D182864
This commit is contained in:
James Teh 2023-07-11 21:58:49 +00:00
Родитель cb27283aab
Коммит e72ae1eb3e
2 изменённых файлов: 2 добавлений и 28 удалений

Просмотреть файл

@ -349,33 +349,7 @@ LazyInstantiator::MaybeResolveRoot() {
return S_OK;
}
// If we don't want a real root, let's resolve a fake one.
const WPARAM flags = 0xFFFFFFFFUL;
// Synthesize a WM_GETOBJECT request to obtain a system-implemented
// IAccessible object from DefWindowProc
LRESULT lresult = ::DefWindowProc(mHwnd, WM_GETOBJECT, flags,
static_cast<LPARAM>(OBJID_CLIENT));
HRESULT hr = ObjectFromLresult(lresult, IID_IAccessible, flags,
getter_AddRefs(mRealRootUnk));
if (FAILED(hr)) {
return hr;
}
if (!mRealRootUnk) {
return E_NOTIMPL;
}
hr = mRealRootUnk->QueryInterface(IID_IAccessible, (void**)&mWeakAccessible);
if (FAILED(hr)) {
return hr;
}
// mWeakAccessible is weak, so don't hold a strong ref
mWeakAccessible->Release();
return S_OK;
return E_FAIL;
}
#define RESOLVE_ROOT \

Просмотреть файл

@ -112,7 +112,7 @@ class LazyInstantiator final : public IAccessible, public IServiceProvider {
RefPtr<IUnknown> mRealRootUnk;
RefPtr<IUnknown> mStdDispatch;
/**
* mWeakRootAccWrap, mWeakAccessible and mWeakDispatch are weak because they
* mWeakMsaaRoot, mWeakAccessible and mWeakDispatch are weak because they
* are interfaces that come from objects that we aggregate. Aggregated object
* interfaces share refcount methods with ours, so if we were to hold strong
* references to them, we would be holding strong references to ourselves,