Bug 1774193: Allow IAccessible::accHitTest to use RemoteAccessible's ChildAtPoint. r=morgan

When the cache is enabled, this now also fetches the deepest descendant instead of a direct child.
In addition, I removed some unnecessary/misleading comments.

Differential Revision: https://phabricator.services.mozilla.com/D149240
This commit is contained in:
James Teh 2022-06-14 22:18:29 +00:00
parent 23c3b53d41
commit 2b226822c0

View File

@ -1624,21 +1624,24 @@ MsaaAccessible::accHitTest(
if (!mAcc) {
return CO_E_OBJNOTCONNECTED;
}
LocalAccessible* localAcc = LocalAcc();
if (!localAcc) {
return E_NOTIMPL; // XXX Not supported for RemoteAccessible yet.
}
Accessible* accessible = mAcc->ChildAtPoint(
xLeft, yTop, Accessible::EWhichChildAtPoint::DirectChild);
xLeft, yTop,
// The MSAA documentation says accHitTest should return a child. However,
// clients call AccessibleObjectFromPoint, which ends up walking the
// descendants calling accHitTest on each one. Since clients want the
// deepest descendant anyway, it's faster and probably more accurate to
// just do this ourselves. For now, we keep this behind the cache pref.
StaticPrefs::accessibility_cache_enabled_AtStartup()
? Accessible::EWhichChildAtPoint::DeepestChild
: Accessible::EWhichChildAtPoint::DirectChild);
// if we got a child
if (accessible) {
// if the child is us
if (accessible == mAcc) {
pvarChild->vt = VT_I4;
pvarChild->lVal = CHILDID_SELF;
} else { // its not create a LocalAccessible for it.
} else {
pvarChild->vt = VT_DISPATCH;
pvarChild->pdispVal = NativeAccessible(accessible);
}