Skip to content

Commit c7091e1

Browse files
Alexander Zuevarapte
authored andcommitted
8313556: Create implementation of NSAccessibilitySlider protocol
8313558: Create implementation of NSAccessibilityStepper protocol Reviewed-by: arapte, angorya
1 parent 0a20fef commit c7091e1

File tree

6 files changed

+276
-3
lines changed

6 files changed

+276
-3
lines changed

modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626
#import <Cocoa/Cocoa.h>
2727
#import <jni.h>
2828

29+
#define INCREMENT @"AXIncrement"
30+
#define DECREMENT @"AXDecrement"
31+
2932
@interface AccessibleBase : NSAccessibilityElement {
3033
@private
3134
jobject jAccessible;

modules/javafx.graphics/src/main/native-glass/mac/a11y/AccessibleBase.m

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ + (void) initializeRolesMap {
4040
* All JavaFX roles and corresponding available properties are defined in
4141
* enum javafx.scene.AccessibleRole
4242
*/
43-
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:9];
43+
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:11];
4444

4545
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"BUTTON"];
4646
[rolesMap setObject:@"JFXButtonAccessibility" forKey:@"DECREMENT_BUTTON"];
@@ -53,6 +53,8 @@ + (void) initializeRolesMap {
5353
[rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"CHECK_BOX"];
5454
[rolesMap setObject:@"JFXCheckboxAccessibility" forKey:@"TOGGLE_BUTTON"];
5555
[rolesMap setObject:@"JFXStaticTextAccessibility" forKey:@"TEXT"];
56+
[rolesMap setObject:@"JFXStepperAccessibility" forKey:@"SPINNER"];
57+
[rolesMap setObject:@"JFXSliderAccessibility" forKey:@"SLIDER"];
5658

5759
}
5860

@@ -105,16 +107,35 @@ - (id)accessibilityValue
105107
return variantToID(env, jresult);
106108
}
107109

108-
- (NSString *)accessibilityLabel
110+
- (id)accessibilityMinValue
111+
{
112+
jobject jresult = NULL;
113+
GET_MAIN_JENV;
114+
if (env == NULL) return NULL;
115+
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible,
116+
jAccessibilityAttributeValue, (jlong)@"AXMinValue");
117+
GLASS_CHECK_EXCEPTION(env);
118+
return variantToID(env, jresult);
119+
}
120+
121+
- (id)accessibilityMaxValue
109122
{
110123
jobject jresult = NULL;
111124
GET_MAIN_JENV;
112125
if (env == NULL) return NULL;
113-
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, jAccessibilityAttributeValue, (jlong)@"AXTitle");
126+
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible,
127+
jAccessibilityAttributeValue, (jlong)@"AXMaxValue");
114128
GLASS_CHECK_EXCEPTION(env);
115129
return variantToID(env, jresult);
116130
}
117131

132+
- (NSString *)accessibilityLabel
133+
{
134+
// Use the same value that is set for accessibilityTitle - some component
135+
// do not have titles and request it as a label
136+
return [self accessibilityTitle];
137+
}
138+
118139
- (id)accessibilityParent
119140
{
120141
if (parent == nil) {
@@ -129,6 +150,30 @@ - (id)accessibilityParent
129150
return parent;
130151
}
131152

153+
- (id)accessibilityTitle
154+
{
155+
jobject jresult = NULL;
156+
GET_MAIN_JENV;
157+
if (env == NULL) return NULL;
158+
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible,
159+
jAccessibilityAttributeValue, (jlong)@"AXTitle");
160+
GLASS_CHECK_EXCEPTION(env);
161+
return variantToID(env, jresult);
162+
}
163+
164+
- (id)accessibilityTitleUIElement
165+
{
166+
jobject jresult = NULL;
167+
GET_MAIN_JENV;
168+
if (env == NULL) return NULL;
169+
jresult = (jobject)(*env)->CallLongMethod(env, self->jAccessible, jAccessibilityAttributeValue,
170+
(jlong)@"AXTitleUIElement");
171+
GLASS_CHECK_EXCEPTION(env);
172+
return variantToID(env, jresult);
173+
}
174+
175+
176+
132177
// Actions support
133178
- (BOOL)performAccessibleAction:(NSString *)action
134179
{
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2023, 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 "AccessibleBase.h"
27+
#import <AppKit/AppKit.h>
28+
29+
@interface JFXSliderAccessibility : AccessibleBase <NSAccessibilitySlider> {
30+
31+
};
32+
- (NSAccessibilityRole)accessibilityRole;
33+
- (NSString *)accessibilityLabel;
34+
- (id)accessibilityValue;
35+
- (BOOL)accessibilityPerformDecrement;
36+
- (BOOL)accessibilityPerformIncrement;
37+
@end
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2023, 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 "JFXSliderAccessibility.h"
27+
28+
/*
29+
* Implementation of the accessibility peer for the slider role
30+
*/
31+
32+
@implementation JFXSliderAccessibility
33+
- (NSAccessibilityRole)accessibilityRole
34+
{
35+
return NSAccessibilitySliderRole;
36+
}
37+
38+
- (NSString *)accessibilityLabel
39+
{
40+
return [super accessibilityLabel];
41+
}
42+
43+
- (id)accessibilityValue
44+
{
45+
return [super accessibilityValue];
46+
}
47+
48+
- (id)accessibilityTitle
49+
{
50+
return [super accessibilityTitle];
51+
}
52+
53+
- (BOOL)accessibilityPerformIncrement
54+
{
55+
return [self performAccessibleAction:INCREMENT];
56+
}
57+
58+
- (BOOL)accessibilityPerformDecrement
59+
{
60+
return [self performAccessibleAction:DECREMENT];
61+
}
62+
63+
- (NSRect)accessibilityFrame
64+
{
65+
return [super accessibilityFrame];
66+
}
67+
68+
- (id)accessibilityParent
69+
{
70+
return [super accessibilityParent];
71+
}
72+
73+
@end
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright (c) 2023, 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 "AccessibleBase.h"
27+
#import <AppKit/AppKit.h>
28+
29+
@interface JFXStepperAccessibility : AccessibleBase <NSAccessibilityStepper> {
30+
31+
};
32+
- (NSAccessibilityRole)accessibilityRole;
33+
- (NSString *)accessibilityLabel;
34+
- (id)accessibilityValue;
35+
- (BOOL)accessibilityPerformDecrement;
36+
- (BOOL)accessibilityPerformIncrement;
37+
@end
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/*
2+
* Copyright (c) 2023, 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 "JFXStepperAccessibility.h"
27+
28+
/*
29+
* Implementation of the accessibility peer for the stepper role
30+
*/
31+
32+
@implementation JFXStepperAccessibility
33+
- (NSAccessibilityRole)accessibilityRole
34+
{
35+
return NSAccessibilityIncrementorRole;
36+
}
37+
38+
- (NSString *)accessibilityLabel
39+
{
40+
return [super accessibilityLabel];
41+
}
42+
43+
- (id)accessibilityValue
44+
{
45+
return [super accessibilityValue];
46+
}
47+
48+
- (id)accessibilityMinValue
49+
{
50+
return [super accessibilityMinValue];
51+
}
52+
53+
- (id)accessibilityMaxValue
54+
{
55+
return [super accessibilityMaxValue];
56+
}
57+
58+
- (BOOL)accessibilityPerformIncrement
59+
{
60+
return [self performAccessibleAction:INCREMENT];
61+
}
62+
63+
- (BOOL)accessibilityPerformDecrement
64+
{
65+
return [self performAccessibleAction:DECREMENT];
66+
}
67+
68+
- (NSRect)accessibilityFrame
69+
{
70+
return [super accessibilityFrame];
71+
}
72+
73+
- (id)accessibilityParent
74+
{
75+
return [super accessibilityParent];
76+
}
77+
78+
@end

0 commit comments

Comments
 (0)