mozHTMLAccessible.mm (2010B)
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/. */ 7 8 #import "mozHTMLAccessible.h" 9 10 #import "LocalAccessible-inl.h" 11 #import "HyperTextAccessible.h" 12 13 #import "nsCocoaUtils.h" 14 15 using namespace mozilla::a11y; 16 17 @implementation mozHeadingAccessible 18 19 - (NSString*)moxTitle { 20 nsAutoString title; 21 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 } 28 29 return nsCocoaUtils::ToNSString(title); 30 } 31 32 - (id)moxValue { 33 GroupPos groupPos = mGeckoAccessible->GroupPosition(); 34 35 return [NSNumber numberWithInt:groupPos.level]; 36 } 37 38 @end 39 40 @implementation mozLinkAccessible 41 42 - (NSString*)moxValue { 43 return @""; 44 } 45 46 - (NSURL*)moxURL { 47 nsAutoString value; 48 mGeckoAccessible->Value(value); 49 50 NSString* urlString = value.IsEmpty() ? nil : nsCocoaUtils::ToNSString(value); 51 if (!urlString) return nil; 52 53 return [NSURL URLWithString:urlString]; 54 } 55 56 - (NSNumber*)moxVisited { 57 return @([self stateWithMask:states::TRAVERSED] != 0); 58 } 59 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 } 67 68 return [super moxRole]; 69 } 70 71 - (NSArray*)moxLinkedUIElements { 72 return [self getRelationsByType:RelationType::LINKS_TO]; 73 } 74 75 @end 76 77 @implementation MOXListItemAccessible 78 79 - (NSString*)moxTitle { 80 return @""; 81 } 82 83 @end 84 85 @implementation MOXLabelAccessible 86 87 - (NSString*)moxTitle { 88 return @""; 89 } 90 91 @end