no bug - Correct some typos in the comments. a=typo-fix
[gecko.git] / accessible / mac / mozHTMLAccessible.mm
blob09680033419f79127a70c1bcc0d388d5338784db
1 /* clang-format off */
2 /* -*- Mode: Objective-C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
3 /* clang-format on */
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 {
20   nsAutoString title;
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.
26     return nil;
27   }
29   return nsCocoaUtils::ToNSString(title);
32 - (id)moxValue {
33   GroupPos groupPos = mGeckoAccessible->GroupPosition();
35   return [NSNumber numberWithInt:groupPos.level];
38 @end
40 @implementation mozLinkAccessible
42 - (NSString*)moxValue {
43   return @"";
46 - (NSURL*)moxURL {
47   nsAutoString value;
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;
66   }
68   return [super moxRole];
71 - (NSArray*)moxLinkedUIElements {
72   return [self getRelationsByType:RelationType::LINKS_TO];
75 @end
77 @implementation MOXListItemAccessible
79 - (NSString*)moxTitle {
80   return @"";
83 @end