зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1735970 part 1: Templatise ConvertToNSArray so it can take an array of Accessible*. r=morgan
Previously, there were variants for LocalAccessible and RemoteAccessible, but they did exactly the same thing anyway. We still need to support LocalAccessible and RemoteAccessible arrays, but we also want to support just Accessible. Use a template to allow for all three. Differential Revision: https://phabricator.services.mozilla.com/D141204
This commit is contained in:
Родитель
22f5f0d674
Коммит
4a2e6a75e3
|
@ -18,11 +18,8 @@ namespace a11y {
|
|||
namespace utils {
|
||||
|
||||
// convert an array of Gecko accessibles to an NSArray of native accessibles
|
||||
NSArray<mozAccessible*>* ConvertToNSArray(nsTArray<LocalAccessible*>& aArray);
|
||||
|
||||
// convert an array of Gecko proxy accessibles to an NSArray of native
|
||||
// accessibles
|
||||
NSArray<mozAccessible*>* ConvertToNSArray(nsTArray<RemoteAccessible*>& aArray);
|
||||
template <typename AccArray>
|
||||
NSArray<mozAccessible*>* ConvertToNSArray(AccArray& aArray);
|
||||
|
||||
/**
|
||||
* Get a localized string from the string bundle.
|
||||
|
|
|
@ -16,30 +16,12 @@ namespace a11y {
|
|||
namespace utils {
|
||||
|
||||
// convert an array of Gecko accessibles to an NSArray of native accessibles
|
||||
NSArray<mozAccessible*>* ConvertToNSArray(nsTArray<LocalAccessible*>& aArray) {
|
||||
template <typename AccArray>
|
||||
NSArray<mozAccessible*>* ConvertToNSArray(AccArray& aArray) {
|
||||
NSMutableArray* nativeArray = [[[NSMutableArray alloc] init] autorelease];
|
||||
|
||||
// iterate through the list, and get each native accessible.
|
||||
size_t totalCount = aArray.Length();
|
||||
for (size_t i = 0; i < totalCount; i++) {
|
||||
LocalAccessible* curAccessible = aArray.ElementAt(i);
|
||||
mozAccessible* curNative = GetNativeFromGeckoAccessible(curAccessible);
|
||||
if (curNative)
|
||||
[nativeArray addObject:GetObjectOrRepresentedView(curNative)];
|
||||
}
|
||||
|
||||
return nativeArray;
|
||||
}
|
||||
|
||||
// convert an array of Gecko proxy accessibles to an NSArray of native
|
||||
// accessibles
|
||||
NSArray<mozAccessible*>* ConvertToNSArray(nsTArray<RemoteAccessible*>& aArray) {
|
||||
NSMutableArray* nativeArray = [[[NSMutableArray alloc] init] autorelease];
|
||||
|
||||
// iterate through the list, and get each native accessible.
|
||||
size_t totalCount = aArray.Length();
|
||||
for (size_t i = 0; i < totalCount; i++) {
|
||||
RemoteAccessible* curAccessible = aArray.ElementAt(i);
|
||||
for (Accessible* curAccessible : aArray) {
|
||||
mozAccessible* curNative = GetNativeFromGeckoAccessible(curAccessible);
|
||||
if (curNative)
|
||||
[nativeArray addObject:GetObjectOrRepresentedView(curNative)];
|
||||
|
|
Загрузка…
Ссылка в новой задаче