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 "AccessibleWrap.h"
|
||||
#include "nsAccUtils.h"
|
||||
#include "nsCoreUtils.h"
|
||||
#include "nsMai.h"
|
||||
#include "mozilla/Likely.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.
|
||||
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 =
|
||||
nsCoreUtils::GetScreenCoordsForWindow(node);
|
||||
nsAccUtils::GetScreenCoordsForWindow(acc);
|
||||
aX += winCoords.x;
|
||||
aY += winCoords.y;
|
||||
}
|
||||
@ -138,7 +127,7 @@ void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
||||
|
||||
if (aCoordType == ATK_XY_WINDOW) {
|
||||
mozilla::LayoutDeviceIntPoint winCoords =
|
||||
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
|
||||
nsAccUtils::GetScreenCoordsForWindow(accWrap);
|
||||
screenRect.x -= winCoords.x;
|
||||
screenRect.y -= winCoords.y;
|
||||
}
|
||||
|
@ -18,6 +18,8 @@
|
||||
#include "States.h"
|
||||
#include "TextLeafAccessible.h"
|
||||
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "nsIDOMXULContainerElement.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "mozilla/a11y/PDocAccessibleChild.h"
|
||||
@ -251,16 +253,17 @@ HyperTextAccessible* nsAccUtils::GetTextContainer(nsINode* aNode) {
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint nsAccUtils::ConvertToScreenCoords(
|
||||
int32_t aX, int32_t aY, uint32_t aCoordinateType,
|
||||
LocalAccessible* aAccessible) {
|
||||
int32_t aX, int32_t aY, uint32_t aCoordinateType, Accessible* aAccessible) {
|
||||
LayoutDeviceIntPoint coords(aX, aY);
|
||||
|
||||
switch (aCoordinateType) {
|
||||
// Regardless of coordinate type, the coords returned
|
||||
// are in dev pixels.
|
||||
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
|
||||
break;
|
||||
|
||||
case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE: {
|
||||
coords += nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode());
|
||||
coords += GetScreenCoordsForWindow(aAccessible);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -278,14 +281,15 @@ LayoutDeviceIntPoint nsAccUtils::ConvertToScreenCoords(
|
||||
|
||||
void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
||||
uint32_t aCoordinateType,
|
||||
LocalAccessible* aAccessible) {
|
||||
Accessible* aAccessible) {
|
||||
switch (aCoordinateType) {
|
||||
// Regardless of coordinate type, the values returned for
|
||||
// aX and aY are in dev pixels.
|
||||
case nsIAccessibleCoordinateType::COORDTYPE_SCREEN_RELATIVE:
|
||||
break;
|
||||
|
||||
case nsIAccessibleCoordinateType::COORDTYPE_WINDOW_RELATIVE: {
|
||||
LayoutDeviceIntPoint coords =
|
||||
nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode());
|
||||
LayoutDeviceIntPoint coords = GetScreenCoordsForWindow(aAccessible);
|
||||
*aX -= coords.x;
|
||||
*aY -= coords.y;
|
||||
break;
|
||||
@ -304,17 +308,41 @@ void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint nsAccUtils::GetScreenCoordsForParent(
|
||||
LocalAccessible* aAccessible) {
|
||||
LocalAccessible* parent = aAccessible->LocalParent();
|
||||
if (!parent) return LayoutDeviceIntPoint(0, 0);
|
||||
Accessible* aAccessible) {
|
||||
if (!aAccessible) return LayoutDeviceIntPoint();
|
||||
|
||||
nsIFrame* parentFrame = parent->GetFrame();
|
||||
if (!parentFrame) return LayoutDeviceIntPoint(0, 0);
|
||||
if (Accessible* parent = aAccessible->Parent()) {
|
||||
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();
|
||||
nscoord appUnitsRatio = parentFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
return LayoutDeviceIntPoint::FromAppUnitsToNearest(
|
||||
nsPoint(rect.X(), rect.Y()), appUnitsRatio);
|
||||
return LayoutDeviceIntPoint();
|
||||
}
|
||||
|
||||
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) {
|
||||
|
@ -140,9 +140,9 @@ class nsAccUtils {
|
||||
* relative it.
|
||||
* @return converted coordinates
|
||||
*/
|
||||
static LayoutDeviceIntPoint ConvertToScreenCoords(
|
||||
int32_t aX, int32_t aY, uint32_t aCoordinateType,
|
||||
LocalAccessible* aAccessible);
|
||||
static LayoutDeviceIntPoint ConvertToScreenCoords(int32_t aX, int32_t aY,
|
||||
uint32_t aCoordinateType,
|
||||
Accessible* aAccessible);
|
||||
|
||||
/**
|
||||
* Converts the given coordinates relative screen to another coordinate
|
||||
@ -157,7 +157,7 @@ class nsAccUtils {
|
||||
*/
|
||||
static void ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
||||
uint32_t aCoordinateType,
|
||||
LocalAccessible* aAccessible);
|
||||
Accessible* aAccessible);
|
||||
|
||||
/**
|
||||
* Returns screen-relative coordinates (in dev pixels) for the parent of the
|
||||
@ -165,8 +165,16 @@ class nsAccUtils {
|
||||
*
|
||||
* @param [in] aAccessible the accessible
|
||||
*/
|
||||
static LayoutDeviceIntPoint GetScreenCoordsForParent(
|
||||
LocalAccessible* aAccessible);
|
||||
static LayoutDeviceIntPoint GetScreenCoordsForParent(Accessible* 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
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
#include "nsIAccessibleTypes.h"
|
||||
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsRange.h"
|
||||
#include "nsXULElement.h"
|
||||
@ -322,23 +320,6 @@ void nsCoreUtils::ConvertScrollTypeToPercents(uint32_t aScrollType,
|
||||
*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) {
|
||||
if (!aNode) return nullptr;
|
||||
|
||||
|
@ -181,14 +181,6 @@ class nsCoreUtils {
|
||||
mozilla::ScrollAxis* aVertical,
|
||||
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.
|
||||
*/
|
||||
|
@ -1601,7 +1601,7 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvExtents(
|
||||
if (!screenRect.IsEmpty()) {
|
||||
if (aNeedsScreenCoords) {
|
||||
LayoutDeviceIntPoint winCoords =
|
||||
nsCoreUtils::GetScreenCoordsForWindow(acc->GetNode());
|
||||
nsAccUtils::GetScreenCoordsForWindow(acc);
|
||||
screenRect.x -= winCoords.x;
|
||||
screenRect.y -= winCoords.y;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user