From 8a22dbafd4c91ae24f020cfdabb6f3e8b240a7ac Mon Sep 17 00:00:00 2001 From: Trevor Saunders Date: Thu, 11 Feb 2016 16:12:02 -0500 Subject: [PATCH] bug 1250882 - make xpcAccessible::GetAttributes() work with proxied accessibles r=davidb --- accessible/xpcom/xpcAccessible.cpp | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/accessible/xpcom/xpcAccessible.cpp b/accessible/xpcom/xpcAccessible.cpp index a671e00c4ae..35f969f1ffd 100644 --- a/accessible/xpcom/xpcAccessible.cpp +++ b/accessible/xpcom/xpcAccessible.cpp @@ -5,6 +5,7 @@ * You can obtain one at http://mozilla.org/MPL/2.0/. */ #include "Accessible-inl.h" +#include "mozilla/a11y/DocAccessibleParent.h" #include "nsAccUtils.h" #include "nsIAccessibleRelation.h" #include "nsIAccessibleRole.h" @@ -342,12 +343,29 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes) NS_ENSURE_ARG_POINTER(aAttributes); *aAttributes = nullptr; - if (!Intl()) + if (IntlGeneric().IsNull()) { return NS_ERROR_FAILURE; + } - nsCOMPtr attributes = Intl()->Attributes(); - attributes.swap(*aAttributes); + if (Accessible* acc = Intl()) { + nsCOMPtr attributes = acc->Attributes(); + attributes.swap(*aAttributes); + return NS_OK; + } + ProxyAccessible* proxy = IntlGeneric().AsProxy(); + AutoTArray attrs; + proxy->Attributes(&attrs); + + nsCOMPtr props = + do_CreateInstance(NS_PERSISTENTPROPERTIES_CONTRACTID); + uint32_t attrCount = attrs.Length(); + nsAutoString unused; + for (uint32_t i = 0; i < attrCount; i++) { + props->SetStringProperty(attrs[i].Name(), attrs[i].Value(), unused); + } + + props.forget(aAttributes); return NS_OK; }