Bug 1187739 - (Part 1) Handle proxies in mozActionElements r=tbsaunde

This commit is contained in:
Lorien Hu 2015-08-04 14:56:18 -04:00
parent ab1d107b8f
commit 4ff6db9fc2
6 changed files with 62 additions and 9 deletions

View File

@ -144,6 +144,20 @@ DocAccessibleChild::RecvState(const uint64_t& aID, uint64_t* aState)
return true;
}
bool
DocAccessibleChild::RecvNativeState(const uint64_t& aID, uint64_t* aState)
{
Accessible* acc = IdToAccessible(aID);
if (!acc) {
*aState = states::DEFUNCT;
return true;
}
*aState = acc->NativeState();
return true;
}
bool
DocAccessibleChild::RecvName(const uint64_t& aID, nsString* aName)
{

View File

@ -63,6 +63,11 @@ public:
*/
virtual bool RecvState(const uint64_t& aID, uint64_t* aState) override;
/*
* Return the native state for the accessible with given ID.
*/
virtual bool RecvNativeState(const uint64_t& aID, uint64_t* aState) override;
/*
* Get the name for the accessible with given id.
*/

View File

@ -73,6 +73,7 @@ child:
// Accessible
prio(high) sync State(uint64_t aID) returns(uint64_t states);
prio(high) sync NativeState(uint64_t aID) returns(uint64_t states);
prio(high) sync Name(uint64_t aID) returns(nsString name);
prio(high) sync Value(uint64_t aID) returns(nsString value);
prio(high) sync Help(uint64_t aID) returns(nsString help);

View File

@ -83,6 +83,14 @@ ProxyAccessible::State() const
return state;
}
uint64_t
ProxyAccessible::NativeState() const
{
uint64_t state = 0;
unused << mDoc->SendNativeState(mID, &state);
return state;
}
void
ProxyAccessible::Name(nsString& aName) const
{

View File

@ -79,6 +79,11 @@ public:
*/
uint64_t State() const;
/*
* Return the native states for the proxied accessible.
*/
uint64_t NativeState() const;
/*
* Set aName to the name of the proxied accessible.
*/

View File

@ -141,21 +141,31 @@ enum CheckboxValue {
- (BOOL)isTab
{
AccessibleWrap* accWrap = [self getGeckoAccessible];
return (accWrap && (accWrap->Role() == roles::PAGETAB));
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
return accWrap->Role() == roles::PAGETAB;
if (ProxyAccessible* proxy = [self getProxyAccessible])
return proxy->Role() == roles::PAGETAB;
return false;
}
- (BOOL)hasPopup
{
AccessibleWrap* accWrap = [self getGeckoAccessible];
return accWrap && (accWrap->NativeState() & mozilla::a11y::states::HASPOPUP);
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
return accWrap->NativeState() & states::HASPOPUP;
if (ProxyAccessible* proxy = [self getProxyAccessible])
return proxy->NativeState() & states::HASPOPUP;
return false;
}
@end
@implementation mozCheckboxAccessible
- (NSString*)accessibilityActionDescription:(NSString*)action
- (NSString*)accessibilityActionDescription:(NSString*)action
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
@ -173,7 +183,11 @@ enum CheckboxValue {
- (int)isChecked
{
uint64_t state = [self getGeckoAccessible]->NativeState();
uint64_t state = 0;
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
state = accWrap->NativeState();
else if (ProxyAccessible* proxy = [self getProxyAccessible])
state = proxy->NativeState();
// check if we're checked or in a mixed state
if (state & states::CHECKED) {
@ -279,13 +293,19 @@ enum CheckboxValue {
- (NSUInteger)accessibilityArrayAttributeCount:(NSString*)attribute
{
if (![self getGeckoAccessible])
AccessibleWrap* accWrap = [self getGeckoAccessible];
ProxyAccessible* proxy = [self getProxyAccessible];
if (!accWrap && !proxy)
return 0;
// By default this calls -[[mozAccessible children] count].
// Since we don't cache mChildren. This is faster.
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
return [self getGeckoAccessible]->ChildCount() ? 1 : 0;
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
if (accWrap)
return accWrap->ChildCount() ? 1 : 0;
return proxy->ChildrenCount() ? 1 : 0;
}
return [super accessibilityArrayAttributeCount:attribute];
}