Bug 1199785 - Make atk methods in nsMaiInterfaceComponent.cpp to work with ipc proxies, r=tbsaunde

This commit is contained in:
Olli Pettay 2015-09-02 00:57:57 +03:00
Родитель dbd45351dc
Коммит e0121eceb5
10 изменённых файлов: 239 добавлений и 130 удалений

Просмотреть файл

@ -1042,14 +1042,17 @@ refRelationSetCB(AtkObject *aAtkObj)
AccessibleWrap*
GetAccessibleWrap(AtkObject* aAtkObj)
{
NS_ENSURE_TRUE(IS_MAI_OBJECT(aAtkObj), nullptr);
bool isMAIObject = IS_MAI_OBJECT(aAtkObj);
NS_ENSURE_TRUE(isMAIObject || MAI_IS_ATK_SOCKET(aAtkObj),
nullptr);
// Make sure its native is an AccessibleWrap not a proxy.
if (MAI_ATK_OBJECT(aAtkObj)->accWrap & IS_PROXY)
uintptr_t accWrapPtr = isMAIObject ?
MAI_ATK_OBJECT(aAtkObj)->accWrap :
reinterpret_cast<uintptr_t>(MAI_ATK_SOCKET(aAtkObj)->accWrap);
if (accWrapPtr & IS_PROXY)
return nullptr;
AccessibleWrap* accWrap =
reinterpret_cast<AccessibleWrap*>(MAI_ATK_OBJECT(aAtkObj)->accWrap);
AccessibleWrap* accWrap = reinterpret_cast<AccessibleWrap*>(accWrapPtr);
// Check if the accessible was deconstructed.
if (!accWrap)
@ -1067,7 +1070,8 @@ GetAccessibleWrap(AtkObject* aAtkObj)
ProxyAccessible*
GetProxy(AtkObject* aObj)
{
if (!aObj || !(MAI_ATK_OBJECT(aObj)->accWrap & IS_PROXY))
if (!aObj || !IS_MAI_OBJECT(aObj) ||
!(MAI_ATK_OBJECT(aObj)->accWrap & IS_PROXY))
return nullptr;
return reinterpret_cast<ProxyAccessible*>(MAI_ATK_OBJECT(aObj)->accWrap

Просмотреть файл

@ -21,35 +21,6 @@ const char* AtkSocketAccessible::sATKSocketGetTypeSymbol = "atk_socket_get_type"
bool AtkSocketAccessible::gCanEmbed = FALSE;
extern "C" void mai_atk_component_iface_init(AtkComponentIface* aIface);
extern "C" GType mai_atk_socket_get_type(void);
/* MaiAtkSocket */
#define MAI_TYPE_ATK_SOCKET (mai_atk_socket_get_type ())
#define MAI_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
#define MAI_IS_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
#define MAI_IS_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
typedef struct _MaiAtkSocket
{
AtkSocket parent;
AccessibleWrap* accWrap;
} MaiAtkSocket;
typedef struct _MaiAtkSocketClass
{
AtkSocketClass parent_class;
} MaiAtkSocketClass;
G_DEFINE_TYPE_EXTENDED(MaiAtkSocket, mai_atk_socket,
AtkSocketAccessible::g_atk_socket_type, 0,
@ -86,7 +57,7 @@ RefAccessibleAtPoint(AtkComponent* aComponent, gint aX, gint aY,
{
NS_ENSURE_TRUE(MAI_IS_ATK_SOCKET(aComponent), nullptr);
return refAccessibleAtPointHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
return refAccessibleAtPointHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
aX, aY, aCoordType);
}
@ -99,7 +70,7 @@ GetExtents(AtkComponent* aComponent, gint* aX, gint* aY, gint* aWidth,
if (!MAI_IS_ATK_SOCKET(aComponent))
return;
getExtentsHelper(MAI_ATK_SOCKET(aComponent)->accWrap,
getExtentsHelper(ATK_OBJECT(MAI_ATK_SOCKET(aComponent)),
aX, aY, aWidth, aHeight, aCoordType);
}
}

Просмотреть файл

@ -34,9 +34,9 @@ void valueInterfaceInitCB(AtkValueIface *aIface);
/**
* XXX these should live in a file of utils for atk.
*/
AtkObject* refAccessibleAtPointHelper(mozilla::a11y::AccessibleWrap* aAccWrap,
AtkObject* refAccessibleAtPointHelper(AtkObject* aAtkObj,
gint aX, gint aY, AtkCoordType aCoordType);
void getExtentsHelper(mozilla::a11y::AccessibleWrap* aAccWrap,
void getExtentsHelper(AtkObject* aAtkObj,
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
AtkCoordType aCoordType);

Просмотреть файл

@ -34,6 +34,36 @@ class ProxyAccessible;
MaiAtkObjectClass))
GType mai_atk_object_get_type(void);
GType mai_util_get_type();
extern "C" GType mai_atk_socket_get_type(void);
/* MaiAtkSocket */
#define MAI_TYPE_ATK_SOCKET (mai_atk_socket_get_type ())
#define MAI_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj),\
MAI_TYPE_ATK_SOCKET, MaiAtkSocket))
#define MAI_IS_ATK_SOCKET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
#define MAI_IS_ATK_SOCKET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass),\
MAI_TYPE_ATK_SOCKET))
#define MAI_ATK_SOCKET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj),\
MAI_TYPE_ATK_SOCKET,\
MaiAtkSocketClass))
typedef struct _MaiAtkSocket
{
AtkSocket parent;
mozilla::a11y::AccessibleWrap* accWrap;
} MaiAtkSocket;
typedef struct _MaiAtkSocketClass
{
AtkSocketClass parent_class;
} MaiAtkSocketClass;
mozilla::a11y::AccessibleWrap* GetAccessibleWrap(AtkObject* aAtkObj);
mozilla::a11y::ProxyAccessible* GetProxy(AtkObject* aAtkObj);
AtkObject* GetWrapperFor(mozilla::a11y::ProxyAccessible* aProxy);

Просмотреть файл

@ -11,6 +11,7 @@
#include "nsCoreUtils.h"
#include "nsMai.h"
#include "mozilla/Likely.h"
#include "mozilla/a11y/ProxyAccessible.h"
using namespace mozilla::a11y;
@ -20,7 +21,7 @@ static AtkObject*
refAccessibleAtPointCB(AtkComponent* aComponent, gint aAccX, gint aAccY,
AtkCoordType aCoordType)
{
return refAccessibleAtPointHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
return refAccessibleAtPointHelper(ATK_OBJECT(aComponent),
aAccX, aAccY, aCoordType);
}
@ -28,73 +29,109 @@ static void
getExtentsCB(AtkComponent* aComponent, gint* aX, gint* aY,
gint* aWidth, gint* aHeight, AtkCoordType aCoordType)
{
getExtentsHelper(GetAccessibleWrap(ATK_OBJECT(aComponent)),
getExtentsHelper(ATK_OBJECT(aComponent),
aX, aY, aWidth, aHeight, aCoordType);
}
static gboolean
grabFocusCB(AtkComponent* aComponent)
{
AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aComponent));
if (!accWrap)
return FALSE;
AtkObject* atkObject = ATK_OBJECT(aComponent);
AccessibleWrap* accWrap = GetAccessibleWrap(atkObject);
if (accWrap) {
accWrap->TakeFocus();
return TRUE;
}
accWrap->TakeFocus();
return TRUE;
ProxyAccessible* proxy = GetProxy(atkObject);
if (proxy) {
proxy->TakeFocus();
return TRUE;
}
return FALSE;
}
}
AtkObject*
refAccessibleAtPointHelper(AccessibleWrap* aAccWrap, gint aX, gint aY,
refAccessibleAtPointHelper(AtkObject* aAtkObj, gint aX, gint aY,
AtkCoordType aCoordType)
{
if (!aAccWrap || aAccWrap->IsDefunct() || nsAccUtils::MustPrune(aAccWrap))
return nullptr;
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
if (accWrap) {
if (accWrap->IsDefunct() || nsAccUtils::MustPrune(accWrap)) {
return nullptr;
}
// Accessible::ChildAtPoint(x,y) is in screen pixels.
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
aX += winCoords.x;
aY += winCoords.y;
// Accessible::ChildAtPoint(x,y) is in screen pixels.
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
aX += winCoords.x;
aY += winCoords.y;
}
Accessible* accAtPoint = accWrap->ChildAtPoint(aX, aY,
Accessible::eDirectChild);
if (!accAtPoint) {
return nullptr;
}
AtkObject* atkObj = AccessibleWrap::GetAtkObject(accAtPoint);
if (atkObj) {
g_object_ref(atkObj);
}
return atkObj;
}
Accessible* accAtPoint = aAccWrap->ChildAtPoint(aX, aY,
Accessible::eDirectChild);
if (!accAtPoint)
return nullptr;
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
ProxyAccessible* result =
proxy->AccessibleAtPoint(aX, aY, aCoordType == ATK_XY_WINDOW);
AtkObject* atkObj = result ? GetWrapperFor(result) : nullptr;
if (atkObj) {
g_object_ref(atkObj);
}
return atkObj;
}
AtkObject* atkObj = AccessibleWrap::GetAtkObject(accAtPoint);
if (atkObj)
g_object_ref(atkObj);
return atkObj;
return nullptr;
}
void
getExtentsHelper(AccessibleWrap* aAccWrap,
getExtentsHelper(AtkObject* aAtkObj,
gint* aX, gint* aY, gint* aWidth, gint* aHeight,
AtkCoordType aCoordType)
{
AccessibleWrap* accWrap = GetAccessibleWrap(aAtkObj);
*aX = *aY = *aWidth = *aHeight = 0;
if (!aAccWrap || aAccWrap->IsDefunct())
return;
if (accWrap) {
if (accWrap->IsDefunct()) {
return;
}
nsIntRect screenRect = aAccWrap->Bounds();
if (screenRect.IsEmpty())
return;
nsIntRect screenRect = accWrap->Bounds();
if (screenRect.IsEmpty())
return;
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(aAccWrap->GetNode());
screenRect.x -= winCoords.x;
screenRect.y -= winCoords.y;
if (aCoordType == ATK_XY_WINDOW) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(accWrap->GetNode());
screenRect.x -= winCoords.x;
screenRect.y -= winCoords.y;
}
*aX = screenRect.x;
*aY = screenRect.y;
*aWidth = screenRect.width;
*aHeight = screenRect.height;
return;
}
*aX = screenRect.x;
*aY = screenRect.y;
*aWidth = screenRect.width;
*aHeight = screenRect.height;
if (ProxyAccessible* proxy = GetProxy(aAtkObj)) {
proxy->Extents(aCoordType == ATK_XY_WINDOW, aX, aY, aWidth, aHeight);
}
}
void

Просмотреть файл

@ -1792,42 +1792,6 @@ DocAccessibleChild::RecvFocusedChild(const uint64_t& aID,
return true;
}
bool
DocAccessibleChild::RecvChildAtPoint(const uint64_t& aID,
const int32_t& aX,
const int32_t& aY,
const uint32_t& aWhich,
uint64_t* aChild,
bool* aOk)
{
*aChild = 0;
*aOk = false;
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct() && !nsAccUtils::MustPrune(acc)) {
Accessible* child =
acc->ChildAtPoint(aX, aY,
static_cast<Accessible::EWhichChildAtPoint>(aWhich));
if (child) {
*aChild = reinterpret_cast<uint64_t>(child->UniqueID());
*aOk = true;
}
}
return true;
}
bool
DocAccessibleChild::RecvBounds(const uint64_t& aID,
nsIntRect* aRect)
{
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct()) {
*aRect = acc->Bounds();
}
return false;
}
bool
DocAccessibleChild::RecvLanguage(const uint64_t& aID,
nsString* aLocale)
@ -1906,5 +1870,71 @@ DocAccessibleChild::RecvURLDocTypeMimeType(const uint64_t& aID,
return true;
}
bool
DocAccessibleChild::RecvAccessibleAtPoint(const uint64_t& aID,
const int32_t& aX,
const int32_t& aY,
const bool& aNeedsScreenCoords,
const uint32_t& aWhich,
uint64_t* aResult,
bool* aOk)
{
*aResult = 0;
*aOk = false;
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct() && !nsAccUtils::MustPrune(acc)) {
int32_t x = aX;
int32_t y = aY;
if (aNeedsScreenCoords) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(acc->GetNode());
x += winCoords.x;
y += winCoords.y;
}
Accessible* result =
acc->ChildAtPoint(x, y,
static_cast<Accessible::EWhichChildAtPoint>(aWhich));
if (result) {
*aResult = reinterpret_cast<uint64_t>(result->UniqueID());
*aOk = true;
}
}
return true;
}
bool
DocAccessibleChild::RecvExtents(const uint64_t& aID,
const bool& aNeedsScreenCoords,
int32_t* aX,
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight)
{
*aX = 0;
*aY = 0;
*aWidth = 0;
*aHeight = 0;
Accessible* acc = IdToAccessible(aID);
if (acc && !acc->IsDefunct() && !nsAccUtils::MustPrune(acc)) {
nsIntRect screenRect = acc->Bounds();
if (!screenRect.IsEmpty()) {
if (aNeedsScreenCoords) {
nsIntPoint winCoords =
nsCoreUtils::GetScreenCoordsForWindow(acc->GetNode());
screenRect.x -= winCoords.x;
screenRect.y -= winCoords.y;
}
*aX = screenRect.x;
*aY = screenRect.y;
*aWidth = screenRect.width;
*aHeight = screenRect.height;
}
}
return true;
}
}
}

Просмотреть файл

@ -448,15 +448,6 @@ public:
uint64_t* aChild,
bool* aOk) override;
virtual bool RecvChildAtPoint(const uint64_t& aID,
const int32_t& aX,
const int32_t& aY,
const uint32_t& aWhich,
uint64_t* aChild,
bool* aOk) override;
virtual bool RecvBounds(const uint64_t& aID, nsIntRect* aRect) override;
virtual bool RecvLanguage(const uint64_t& aID, nsString* aLocale) override;
virtual bool RecvDocType(const uint64_t& aID, nsString* aType) override;
virtual bool RecvTitle(const uint64_t& aID, nsString* aTitle) override;
@ -466,6 +457,21 @@ public:
nsString* aURL,
nsString* aDocType,
nsString* aMimeType) override;
virtual bool RecvAccessibleAtPoint(const uint64_t& aID,
const int32_t& aX,
const int32_t& aY,
const bool& aNeedsScreenCoords,
const uint32_t& aWhich,
uint64_t* aResult,
bool* aOk) override;
virtual bool RecvExtents(const uint64_t& aID,
const bool& aNeedsScreenCoords,
int32_t* aX,
int32_t* aY,
int32_t* aWidth,
int32_t* aHeight) override;
private:
Accessible* IdToAccessible(const uint64_t& aID) const;

Просмотреть файл

@ -233,9 +233,6 @@ child:
returns(uint64_t aChild);
prio(high) sync FocusedChild(uint64_t aID)
returns(uint64_t aChild, bool aOk);
prio(high) sync ChildAtPoint(uint64_t aID, int32_t aX, int32_t aY, uint32_t aWhich)
returns(uint64_t aChild, bool aOk);
prio(high) sync Bounds(uint64_t aID) returns(nsIntRect aRect);
prio(high) sync Language(uint64_t aID) returns(nsString aLocale);
prio(high) sync DocType(uint64_t aID) returns(nsString aType);
@ -243,6 +240,12 @@ child:
prio(high) sync URL(uint64_t aID) returns(nsString aURL);
prio(high) sync MimeType(uint64_t aID) returns(nsString aMime);
prio(high) sync URLDocTypeMimeType(uint64_t aID) returns(nsString aURL, nsString aDocType, nsString aMimeType);
prio(high) sync AccessibleAtPoint(uint64_t aID, int32_t aX, int32_t aY, bool aNeedsScreenCoords, uint32_t aWhich)
returns(uint64_t aResult, bool aOk);
prio(high) sync Extents(uint64_t aID, bool aNeedsScreenCoords)
returns(int32_t aX, int32_t aY, int32_t aWidth, int32_t aHeight);
};
}

Просмотреть файл

@ -1019,9 +1019,9 @@ ProxyAccessible::ChildAtPoint(int32_t aX, int32_t aY,
{
uint64_t childID = 0;
bool ok = false;
unused << mDoc->SendChildAtPoint(mID, aX, aY,
static_cast<uint32_t>(aWhichChild),
&childID, &ok);
unused << mDoc->SendAccessibleAtPoint(mID, aX, aY, false,
static_cast<uint32_t>(aWhichChild),
&childID, &ok);
return ok ? mDoc->GetAccessible(childID) : nullptr;
}
@ -1029,7 +1029,9 @@ nsIntRect
ProxyAccessible::Bounds()
{
nsIntRect rect;
unused << mDoc->SendBounds(mID, &rect);
unused << mDoc->SendExtents(mID, false,
&(rect.x), &(rect.y),
&(rect.width), &(rect.height));
return rect;
}
@ -1070,6 +1072,26 @@ ProxyAccessible::URLDocTypeMimeType(nsString& aURL, nsString& aDocType,
unused << mDoc->SendURLDocTypeMimeType(mID, &aURL, &aDocType, &aMimeType);
}
ProxyAccessible*
ProxyAccessible::AccessibleAtPoint(int32_t aX, int32_t aY,
bool aNeedsScreenCoords)
{
uint64_t childID = 0;
bool ok = false;
unused <<
mDoc->SendAccessibleAtPoint(mID, aX, aY, aNeedsScreenCoords,
static_cast<uint32_t>(Accessible::eDirectChild),
&childID, &ok);
return ok ? mDoc->GetAccessible(childID) : nullptr;
}
void
ProxyAccessible::Extents(bool aNeedsScreenCoords, int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight)
{
unused << mDoc->SendExtents(mID, aNeedsScreenCoords, aX, aY, aWidth, aHeight);
}
Accessible*
ProxyAccessible::OuterDocOfRemoteBrowser() const
{

Просмотреть файл

@ -319,6 +319,12 @@ public:
void URLDocTypeMimeType(nsString& aURL, nsString& aDocType,
nsString& aMimeType);
ProxyAccessible* AccessibleAtPoint(int32_t aX, int32_t aY,
bool aNeedsScreenCoords);
void Extents(bool aNeedsScreenCoords, int32_t* aX, int32_t* aY,
int32_t* aWidth, int32_t* aHeight);
/**
* Allow the platform to store a pointers worth of data on us.
*/