Bug 1376303 - Expose aria-orientation via NSAccessibilityOrientationAttribute. r=MarcoZ

Add orientation() method to the macOS accessibility wrapper, mapping
states::Horizontal to NSAccessibilityHorizontalOrientationValue,
states::NSAccessibilityVerticalOrientationValue and the absence of
both to NSAccessibilityUnknownOrientationValue.
This commit is contained in:
Joanmarie Diggs 2017-06-27 05:26:00 -04:00
Родитель cb111ebec5
Коммит 68f6fdc9bf
2 изменённых файлов: 28 добавлений и 0 удалений

Просмотреть файл

@ -114,6 +114,9 @@ static const uintptr_t IS_PROXY = 1;
// the accessible description (help text) of this particular instance.
- (NSString*)help;
// returns the orientation (vertical, horizontal, or undefined)
- (NSString*)orientation;
- (BOOL)isEnabled;
// information about focus.

Просмотреть файл

@ -323,6 +323,9 @@ ConvertToNSArray(nsTArray<ProxyAccessible*>& aArray)
}
if ([attribute isEqualToString:NSAccessibilityHelpAttribute])
return [self help];
if ([attribute isEqualToString:NSAccessibilityOrientationAttribute])
return [self orientation];
if ([attribute isEqualToString:NSAccessibilityDOMIdentifierAttribute]) {
nsAutoString id;
if (accWrap)
@ -1067,6 +1070,28 @@ struct RoleDescrComparator
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
- (NSString*)orientation
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
uint64_t state;
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
state = accWrap->InteractiveState();
else if (ProxyAccessible* proxy = [self getProxyAccessible])
state = proxy->State();
else
state = 0;
if (state & states::HORIZONTAL)
return NSAccessibilityHorizontalOrientationValue;
if (state & states::VERTICAL)
return NSAccessibilityVerticalOrientationValue;
return NSAccessibilityUnknownOrientationValue;
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
}
// objc-style description (from NSObject); not to be confused with the accessible description above.
- (NSString*)description
{