Bug 1621519: Implement xpcAccessible::GetDeepestChildAtPoint for ProxyAccessibles on Windows. r=yzen

Differential Revision: https://phabricator.services.mozilla.com/D66359

--HG--
extra : moz-landing-system : lando
This commit is contained in:
James Teh 2020-03-11 23:26:18 +00:00
Родитель f9b51b3540
Коммит 7b7c684070
2 изменённых файлов: 44 добавлений и 4 удалений

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

@ -738,5 +738,49 @@ void ProxyAccessible::TakeFocus() {
acc->accSelect(SELFLAG_TAKEFOCUS, kChildIdSelf); acc->accSelect(SELFLAG_TAKEFOCUS, kChildIdSelf);
} }
ProxyAccessible* ProxyAccessible::ChildAtPoint(
int32_t aX, int32_t aY, Accessible::EWhichChildAtPoint aWhichChild) {
RefPtr<IAccessible2_2> target = QueryInterface<IAccessible2_2>(this);
if (!target) {
return nullptr;
}
DocAccessibleParent* doc = Document();
ProxyAccessible* proxy = this;
// accHitTest only does direct children, but we might want the deepest child.
for (;;) {
VARIANT childVar;
if (FAILED(target->accHitTest(aX, aY, &childVar)) ||
childVar.vt == VT_EMPTY) {
return nullptr;
}
if (childVar.vt == VT_I4 && childVar.lVal == CHILDID_SELF) {
break;
}
MOZ_ASSERT(childVar.vt == VT_DISPATCH && childVar.pdispVal);
target = nullptr;
childVar.pdispVal->QueryInterface(IID_IAccessible2_2,
getter_AddRefs(target));
childVar.pdispVal->Release();
if (!target) {
return nullptr;
}
// We can't always use GetProxyFor because it can't cross document
// boundaries.
if (proxy->ChildrenCount() == 1) {
proxy = proxy->ChildAt(0);
if (proxy->IsDoc()) {
// We're crossing into a child document.
doc = proxy->AsDoc();
}
} else {
proxy = GetProxyFor(doc, target);
}
if (aWhichChild == Accessible::eDirectChild) {
break;
}
}
return proxy;
}
} // namespace a11y } // namespace a11y
} // namespace mozilla } // namespace mozilla

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

@ -590,12 +590,8 @@ xpcAccessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY,
if (IntlGeneric().IsNull()) return NS_ERROR_FAILURE; if (IntlGeneric().IsNull()) return NS_ERROR_FAILURE;
if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) { if (ProxyAccessible* proxy = IntlGeneric().AsProxy()) {
#if defined(XP_WIN)
return NS_ERROR_NOT_IMPLEMENTED;
#else
NS_IF_ADDREF(*aAccessible = ToXPC( NS_IF_ADDREF(*aAccessible = ToXPC(
proxy->ChildAtPoint(aX, aY, Accessible::eDeepestChild))); proxy->ChildAtPoint(aX, aY, Accessible::eDeepestChild)));
#endif
} else { } else {
NS_IF_ADDREF(*aAccessible = ToXPC( NS_IF_ADDREF(*aAccessible = ToXPC(
Intl()->ChildAtPoint(aX, aY, Accessible::eDeepestChild))); Intl()->ChildAtPoint(aX, aY, Accessible::eDeepestChild)));