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 {
22 ENameValueFlag flag = mGeckoAccessible->Name(title);
23 if (flag != eNameFromSubtree) {
24 // If this is a name via relation or attribute (eg. aria-label)
25 // it will be provided via AXDescription.
29 return nsCocoaUtils::ToNSString(title);
33 GroupPos groupPos = mGeckoAccessible->GroupPosition();
35 return [NSNumber numberWithInt:groupPos.level];
40 @implementation mozLinkAccessible
42 - (NSString*)moxValue {
48 mGeckoAccessible->Value(value);
50 NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value);
51 if (!urlString) return nil;
53 return [NSURL URLWithString:urlString];
56 - (NSNumber*)moxVisited {
57 return @([self stateWithMask:states::TRAVERSED] != 0);
60 - (NSString*)moxRole {
61 // If this is not LINKED, just expose this as a generic group accessible.
62 // Chrome and Safari expose this as a childless AXStaticText, but
63 // the HTML Accessibility API Mappings spec says this should be an AXGroup.
64 if (![self stateWithMask:states::LINKED]) {
65 return NSAccessibilityGroupRole;
68 return [super moxRole];
71 - (NSArray*)moxLinkedUIElements {
72 return [self getRelationsByType:RelationType::LINKS_TO];
77 @implementation MOXListItemAccessible
79 - (NSString*)moxTitle {