Bug 1854473 - Use screen's scale factor when providing accessible bounds in ATK. r=nlapre
Differential Revision: https://phabricator.services.mozilla.com/D188883
This commit is contained in:
@@ -10,10 +10,12 @@
|
|||||||
#include "AccessibleWrap.h"
|
#include "AccessibleWrap.h"
|
||||||
#include "nsAccUtils.h"
|
#include "nsAccUtils.h"
|
||||||
#include "nsMai.h"
|
#include "nsMai.h"
|
||||||
|
#include "nsWindow.h"
|
||||||
#include "mozilla/Likely.h"
|
#include "mozilla/Likely.h"
|
||||||
#include "mozilla/a11y/DocAccessibleParent.h"
|
#include "mozilla/a11y/DocAccessibleParent.h"
|
||||||
#include "mozilla/a11y/RemoteAccessible.h"
|
#include "mozilla/a11y/RemoteAccessible.h"
|
||||||
#include "mozilla/dom/BrowserParent.h"
|
#include "mozilla/dom/BrowserParent.h"
|
||||||
|
#include "mozilla/dom/Document.h"
|
||||||
#include "nsAccessibilityService.h"
|
#include "nsAccessibilityService.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
@@ -107,6 +109,36 @@ AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
|
|||||||
return atkObj;
|
return atkObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static double getScaleFactor(Accessible* aAccessible) {
|
||||||
|
DocAccessible* docAcc = nullptr;
|
||||||
|
if (LocalAccessible* localAcc = aAccessible->AsLocal()) {
|
||||||
|
docAcc = localAcc->Document();
|
||||||
|
} else {
|
||||||
|
RemoteAccessible* remote = aAccessible->AsRemote();
|
||||||
|
LocalAccessible* outerDoc = remote->OuterDocOfRemoteBrowser();
|
||||||
|
if (outerDoc) {
|
||||||
|
docAcc = outerDoc->Document();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!docAcc || !docAcc->DocumentNode()) {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIWidget> rootWidget =
|
||||||
|
nsContentUtils::WidgetForDocument(docAcc->DocumentNode());
|
||||||
|
if (!rootWidget) {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (RefPtr<nsWindow> window =
|
||||||
|
static_cast<nsWindow*>(rootWidget->GetTopLevelWidget())) {
|
||||||
|
return window->FractionalScaleFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
|
||||||
void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
||||||
gint* aHeight, AtkCoordType aCoordType) {
|
gint* aHeight, AtkCoordType aCoordType) {
|
||||||
*aX = *aY = *aWidth = *aHeight = -1;
|
*aX = *aY = *aWidth = *aHeight = -1;
|
||||||
@@ -128,10 +160,12 @@ void getExtentsHelper(AtkObject* aAtkObj, gint* aX, gint* aY, gint* aWidth,
|
|||||||
screenRect.y -= winCoords.y;
|
screenRect.y -= winCoords.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
*aX = screenRect.x;
|
double scaleFactor = getScaleFactor(acc);
|
||||||
*aY = screenRect.y;
|
|
||||||
*aWidth = screenRect.width;
|
*aX = screenRect.x / scaleFactor;
|
||||||
*aHeight = screenRect.height;
|
*aY = screenRect.y / scaleFactor;
|
||||||
|
*aWidth = screenRect.width / scaleFactor;
|
||||||
|
*aHeight = screenRect.height / scaleFactor;
|
||||||
}
|
}
|
||||||
|
|
||||||
void componentInterfaceInitCB(AtkComponentIface* aIface) {
|
void componentInterfaceInitCB(AtkComponentIface* aIface) {
|
||||||
|
|||||||
Reference in New Issue
Block a user