2012-01-24 02:37:21 +04:00
|
|
|
/* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim:expandtab:shiftwidth=2:tabstop=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/. */
|
2012-01-24 02:37:21 +04:00
|
|
|
|
|
|
|
#import "mozHTMLAccessible.h"
|
|
|
|
|
2012-12-21 07:16:44 +04:00
|
|
|
#import "Accessible-inl.h"
|
2012-05-31 12:04:41 +04:00
|
|
|
#import "HyperTextAccessible.h"
|
2012-01-24 02:37:21 +04:00
|
|
|
|
2012-01-27 19:50:04 +04:00
|
|
|
#import "nsCocoaUtils.h"
|
|
|
|
|
2012-01-24 02:37:21 +04:00
|
|
|
@implementation mozHeadingAccessible
|
|
|
|
|
2012-06-30 01:12:16 +04:00
|
|
|
- (NSString*)title
|
|
|
|
{
|
|
|
|
nsAutoString title;
|
2015-08-06 04:55:15 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
|
|
|
mozilla::ErrorResult rv;
|
|
|
|
// XXX use the flattening API when there are available
|
|
|
|
// see bug 768298
|
|
|
|
accWrap->GetContent()->GetTextContent(title, rv);
|
|
|
|
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
|
|
|
proxy->Title(title);
|
|
|
|
}
|
2012-06-30 01:12:16 +04:00
|
|
|
|
|
|
|
return nsCocoaUtils::ToNSString(title);
|
|
|
|
}
|
|
|
|
|
2012-01-24 02:37:21 +04:00
|
|
|
- (id)value
|
|
|
|
{
|
2015-08-06 04:55:15 +03:00
|
|
|
uint32_t level = 0;
|
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
|
|
|
level = accWrap->GetLevelInternal();
|
|
|
|
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
|
|
|
level = proxy->GetLevelInternal();
|
|
|
|
}
|
2012-01-24 02:37:21 +04:00
|
|
|
|
|
|
|
return [NSNumber numberWithInt:level];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|
2012-01-27 19:50:04 +04:00
|
|
|
|
|
|
|
@interface mozLinkAccessible ()
|
|
|
|
-(NSURL*)url;
|
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation mozLinkAccessible
|
|
|
|
|
|
|
|
- (NSArray*)accessibilityAttributeNames
|
|
|
|
{
|
|
|
|
// if we're expired, we don't support any attributes.
|
2015-08-06 04:55:15 +03:00
|
|
|
if (![self getGeckoAccessible] && ![self getProxyAccessible])
|
2012-01-27 19:50:04 +04:00
|
|
|
return [NSArray array];
|
2015-08-06 04:55:15 +03:00
|
|
|
|
2012-01-27 19:50:04 +04:00
|
|
|
static NSMutableArray* attributes = nil;
|
2015-08-06 04:55:15 +03:00
|
|
|
|
2012-01-27 19:50:04 +04:00
|
|
|
if (!attributes) {
|
|
|
|
attributes = [[super accessibilityAttributeNames] mutableCopy];
|
|
|
|
[attributes addObject:NSAccessibilityURLAttribute];
|
|
|
|
}
|
|
|
|
|
|
|
|
return attributes;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id)accessibilityAttributeValue:(NSString *)attribute
|
|
|
|
{
|
|
|
|
if ([attribute isEqualToString:NSAccessibilityURLAttribute])
|
|
|
|
return [self url];
|
|
|
|
|
|
|
|
return [super accessibilityAttributeValue:attribute];
|
|
|
|
}
|
|
|
|
|
2015-08-06 04:55:15 +03:00
|
|
|
- (NSArray*)accessibilityActionNames
|
2012-01-27 19:50:04 +04:00
|
|
|
{
|
|
|
|
// if we're expired, we don't support any attributes.
|
2015-08-06 04:55:15 +03:00
|
|
|
if (![self getGeckoAccessible] && ![self getProxyAccessible])
|
2012-01-27 19:50:04 +04:00
|
|
|
return [NSArray array];
|
|
|
|
|
|
|
|
static NSArray* actionNames = nil;
|
|
|
|
|
|
|
|
if (!actionNames) {
|
|
|
|
actionNames = [[NSArray alloc] initWithObjects:NSAccessibilityPressAction,
|
|
|
|
nil];
|
|
|
|
}
|
|
|
|
|
|
|
|
return actionNames;
|
|
|
|
}
|
|
|
|
|
2015-08-06 04:55:15 +03:00
|
|
|
- (void)accessibilityPerformAction:(NSString*)action
|
2012-01-27 19:50:04 +04:00
|
|
|
{
|
2015-05-22 17:59:26 +03:00
|
|
|
AccessibleWrap* accWrap = [self getGeckoAccessible];
|
2015-08-06 04:55:15 +03:00
|
|
|
ProxyAccessible* proxy = [self getProxyAccessible];
|
|
|
|
if (!accWrap && !proxy) {
|
|
|
|
return;
|
|
|
|
}
|
2015-05-22 17:59:26 +03:00
|
|
|
|
2015-08-06 04:55:15 +03:00
|
|
|
if ([action isEqualToString:NSAccessibilityPressAction]) {
|
|
|
|
if (accWrap) {
|
|
|
|
accWrap->DoAction(0);
|
|
|
|
} else if (proxy) {
|
|
|
|
proxy->DoAction(0);
|
|
|
|
}
|
2012-01-27 19:50:04 +04:00
|
|
|
return;
|
2015-08-06 04:55:15 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
[super accessibilityPerformAction:action];
|
2012-01-27 19:50:04 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-07-12 04:22:28 +04:00
|
|
|
- (NSString*)customDescription
|
|
|
|
{
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
|
|
|
- (NSString*)value
|
|
|
|
{
|
|
|
|
return @"";
|
|
|
|
}
|
|
|
|
|
2012-01-27 19:50:04 +04:00
|
|
|
- (NSURL*)url
|
|
|
|
{
|
|
|
|
nsAutoString value;
|
2015-08-06 04:55:15 +03:00
|
|
|
if (AccessibleWrap* accWrap = [self getGeckoAccessible]) {
|
|
|
|
accWrap->Value(value);
|
|
|
|
} else if (ProxyAccessible* proxy = [self getProxyAccessible]) {
|
|
|
|
proxy->Value(value);
|
|
|
|
}
|
2012-01-27 19:50:04 +04:00
|
|
|
|
|
|
|
NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value);
|
|
|
|
if (!urlString)
|
|
|
|
return nil;
|
|
|
|
|
|
|
|
return [NSURL URLWithString:urlString];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|