From cc07441b9664d3469654f8c84d46df8ccf9e8a66 Mon Sep 17 00:00:00 2001 From: James Teh Date: Thu, 26 Mar 2020 18:00:59 +0000 Subject: [PATCH] Bug 1622699 part 1: Add nsIAccessible::GetDeepestChildAtPointInProcess. r=yzen Dev Tools A11y Panel interacts with accessibles in the process in which they reside. It does not (and cannot) deal with ProxyAccessibles. However, GetDeepestChildAtPoint now walks into the ProxyAccessible tree if appropriate, which is what we want for tests and what normally makes sense. This patch introduces GetDeepestChildAtPointInProcess, which Dev Tools will use instead. Differential Revision: https://phabricator.services.mozilla.com/D68302 --HG-- extra : moz-landing-system : lando --- accessible/interfaces/nsIAccessible.idl | 16 +++++++++++++++- accessible/xpcom/xpcAccessible.cpp | 16 ++++++++++++++++ accessible/xpcom/xpcAccessible.h | 2 ++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/accessible/interfaces/nsIAccessible.idl b/accessible/interfaces/nsIAccessible.idl index dc0b6e8c8474..51b5347efbe3 100644 --- a/accessible/interfaces/nsIAccessible.idl +++ b/accessible/interfaces/nsIAccessible.idl @@ -193,7 +193,7 @@ interface nsIAccessible : nsISupports * * @param x screen's x coordinate * @param y screen's y coordinate - * @return the deepest accessible child containing the given point + * @return the direct accessible child containing the given point */ nsIAccessible getChildAtPoint(in long x, in long y); @@ -209,6 +209,20 @@ interface nsIAccessible : nsISupports */ nsIAccessible getDeepestChildAtPoint(in long x, in long y); +/** + * Like GetDeepestChildAtPoint, but restricted to the current process. + * If the point is within a remote document, the accessible for the browser + * element containing that document will be returned; i.e. this will not + * descend into the document. If called on an accessible inside a remote + * document, this will fail. + * + * @param x screen's x coordinate + * @param y screen's y coordinate + * @return the deepest accessible child in this process containing the given + * point + */ + nsIAccessible getDeepestChildAtPointInProcess(in long x, in long y); + /** * Nth accessible child using zero-based index or last child if index less than zero */ diff --git a/accessible/xpcom/xpcAccessible.cpp b/accessible/xpcom/xpcAccessible.cpp index 9c623523d69e..c2e5ad83ac87 100644 --- a/accessible/xpcom/xpcAccessible.cpp +++ b/accessible/xpcom/xpcAccessible.cpp @@ -586,6 +586,22 @@ xpcAccessible::GetDeepestChildAtPoint(int32_t aX, int32_t aY, return NS_OK; } +NS_IMETHODIMP +xpcAccessible::GetDeepestChildAtPointInProcess(int32_t aX, int32_t aY, + nsIAccessible** aAccessible) { + NS_ENSURE_ARG_POINTER(aAccessible); + *aAccessible = nullptr; + + AccessibleOrProxy generic = IntlGeneric(); + if (generic.IsNull() || generic.IsProxy()) { + return NS_ERROR_FAILURE; + } + + NS_IF_ADDREF(*aAccessible = ToXPC( + Intl()->ChildAtPoint(aX, aY, Accessible::eDeepestChild))); + return NS_OK; +} + NS_IMETHODIMP xpcAccessible::SetSelected(bool aSelect) { if (IntlGeneric().IsNull()) return NS_ERROR_FAILURE; diff --git a/accessible/xpcom/xpcAccessible.h b/accessible/xpcom/xpcAccessible.h index 9fc9ad00cc95..598828827cef 100644 --- a/accessible/xpcom/xpcAccessible.h +++ b/accessible/xpcom/xpcAccessible.h @@ -67,6 +67,8 @@ class xpcAccessible : public nsIAccessible { nsIAccessible** aAccessible) final; NS_IMETHOD GetDeepestChildAtPoint(int32_t aX, int32_t aY, nsIAccessible** aAccessible) final; + NS_IMETHOD GetDeepestChildAtPointInProcess(int32_t aX, int32_t aY, + nsIAccessible** aAccessible) final; NS_IMETHOD SetSelected(bool aSelect) final; NS_IMETHOD TakeSelection() final;