Bug 1841942: Don't call GetProp in LazyInstantiator::GetRootAccessible if a11y is already instantiated. r=nlapre

If a11y is instantiated, we always want to return the real root.
Furthermore, we clear the instantiator prop anyway when we instantiate a11y.
Therefore, calling GetProp is wasteful if a11y is instantiated.
Instead, we now only call GetProp if a11y isn't instantiated yet.

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

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

@ -41,25 +41,26 @@ static const wchar_t kLazyInstantiatorProp[] =
/* static */
already_AddRefed<IAccessible> LazyInstantiator::GetRootAccessible(HWND aHwnd) {
// There must only be one LazyInstantiator per HWND.
// To track this, we set the kLazyInstantiatorProp on the HWND with a pointer
// to an existing instance. We only create a new LazyInstatiator if that prop
// has not already been set.
LazyInstantiator* existingInstantiator = reinterpret_cast<LazyInstantiator*>(
::GetProp(aHwnd, kLazyInstantiatorProp));
RefPtr<IAccessible> result;
if (existingInstantiator) {
// Temporarily disable blind aggregation until we know that we have been
// marshaled. See EnableBlindAggregation for more information.
existingInstantiator->mAllowBlindAggregation = false;
result = existingInstantiator;
return result.forget();
}
// At this time we only want to check whether the acc service is running; We
// At this time we only want to check whether the acc service is running. We
// don't actually want to create the acc service yet.
if (!GetAccService()) {
// There must only be one LazyInstantiator per HWND.
// To track this, we set the kLazyInstantiatorProp on the HWND with a
// pointer to an existing instance. We only create a new LazyInstatiator if
// that prop has not already been set.
LazyInstantiator* existingInstantiator =
reinterpret_cast<LazyInstantiator*>(
::GetProp(aHwnd, kLazyInstantiatorProp));
if (existingInstantiator) {
// Temporarily disable blind aggregation until we know that we have been
// marshaled. See EnableBlindAggregation for more information.
existingInstantiator->mAllowBlindAggregation = false;
result = existingInstantiator;
return result.forget();
}
// a11y is not running yet, there are no existing LazyInstantiators for this
// HWND, so create a new one and return it as a surrogate for the root
// accessible.