Bug 1777562 [wpt PR 34663] - [FedCM] Rename FederatedCredential to IdentityCredential...
[gecko.git] / accessible / mac / mozHTMLAccessible.mm
blob5465f578a8a567c5342ada3ec531de15a3707f73
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;
21   if (LocalAccessible* acc = mGeckoAccessible->AsLocal()) {
22     mozilla::ErrorResult rv;
23     // XXX use the flattening API when there are available
24     // see bug 768298
25     acc->GetContent()->GetTextContent(title, rv);
26   } else if (RemoteAccessible* proxy = mGeckoAccessible->AsRemote()) {
27     proxy->Title(title);
28   }
30   title.CompressWhitespace();
32   return nsCocoaUtils::ToNSString(title);
35 - (id)moxValue {
36   GroupPos groupPos = mGeckoAccessible->GroupPosition();
38   return [NSNumber numberWithInt:groupPos.level];
41 @end
43 @implementation mozLinkAccessible
45 - (NSString*)moxValue {
46   return @"";
49 - (NSURL*)moxURL {
50   nsAutoString value;
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;
69   }
71   return [super moxRole];
74 - (NSArray*)moxLinkedUIElements {
75   return [self getRelationsByType:RelationType::LINKS_TO];
78 @end
80 @implementation MOXListItemAccessible
82 - (NSString*)moxTitle {
83   return @"";
86 @end