mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 13:21:05 +00:00
Bug 1763191: Add suppport for cached remote accessibles in coordinate conversion functions r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D142970
This commit is contained in:
parent
a2c5c5d3b6
commit
278582922a
@ -9,7 +9,6 @@
|
|||||||
#include "LocalAccessible-inl.h"
|
#include "LocalAccessible-inl.h"
|
||||||
#include "AccessibleWrap.h"
|
#include "AccessibleWrap.h"
|
||||||
#include "nsAccUtils.h"
|
#include "nsAccUtils.h"
|
||||||
#include "nsCoreUtils.h"
|
|
||||||
#include "nsMai.h"
|
#include "nsMai.h"
|
||||||
#include "mozilla/Likely.h"
|
#include "mozilla/Likely.h"
|
||||||
#include "mozilla/a11y/DocAccessibleParent.h"
|
#include "mozilla/a11y/DocAccessibleParent.h"
|
||||||
@ -89,18 +88,8 @@ AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
|||||||
|
|
||||||
// Accessible::ChildAtPoint(x,y) is in screen pixels.
|
// Accessible::ChildAtPoint(x,y) is in screen pixels.
|
||||||
if (aCoordType == ATK_XY_WINDOW) {
|
if (aCoordType == ATK_XY_WINDOW) {
|
||||||
nsINode* node = nullptr;
|
|
||||||
if (acc->IsLocal()) {
|
|
||||||
node = acc->AsLocal()->GetNode();
|
|
||||||
} else {
|
|
||||||
// Use the XUL browser embedding this remote document.
|
|
||||||
auto browser = static_cast<mozilla::dom::BrowserParent*>(
|
|
||||||
acc->AsRemote()->Document()->Manager());
|
|
||||||
node = browser->GetOwnerElement();
|
|
||||||
}
|
|
||||||
MOZ_ASSERT(node);
|
|
||||||
mozilla::LayoutDeviceIntPoint winCoords =
|
mozilla::LayoutDeviceIntPoint winCoords =
|
||||||
nsCoreUtils::GetScreenCoordsForWindow(node);
|
nsAccUtils::GetScreenCoordsForWindow(acc);
|
||||||
aX += winCoords.x;
|
aX += winCoords.x;
|
||||||
aY += winCoords.y;
|
aY += winCoords.y;
|
||||||
}
|
}
|
||||||
@ -138,7 +127,7 @@ void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
|||||||
|
|
||||||
if (aCoordType == ATK_XY_WINDOW) {
|
if (aCoordType == ATK_XY_WINDOW) {
|
||||||
mozilla::LayoutDeviceIntPoint winCoords =
|
mozilla::LayoutDeviceIntPoint winCoords =
|
||||||
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
|
nsAccUtils::GetScreenCoordsForWindow(accWrap);
|
||||||
screenRect.x -= winCoords.x;
|
screenRect.x -= winCoords.x;
|
||||||
screenRect.y -= winCoords.y;
|
screenRect.y -= winCoords.y;
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#include "States.h"
|
#include "States.h"
|
||||||
#include "TextLeafAccessible.h"
|
#include "TextLeafAccessible.h"
|
||||||
|
|
||||||
|
#include "nsIBaseWindow.h"
|
||||||
|
#include "nsIDocShellTreeOwner.h"
|
||||||
#include "nsIDOMXULContainerElement.h"
|
#include "nsIDOMXULContainerElement.h"
|
||||||
#include "nsISimpleEnumerator.h"
|
#include "nsISimpleEnumerator.h"
|
||||||
#include "mozilla/a11y/PDocAccessibleChild.h"
|
#include "mozilla/a11y/PDocAccessibleChild.h"
|
||||||
@ -251,16 +253,17 @@ HyperTextAccessible* nsAccUtils::GetTextContainer(nsINode* aNode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
LayoutDeviceIntPoint nsAccUtils::ConvertToScreenCoords(
|
LayoutDeviceIntPoint nsAccUtils::ConvertToScreenCoords(
|
||||||
int32_t aX, int32_t aY, uint32_t aCoordinateType,
|
int32_t aX, int32_t aY, uint32_t aCoordinateType, Accessible* aAccessible) {
|
||||||
LocalAccessible* aAccessible) {
|
|
||||||
LayoutDeviceIntPoint coords(aX, aY);
|
LayoutDeviceIntPoint coords(aX, aY);
|
||||||
|
|
||||||
switch (aCoordinateType) {
|
switch (aCoordinateType) {
|
||||||
|
// Regardless of coordinate type, the coords returned
|
||||||
|
// are in dev pixels.
|
||||||
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
|
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE: {
|
case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE: {
|
||||||
coords += nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode());
|
coords += GetScreenCoordsForWindow(aAccessible);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,14 +281,15 @@ LayoutDeviceIntPoint nsAccUtils::ConvertToScreenCoords(
|
|||||||
|
|
||||||
void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
||||||
uint32_t aCoordinateType,
|
uint32_t aCoordinateType,
|
||||||
LocalAccessible* aAccessible) {
|
Accessible* aAccessible) {
|
||||||
switch (aCoordinateType) {
|
switch (aCoordinateType) {
|
||||||
|
// Regardless of coordinate type, the values returned for
|
||||||
|
// aX and aY are in dev pixels.
|
||||||
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
|
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE: {
|
case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE: {
|
||||||
LayoutDeviceIntPoint coords =
|
LayoutDeviceIntPoint coords = GetScreenCoordsForWindow(aAccessible);
|
||||||
nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode());
|
|
||||||
*aX -= coords.x;
|
*aX -= coords.x;
|
||||||
*aY -= coords.y;
|
*aY -= coords.y;
|
||||||
break;
|
break;
|
||||||
@ -304,17 +308,41 @@ void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LayoutDeviceIntPoint nsAccUtils::GetScreenCoordsForParent(
|
LayoutDeviceIntPoint nsAccUtils::GetScreenCoordsForParent(
|
||||||
LocalAccessible* aAccessible) {
|
Accessible* aAccessible) {
|
||||||
LocalAccessible* parent = aAccessible->LocalParent();
|
if (!aAccessible) return LayoutDeviceIntPoint();
|
||||||
if (!parent) return LayoutDeviceIntPoint(0, 0);
|
|
||||||
|
|
||||||
nsIFrame* parentFrame = parent->GetFrame();
|
if (Accessible* parent = aAccessible->Parent()) {
|
||||||
if (!parentFrame) return LayoutDeviceIntPoint(0, 0);
|
LayoutDeviceIntRect parentBounds = parent->Bounds();
|
||||||
|
// The rect returned from Bounds() is already in dev
|
||||||
|
// pixels, so we don't need to do any conversion here.
|
||||||
|
return parentBounds.TopLeft();
|
||||||
|
}
|
||||||
|
|
||||||
nsRect rect = parentFrame->GetScreenRectInAppUnits();
|
return LayoutDeviceIntPoint();
|
||||||
nscoord appUnitsRatio = parentFrame->PresContext()->AppUnitsPerDevPixel();
|
}
|
||||||
return LayoutDeviceIntPoint::FromAppUnitsToNearest(
|
|
||||||
nsPoint(rect.X(), rect.Y()), appUnitsRatio);
|
LayoutDeviceIntPoint nsAccUtils::GetScreenCoordsForWindow(
|
||||||
|
Accessible* aAccessible) {
|
||||||
|
a11y::LocalAccessible* localAcc = aAccessible->AsLocal();
|
||||||
|
if (!localAcc) {
|
||||||
|
localAcc = aAccessible->AsRemote()->OuterDocOfRemoteBrowser();
|
||||||
|
}
|
||||||
|
|
||||||
|
LayoutDeviceIntPoint coords(0, 0);
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> treeItem(
|
||||||
|
nsCoreUtils::GetDocShellFor(localAcc->GetNode()));
|
||||||
|
if (!treeItem) return coords;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
||||||
|
treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
||||||
|
if (!treeOwner) return coords;
|
||||||
|
|
||||||
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(treeOwner);
|
||||||
|
if (baseWindow) {
|
||||||
|
baseWindow->GetPosition(&coords.x, &coords.y); // in device pixels
|
||||||
|
}
|
||||||
|
|
||||||
|
return coords;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool nsAccUtils::GetLiveAttrValue(uint32_t aRule, nsAString& aValue) {
|
bool nsAccUtils::GetLiveAttrValue(uint32_t aRule, nsAString& aValue) {
|
||||||
|
@ -140,9 +140,9 @@ class nsAccUtils {
|
|||||||
* relative it.
|
* relative it.
|
||||||
* @return converted coordinates
|
* @return converted coordinates
|
||||||
*/
|
*/
|
||||||
static LayoutDeviceIntPoint ConvertToScreenCoords(
|
static LayoutDeviceIntPoint ConvertToScreenCoords(int32_t aX, int32_t aY,
|
||||||
int32_t aX, int32_t aY, uint32_t aCoordinateType,
|
uint32_t aCoordinateType,
|
||||||
LocalAccessible* aAccessible);
|
Accessible* aAccessible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts the given coordinates relative screen to another coordinate
|
* Converts the given coordinates relative screen to another coordinate
|
||||||
@ -157,7 +157,7 @@ class nsAccUtils {
|
|||||||
*/
|
*/
|
||||||
static void ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
static void ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
||||||
uint32_t aCoordinateType,
|
uint32_t aCoordinateType,
|
||||||
LocalAccessible* aAccessible);
|
Accessible* aAccessible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns screen-relative coordinates (in dev pixels) for the parent of the
|
* Returns screen-relative coordinates (in dev pixels) for the parent of the
|
||||||
@ -165,8 +165,16 @@ class nsAccUtils {
|
|||||||
*
|
*
|
||||||
* @param [in] aAccessible the accessible
|
* @param [in] aAccessible the accessible
|
||||||
*/
|
*/
|
||||||
static LayoutDeviceIntPoint GetScreenCoordsForParent(
|
static LayoutDeviceIntPoint GetScreenCoordsForParent(Accessible* aAccessible);
|
||||||
LocalAccessible* aAccessible);
|
|
||||||
|
/**
|
||||||
|
* Returns coordinates in device pixels relative screen for the top level
|
||||||
|
* window.
|
||||||
|
*
|
||||||
|
* @param aAccessible the acc hosted in the window.
|
||||||
|
*/
|
||||||
|
static mozilla::LayoutDeviceIntPoint GetScreenCoordsForWindow(
|
||||||
|
mozilla::a11y::Accessible* aAccessible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the 'live' or 'container-live' object attribute value from the given
|
* Get the 'live' or 'container-live' object attribute value from the given
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
|
|
||||||
#include "nsIAccessibleTypes.h"
|
#include "nsIAccessibleTypes.h"
|
||||||
|
|
||||||
#include "nsIBaseWindow.h"
|
|
||||||
#include "nsIDocShellTreeOwner.h"
|
|
||||||
#include "mozilla/dom/Document.h"
|
#include "mozilla/dom/Document.h"
|
||||||
#include "nsRange.h"
|
#include "nsRange.h"
|
||||||
#include "nsXULElement.h"
|
#include "nsXULElement.h"
|
||||||
@ -322,23 +320,6 @@ void nsCoreUtils::ConvertScrollTypeToPercents(uint32_t aScrollType,
|
|||||||
*aHorizontal = ScrollAxis(whereX, whenX);
|
*aHorizontal = ScrollAxis(whereX, whenX);
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutDeviceIntPoint nsCoreUtils::GetScreenCoordsForWindow(nsINode* aNode) {
|
|
||||||
LayoutDeviceIntPoint coords(0, 0);
|
|
||||||
nsCOMPtr<nsIDocShellTreeItem> treeItem(GetDocShellFor(aNode));
|
|
||||||
if (!treeItem) return coords;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDocShellTreeOwner> treeOwner;
|
|
||||||
treeItem->GetTreeOwner(getter_AddRefs(treeOwner));
|
|
||||||
if (!treeOwner) return coords;
|
|
||||||
|
|
||||||
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(treeOwner);
|
|
||||||
if (baseWindow) {
|
|
||||||
baseWindow->GetPosition(&coords.x, &coords.y); // in device pixels
|
|
||||||
}
|
|
||||||
|
|
||||||
return coords;
|
|
||||||
}
|
|
||||||
|
|
||||||
already_AddRefed<nsIDocShell> nsCoreUtils::GetDocShellFor(nsINode* aNode) {
|
already_AddRefed<nsIDocShell> nsCoreUtils::GetDocShellFor(nsINode* aNode) {
|
||||||
if (!aNode) return nullptr;
|
if (!aNode) return nullptr;
|
||||||
|
|
||||||
|
@ -181,14 +181,6 @@ class nsCoreUtils {
|
|||||||
mozilla::ScrollAxis* aVertical,
|
mozilla::ScrollAxis* aVertical,
|
||||||
mozilla::ScrollAxis* aHorizontal);
|
mozilla::ScrollAxis* aHorizontal);
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns coordinates in device pixels relative screen for the top level
|
|
||||||
* window.
|
|
||||||
*
|
|
||||||
* @param aNode the DOM node hosted in the window.
|
|
||||||
*/
|
|
||||||
static mozilla::LayoutDeviceIntPoint GetScreenCoordsForWindow(nsINode* aNode);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return document shell for the given DOM node.
|
* Return document shell for the given DOM node.
|
||||||
*/
|
*/
|
||||||
|
@ -1601,7 +1601,7 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvExtents(
|
|||||||
if (!screenRect.IsEmpty()) {
|
if (!screenRect.IsEmpty()) {
|
||||||
if (aNeedsScreenCoords) {
|
if (aNeedsScreenCoords) {
|
||||||
LayoutDeviceIntPoint winCoords =
|
LayoutDeviceIntPoint winCoords =
|
||||||
nsCoreUtils::GetScreenCoordsForWindow(acc->GetNode());
|
nsAccUtils::GetScreenCoordsForWindow(acc);
|
||||||
screenRect.x -= winCoords.x;
|
screenRect.x -= winCoords.x;
|
||||||
screenRect.y -= winCoords.y;
|
screenRect.y -= winCoords.y;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user