bug 1250882 - make xpcAccessible::GetAttributes() work with proxied accessibles r=davidb

This commit is contained in:
Trevor Saunders 2016-02-11 16:12:02 -05:00
parent 8d8ca6ac5e
commit 8a22dbafd4

View File

@ -5,6 +5,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/. */ * You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "Accessible-inl.h" #include "Accessible-inl.h"
#include "mozilla/a11y/DocAccessibleParent.h"
#include "nsAccUtils.h" #include "nsAccUtils.h"
#include "nsIAccessibleRelation.h" #include "nsIAccessibleRelation.h"
#include "nsIAccessibleRole.h" #include "nsIAccessibleRole.h"
@ -342,12 +343,29 @@ xpcAccessible::GetAttributes(nsIPersistentProperties** aAttributes)
NS_ENSURE_ARG_POINTER(aAttributes); NS_ENSURE_ARG_POINTER(aAttributes);
*aAttributes = nullptr; *aAttributes = nullptr;
if (!Intl()) if (IntlGeneric().IsNull()) {
return NS_ERROR_FAILURE; return NS_ERROR_FAILURE;
}
nsCOMPtr<nsIPersistentProperties> attributes = Intl()->Attributes(); if (Accessible* acc = Intl()) {
attributes.swap(*aAttributes); nsCOMPtr<nsIPersistentProperties> attributes = acc->Attributes();
attributes.swap(*aAttributes);
return NS_OK;
}
ProxyAccessible* proxy = IntlGeneric().AsProxy();
AutoTArray<Attribute, 10> attrs;
proxy->Attributes(&attrs);
nsCOMPtr<nsIPersistentProperties> 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; return NS_OK;
} }