diff --git a/accessible/atk/AccessibleWrap.cpp b/accessible/atk/AccessibleWrap.cpp index e379b371370e..4158da5d4863 100644 --- a/accessible/atk/AccessibleWrap.cpp +++ b/accessible/atk/AccessibleWrap.cpp @@ -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(MAI_ATK_SOCKET(aAtkObj)->accWrap); + if (accWrapPtr & IS_PROXY) return nullptr; - AccessibleWrap* accWrap = - reinterpret_cast(MAI_ATK_OBJECT(aAtkObj)->accWrap); + AccessibleWrap* accWrap = reinterpret_cast(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(MAI_ATK_OBJECT(aObj)->accWrap diff --git a/accessible/atk/AtkSocketAccessible.cpp b/accessible/atk/AtkSocketAccessible.cpp index 7c049b94ca3f..95c3075e8048 100644 --- a/accessible/atk/AtkSocketAccessible.cpp +++ b/accessible/atk/AtkSocketAccessible.cpp @@ -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); } } diff --git a/accessible/atk/InterfaceInitFuncs.h b/accessible/atk/InterfaceInitFuncs.h index 805001e8222d..4714018cc427 100644 --- a/accessible/atk/InterfaceInitFuncs.h +++ b/accessible/atk/InterfaceInitFuncs.h @@ -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); diff --git a/accessible/atk/nsMai.h b/accessible/atk/nsMai.h index aba96a4b38c7..4618524f7cf1 100644 --- a/accessible/atk/nsMai.h +++ b/accessible/atk/nsMai.h @@ -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); diff --git a/accessible/atk/nsMaiInterfaceComponent.cpp b/accessible/atk/nsMaiInterfaceComponent.cpp index 6a925e70ddb9..efd8eb65cd2b 100644 --- a/accessible/atk/nsMaiInterfaceComponent.cpp +++ b/accessible/atk/nsMaiInterfaceComponent.cpp @@ -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 diff --git a/accessible/ipc/DocAccessibleChild.cpp b/accessible/ipc/DocAccessibleChild.cpp index 98677f8085ae..0b1b010ef2f2 100644 --- a/accessible/ipc/DocAccessibleChild.cpp +++ b/accessible/ipc/DocAccessibleChild.cpp @@ -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(aWhich)); - if (child) { - *aChild = reinterpret_cast(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(aWhich)); + if (result) { + *aResult = reinterpret_cast(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; +} + } } diff --git a/accessible/ipc/DocAccessibleChild.h b/accessible/ipc/DocAccessibleChild.h index 736195355cb3..b85c354892b0 100644 --- a/accessible/ipc/DocAccessibleChild.h +++ b/accessible/ipc/DocAccessibleChild.h @@ -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; diff --git a/accessible/ipc/PDocAccessible.ipdl b/accessible/ipc/PDocAccessible.ipdl index 9120366a543c..8938aa28038a 100644 --- a/accessible/ipc/PDocAccessible.ipdl +++ b/accessible/ipc/PDocAccessible.ipdl @@ -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); }; } diff --git a/accessible/ipc/ProxyAccessible.cpp b/accessible/ipc/ProxyAccessible.cpp index 4171925cf1f0..8c7fd97a6031 100644 --- a/accessible/ipc/ProxyAccessible.cpp +++ b/accessible/ipc/ProxyAccessible.cpp @@ -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(aWhichChild), - &childID, &ok); + unused << mDoc->SendAccessibleAtPoint(mID, aX, aY, false, + static_cast(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(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 { diff --git a/accessible/ipc/ProxyAccessible.h b/accessible/ipc/ProxyAccessible.h index 4dc401360fe9..efd197417a6b 100644 --- a/accessible/ipc/ProxyAccessible.h +++ b/accessible/ipc/ProxyAccessible.h @@ -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. */ diff --git a/browser/base/content/browser-context.inc b/browser/base/content/browser-context.inc index cd7b2ede3ae7..e3e0df56c231 100644 --- a/browser/base/content/browser-context.inc +++ b/browser/base/content/browser-context.inc @@ -419,9 +419,14 @@ oncommand="gContextMenu.switchPageDirection();"/>