Bug 1769547 - Do not MOZ_CRASH() on missing process r=nika
[gecko.git] / accessible / mac / MacUtils.h
blob3f095a7996a2523efa6fadb847f6e385e734dd0b
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 #ifndef _MacUtils_H_
9 #define _MacUtils_H_
11 #include "nsStringFwd.h"
13 @class NSString;
14 @class mozAccessible;
16 namespace mozilla {
17 namespace a11y {
18 namespace utils {
20 // convert an array of Gecko accessibles to an NSArray of native accessibles
21 template <typename AccArray>
22 NSArray<mozAccessible*>* ConvertToNSArray(AccArray& aArray) {
23 NSMutableArray* nativeArray = [[[NSMutableArray alloc] init] autorelease];
25 // iterate through the list, and get each native accessible.
26 for (Accessible* curAccessible : aArray) {
27 mozAccessible* curNative = GetNativeFromGeckoAccessible(curAccessible);
28 if (curNative)
29 [nativeArray addObject:GetObjectOrRepresentedView(curNative)];
32 return nativeArray;
35 /**
36 * Get a localized string from the string bundle.
37 * Return nil if not found.
39 NSString* LocalizedString(const nsString& aString);
41 /**
42 * Gets an accessible atttribute from the mozAccessible's associated
43 * accessible wrapper or proxy, and returns the value as an NSString.
44 * nil if no attribute is found.
46 NSString* GetAccAttr(mozAccessible* aNativeAccessible, nsAtom* aAttrName);
51 #endif