36
36
" (Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleComponent;" , ret);
37
37
38
38
static NSMutableDictionary * _Nullable rolesMap;
39
+ NSString *const IgnoreClassName = @" IgnoreAccessibility" ;
40
+ static jobject sAccessibilityClass = NULL ;
39
41
40
42
/*
41
43
* Common ancestor for all the accessibility peers that implements the new method-based accessibility API
@@ -46,7 +48,7 @@ + (void) initializeRolesMap {
46
48
/*
47
49
* Here we should keep all the mapping between the accessibility roles and implementing classes
48
50
*/
49
- rolesMap = [[NSMutableDictionary alloc ] initWithCapacity: 8 ];
51
+ rolesMap = [[NSMutableDictionary alloc ] initWithCapacity: 26 ];
50
52
51
53
[rolesMap setObject: @" ButtonAccessibility" forKey: @" pushbutton" ];
52
54
[rolesMap setObject: @" ImageAccessibility" forKey: @" icon" ];
@@ -56,6 +58,63 @@ + (void) initializeRolesMap {
56
58
[rolesMap setObject: @" StaticTextAccessibility" forKey: @" label" ];
57
59
[rolesMap setObject: @" RadiobuttonAccessibility" forKey: @" radiobutton" ];
58
60
[rolesMap setObject: @" CheckboxAccessibility" forKey: @" checkbox" ];
61
+
62
+ /*
63
+ * All the components below should be ignored by the accessibility subsystem,
64
+ * If any of the enclosed component asks for a parent the first ancestor
65
+ * participating in accessibility exchange should be returned.
66
+ */
67
+ [rolesMap setObject: IgnoreClassName forKey: @" alert" ];
68
+ [rolesMap setObject: IgnoreClassName forKey: @" colorchooser" ];
69
+ [rolesMap setObject: IgnoreClassName forKey: @" desktoppane" ];
70
+ [rolesMap setObject: IgnoreClassName forKey: @" dialog" ];
71
+ [rolesMap setObject: IgnoreClassName forKey: @" directorypane" ];
72
+ [rolesMap setObject: IgnoreClassName forKey: @" filechooser" ];
73
+ [rolesMap setObject: IgnoreClassName forKey: @" filler" ];
74
+ [rolesMap setObject: IgnoreClassName forKey: @" fontchooser" ];
75
+ [rolesMap setObject: IgnoreClassName forKey: @" frame" ];
76
+ [rolesMap setObject: IgnoreClassName forKey: @" glasspane" ];
77
+ [rolesMap setObject: IgnoreClassName forKey: @" layeredpane" ];
78
+ [rolesMap setObject: IgnoreClassName forKey: @" optionpane" ];
79
+ [rolesMap setObject: IgnoreClassName forKey: @" panel" ];
80
+ [rolesMap setObject: IgnoreClassName forKey: @" rootpane" ];
81
+ [rolesMap setObject: IgnoreClassName forKey: @" separator" ];
82
+ [rolesMap setObject: IgnoreClassName forKey: @" tooltip" ];
83
+ [rolesMap setObject: IgnoreClassName forKey: @" viewport" ];
84
+ [rolesMap setObject: IgnoreClassName forKey: @" window" ];
85
+
86
+ /*
87
+ * Initialize CAccessibility instance
88
+ */
89
+ #ifdef JAVA_AX_NO_IGNORES
90
+ NSArray *ignoredKeys = [NSArray array ];
91
+ #else
92
+ NSArray *ignoredKeys = [rolesMap allKeysForObject: IgnoreClassName];
93
+ #endif
94
+
95
+ JNIEnv *env = [ThreadUtilities getJNIEnv ];
96
+ GET_CACCESSIBILITY_CLASS ();
97
+ DECLARE_STATIC_METHOD (jm_getAccessibility, sjc_CAccessibility, " getAccessibility" , " ([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;" );
98
+ jobjectArray result = NULL ;
99
+ jsize count = [ignoredKeys count ];
100
+
101
+ DECLARE_CLASS (jc_String, " java/lang/String" );
102
+ result = (*env)->NewObjectArray (env, count, jc_String, NULL );
103
+ CHECK_EXCEPTION ();
104
+ if (!result) {
105
+ NSLog (@" In %s , can't create Java array of String objects" , __FUNCTION__);
106
+ return ;
107
+ }
108
+
109
+ NSInteger i;
110
+ for (i = 0 ; i < count; i++) {
111
+ jstring jString = NSStringToJavaString(env, [ignoredKeys objectAtIndex: i]);
112
+ (*env)->SetObjectArrayElement (env, result, i, jString);
113
+ (*env)->DeleteLocalRef (env, jString);
114
+ }
115
+
116
+ sAccessibilityClass = (*env)->CallStaticObjectMethod (env, sjc_CAccessibility, jm_getAccessibility, result);
117
+ CHECK_EXCEPTION ();
59
118
}
60
119
61
120
/*
@@ -117,4 +176,8 @@ - (BOOL)performAccessibleAction:(int)index
117
176
return TRUE ;
118
177
}
119
178
179
+ - (BOOL )isAccessibilityElement {
180
+ return YES ;
181
+ }
182
+
120
183
@end
0 commit comments