2006-09-11 19:44:00 +04:00
|
|
|
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
#import "mozAccessible.h"
|
|
|
|
|
2012-01-27 10:14:09 +04:00
|
|
|
#import "MacUtils.h"
|
2006-09-11 19:44:00 +04:00
|
|
|
#import "mozView.h"
|
|
|
|
|
2012-04-13 18:17:03 +04:00
|
|
|
#include "Accessible-inl.h"
|
2012-06-30 01:12:18 +04:00
|
|
|
#include "nsAccUtils.h"
|
2011-12-09 01:19:29 +04:00
|
|
|
#include "nsIAccessibleRelation.h"
|
2006-11-15 14:08:14 +03:00
|
|
|
#include "nsIAccessibleEditableText.h"
|
2013-09-11 02:18:59 +04:00
|
|
|
#include "nsIPersistentProperties2.h"
|
2011-12-09 01:19:29 +04:00
|
|
|
#include "Relation.h"
|
2012-01-12 07:07:35 +04:00
|
|
|
#include "Role.h"
|
2012-05-04 10:09:22 +04:00
|
|
|
#include "RootAccessible.h"
|
2015-06-25 22:51:00 +03:00
|
|
|
#include "TableAccessible.h"
|
|
|
|
#include "TableCellAccessible.h"
|
2015-07-17 00:34:52 +03:00
|
|
|
#include "mozilla/a11y/PDocAccessible.h"
|
2016-06-10 00:33:48 +03:00
|
|
|
#include "OuterDocAccessible.h"
|
2006-09-11 19:44:00 +04:00
|
|
|
|
2012-01-07 03:21:17 +04:00
|
|
|
#include "mozilla/Services.h"
|
2012-04-13 18:17:03 +04:00
|
|
|
#include "nsRect.h"
|
|
|
|
#include "nsCocoaUtils.h"
|
|
|
|
#include "nsCoord.h"
|
|
|
|
#include "nsObjCExceptions.h"
|
2012-06-30 01:12:18 +04:00
|
|
|
#include "nsWhitespaceTokenizer.h"
|
2015-07-02 07:01:00 +03:00
|
|
|
#include <prdtoa.h>
|
2012-01-07 03:21:17 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
2011-07-27 16:43:01 +04:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2015-06-23 19:17:00 +03:00
|
|
|
#define NSAccessibilityMathRootRadicandAttribute @"AXMathRootRadicand"
|
|
|
|
#define NSAccessibilityMathRootIndexAttribute @"AXMathRootIndex"
|
|
|
|
#define NSAccessibilityMathFractionNumeratorAttribute @"AXMathFractionNumerator"
|
|
|
|
#define NSAccessibilityMathFractionDenominatorAttribute @"AXMathFractionDenominator"
|
|
|
|
#define NSAccessibilityMathBaseAttribute @"AXMathBase"
|
|
|
|
#define NSAccessibilityMathSubscriptAttribute @"AXMathSubscript"
|
|
|
|
#define NSAccessibilityMathSuperscriptAttribute @"AXMathSuperscript"
|
|
|
|
#define NSAccessibilityMathUnderAttribute @"AXMathUnder"
|
|
|
|
#define NSAccessibilityMathOverAttribute @"AXMathOver"
|
2015-07-02 07:01:00 +03:00
|
|
|
#define NSAccessibilityMathLineThicknessAttribute @"AXMathLineThickness"
|
2015-06-23 19:17:00 +03:00
|
|
|
// XXX WebKit also defines the following attributes.
|
2015-07-02 07:01:00 +03:00
|
|
|
// See bugs 1176970 and 1176983.
|
2015-06-23 19:17:00 +03:00
|
|
|
// - NSAccessibilityMathFencedOpenAttribute @"AXMathFencedOpen"
|
|
|
|
// - NSAccessibilityMathFencedCloseAttribute @"AXMathFencedClose"
|
|
|
|
// - NSAccessibilityMathPrescriptsAttribute @"AXMathPrescripts"
|
|
|
|
// - NSAccessibilityMathPostscriptsAttribute @"AXMathPostscripts"
|
|
|
|
|
2015-06-25 22:51:00 +03:00
|
|
|
// convert an array of Gecko accessibles to an NSArray of native accessibles
|
|
|
|
static inline NSMutableArray*
|
|
|
|
ConvertToNSArray(nsTArray<Accessible*>& aArray)
|
|
|
|
{
|
|
|
|
NSMutableArray* nativeArray = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
// iterate through the list, and get each native accessible.
|
2015-07-15 07:51:23 +03:00
|
|
|
size_t totalCount = aArray.Length();
|
|
|
|
for (size_t i = 0; i < totalCount; i++) {
|
2015-06-25 22:51:00 +03:00
|
|
|
Accessible* curAccessible = aArray.ElementAt(i);
|
|
|
|
mozAccessible* curNative = GetNativeFromGeckoAccessible(curAccessible);
|
|
|
|
if (curNative)
|
|
|
|
[nativeArray addObject:GetObjectOrRepresentedView(curNative)];
|
|
|
|
}
|
|
|
|
|
|
|
|
return nativeArray;
|
|
|
|
}
|
|
|
|
|
2015-07-15 07:51:23 +03:00
|
|
|
// convert an array of Gecko proxy accessibles to an NSArray of native accessibles
|
|
|
|
static inline NSMutableArray*
|
|
|
|
ConvertToNSArray(nsTArray<ProxyAccessible*>& aArray)
|
|
|
|
{
|
|
|
|
NSMutableArray* nativeArray = [[NSMutableArray alloc] init];
|
|
|
|
|
|
|
|
// iterate through the list, and get each native accessible.
|
|
|
|
size_t totalCount = aArray.Length();
|
|
|
|
for (size_t i = 0; i < totalCount; i++) {
|
|
|
|
ProxyAccessible* curAccessible = aArray.ElementAt(i);
|
|
|
|
mozAccessible* curNative = GetNativeFromProxy(curAccessible);
|
|
|
|
if (curNative)
|
|
|
|
[nativeArray addObject:GetObjectOrRepresentedView(curNative)];
|
|
|
|
}
|
|
|
|
|
|
|
|
return nativeArray;
|
|
|
|
}
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
#pragma mark -
|
2012-01-07 03:21:17 +04:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
@implementation mozAccessible
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2015-05-29 20:42:23 +03:00
|
|
|
- (id)initWithAccessible:(uintptr_t)aGeckoAccessible
|
2006-09-11 19:44:00 +04:00
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
if ((self = [super init])) {
|
2015-05-29 20:42:23 +03:00
|
|
|
mGeckoAccessible = aGeckoAccessible;
|
|
|
|
if (aGeckoAccessible & IS_PROXY)
|
|
|
|
mRole = [self getProxyAccessible]->Role();
|
|
|
|
else
|
|
|
|
mRole = [self getGeckoAccessible]->Role();
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
2015-05-29 20:42:23 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
return self;
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)dealloc
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-09-11 20:22:22 +04:00
|
|
|
[mChildren release];
|
2006-09-11 19:44:00 +04:00
|
|
|
[super dealloc];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
2015-05-22 17:59:26 +03:00
|
|
|
|
|
|
|
- (mozilla::a11y::AccessibleWrap*)getGeckoAccessible
|
|
|
|
{
|
2015-05-22 18:04:47 +03:00
|
|
|
// Check if mGeckoAccessible points at a proxy
|
|
|
|
if (mGeckoAccessible & IS_PROXY)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
return reinterpret_cast<AccessibleWrap*>(mGeckoAccessible);
|
2015-05-22 17:59:26 +03:00
|
|
|
}
|
2015-05-29 20:42:23 +03:00
|
|
|
|
|
|
|
- (mozilla::a11y::ProxyAccessible*)getProxyAccessible
|
|
|
|
{
|
|
|
|
// Check if mGeckoAccessible points at a proxy
|
|
|
|
if (!(mGeckoAccessible & IS_PROXY))
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
return reinterpret_cast<ProxyAccessible*>(mGeckoAccessible & ~IS_PROXY);
|
|
|
|
}
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
- (BOOL)accessibilityIsIgnored
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
|
|
|
|
2006-09-27 16:56:28 +04:00
|
|
|
// unknown (either unimplemented, or irrelevant) elements are marked as ignored
|
|
|
|
// as well as expired elements.
|
2015-05-22 17:59:26 +03:00
|
|
|
|
2015-07-17 00:34:51 +03:00
|
|
|
bool noRole = [[self role] isEqualToString:NSAccessibilityUnknownRole];
|
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
|
|
|
return (noRole && !(accWrap->InteractiveState() & states::FOCUSABLE));
|
|
|
|
|
|
|
|
if (ProxyAccessible* proxy = [self getProxyAccessible])
|
|
|
|
return (noRole && !(proxy->State() & states::FOCUSABLE));
|
|
|
|
|
|
|
|
return true;
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2015-06-23 19:17:00 +03:00
|
|
|
- (NSArray*)additionalAccessibilityAttributeNames
|
|
|
|
{
|
|
|
|
NSMutableArray* additional = [NSMutableArray array];
|
|
|
|
switch (mRole) {
|
|
|
|
case roles::MATHML_ROOT:
|
|
|
|
[additional addObject:NSAccessibilityMathRootIndexAttribute];
|
|
|
|
[additional addObject:NSAccessibilityMathRootRadicandAttribute];
|
|
|
|
break;
|
|
|
|
case roles::MATHML_SQUARE_ROOT:
|
|
|
|
[additional addObject:NSAccessibilityMathRootRadicandAttribute];
|
|
|
|
break;
|
|
|
|
case roles::MATHML_FRACTION:
|
|
|
|
[additional addObject:NSAccessibilityMathFractionNumeratorAttribute];
|
|
|
|
[additional addObject:NSAccessibilityMathFractionDenominatorAttribute];
|
2015-07-02 07:01:00 +03:00
|
|
|
[additional addObject:NSAccessibilityMathLineThicknessAttribute];
|
2015-06-23 19:17:00 +03:00
|
|
|
break;
|
|
|
|
case roles::MATHML_SUB:
|
|
|
|
case roles::MATHML_SUP:
|
|
|
|
case roles::MATHML_SUB_SUP:
|
|
|
|
[additional addObject:NSAccessibilityMathBaseAttribute];
|
|
|
|
[additional addObject:NSAccessibilityMathSubscriptAttribute];
|
|
|
|
[additional addObject:NSAccessibilityMathSuperscriptAttribute];
|
|
|
|
break;
|
|
|
|
case roles::MATHML_UNDER:
|
|
|
|
case roles::MATHML_OVER:
|
|
|
|
case roles::MATHML_UNDER_OVER:
|
|
|
|
[additional addObject:NSAccessibilityMathBaseAttribute];
|
|
|
|
[additional addObject:NSAccessibilityMathUnderAttribute];
|
|
|
|
[additional addObject:NSAccessibilityMathOverAttribute];
|
|
|
|
break;
|
|
|
|
// XXX bug 1176983
|
|
|
|
// roles::MATHML_MULTISCRIPTS should also have the following attributes:
|
|
|
|
// - NSAccessibilityMathPrescriptsAttribute
|
|
|
|
// - NSAccessibilityMathPostscriptsAttribute
|
|
|
|
// XXX bug 1176970
|
|
|
|
// roles::MATHML_FENCED should also have the following attributes:
|
|
|
|
// - NSAccessibilityMathFencedOpenAttribute
|
|
|
|
// - NSAccessibilityMathFencedCloseAttribute
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return additional;
|
|
|
|
}
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
- (NSArray*)accessibilityAttributeNames
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
// if we're expired, we don't support any attributes.
|
2015-06-25 22:51:00 +03:00
|
|
|
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
2015-07-17 00:34:52 +03:00
|
|
|
ProxyAccessible* proxy = [self getProxyAccessible];
|
|
|
|
if (!accWrap && !proxy)
|
2006-09-11 19:44:00 +04:00
|
|
|
return [NSArray array];
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2015-06-25 22:51:00 +03:00
|
|
|
static NSArray* generalAttributes = nil;
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
if (!generalAttributes) {
|
2006-09-11 19:44:00 +04:00
|
|
|
// standard attributes that are shared and supported by all generic elements.
|
2015-06-08 17:59:19 +03:00
|
|
|
generalAttributes = [[NSArray alloc] initWithObjects: NSAccessibilityChildrenAttribute,
|
2006-09-11 19:44:00 +04:00
|
|
|
NSAccessibilityParentAttribute,
|
|
|
|
NSAccessibilityRoleAttribute,
|
|
|
|
NSAccessibilityTitleAttribute,
|
|
|
|
NSAccessibilityValueAttribute,
|
|
|
|
NSAccessibilitySubroleAttribute,
|
|
|
|
NSAccessibilityRoleDescriptionAttribute,
|
|
|
|
NSAccessibilityPositionAttribute,
|
2006-11-15 14:08:14 +03:00
|
|
|
NSAccessibilityEnabledAttribute,
|
2006-09-11 19:44:00 +04:00
|
|
|
NSAccessibilitySizeAttribute,
|
|
|
|
NSAccessibilityWindowAttribute,
|
|
|
|
NSAccessibilityFocusedAttribute,
|
2006-11-15 14:08:14 +03:00
|
|
|
NSAccessibilityHelpAttribute,
|
|
|
|
NSAccessibilityTitleUIElementAttribute,
|
2011-12-09 11:25:25 +04:00
|
|
|
NSAccessibilityTopLevelUIElementAttribute,
|
2012-01-27 10:14:09 +04:00
|
|
|
#if DEBUG
|
|
|
|
@"AXMozDescription",
|
|
|
|
#endif
|
2006-09-11 19:44:00 +04:00
|
|
|
nil];
|
|
|
|
}
|
|
|
|
|
2015-06-23 19:17:00 +03:00
|
|
|
NSArray* objectAttributes = generalAttributes;
|
2015-06-25 22:51:00 +03:00
|
|
|
|
2015-06-23 19:17:00 +03:00
|
|
|
NSArray* additionalAttributes = [self additionalAccessibilityAttributeNames];
|
|
|
|
if ([additionalAttributes count])
|
|
|
|
objectAttributes = [objectAttributes arrayByAddingObjectsFromArray:additionalAttributes];
|
|
|
|
|
|
|
|
return objectAttributes;
|
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)childAt:(uint32_t)i
|
|
|
|
{
|
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2015-07-26 17:30:56 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
|
|
|
Accessible* child = accWrap->GetChildAt(i);
|
|
|
|
return child ? GetNativeFromGeckoAccessible(child) : nil;
|
|
|
|
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
|
|
|
ProxyAccessible* child = proxy->ChildAt(i);
|
|
|
|
return child ? GetNativeFromProxy(child) : nil;
|
2015-06-23 19:17:00 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return nil;
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id)accessibilityAttributeValue:(NSString*)attribute
|
2015-06-08 17:59:19 +03:00
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2015-06-25 22:51:00 +03:00
|
|
|
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
2015-07-17 00:34:52 +03:00
|
|
|
ProxyAccessible* proxy = [self getProxyAccessible];
|
|
|
|
if (!accWrap && !proxy)
|
2006-09-11 19:44:00 +04:00
|
|
|
return nil;
|
2012-01-27 10:14:09 +04:00
|
|
|
|
|
|
|
#if DEBUG
|
|
|
|
if ([attribute isEqualToString:@"AXMozDescription"])
|
2012-01-27 19:50:04 +04:00
|
|
|
return [NSString stringWithFormat:@"role = %u native = %@", mRole, [self class]];
|
2012-01-27 10:14:09 +04:00
|
|
|
#endif
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityChildrenAttribute])
|
2006-12-18 16:57:37 +03:00
|
|
|
return [self children];
|
2015-06-08 17:59:19 +03:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityParentAttribute])
|
2006-11-15 14:08:14 +03:00
|
|
|
return [self parent];
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
#ifdef DEBUG_hakan
|
|
|
|
NSLog (@"(%@ responding to attr %@)", self, attribute);
|
|
|
|
#endif
|
2006-11-15 14:08:14 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityRoleAttribute])
|
|
|
|
return [self role];
|
2015-06-08 17:59:19 +03:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityPositionAttribute])
|
2006-11-15 14:08:14 +03:00
|
|
|
return [self position];
|
2006-09-11 19:44:00 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilitySubroleAttribute])
|
2006-11-15 14:08:14 +03:00
|
|
|
return [self subrole];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityEnabledAttribute])
|
|
|
|
return [NSNumber numberWithBool:[self isEnabled]];
|
2006-09-11 19:44:00 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityValueAttribute])
|
|
|
|
return [self value];
|
2015-06-08 17:59:19 +03:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityRoleDescriptionAttribute])
|
|
|
|
return [self roleDescription];
|
2006-09-11 19:44:00 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityFocusedAttribute])
|
|
|
|
return [NSNumber numberWithBool:[self isFocused]];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilitySizeAttribute])
|
|
|
|
return [self size];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityWindowAttribute])
|
|
|
|
return [self window];
|
2011-12-09 11:25:25 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityTopLevelUIElementAttribute])
|
2006-09-11 19:44:00 +04:00
|
|
|
return [self window];
|
2011-12-09 01:19:29 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityTitleAttribute])
|
2006-09-11 19:44:00 +04:00
|
|
|
return [self title];
|
2011-12-09 01:19:29 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityTitleUIElementAttribute]) {
|
2015-07-17 00:34:52 +03:00
|
|
|
if (accWrap) {
|
|
|
|
Relation rel = accWrap->RelationByType(RelationType::LABELLED_BY);
|
|
|
|
Accessible* tempAcc = rel.Next();
|
|
|
|
return tempAcc ? GetNativeFromGeckoAccessible(tempAcc) : nil;
|
|
|
|
}
|
|
|
|
nsTArray<ProxyAccessible*> rel = proxy->RelationByType(RelationType::LABELLED_BY);
|
|
|
|
ProxyAccessible* tempProxy = rel.SafeElementAt(0);
|
|
|
|
return tempProxy ? GetNativeFromProxy(tempProxy) : nil;
|
2011-12-09 01:19:29 +04:00
|
|
|
}
|
2006-11-15 14:08:14 +03:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityHelpAttribute])
|
|
|
|
return [self help];
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2015-06-23 19:17:00 +03:00
|
|
|
switch (mRole) {
|
|
|
|
case roles::MATHML_ROOT:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathRootRadicandAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathRootIndexAttribute])
|
|
|
|
return [self childAt:1];
|
|
|
|
break;
|
|
|
|
case roles::MATHML_SQUARE_ROOT:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathRootRadicandAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
break;
|
|
|
|
case roles::MATHML_FRACTION:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathFractionNumeratorAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathFractionDenominatorAttribute])
|
|
|
|
return [self childAt:1];
|
2015-07-02 07:01:00 +03:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathLineThicknessAttribute]) {
|
|
|
|
// WebKit sets line thickness to some logical value parsed in the
|
|
|
|
// renderer object of the <mfrac> element. It's not clear whether the
|
|
|
|
// exact value is relevant to assistive technologies. From a semantic
|
|
|
|
// point of view, the only important point is to distinguish between
|
|
|
|
// <mfrac> elements that have a fraction bar and those that do not.
|
|
|
|
// Per the MathML 3 spec, the latter happens iff the linethickness
|
|
|
|
// attribute is of the form [zero-float][optional-unit]. In that case we
|
|
|
|
// set line thickness to zero and in the other cases we set it to one.
|
|
|
|
nsAutoString thickness;
|
2015-07-17 00:34:52 +03:00
|
|
|
if (accWrap) {
|
|
|
|
nsCOMPtr<nsIPersistentProperties> attributes = accWrap->Attributes();
|
|
|
|
nsAccUtils::GetAccAttr(attributes, nsGkAtoms::linethickness_, thickness);
|
|
|
|
} else {
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<Attribute, 10> attrs;
|
2015-07-17 00:34:52 +03:00
|
|
|
proxy->Attributes(&attrs);
|
|
|
|
for (size_t i = 0 ; i < attrs.Length() ; i++) {
|
|
|
|
if (attrs.ElementAt(i).Name() == "thickness") {
|
|
|
|
thickness = attrs.ElementAt(i).Value();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-07-02 07:01:00 +03:00
|
|
|
double value = 1.0;
|
|
|
|
if (!thickness.IsEmpty())
|
|
|
|
value = PR_strtod(NS_LossyConvertUTF16toASCII(thickness).get(),
|
|
|
|
nullptr);
|
|
|
|
return [NSNumber numberWithInteger:(value ? 1 : 0)];
|
|
|
|
}
|
2015-06-23 19:17:00 +03:00
|
|
|
break;
|
|
|
|
case roles::MATHML_SUB:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathBaseAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathSubscriptAttribute])
|
|
|
|
return [self childAt:1];
|
|
|
|
#ifdef DEBUG
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathSuperscriptAttribute])
|
|
|
|
return nil;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case roles::MATHML_SUP:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathBaseAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
#ifdef DEBUG
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathSubscriptAttribute])
|
|
|
|
return nil;
|
|
|
|
#endif
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathSuperscriptAttribute])
|
|
|
|
return [self childAt:1];
|
|
|
|
break;
|
|
|
|
case roles::MATHML_SUB_SUP:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathBaseAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathSubscriptAttribute])
|
|
|
|
return [self childAt:1];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathSuperscriptAttribute])
|
|
|
|
return [self childAt:2];
|
|
|
|
break;
|
|
|
|
case roles::MATHML_UNDER:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathBaseAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathUnderAttribute])
|
|
|
|
return [self childAt:1];
|
|
|
|
#ifdef DEBUG
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathOverAttribute])
|
|
|
|
return nil;
|
|
|
|
#endif
|
|
|
|
break;
|
|
|
|
case roles::MATHML_OVER:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathBaseAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
#ifdef DEBUG
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathUnderAttribute])
|
|
|
|
return nil;
|
|
|
|
#endif
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathOverAttribute])
|
|
|
|
return [self childAt:1];
|
|
|
|
break;
|
|
|
|
case roles::MATHML_UNDER_OVER:
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathBaseAttribute])
|
|
|
|
return [self childAt:0];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathUnderAttribute])
|
|
|
|
return [self childAt:1];
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityMathOverAttribute])
|
|
|
|
return [self childAt:2];
|
|
|
|
break;
|
|
|
|
// XXX bug 1176983
|
|
|
|
// roles::MATHML_MULTISCRIPTS should also have the following attributes:
|
|
|
|
// - NSAccessibilityMathPrescriptsAttribute
|
|
|
|
// - NSAccessibilityMathPostscriptsAttribute
|
|
|
|
// XXX bug 1176970
|
|
|
|
// roles::MATHML_FENCED should also have the following attributes:
|
|
|
|
// - NSAccessibilityMathFencedOpenAttribute
|
|
|
|
// - NSAccessibilityMathFencedCloseAttribute
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
#ifdef DEBUG
|
|
|
|
NSLog (@"!!! %@ can't respond to attribute %@", self, attribute);
|
|
|
|
#endif
|
2011-12-09 01:19:29 +04:00
|
|
|
return nil;
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)accessibilityIsAttributeSettable:(NSString*)attribute
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
if ([attribute isEqualToString:NSAccessibilityFocusedAttribute])
|
|
|
|
return [self canBeFocused];
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
return NO;
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(NO);
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)accessibilitySetValue:(id)value forAttribute:(NSString*)attribute
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
#ifdef DEBUG_hakan
|
|
|
|
NSLog (@"[%@] %@='%@'", self, attribute, value);
|
|
|
|
#endif
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
// we only support focusing elements so far.
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityFocusedAttribute] && [value boolValue])
|
|
|
|
[self focus];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (id)accessibilityHitTest:(NSPoint)point
|
|
|
|
{
|
2015-05-22 17:59:26 +03:00
|
|
|
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
2015-07-17 00:34:52 +03:00
|
|
|
ProxyAccessible* proxy = [self getProxyAccessible];
|
|
|
|
if (!accWrap && !proxy)
|
2006-09-11 19:44:00 +04:00
|
|
|
return nil;
|
2008-09-17 17:11:39 +04:00
|
|
|
|
2014-03-08 05:05:20 +04:00
|
|
|
// Convert the given screen-global point in the cocoa coordinate system (with
|
|
|
|
// origin in the bottom-left corner of the screen) into point in the Gecko
|
|
|
|
// coordinate system (with origin in a top-left screen point).
|
|
|
|
NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
|
|
|
|
NSPoint tmpPoint = NSMakePoint(point.x,
|
|
|
|
[mainView frame].size.height - point.y);
|
2015-11-19 09:34:20 +03:00
|
|
|
LayoutDeviceIntPoint geckoPoint = nsCocoaUtils::
|
2014-03-08 05:05:20 +04:00
|
|
|
CocoaPointsToDevPixels(tmpPoint, nsCocoaUtils::GetBackingScaleFactor(mainView));
|
2006-12-01 13:53:52 +03:00
|
|
|
|
2015-07-17 00:34:52 +03:00
|
|
|
mozAccessible* nativeChild = nil;
|
|
|
|
if (accWrap) {
|
|
|
|
Accessible* child = accWrap->ChildAtPoint(geckoPoint.x, geckoPoint.y,
|
|
|
|
Accessible::eDeepestChild);
|
|
|
|
if (child)
|
|
|
|
nativeChild = GetNativeFromGeckoAccessible(child);
|
|
|
|
} else if (proxy) {
|
|
|
|
ProxyAccessible* child = proxy->ChildAtPoint(geckoPoint.x, geckoPoint.y,
|
|
|
|
Accessible::eDeepestChild);
|
|
|
|
if (child)
|
|
|
|
nativeChild = GetNativeFromProxy(child);
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
2014-03-08 05:05:20 +04:00
|
|
|
|
2015-07-17 00:34:52 +03:00
|
|
|
if (nativeChild)
|
2016-06-10 00:33:48 +03:00
|
|
|
return nativeChild;
|
2015-07-17 00:34:52 +03:00
|
|
|
|
2016-06-10 00:33:48 +03:00
|
|
|
// if we didn't find anything, return ourself or child view.
|
|
|
|
return GetObjectOrRepresentedView(self);
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2015-06-08 17:59:19 +03:00
|
|
|
- (NSArray*)accessibilityActionNames
|
2006-09-11 19:44:00 +04:00
|
|
|
{
|
2006-11-15 14:08:14 +03:00
|
|
|
return nil;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2015-06-08 17:59:19 +03:00
|
|
|
- (NSString*)accessibilityActionDescription:(NSString*)action
|
2006-09-11 19:44:00 +04:00
|
|
|
{
|
2012-01-27 19:50:04 +04:00
|
|
|
// by default we return whatever the MacOS API know about.
|
|
|
|
// if you have custom actions, override.
|
|
|
|
return NSAccessibilityActionDescription(action);
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2015-06-08 17:59:19 +03:00
|
|
|
- (void)accessibilityPerformAction:(NSString*)action
|
2006-09-11 19:44:00 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)accessibilityFocusedUIElement
|
|
|
|
{
|
2015-05-22 17:59:26 +03:00
|
|
|
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
2015-07-17 00:34:52 +03:00
|
|
|
ProxyAccessible* proxy = [self getProxyAccessible];
|
|
|
|
if (!accWrap && !proxy)
|
2006-09-11 19:44:00 +04:00
|
|
|
return nil;
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2015-07-17 00:34:52 +03:00
|
|
|
mozAccessible* focusedChild = nil;
|
|
|
|
if (accWrap) {
|
|
|
|
Accessible* focusedGeckoChild = accWrap->FocusedChild();
|
|
|
|
if (focusedGeckoChild)
|
|
|
|
focusedChild = GetNativeFromGeckoAccessible(focusedGeckoChild);
|
|
|
|
} else if (proxy) {
|
|
|
|
ProxyAccessible* focusedGeckoChild = proxy->FocusedChild();
|
|
|
|
if (focusedGeckoChild)
|
|
|
|
focusedChild = GetNativeFromProxy(focusedGeckoChild);
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2015-07-17 00:34:52 +03:00
|
|
|
if (focusedChild)
|
2016-06-10 00:33:48 +03:00
|
|
|
return GetObjectOrRepresentedView(focusedChild);
|
2015-07-17 00:34:52 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
// return ourself if we can't get a native focused child.
|
2016-06-10 00:33:48 +03:00
|
|
|
return GetObjectOrRepresentedView(self);
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
- (id <mozAccessible>)parent
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2015-07-15 07:50:27 +03:00
|
|
|
id nativeParent = nil;
|
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
2016-06-10 00:33:48 +03:00
|
|
|
Accessible* accessibleParent = accWrap->Parent();
|
2015-07-15 07:50:27 +03:00
|
|
|
if (accessibleParent)
|
|
|
|
nativeParent = GetNativeFromGeckoAccessible(accessibleParent);
|
|
|
|
if (nativeParent)
|
2016-06-10 00:33:48 +03:00
|
|
|
return GetObjectOrRepresentedView(nativeParent);
|
2016-06-10 00:33:48 +03:00
|
|
|
|
|
|
|
// Return native of root accessible if we have no direct parent
|
2015-07-15 07:50:27 +03:00
|
|
|
nativeParent = GetNativeFromGeckoAccessible(accWrap->RootAccessible());
|
|
|
|
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
2016-06-10 00:33:48 +03:00
|
|
|
if (ProxyAccessible* proxyParent = proxy->Parent()) {
|
|
|
|
nativeParent = GetNativeFromProxy(proxyParent);
|
|
|
|
}
|
|
|
|
|
2011-12-09 11:53:05 +04:00
|
|
|
if (nativeParent)
|
2016-06-10 00:33:48 +03:00
|
|
|
return GetObjectOrRepresentedView(nativeParent);
|
2015-07-15 07:50:27 +03:00
|
|
|
|
|
|
|
Accessible* outerDoc = proxy->OuterDocOfRemoteBrowser();
|
|
|
|
nativeParent = outerDoc ?
|
2016-06-10 00:33:48 +03:00
|
|
|
GetNativeFromGeckoAccessible(outerDoc) : nil;
|
2015-07-15 07:50:27 +03:00
|
|
|
} else {
|
|
|
|
return nil;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-12-01 13:53:52 +03:00
|
|
|
NSAssert1 (nativeParent, @"!!! we can't find a parent for %@", self);
|
2014-10-22 04:49:28 +04:00
|
|
|
|
2016-06-10 00:33:48 +03:00
|
|
|
return GetObjectOrRepresentedView(nativeParent);
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
- (BOOL)hasRepresentedView
|
2006-09-11 19:44:00 +04:00
|
|
|
{
|
2006-11-15 14:08:14 +03:00
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)representedView
|
|
|
|
{
|
|
|
|
return nil;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2006-09-19 12:48:33 +04:00
|
|
|
- (BOOL)isRoot
|
|
|
|
{
|
|
|
|
return NO;
|
|
|
|
}
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
// gets our native children lazily.
|
|
|
|
// returns nil when there are no children.
|
|
|
|
- (NSArray*)children
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2016-04-06 00:34:00 +03:00
|
|
|
if (mChildren)
|
2006-09-11 20:22:22 +04:00
|
|
|
return mChildren;
|
2011-12-06 00:33:30 +04:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
// get the array of children.
|
2016-06-10 00:33:48 +03:00
|
|
|
mChildren = [[NSMutableArray alloc] init];
|
|
|
|
|
2016-04-06 00:34:00 +03:00
|
|
|
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
2015-07-15 07:51:23 +03:00
|
|
|
if (accWrap) {
|
2016-06-10 00:33:48 +03:00
|
|
|
uint32_t childCount = accWrap->ChildCount();
|
|
|
|
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
|
|
|
|
mozAccessible* nativeChild = GetNativeFromGeckoAccessible(accWrap->GetChildAt(childIdx));
|
|
|
|
if (nativeChild)
|
2016-06-10 00:33:48 +03:00
|
|
|
[mChildren addObject:nativeChild];
|
2016-06-10 00:33:48 +03:00
|
|
|
}
|
|
|
|
|
2016-06-10 00:33:48 +03:00
|
|
|
// children from child if this is an outerdoc
|
|
|
|
OuterDocAccessible* docOwner = accWrap->AsOuterDoc();
|
|
|
|
if (docOwner) {
|
|
|
|
if (ProxyAccessible* proxyDoc = docOwner->RemoteChildDoc()) {
|
|
|
|
mozAccessible* nativeRemoteChild = GetNativeFromProxy(proxyDoc);
|
|
|
|
[mChildren insertObject:nativeRemoteChild atIndex:0];
|
|
|
|
NSAssert1 (nativeRemoteChild, @"%@ found a child remote doc missing a native\n", self);
|
|
|
|
}
|
|
|
|
}
|
2015-07-15 07:51:23 +03:00
|
|
|
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
2016-06-10 00:33:48 +03:00
|
|
|
uint32_t childCount = proxy->ChildrenCount();
|
|
|
|
for (uint32_t childIdx = 0; childIdx < childCount; childIdx++) {
|
|
|
|
mozAccessible* nativeChild = GetNativeFromProxy(proxy->ChildAt(childIdx));
|
|
|
|
if (nativeChild)
|
2016-06-10 00:33:48 +03:00
|
|
|
[mChildren addObject:nativeChild];
|
2016-06-10 00:33:48 +03:00
|
|
|
}
|
|
|
|
|
2015-07-15 07:51:23 +03:00
|
|
|
}
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 20:22:22 +04:00
|
|
|
return mChildren;
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSValue*)position
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2015-07-26 17:33:23 +03:00
|
|
|
nsIntRect rect;
|
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
|
|
|
rect = accWrap->Bounds();
|
|
|
|
else if (ProxyAccessible* proxy = [self getProxyAccessible])
|
|
|
|
rect = proxy->Bounds();
|
|
|
|
else
|
2014-03-08 05:05:20 +04:00
|
|
|
return nil;
|
|
|
|
|
|
|
|
NSScreen* mainView = [[NSScreen screens] objectAtIndex:0];
|
|
|
|
CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(mainView);
|
2014-09-16 21:30:23 +04:00
|
|
|
NSPoint p = NSMakePoint(static_cast<CGFloat>(rect.x) / scaleFactor,
|
|
|
|
[mainView frame].size.height - static_cast<CGFloat>(rect.y + rect.height) / scaleFactor);
|
2014-03-08 05:05:20 +04:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
return [NSValue valueWithPoint:p];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSValue*)size
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2015-07-26 17:33:51 +03:00
|
|
|
nsIntRect rect;
|
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
|
|
|
rect = accWrap->Bounds();
|
|
|
|
else if (ProxyAccessible* proxy = [self getProxyAccessible])
|
|
|
|
rect = proxy->Bounds();
|
|
|
|
else
|
2014-03-08 05:05:20 +04:00
|
|
|
return nil;
|
|
|
|
|
|
|
|
CGFloat scaleFactor =
|
|
|
|
nsCocoaUtils::GetBackingScaleFactor([[NSScreen screens] objectAtIndex:0]);
|
2014-10-22 04:49:28 +04:00
|
|
|
return [NSValue valueWithSize:NSMakeSize(static_cast<CGFloat>(rect.width) / scaleFactor,
|
|
|
|
static_cast<CGFloat>(rect.height) / scaleFactor)];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*)role
|
|
|
|
{
|
2015-05-22 17:59:26 +03:00
|
|
|
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
2015-08-04 21:56:07 +03:00
|
|
|
if (accWrap) {
|
|
|
|
#ifdef DEBUG_A11Y
|
|
|
|
NS_ASSERTION(nsAccUtils::IsTextInterfaceSupportCorrect(accWrap),
|
|
|
|
"Does not support Text when it should");
|
|
|
|
#endif
|
|
|
|
} else if (![self getProxyAccessible]) {
|
2012-05-25 04:24:09 +04:00
|
|
|
return nil;
|
2015-08-04 21:56:07 +03:00
|
|
|
}
|
2012-04-26 22:25:33 +04:00
|
|
|
|
2012-07-21 22:32:25 +04:00
|
|
|
#define ROLE(geckoRole, stringRole, atkRole, macRole, msaaRole, ia2Role, nameRule) \
|
2012-04-26 22:25:33 +04:00
|
|
|
case roles::geckoRole: \
|
|
|
|
return macRole;
|
|
|
|
|
|
|
|
switch (mRole) {
|
|
|
|
#include "RoleMap.h"
|
|
|
|
default:
|
|
|
|
NS_NOTREACHED("Unknown role.");
|
|
|
|
return NSAccessibilityUnknownRole;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef ROLE
|
2006-11-15 14:08:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*)subrole
|
|
|
|
{
|
2015-05-22 17:59:26 +03:00
|
|
|
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
2015-08-04 21:56:07 +03:00
|
|
|
ProxyAccessible* proxy = [self getProxyAccessible];
|
2012-06-30 01:12:18 +04:00
|
|
|
|
2015-06-27 03:31:44 +03:00
|
|
|
// Deal with landmarks first
|
2015-08-04 21:56:07 +03:00
|
|
|
nsIAtom* landmark = nullptr;
|
|
|
|
if (accWrap)
|
|
|
|
landmark = accWrap->LandmarkRole();
|
|
|
|
else if (proxy)
|
|
|
|
landmark = proxy->LandmarkRole();
|
|
|
|
|
2015-03-01 01:25:06 +03:00
|
|
|
if (landmark) {
|
|
|
|
if (landmark == nsGkAtoms::application)
|
|
|
|
return @"AXLandmarkApplication";
|
|
|
|
if (landmark == nsGkAtoms::banner)
|
2012-06-30 01:12:18 +04:00
|
|
|
return @"AXLandmarkBanner";
|
2015-03-01 01:25:06 +03:00
|
|
|
if (landmark == nsGkAtoms::complementary)
|
2012-06-30 01:12:18 +04:00
|
|
|
return @"AXLandmarkComplementary";
|
2015-03-01 01:25:06 +03:00
|
|
|
if (landmark == nsGkAtoms::contentinfo)
|
2012-06-30 01:12:18 +04:00
|
|
|
return @"AXLandmarkContentInfo";
|
2015-03-01 01:25:06 +03:00
|
|
|
if (landmark == nsGkAtoms::form)
|
|
|
|
return @"AXLandmarkForm";
|
|
|
|
if (landmark == nsGkAtoms::main)
|
2012-06-30 01:12:18 +04:00
|
|
|
return @"AXLandmarkMain";
|
2015-03-01 01:25:06 +03:00
|
|
|
if (landmark == nsGkAtoms::navigation)
|
2012-06-30 01:12:18 +04:00
|
|
|
return @"AXLandmarkNavigation";
|
2015-03-01 01:25:06 +03:00
|
|
|
if (landmark == nsGkAtoms::search)
|
2012-06-30 01:12:18 +04:00
|
|
|
return @"AXLandmarkSearch";
|
2015-03-01 01:25:06 +03:00
|
|
|
if (landmark == nsGkAtoms::searchbox)
|
2015-02-27 17:41:57 +03:00
|
|
|
return @"AXSearchField";
|
2012-06-30 01:12:18 +04:00
|
|
|
}
|
|
|
|
|
2015-06-27 03:31:44 +03:00
|
|
|
// Now, deal with widget roles
|
2015-08-04 21:56:07 +03:00
|
|
|
nsIAtom* roleAtom = nullptr;
|
|
|
|
if (accWrap && accWrap->HasARIARole()) {
|
2016-03-11 05:13:01 +03:00
|
|
|
const nsRoleMapEntry* roleMap = accWrap->ARIARoleMap();
|
2015-08-04 21:56:07 +03:00
|
|
|
roleAtom = *roleMap->roleAtom;
|
|
|
|
}
|
|
|
|
if (proxy)
|
|
|
|
roleAtom = proxy->ARIARoleAtom();
|
|
|
|
|
|
|
|
if (roleAtom) {
|
|
|
|
if (roleAtom == nsGkAtoms::alert)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXApplicationAlert";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::alertdialog)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXApplicationAlertDialog";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::article)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXDocumentArticle";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::dialog)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXApplicationDialog";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::document)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXDocument";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::log_)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXApplicationLog";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::marquee)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXApplicationMarquee";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::math)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXDocumentMath";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::note_)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXDocumentNote";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::region)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXDocumentRegion";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::status)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXApplicationStatus";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::tabpanel)
|
2015-06-27 20:50:33 +03:00
|
|
|
return @"AXTabPanel";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::timer)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXApplicationTimer";
|
2015-08-04 21:56:07 +03:00
|
|
|
if (roleAtom == nsGkAtoms::tooltip)
|
2015-06-27 03:31:44 +03:00
|
|
|
return @"AXUserInterfaceTooltip";
|
|
|
|
}
|
|
|
|
|
2012-04-13 22:22:36 +04:00
|
|
|
switch (mRole) {
|
|
|
|
case roles::LIST:
|
2012-05-10 04:47:28 +04:00
|
|
|
return @"AXContentList"; // 10.6+ NSAccessibilityContentListSubrole;
|
2012-04-13 22:22:36 +04:00
|
|
|
|
2015-03-01 01:25:06 +03:00
|
|
|
case roles::ENTRY:
|
2015-08-04 21:56:07 +03:00
|
|
|
if ((accWrap && accWrap->IsSearchbox()) ||
|
|
|
|
(proxy && proxy->IsSearchbox()))
|
2015-03-01 01:25:06 +03:00
|
|
|
return @"AXSearchField";
|
|
|
|
break;
|
|
|
|
|
2012-04-24 22:35:23 +04:00
|
|
|
case roles::DEFINITION_LIST:
|
2012-05-10 04:47:28 +04:00
|
|
|
return @"AXDefinitionList"; // 10.6+ NSAccessibilityDefinitionListSubrole;
|
2012-04-13 22:22:36 +04:00
|
|
|
|
2012-04-24 22:35:23 +04:00
|
|
|
case roles::TERM:
|
|
|
|
return @"AXTerm";
|
2012-04-13 22:22:36 +04:00
|
|
|
|
2012-04-24 22:35:23 +04:00
|
|
|
case roles::DEFINITION:
|
|
|
|
return @"AXDefinition";
|
2012-04-13 22:22:36 +04:00
|
|
|
|
2015-06-19 16:55:00 +03:00
|
|
|
case roles::MATHML_MATH:
|
|
|
|
return @"AXDocumentMath";
|
|
|
|
|
|
|
|
case roles::MATHML_FRACTION:
|
|
|
|
return @"AXMathFraction";
|
|
|
|
|
|
|
|
case roles::MATHML_FENCED:
|
2015-06-23 19:17:00 +03:00
|
|
|
// XXX bug 1176970
|
|
|
|
// This should be AXMathFence, but doing so without implementing the
|
2015-06-19 16:55:00 +03:00
|
|
|
// whole fence interface seems to make VoiceOver crash, so we present it
|
|
|
|
// as a row for now.
|
|
|
|
return @"AXMathRow";
|
|
|
|
|
|
|
|
case roles::MATHML_SUB:
|
|
|
|
case roles::MATHML_SUP:
|
|
|
|
case roles::MATHML_SUB_SUP:
|
|
|
|
return @"AXMathSubscriptSuperscript";
|
|
|
|
|
|
|
|
case roles::MATHML_ROW:
|
2015-07-01 09:14:00 +03:00
|
|
|
case roles::MATHML_STYLE:
|
|
|
|
case roles::MATHML_ERROR:
|
2015-06-19 16:55:00 +03:00
|
|
|
return @"AXMathRow";
|
|
|
|
|
|
|
|
case roles::MATHML_UNDER:
|
|
|
|
case roles::MATHML_OVER:
|
|
|
|
case roles::MATHML_UNDER_OVER:
|
|
|
|
return @"AXMathUnderOver";
|
|
|
|
|
|
|
|
case roles::MATHML_SQUARE_ROOT:
|
|
|
|
return @"AXMathSquareRoot";
|
|
|
|
|
|
|
|
case roles::MATHML_ROOT:
|
|
|
|
return @"AXMathRoot";
|
|
|
|
|
|
|
|
case roles::MATHML_TEXT:
|
|
|
|
return @"AXMathText";
|
|
|
|
|
|
|
|
case roles::MATHML_NUMBER:
|
|
|
|
return @"AXMathNumber";
|
|
|
|
|
|
|
|
case roles::MATHML_IDENTIFIER:
|
|
|
|
return @"AXMathIdentifier";
|
|
|
|
|
|
|
|
case roles::MATHML_TABLE:
|
|
|
|
return @"AXMathTable";
|
|
|
|
|
|
|
|
case roles::MATHML_TABLE_ROW:
|
|
|
|
return @"AXMathTableRow";
|
|
|
|
|
|
|
|
case roles::MATHML_CELL:
|
|
|
|
return @"AXMathTableCell";
|
|
|
|
|
|
|
|
// XXX: NSAccessibility also uses subroles AXMathSeparatorOperator and
|
|
|
|
// AXMathFenceOperator. We should use the NS_MATHML_OPERATOR_FENCE and
|
|
|
|
// NS_MATHML_OPERATOR_SEPARATOR bits of nsOperatorFlags, but currently they
|
|
|
|
// are only available from the MathML layout code. Hence we just fallback
|
|
|
|
// to subrole AXMathOperator for now.
|
2015-06-23 19:17:00 +03:00
|
|
|
// XXX bug 1175747 WebKit also creates anonymous operators for <mfenced>
|
|
|
|
// which have subroles AXMathSeparatorOperator and AXMathFenceOperator.
|
2015-06-19 16:55:00 +03:00
|
|
|
case roles::MATHML_OPERATOR:
|
|
|
|
return @"AXMathOperator";
|
|
|
|
|
|
|
|
case roles::MATHML_MULTISCRIPTS:
|
|
|
|
return @"AXMathMultiscript";
|
|
|
|
|
2015-02-26 16:47:15 +03:00
|
|
|
case roles::SWITCH:
|
|
|
|
return @"AXSwitch";
|
|
|
|
|
2015-06-27 20:50:33 +03:00
|
|
|
case roles::ALERT:
|
|
|
|
return @"AXApplicationAlert";
|
|
|
|
|
|
|
|
case roles::SEPARATOR:
|
|
|
|
return @"AXContentSeparator";
|
|
|
|
|
|
|
|
case roles::PROPERTYPAGE:
|
|
|
|
return @"AXTabPanel";
|
|
|
|
|
2016-06-01 18:07:56 +03:00
|
|
|
case roles::DETAILS:
|
|
|
|
return @"AXDetails";
|
|
|
|
|
|
|
|
case roles::SUMMARY:
|
|
|
|
return @"AXSummary";
|
|
|
|
|
2012-04-13 22:22:36 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
return nil;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2015-03-01 01:25:06 +03:00
|
|
|
struct RoleDescrMap
|
|
|
|
{
|
|
|
|
NSString* role;
|
2015-06-17 19:37:19 +03:00
|
|
|
const nsString description;
|
2015-03-01 01:25:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
static const RoleDescrMap sRoleDescrMap[] = {
|
2015-06-27 03:31:44 +03:00
|
|
|
{ @"AXApplicationAlert", NS_LITERAL_STRING("alert") },
|
|
|
|
{ @"AXApplicationAlertDialog", NS_LITERAL_STRING("alertDialog") },
|
|
|
|
{ @"AXApplicationLog", NS_LITERAL_STRING("log") },
|
|
|
|
{ @"AXApplicationMarquee", NS_LITERAL_STRING("marquee") },
|
|
|
|
{ @"AXApplicationStatus", NS_LITERAL_STRING("status") },
|
|
|
|
{ @"AXApplicationTimer", NS_LITERAL_STRING("timer") },
|
2015-06-27 20:50:33 +03:00
|
|
|
{ @"AXContentSeparator", NS_LITERAL_STRING("separator") },
|
2015-03-01 01:25:06 +03:00
|
|
|
{ @"AXDefinition", NS_LITERAL_STRING("definition") },
|
2015-06-27 03:31:44 +03:00
|
|
|
{ @"AXDocument", NS_LITERAL_STRING("document") },
|
|
|
|
{ @"AXDocumentArticle", NS_LITERAL_STRING("article") },
|
|
|
|
{ @"AXDocumentMath", NS_LITERAL_STRING("math") },
|
|
|
|
{ @"AXDocumentNote", NS_LITERAL_STRING("note") },
|
|
|
|
{ @"AXDocumentRegion", NS_LITERAL_STRING("region") },
|
|
|
|
{ @"AXLandmarkApplication", NS_LITERAL_STRING("application") },
|
2015-03-01 01:25:06 +03:00
|
|
|
{ @"AXLandmarkBanner", NS_LITERAL_STRING("banner") },
|
|
|
|
{ @"AXLandmarkComplementary", NS_LITERAL_STRING("complementary") },
|
|
|
|
{ @"AXLandmarkContentInfo", NS_LITERAL_STRING("content") },
|
|
|
|
{ @"AXLandmarkMain", NS_LITERAL_STRING("main") },
|
|
|
|
{ @"AXLandmarkNavigation", NS_LITERAL_STRING("navigation") },
|
|
|
|
{ @"AXLandmarkSearch", NS_LITERAL_STRING("search") },
|
|
|
|
{ @"AXSearchField", NS_LITERAL_STRING("searchTextField") },
|
2015-06-27 20:50:33 +03:00
|
|
|
{ @"AXTabPanel", NS_LITERAL_STRING("tabPanel") },
|
2015-06-27 03:31:44 +03:00
|
|
|
{ @"AXTerm", NS_LITERAL_STRING("term") },
|
|
|
|
{ @"AXUserInterfaceTooltip", NS_LITERAL_STRING("tooltip") }
|
2015-03-01 01:25:06 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct RoleDescrComparator
|
|
|
|
{
|
|
|
|
const NSString* mRole;
|
|
|
|
explicit RoleDescrComparator(const NSString* aRole) : mRole(aRole) {}
|
|
|
|
int operator()(const RoleDescrMap& aEntry) const {
|
|
|
|
return [mRole compare:aEntry.role];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-04-18 04:31:03 +04:00
|
|
|
- (NSString*)roleDescription
|
|
|
|
{
|
|
|
|
if (mRole == roles::DOCUMENT)
|
|
|
|
return utils::LocalizedString(NS_LITERAL_STRING("htmlContent"));
|
2012-06-30 01:12:18 +04:00
|
|
|
|
2012-04-18 04:31:03 +04:00
|
|
|
NSString* subrole = [self subrole];
|
2012-06-30 01:12:18 +04:00
|
|
|
|
2015-06-26 03:23:01 +03:00
|
|
|
if (subrole) {
|
|
|
|
size_t idx = 0;
|
|
|
|
if (BinarySearchIf(sRoleDescrMap, 0, ArrayLength(sRoleDescrMap),
|
|
|
|
RoleDescrComparator(subrole), &idx)) {
|
|
|
|
return utils::LocalizedString(sRoleDescrMap[idx].description);
|
|
|
|
}
|
2012-06-30 01:12:18 +04:00
|
|
|
}
|
|
|
|
|
2015-03-01 01:25:06 +03:00
|
|
|
return NSAccessibilityRoleDescription([self role], subrole);
|
2012-04-18 04:31:03 +04:00
|
|
|
}
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
- (NSString*)title
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
nsAutoString title;
|
2015-08-04 21:56:17 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
|
|
|
accWrap->Name(title);
|
|
|
|
else if (ProxyAccessible* proxy = [self getProxyAccessible])
|
|
|
|
proxy->Name(title);
|
|
|
|
|
2012-06-30 01:12:16 +04:00
|
|
|
return nsCocoaUtils::ToNSString(title);
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
- (id)value
|
2006-09-11 19:44:00 +04:00
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
nsAutoString value;
|
2015-08-04 21:56:17 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
|
|
|
accWrap->Value(value);
|
|
|
|
else if (ProxyAccessible* proxy = [self getProxyAccessible])
|
|
|
|
proxy->Value(value);
|
|
|
|
|
2015-03-27 20:05:26 +03:00
|
|
|
return nsCocoaUtils::ToNSString(value);
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-11-15 14:08:14 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)valueDidChange
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
#ifdef DEBUG_hakan
|
|
|
|
NSLog(@"%@'s value changed!", self);
|
|
|
|
#endif
|
|
|
|
// sending out a notification is expensive, so we don't do it other than for really important objects,
|
|
|
|
// like mozTextAccessible.
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2012-04-02 21:15:00 +04:00
|
|
|
- (void)selectedTextDidChange
|
|
|
|
{
|
|
|
|
// Do nothing. mozTextAccessible will.
|
|
|
|
}
|
|
|
|
|
2015-10-02 06:42:00 +03:00
|
|
|
- (void)documentLoadComplete
|
|
|
|
{
|
|
|
|
id realSelf = GetObjectOrRepresentedView(self);
|
|
|
|
NSAccessibilityPostNotification(realSelf, NSAccessibilityFocusedUIElementChangedNotification);
|
|
|
|
NSAccessibilityPostNotification(realSelf, @"AXLoadComplete");
|
|
|
|
NSAccessibilityPostNotification(realSelf, @"AXLayoutComplete");
|
|
|
|
}
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
- (NSString*)help
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2015-08-26 17:28:05 +03:00
|
|
|
// What needs to go here is actually the accDescription of an item.
|
|
|
|
// The MSAA acc_help method has nothing to do with this one.
|
2006-11-15 14:08:14 +03:00
|
|
|
nsAutoString helpText;
|
2015-08-04 21:56:17 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
2015-08-26 17:28:05 +03:00
|
|
|
accWrap->Description(helpText);
|
2015-08-04 21:56:17 +03:00
|
|
|
else if (ProxyAccessible* proxy = [self getProxyAccessible])
|
2015-08-26 17:28:05 +03:00
|
|
|
proxy->Description(helpText);
|
2015-08-04 21:56:17 +03:00
|
|
|
|
2015-03-27 20:05:26 +03:00
|
|
|
return nsCocoaUtils::ToNSString(helpText);
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// objc-style description (from NSObject); not to be confused with the accessible description above.
|
|
|
|
- (NSString*)description
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
return [NSString stringWithFormat:@"(%p) %@", self, [self role]];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)isFocused
|
|
|
|
{
|
2015-05-22 17:59:26 +03:00
|
|
|
return FocusMgr()->IsFocused([self getGeckoAccessible]);
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)canBeFocused
|
|
|
|
{
|
2015-08-04 21:56:13 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
|
|
|
return accWrap->InteractiveState() & states::FOCUSABLE;
|
|
|
|
|
|
|
|
if (ProxyAccessible* proxy = [self getProxyAccessible])
|
|
|
|
return proxy->State() & states::FOCUSABLE;
|
|
|
|
|
|
|
|
return false;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (BOOL)focus
|
|
|
|
{
|
2015-08-04 21:56:09 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
|
|
|
accWrap->TakeFocus();
|
|
|
|
else if (ProxyAccessible* proxy = [self getProxyAccessible])
|
|
|
|
proxy->TakeFocus();
|
|
|
|
else
|
2012-06-30 01:12:02 +04:00
|
|
|
return NO;
|
2014-09-16 21:30:23 +04:00
|
|
|
|
|
|
|
return YES;
|
2006-09-27 16:56:28 +04:00
|
|
|
}
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
- (BOOL)isEnabled
|
|
|
|
{
|
2015-08-04 21:56:17 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible])
|
|
|
|
return ((accWrap->InteractiveState() & states::UNAVAILABLE) == 0);
|
|
|
|
|
|
|
|
if (ProxyAccessible* proxy = [self getProxyAccessible])
|
|
|
|
return ((proxy->State() & states::UNAVAILABLE) == 0);
|
|
|
|
|
|
|
|
return false;
|
2006-11-15 14:08:14 +03:00
|
|
|
}
|
|
|
|
|
2006-09-27 16:56:28 +04:00
|
|
|
// The root accessible calls this when the focused node was
|
|
|
|
// changed to us.
|
|
|
|
- (void)didReceiveFocus
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
#ifdef DEBUG_hakan
|
|
|
|
NSLog (@"%@ received focus!", self);
|
|
|
|
#endif
|
2006-12-01 13:53:52 +03:00
|
|
|
NSAccessibilityPostNotification(GetObjectOrRepresentedView(self),
|
2006-09-27 16:56:28 +04:00
|
|
|
NSAccessibilityFocusedUIElementChangedNotification);
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (NSWindow*)window
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_NIL;
|
|
|
|
|
2010-09-17 07:23:17 +04:00
|
|
|
// Get a pointer to the native window (NSWindow) we reside in.
|
2006-09-11 19:44:00 +04:00
|
|
|
NSWindow *nativeWindow = nil;
|
2015-08-04 21:56:11 +03:00
|
|
|
DocAccessible* docAcc = nullptr;
|
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
|
|
|
docAcc = accWrap->Document();
|
|
|
|
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
|
|
|
Accessible* outerDoc = proxy->OuterDocOfRemoteBrowser();
|
|
|
|
if (outerDoc)
|
|
|
|
docAcc = outerDoc->Document();
|
|
|
|
}
|
|
|
|
|
2010-09-17 07:23:17 +04:00
|
|
|
if (docAcc)
|
|
|
|
nativeWindow = static_cast<NSWindow*>(docAcc->GetNativeWindow());
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
NSAssert1(nativeWindow, @"Could not get native window for %@", self);
|
2006-09-11 19:44:00 +04:00
|
|
|
return nativeWindow;
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK_NIL;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)invalidateChildren
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
// make room for new children
|
|
|
|
[mChildren release];
|
|
|
|
mChildren = nil;
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2012-05-29 05:18:45 +04:00
|
|
|
- (void)appendChild:(Accessible*)aAccessible
|
2011-12-23 02:31:06 +04:00
|
|
|
{
|
|
|
|
// if mChildren is nil, then we don't even need to bother
|
|
|
|
if (!mChildren)
|
|
|
|
return;
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2011-12-23 02:31:06 +04:00
|
|
|
mozAccessible *curNative = GetNativeFromGeckoAccessible(aAccessible);
|
|
|
|
if (curNative)
|
2016-06-10 00:33:48 +03:00
|
|
|
[mChildren addObject:curNative];
|
2011-12-23 02:31:06 +04:00
|
|
|
}
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
- (void)expire
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
[self invalidateChildren];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
2015-05-22 18:04:47 +03:00
|
|
|
mGeckoAccessible = 0;
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
- (BOOL)isExpired
|
|
|
|
{
|
2015-08-04 21:56:17 +03:00
|
|
|
return ![self getGeckoAccessible] && ![self getProxyAccessible];
|
2006-11-15 14:08:14 +03:00
|
|
|
}
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
#pragma mark -
|
|
|
|
#pragma mark Debug methods
|
|
|
|
#pragma mark -
|
|
|
|
|
|
|
|
#ifdef DEBUG
|
|
|
|
|
|
|
|
// will check that our children actually reference us as their
|
|
|
|
// parent.
|
2006-12-01 13:53:52 +03:00
|
|
|
- (void)sanityCheckChildren:(NSArray *)children
|
2006-09-11 19:44:00 +04:00
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-12-01 13:53:52 +03:00
|
|
|
NSEnumerator *iter = [children objectEnumerator];
|
2006-09-11 19:44:00 +04:00
|
|
|
mozAccessible *curObj = nil;
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-12-01 13:53:52 +03:00
|
|
|
NSLog(@"sanity checking %@", self);
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-12-01 13:53:52 +03:00
|
|
|
while ((curObj = [iter nextObject])) {
|
|
|
|
id realSelf = GetObjectOrRepresentedView(self);
|
|
|
|
NSLog(@"checking %@", realSelf);
|
2015-06-08 17:59:19 +03:00
|
|
|
NSAssert2([curObj parent] == realSelf,
|
2006-12-01 13:53:52 +03:00
|
|
|
@"!!! %@ not returning %@ as AXParent, even though it is a AXChild of it!", curObj, realSelf);
|
|
|
|
}
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-12-01 13:53:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)sanityCheckChildren
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-12-01 13:53:52 +03:00
|
|
|
[self sanityCheckChildren:[self children]];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)printHierarchy
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
[self printHierarchyWithLevel:0];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)printHierarchyWithLevel:(unsigned)level
|
|
|
|
{
|
2008-02-22 23:13:17 +03:00
|
|
|
NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
|
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
NSAssert(![self isExpired], @"!!! trying to print hierarchy of expired object!");
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
// print this node
|
|
|
|
NSMutableString *indent = [NSMutableString stringWithCapacity:level];
|
|
|
|
unsigned i=0;
|
|
|
|
for (;i<level;i++)
|
|
|
|
[indent appendString:@" "];
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
NSLog (@"%@(#%i) %@", indent, level, self);
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
// use |children| method to make sure our children are lazily fetched first.
|
|
|
|
NSArray *children = [self children];
|
|
|
|
if (!children)
|
|
|
|
return;
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2016-06-10 00:33:48 +03:00
|
|
|
[self sanityCheckChildren];
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-11-15 14:08:14 +03:00
|
|
|
NSEnumerator *iter = [children objectEnumerator];
|
2006-09-11 19:44:00 +04:00
|
|
|
mozAccessible *object = nil;
|
2015-06-08 17:59:19 +03:00
|
|
|
|
2006-09-11 19:44:00 +04:00
|
|
|
while (iter && (object = [iter nextObject]))
|
|
|
|
// print every child node's subtree, increasing the indenting
|
|
|
|
// by two for every level.
|
|
|
|
[object printHierarchyWithLevel:(level+1)];
|
2008-02-22 23:13:17 +03:00
|
|
|
|
|
|
|
NS_OBJC_END_TRY_ABORT_BLOCK;
|
2006-09-11 19:44:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* DEBUG */
|
|
|
|
|
|
|
|
@end
|