2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
4 /* This Source Code Form is subject to the terms of the Mozilla Public
5 * License, v. 2.0. If a copy of the MPL was not distributed with this
6 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
8 #import "mozHTMLAccessible.h"
10 #import "LocalAccessible-inl.h"
11 #import "HyperTextAccessible.h"
13 #import "nsCocoaUtils.h"
15 using namespace mozilla::a11y;
17 @implementation mozHeadingAccessible
19 - (NSString*)moxTitle {
21 if (LocalAccessible* acc = mGeckoAccessible->AsLocal()) {
22 mozilla::ErrorResult rv;
23 // XXX use the flattening API when there are available
25 acc->GetContent()->GetTextContent(title, rv);
26 } else if (RemoteAccessible* proxy = mGeckoAccessible->AsRemote()) {
30 title.CompressWhitespace();
32 return nsCocoaUtils::ToNSString(title);
36 GroupPos groupPos = mGeckoAccessible->GroupPosition();
38 return [NSNumber numberWithInt:groupPos.level];
43 @implementation mozLinkAccessible
45 - (NSString*)moxValue {
51 mGeckoAccessible->Value(value);
53 NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value);
54 if (!urlString) return nil;
56 return [NSURL URLWithString:urlString];
59 - (NSNumber*)moxVisited {
60 return @([self stateWithMask:states::TRAVERSED] != 0);
63 - (NSString*)moxRole {
64 // If this is not LINKED, just expose this as a generic group accessible.
65 // Chrome and Safari expose this as a childless AXStaticText, but
66 // the HTML Accessibility API Mappings spec says this should be an AXGroup.
67 if (![self stateWithMask:states::LINKED]) {
68 return NSAccessibilityGroupRole;
71 return [super moxRole];
74 - (NSArray*)moxLinkedUIElements {
75 return [self getRelationsByType:RelationType::LINKS_TO];
80 @implementation MOXListItemAccessible
82 - (NSString*)moxTitle {