diff --git a/accessible/atk/nsMaiInterfaceDocument.cpp b/accessible/atk/nsMaiInterfaceDocument.cpp index 6ce1e8ff4cca..7f4d3e1ff055 100644 --- a/accessible/atk/nsMaiInterfaceDocument.cpp +++ b/accessible/atk/nsMaiInterfaceDocument.cpp @@ -10,6 +10,7 @@ #include "AccessibleWrap.h" #include "DocAccessible.h" #include "nsMai.h" +#include "ProxyAccessible.h" #include "mozilla/Likely.h" using namespace mozilla::a11y; @@ -46,12 +47,14 @@ documentInterfaceInitCB(AtkDocumentIface *aIface) const gchar * getDocumentLocaleCB(AtkDocument *aDocument) { - AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument)); - if (!accWrap) - return nullptr; - nsAutoString locale; - accWrap->Language(locale); + AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument)); + if (accWrap) { + accWrap->Language(locale); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aDocument))) { + proxy->Language(locale); + } + return locale.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(locale); } @@ -71,24 +74,30 @@ prependToList(GSList *aList, const char *const aName, const nsAutoString &aValue AtkAttributeSet * getDocumentAttributesCB(AtkDocument *aDocument) { + nsAutoString url; + nsAutoString w3cDocType; + nsAutoString mimeType; AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument)); - if (!accWrap || !accWrap->IsDoc()) + if (accWrap) { + if (!accWrap->IsDoc()) { + return nullptr; + } + + DocAccessible* document = accWrap->AsDoc(); + document->URL(url); + document->DocType(w3cDocType); + document->MimeType(mimeType); + } else if (ProxyAccessible* proxy = GetProxy(ATK_OBJECT(aDocument))) { + proxy->URLDocTypeMimeType(url, w3cDocType, mimeType); + } else { return nullptr; + } // according to atkobject.h, AtkAttributeSet is a GSList GSList* attributes = nullptr; - DocAccessible* document = accWrap->AsDoc(); - nsAutoString aURL; - document->URL(aURL); - attributes = prependToList(attributes, kDocUrlName, aURL); - - nsAutoString aW3CDocType; - document->DocType(aW3CDocType); - attributes = prependToList(attributes, kDocTypeName, aW3CDocType); - - nsAutoString aMimeType; - document->MimeType(aMimeType); - attributes = prependToList(attributes, kMimeTypeName, aMimeType); + attributes = prependToList(attributes, kDocUrlName, url); + attributes = prependToList(attributes, kDocTypeName, w3cDocType); + attributes = prependToList(attributes, kMimeTypeName, mimeType); return attributes; } @@ -97,20 +106,44 @@ const gchar * getDocumentAttributeValueCB(AtkDocument *aDocument, const gchar *aAttrName) { + ProxyAccessible* proxy = nullptr; + DocAccessible* document = nullptr; AccessibleWrap* accWrap = GetAccessibleWrap(ATK_OBJECT(aDocument)); - if (!accWrap || !accWrap->IsDoc()) - return nullptr; + if (accWrap) { + if (!accWrap->IsDoc()) { + return nullptr; + } + + document = accWrap->AsDoc(); + } else { + proxy = GetProxy(ATK_OBJECT(aDocument)); + if (!proxy) { + return nullptr; + } + } - DocAccessible* document = accWrap->AsDoc(); nsAutoString attrValue; - if (!strcasecmp(aAttrName, kDocTypeName)) - document->DocType(attrValue); - else if (!strcasecmp(aAttrName, kDocUrlName)) - document->URL(attrValue); - else if (!strcasecmp(aAttrName, kMimeTypeName)) - document->MimeType(attrValue); - else + if (!strcasecmp(aAttrName, kDocTypeName)) { + if (document) { + document->DocType(attrValue); + } else { + proxy->DocType(attrValue); + } + } else if (!strcasecmp(aAttrName, kDocUrlName)) { + if (document) { + document->URL(attrValue); + } else { + proxy->URL(attrValue); + } + } else if (!strcasecmp(aAttrName, kMimeTypeName)) { + if (document) { + document->MimeType(attrValue); + } else { + proxy->MimeType(attrValue); + } + } else { return nullptr; + } return attrValue.IsEmpty() ? nullptr : AccessibleWrap::ReturnString(attrValue); } diff --git a/accessible/ipc/DocAccessibleChild.cpp b/accessible/ipc/DocAccessibleChild.cpp index b25ff6af37ea..61c76d8555cc 100644 --- a/accessible/ipc/DocAccessibleChild.cpp +++ b/accessible/ipc/DocAccessibleChild.cpp @@ -1631,5 +1631,70 @@ DocAccessibleChild::RecvBounds(const uint64_t& aID, return false; } +bool +DocAccessibleChild::RecvLanguage(const uint64_t& aID, + nsString* aLocale) +{ + Accessible* acc = IdToAccessible(aID); + if (acc) { + acc->Language(*aLocale); + } + + return true; +} + +bool +DocAccessibleChild::RecvDocType(const uint64_t& aID, + nsString* aType) +{ + Accessible* acc = IdToAccessible(aID); + if (acc && acc->IsDoc()) { + acc->AsDoc()->DocType(*aType); + } + + return true; +} + +bool +DocAccessibleChild::RecvURL(const uint64_t& aID, + nsString* aURL) +{ + Accessible* acc = IdToAccessible(aID); + if (acc && acc->IsDoc()) { + acc->AsDoc()->URL(*aURL); + } + + return true; +} + +bool +DocAccessibleChild::RecvMimeType(const uint64_t& aID, + nsString* aMime) +{ + Accessible* acc = IdToAccessible(aID); + if (acc && acc->IsDoc()) { + acc->AsDoc()->MimeType(*aMime); + } + + return true; +} + +bool +DocAccessibleChild::RecvURLDocTypeMimeType(const uint64_t& aID, + nsString* aURL, + nsString* aDocType, + nsString* aMimeType) +{ + Accessible* acc = IdToAccessible(aID); + if (acc && acc->IsDoc()) { + DocAccessible* doc = acc->AsDoc(); + doc->URL(*aURL); + doc->DocType(*aDocType); + doc->MimeType(*aMimeType); + } + + return true; +} + } } diff --git a/accessible/ipc/DocAccessibleChild.h b/accessible/ipc/DocAccessibleChild.h index 19ddb6fbb927..41123f2c39f4 100644 --- a/accessible/ipc/DocAccessibleChild.h +++ b/accessible/ipc/DocAccessibleChild.h @@ -401,6 +401,15 @@ public: 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 RecvURL(const uint64_t& aID, nsString* aURL) override; + virtual bool RecvMimeType(const uint64_t& aID, nsString* aMime) override; + virtual bool RecvURLDocTypeMimeType(const uint64_t& aID, + nsString* aURL, + nsString* aDocType, + nsString* aMimeType) override; private: Accessible* IdToAccessible(const uint64_t& aID) const; diff --git a/accessible/ipc/PDocAccessible.ipdl b/accessible/ipc/PDocAccessible.ipdl index 786a2a60302b..3d9fa3a63053 100644 --- a/accessible/ipc/PDocAccessible.ipdl +++ b/accessible/ipc/PDocAccessible.ipdl @@ -209,6 +209,12 @@ child: 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); + 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); }; } diff --git a/accessible/ipc/ProxyAccessible.cpp b/accessible/ipc/ProxyAccessible.cpp index 03df82cfa7f1..f2bf27df2857 100644 --- a/accessible/ipc/ProxyAccessible.cpp +++ b/accessible/ipc/ProxyAccessible.cpp @@ -911,5 +911,36 @@ ProxyAccessible::Bounds() return rect; } +void +ProxyAccessible::Language(nsString& aLocale) +{ + unused << mDoc->SendLanguage(mID, &aLocale); +} + +void +ProxyAccessible::DocType(nsString& aType) +{ + unused << mDoc->SendDocType(mID, &aType); +} + +void +ProxyAccessible::URL(nsString& aURL) +{ + unused << mDoc->SendURL(mID, &aURL); +} + +void +ProxyAccessible::MimeType(nsString aMime) +{ + unused << mDoc->SendMimeType(mID, &aMime); +} + +void +ProxyAccessible::URLDocTypeMimeType(nsString& aURL, nsString& aDocType, + nsString& aMimeType) +{ + unused << mDoc->SendURLDocTypeMimeType(mID, &aURL, &aDocType, &aMimeType); +} + } } diff --git a/accessible/ipc/ProxyAccessible.h b/accessible/ipc/ProxyAccessible.h index efe422aaae80..164a301c34a7 100644 --- a/accessible/ipc/ProxyAccessible.h +++ b/accessible/ipc/ProxyAccessible.h @@ -276,6 +276,13 @@ public: Accessible::EWhichChildAtPoint aWhichChild); nsIntRect Bounds(); + void Language(nsString& aLocale); + void DocType(nsString& aType); + void URL(nsString& aURL); + void MimeType(nsString aMime); + void URLDocTypeMimeType(nsString& aURL, nsString& aDocType, + nsString& aMimeType); + /** * Allow the platform to store a pointers worth of data on us. */