mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 21:31:04 +00:00
Bug 1616679: Map accessible actions to Mac actions based on action name. r=eeejay
Differential Revision: https://phabricator.services.mozilla.com/D67200 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
8df06c6842
commit
70cc6039b1
@ -483,7 +483,45 @@ static inline NSMutableArray* ConvertToNSArray(nsTArray<ProxyAccessible*>& aArra
|
||||
}
|
||||
|
||||
- (NSArray*)accessibilityActionNames {
|
||||
return @[ NSAccessibilityScrollToVisibleAction ];
|
||||
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
||||
ProxyAccessible* proxy = [self getProxyAccessible];
|
||||
// Create actions array
|
||||
NSMutableArray* actions = [NSMutableArray new];
|
||||
if (!accWrap && !proxy) return actions;
|
||||
|
||||
uint8_t count = 0;
|
||||
if (accWrap) {
|
||||
count = accWrap->ActionCount();
|
||||
} else if (proxy) {
|
||||
count = proxy->ActionCount();
|
||||
}
|
||||
|
||||
// Check if the accessible has an existing gecko
|
||||
// action, and add the corresponding Mac action to
|
||||
// the actions array. `count` is guaranteed to be 0 or 1
|
||||
if (count) {
|
||||
nsAutoString name;
|
||||
if (accWrap) {
|
||||
accWrap->ActionNameAt(0, name);
|
||||
} else if (proxy) {
|
||||
proxy->ActionNameAt(0, name);
|
||||
}
|
||||
if (name.EqualsLiteral("select")) {
|
||||
[actions addObject:NSAccessibilityPickAction];
|
||||
} else {
|
||||
[actions addObject:NSAccessibilityPressAction];
|
||||
}
|
||||
}
|
||||
|
||||
// Regardless of `count`, add actions that should be
|
||||
// performable on all accessibles. If we added a press
|
||||
// action, it will be first in the list. We append other
|
||||
// actions here to maintain that invariant.
|
||||
[actions addObject:NSAccessibilityScrollToVisibleAction];
|
||||
// XXX(morgan): we should implement `show menu` as
|
||||
// an "always performable" action. See bug 1623402.
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
- (NSString*)accessibilityActionDescription:(NSString*)action {
|
||||
@ -537,14 +575,21 @@ static inline NSMutableArray* ConvertToNSArray(nsTArray<ProxyAccessible*>& aArra
|
||||
}
|
||||
|
||||
- (void)accessibilityPerformAction:(NSString*)action {
|
||||
RefPtr<AccessibleWrap> accWrap = [self getGeckoAccessible];
|
||||
ProxyAccessible* proxy = [self getProxyAccessible];
|
||||
|
||||
if ([action isEqualToString:NSAccessibilityScrollToVisibleAction]) {
|
||||
RefPtr<AccessibleWrap> accWrap = [self getGeckoAccessible];
|
||||
ProxyAccessible* proxy = [self getProxyAccessible];
|
||||
if (accWrap) {
|
||||
accWrap->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
|
||||
} else if (proxy) {
|
||||
proxy->ScrollTo(nsIAccessibleScrollType::SCROLL_TYPE_ANYWHERE);
|
||||
}
|
||||
} else {
|
||||
if (accWrap) {
|
||||
accWrap->DoAction(0);
|
||||
} else if (proxy) {
|
||||
proxy->DoAction(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11,7 +11,6 @@
|
||||
@interface mozButtonAccessible : mozAccessible {
|
||||
}
|
||||
- (BOOL)hasPopup;
|
||||
- (void)click;
|
||||
@end
|
||||
|
||||
@interface mozCheckboxAccessible : mozButtonAccessible
|
||||
|
@ -70,65 +70,6 @@ enum CheckboxValue {
|
||||
return ![self getGeckoAccessible] && ![self getProxyAccessible];
|
||||
}
|
||||
|
||||
- (NSArray*)accessibilityActionNames {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
NSArray* actions = [super accessibilityActionNames];
|
||||
if ([self isEnabled]) {
|
||||
// VoiceOver expects the press action to be the first in the list.
|
||||
if ([self hasPopup]) {
|
||||
return [@[ NSAccessibilityPressAction, NSAccessibilityShowMenuAction ]
|
||||
arrayByAddingObjectsFromArray:actions];
|
||||
}
|
||||
return [@[ NSAccessibilityPressAction ] arrayByAddingObjectsFromArray:actions];
|
||||
}
|
||||
|
||||
return actions;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||
}
|
||||
|
||||
- (NSString*)accessibilityActionDescription:(NSString*)action {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
||||
|
||||
if ([action isEqualToString:NSAccessibilityPressAction]) {
|
||||
return @"press button"; // XXX: localize this later?
|
||||
}
|
||||
|
||||
if ([self hasPopup]) {
|
||||
if ([action isEqualToString:NSAccessibilityShowMenuAction]) return @"show menu";
|
||||
}
|
||||
|
||||
return nil;
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
||||
}
|
||||
|
||||
- (void)accessibilityPerformAction:(NSString*)action {
|
||||
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
||||
|
||||
if ([self isEnabled] && [action isEqualToString:NSAccessibilityPressAction]) {
|
||||
// TODO: this should bring up the menu, but currently doesn't.
|
||||
// once msaa and atk have merged better, they will implement
|
||||
// the action needed to show the menu.
|
||||
[self click];
|
||||
} else {
|
||||
[super accessibilityPerformAction:action];
|
||||
}
|
||||
|
||||
NS_OBJC_END_TRY_ABORT_BLOCK;
|
||||
}
|
||||
|
||||
- (void)click {
|
||||
// both buttons and checkboxes have only one action. we should really stop using arbitrary
|
||||
// arrays with actions, and define constants for these actions.
|
||||
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
||||
accWrap->DoAction(0);
|
||||
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
||||
proxy->DoAction(0);
|
||||
}
|
||||
}
|
||||
|
||||
- (BOOL)hasPopup {
|
||||
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
||||
return accWrap->NativeState() & states::HASPOPUP;
|
||||
|
@ -76,25 +76,6 @@
|
||||
arrayByAddingObjectsFromArray:[super accessibilityActionNames]];
|
||||
}
|
||||
|
||||
- (void)accessibilityPerformAction:(NSString*)action {
|
||||
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
||||
ProxyAccessible* proxy = [self getProxyAccessible];
|
||||
if (!accWrap && !proxy) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ([action isEqualToString:NSAccessibilityPressAction]) {
|
||||
if (accWrap) {
|
||||
accWrap->DoAction(0);
|
||||
} else if (proxy) {
|
||||
proxy->DoAction(0);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
[super accessibilityPerformAction:action];
|
||||
}
|
||||
|
||||
- (NSString*)customDescription {
|
||||
return @"";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user