mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-24 03:19:06 +00:00
Backed out changeset b424302d8ba0 (bug 1763191) for causing Bp-hybrid bustages on nsAccUtils. CLOSED TREE
This commit is contained in:
parent
6a1c9a4a6a
commit
c97a26b3a1
@ -9,6 +9,7 @@
|
||||
#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"
|
||||
@ -94,8 +95,18 @@ 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 =
|
||||
nsAccUtils::GetScreenCoordsForWindow(acc);
|
||||
nsCoreUtils::GetScreenCoordsForWindow(node);
|
||||
aX += winCoords.x;
|
||||
aY += winCoords.y;
|
||||
}
|
||||
@ -133,7 +144,7 @@ void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
||||
|
||||
if (aCoordType == ATK_XY_WINDOW) {
|
||||
mozilla::LayoutDeviceIntPoint winCoords =
|
||||
nsAccUtils::GetScreenCoordsForWindow(accWrap);
|
||||
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
|
||||
screenRect.x -= winCoords.x;
|
||||
screenRect.y -= winCoords.y;
|
||||
}
|
||||
|
@ -18,7 +18,6 @@
|
||||
#include "States.h"
|
||||
#include "TextLeafAccessible.h"
|
||||
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDOMXULContainerElement.h"
|
||||
#include "nsISimpleEnumerator.h"
|
||||
#include "mozilla/a11y/PDocAccessibleChild.h"
|
||||
@ -252,17 +251,16 @@ HyperTextAccessible* nsAccUtils::GetTextContainer(nsINode* aNode) {
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint nsAccUtils::ConvertToScreenCoords(
|
||||
int32_t aX, int32_t aY, uint32_t aCoordinateType, Accessible* aAccessible) {
|
||||
int32_t aX, int32_t aY, uint32_t aCoordinateType,
|
||||
LocalAccessible* 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 += GetScreenCoordsForWindow(aAccessible);
|
||||
coords += nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode());
|
||||
break;
|
||||
}
|
||||
|
||||
@ -280,15 +278,14 @@ LayoutDeviceIntPoint nsAccUtils::ConvertToScreenCoords(
|
||||
|
||||
void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
||||
uint32_t aCoordinateType,
|
||||
Accessible* aAccessible) {
|
||||
LocalAccessible* 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 = GetScreenCoordsForWindow(aAccessible);
|
||||
LayoutDeviceIntPoint coords =
|
||||
nsCoreUtils::GetScreenCoordsForWindow(aAccessible->GetNode());
|
||||
*aX -= coords.x;
|
||||
*aY -= coords.y;
|
||||
break;
|
||||
@ -307,41 +304,17 @@ void nsAccUtils::ConvertScreenCoordsTo(int32_t* aX, int32_t* aY,
|
||||
}
|
||||
|
||||
LayoutDeviceIntPoint nsAccUtils::GetScreenCoordsForParent(
|
||||
Accessible* aAccessible) {
|
||||
if (!aAccessible) return LayoutDeviceIntPoint();
|
||||
LocalAccessible* aAccessible) {
|
||||
LocalAccessible* parent = aAccessible->LocalParent();
|
||||
if (!parent) 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();
|
||||
}
|
||||
nsIFrame* parentFrame = parent->GetFrame();
|
||||
if (!parentFrame) return LayoutDeviceIntPoint(0, 0);
|
||||
|
||||
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;
|
||||
nsRect rect = parentFrame->GetScreenRectInAppUnits();
|
||||
nscoord appUnitsRatio = parentFrame->PresContext()->AppUnitsPerDevPixel();
|
||||
return LayoutDeviceIntPoint::FromAppUnitsToNearest(
|
||||
nsPoint(rect.X(), rect.Y()), appUnitsRatio);
|
||||
}
|
||||
|
||||
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,
|
||||
Accessible* aAccessible);
|
||||
static LayoutDeviceIntPoint ConvertToScreenCoords(
|
||||
int32_t aX, int32_t aY, uint32_t aCoordinateType,
|
||||
LocalAccessible* 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,
|
||||
Accessible* aAccessible);
|
||||
LocalAccessible* aAccessible);
|
||||
|
||||
/**
|
||||
* Returns screen-relative coordinates (in dev pixels) for the parent of the
|
||||
@ -165,16 +165,8 @@ class nsAccUtils {
|
||||
*
|
||||
* @param [in] aAccessible the accessible
|
||||
*/
|
||||
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);
|
||||
static LayoutDeviceIntPoint GetScreenCoordsForParent(
|
||||
LocalAccessible* aAccessible);
|
||||
|
||||
/**
|
||||
* Get the 'live' or 'container-live' object attribute value from the given
|
||||
|
@ -7,6 +7,7 @@
|
||||
|
||||
#include "nsIAccessibleTypes.h"
|
||||
|
||||
#include "nsIBaseWindow.h"
|
||||
#include "nsIDocShellTreeOwner.h"
|
||||
#include "mozilla/dom/Document.h"
|
||||
#include "nsRange.h"
|
||||
@ -321,6 +322,23 @@ 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,6 +181,14 @@ 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.
|
||||
*/
|
||||
|
@ -1613,7 +1613,7 @@ mozilla::ipc::IPCResult DocAccessibleChild::RecvExtents(
|
||||
if (!screenRect.IsEmpty()) {
|
||||
if (aNeedsScreenCoords) {
|
||||
LayoutDeviceIntPoint winCoords =
|
||||
nsAccUtils::GetScreenCoordsForWindow(acc);
|
||||
nsCoreUtils::GetScreenCoordsForWindow(acc->GetNode());
|
||||
screenRect.x -= winCoords.x;
|
||||
screenRect.y -= winCoords.y;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user