Skip to content

Commit 8f5a8f7

Browse files
author
Alexander Zuev
committed
8264293: Create implementation for NSAccessibilityMenu protocol peer
8264296: Create implementation for NSAccessibilityPopUpButton protocol peer 8264295: Create implementation for NSAccessibilityMenuItem protocol peer 8264294: Create implementation for NSAccessibilityMenuBar protocol peer Reviewed-by: pbansal, ant
1 parent 9f2f46e commit 8f5a8f7

8 files changed

+310
-49
lines changed

Diff for: src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m

-48
Original file line numberDiff line numberDiff line change
@@ -1516,54 +1516,6 @@ - (id)accessibilityFocusedUIElement
15161516
JNI_COCOA_EXIT(env);
15171517
}
15181518

1519-
/*
1520-
* Class: sun_lwawt_macosx_CAccessible
1521-
* Method: menuOpened
1522-
* Signature: (I)V
1523-
*/
1524-
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuOpened
1525-
(JNIEnv *env, jclass jklass, jlong element)
1526-
{
1527-
JNI_COCOA_ENTER(env);
1528-
[ThreadUtilities performOnMainThread:@selector(postMenuOpened)
1529-
on:(JavaComponentAccessibility *)jlong_to_ptr(element)
1530-
withObject:nil
1531-
waitUntilDone:NO];
1532-
JNI_COCOA_EXIT(env);
1533-
}
1534-
1535-
/*
1536-
* Class: sun_lwawt_macosx_CAccessible
1537-
* Method: menuClosed
1538-
* Signature: (I)V
1539-
*/
1540-
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuClosed
1541-
(JNIEnv *env, jclass jklass, jlong element)
1542-
{
1543-
JNI_COCOA_ENTER(env);
1544-
[ThreadUtilities performOnMainThread:@selector(postMenuClosed)
1545-
on:(JavaComponentAccessibility *)jlong_to_ptr(element)
1546-
withObject:nil
1547-
waitUntilDone:NO];
1548-
JNI_COCOA_EXIT(env);
1549-
}
1550-
1551-
/*
1552-
* Class: sun_lwawt_macosx_CAccessible
1553-
* Method: menuItemSelected
1554-
* Signature: (I)V
1555-
*/
1556-
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuItemSelected
1557-
(JNIEnv *env, jclass jklass, jlong element)
1558-
{
1559-
JNI_COCOA_ENTER(env);
1560-
[ThreadUtilities performOnMainThread:@selector(postMenuItemSelected)
1561-
on:(JavaComponentAccessibility *)jlong_to_ptr(element)
1562-
withObject:nil
1563-
waitUntilDone:NO];
1564-
JNI_COCOA_EXIT(env);
1565-
}
1566-
15671519
/*
15681520
* Class: sun_lwawt_macosx_CAccessible
15691521
* Method: unregisterFromCocoaAXSystem

Diff for: src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/CommonComponentAccessibility.m

+53-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ + (void) initializeRolesMap {
122122
/*
123123
* Here we should keep all the mapping between the accessibility roles and implementing classes
124124
*/
125-
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:46];
125+
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:50];
126126

127127
[rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"];
128128
[rolesMap setObject:@"ImageAccessibility" forKey:@"icon"];
@@ -152,6 +152,10 @@ + (void) initializeRolesMap {
152152
[rolesMap setObject:@"ListAccessibility" forKey:@"list"];
153153
[rolesMap setObject:@"OutlineAccessibility" forKey:@"tree"];
154154
[rolesMap setObject:@"TableAccessibility" forKey:@"table"];
155+
[rolesMap setObject:@"MenuBarAccessibility" forKey:@"menubar"];
156+
[rolesMap setObject:@"MenuAccessibility" forKey:@"menu"];
157+
[rolesMap setObject:@"MenuItemAccessibility" forKey:@"menuitem"];
158+
[rolesMap setObject:@"MenuAccessibility" forKey:@"popupmenu"];
155159

156160
/*
157161
* All the components below should be ignored by the accessibility subsystem,
@@ -1253,3 +1257,51 @@ - (BOOL)accessibilityPerformIncrement {
12531257
waitUntilDone:NO];
12541258
JNI_COCOA_EXIT(env);
12551259
}
1260+
1261+
/*
1262+
* Class: sun_lwawt_macosx_CAccessible
1263+
* Method: menuOpened
1264+
* Signature: (I)V
1265+
*/
1266+
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuOpened
1267+
(JNIEnv *env, jclass jklass, jlong element)
1268+
{
1269+
JNI_COCOA_ENTER(env);
1270+
[ThreadUtilities performOnMainThread:@selector(postMenuOpened)
1271+
on:(CommonComponentAccessibility *)jlong_to_ptr(element)
1272+
withObject:nil
1273+
waitUntilDone:NO];
1274+
JNI_COCOA_EXIT(env);
1275+
}
1276+
1277+
/*
1278+
* Class: sun_lwawt_macosx_CAccessible
1279+
* Method: menuClosed
1280+
* Signature: (I)V
1281+
*/
1282+
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuClosed
1283+
(JNIEnv *env, jclass jklass, jlong element)
1284+
{
1285+
JNI_COCOA_ENTER(env);
1286+
[ThreadUtilities performOnMainThread:@selector(postMenuClosed)
1287+
on:(CommonComponentAccessibility *)jlong_to_ptr(element)
1288+
withObject:nil
1289+
waitUntilDone:NO];
1290+
JNI_COCOA_EXIT(env);
1291+
}
1292+
1293+
/*
1294+
* Class: sun_lwawt_macosx_CAccessible
1295+
* Method: menuItemSelected
1296+
* Signature: (I)V
1297+
*/
1298+
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuItemSelected
1299+
(JNIEnv *env, jclass jklass, jlong element)
1300+
{
1301+
JNI_COCOA_ENTER(env);
1302+
[ThreadUtilities performOnMainThread:@selector(postMenuItemSelected)
1303+
on:(CommonComponentAccessibility *)jlong_to_ptr(element)
1304+
withObject:nil
1305+
waitUntilDone:NO];
1306+
JNI_COCOA_EXIT(env);
1307+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
#import "CommonComponentAccessibility.h"
27+
#import "GroupAccessibility.h"
28+
29+
#import <AppKit/AppKit.h>
30+
31+
@interface MenuAccessibility : GroupAccessibility {
32+
33+
};
34+
- (NSAccessibilityRole _Nonnull)accessibilityRole;
35+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
#import "MenuAccessibility.h"
27+
28+
/*
29+
* Implementing a protocol that represents menus both as submenu and as a
30+
* MenuBar components
31+
*/
32+
@implementation MenuAccessibility
33+
- (NSAccessibilityRole _Nonnull)accessibilityRole
34+
{
35+
return [[[self parent] javaRole] isEqualToString:@"combobox"]
36+
? NSAccessibilityPopUpButtonRole
37+
: NSAccessibilityMenuRole;
38+
}
39+
40+
- (BOOL)isAccessibilityElement
41+
{
42+
return YES;
43+
}
44+
45+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
#import "CommonComponentAccessibility.h"
27+
28+
#import <AppKit/AppKit.h>
29+
30+
@interface MenuBarAccessibility : CommonComponentAccessibility {
31+
32+
};
33+
- (NSAccessibilityRole _Nonnull)accessibilityRole;
34+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
#import "MenuBarAccessibility.h"
27+
#import "JNIUtilities.h"
28+
#import "ThreadUtilities.h"
29+
#import "sun_lwawt_macosx_CAccessibility.h"
30+
31+
/*
32+
* This is the protocol for the Menu Bar component
33+
*/
34+
@implementation MenuBarAccessibility
35+
- (NSAccessibilityRole _Nonnull)accessibilityRole
36+
{
37+
return NSAccessibilityMenuBarRole;
38+
}
39+
40+
- (BOOL)isAccessibilityElement
41+
{
42+
return YES;
43+
}
44+
45+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
#import "CommonComponentAccessibility.h"
27+
#import "ButtonAccessibility.h"
28+
29+
#import <AppKit/AppKit.h>
30+
31+
@interface MenuItemAccessibility : ButtonAccessibility {
32+
33+
};
34+
- (NSAccessibilityRole _Nonnull)accessibilityRole;
35+
- (void)handleAction:(NSMenuItem * _Nonnull)sender;
36+
@end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation. Oracle designates this
8+
* particular file as subject to the "Classpath" exception as provided
9+
* by Oracle in the LICENSE file that accompanied this code.
10+
*
11+
* This code is distributed in the hope that it will be useful, but WITHOUT
12+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
* version 2 for more details (a copy is included in the LICENSE file that
15+
* accompanied this code).
16+
*
17+
* You should have received a copy of the GNU General Public License version
18+
* 2 along with this work; if not, write to the Free Software Foundation,
19+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
*
21+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
* or visit www.oracle.com if you need additional information or have any
23+
* questions.
24+
*/
25+
26+
#import "MenuItemAccessibility.h"
27+
28+
/*
29+
* This is the protocol for the MenuItem component.
30+
*/
31+
@implementation MenuItemAccessibility
32+
- (NSAccessibilityRole _Nonnull)accessibilityRole
33+
{
34+
return NSAccessibilityMenuItemRole;
35+
}
36+
37+
- (BOOL)isAccessibilityElement
38+
{
39+
return YES;
40+
}
41+
42+
- (BOOL)accessibilityPerformPick
43+
{
44+
return [self performAccessibleAction:0];
45+
}
46+
47+
- (BOOL)accessibilityPerformPress
48+
{
49+
return [self performAccessibleAction:0];
50+
}
51+
52+
- (NSString * _Nullable)accessibilityLabel
53+
{
54+
return [super accessibilityLabel];
55+
}
56+
57+
- (id _Nullable)accessibilityValue
58+
{
59+
return [super accessibilityValue];
60+
}
61+
62+
@end

0 commit comments

Comments
 (0)