mirror of
https://github.com/openjdk/jdk.git
synced 2026-05-12 06:29:37 +00:00
8256110: Create implementation for NSAccessibilityStepper protocol
Reviewed-by: pbansal, serb
This commit is contained in:
parent
5f2e280cab
commit
5dc5d9401e
@ -24,10 +24,6 @@
|
||||
*/
|
||||
|
||||
#import "ButtonAccessibility.h"
|
||||
#import "JNIUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
|
||||
static jclass sjc_CAccessibility = NULL;
|
||||
|
||||
/*
|
||||
* Implementation of the accessibility peer for the pushbutton role
|
||||
@ -40,17 +36,7 @@ static jclass sjc_CAccessibility = NULL;
|
||||
|
||||
- (BOOL)accessibilityPerformPress
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(FALSE);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_doAccessibleAction, sjc_CAccessibility, "doAccessibleAction",
|
||||
"(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V", FALSE);
|
||||
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_doAccessibleAction,
|
||||
[self axContextWithEnv:(env)], 0, fComponent);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
return TRUE;
|
||||
return [self performAccessibleAction:0];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -36,6 +36,7 @@
|
||||
+ (JavaComponentAccessibility * _Nullable) getComponentAccessibility:(NSString * _Nonnull)role;
|
||||
- (NSRect)accessibilityFrame;
|
||||
- (nullable id)accessibilityParent;
|
||||
- (BOOL)performAccessibleAction:(int)index;
|
||||
@end
|
||||
|
||||
#endif
|
||||
|
||||
@ -46,11 +46,13 @@ static NSMutableDictionary * _Nullable rolesMap;
|
||||
/*
|
||||
* Here we should keep all the mapping between the accessibility roles and implementing classes
|
||||
*/
|
||||
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:3];
|
||||
rolesMap = [[NSMutableDictionary alloc] initWithCapacity:4];
|
||||
|
||||
[rolesMap setObject:@"ButtonAccessibility" forKey:@"pushbutton"];
|
||||
[rolesMap setObject:@"ImageAccessibility" forKey:@"icon"];
|
||||
[rolesMap setObject:@"ImageAccessibility" forKey:@"desktopicon"];
|
||||
[rolesMap setObject:@"SpinboxAccessibility" forKey:@"spinbox"];
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -60,7 +62,6 @@ static NSMutableDictionary * _Nullable rolesMap;
|
||||
+ (JavaComponentAccessibility *) getComponentAccessibility:(NSString *)role
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
|
||||
if (rolesMap == nil) {
|
||||
[self initializeRolesMap];
|
||||
}
|
||||
@ -97,4 +98,20 @@ static NSMutableDictionary * _Nullable rolesMap;
|
||||
return [self accessibilityParentAttribute];
|
||||
}
|
||||
|
||||
// AccessibleAction support
|
||||
- (BOOL)performAccessibleAction:(int)index
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
GET_CACCESSIBILITY_CLASS_RETURN(FALSE);
|
||||
DECLARE_STATIC_METHOD_RETURN(jm_doAccessibleAction, sjc_CAccessibility, "doAccessibleAction",
|
||||
"(Ljavax/accessibility/AccessibleAction;ILjava/awt/Component;)V", FALSE);
|
||||
(*env)->CallStaticVoidMethod(env, sjc_CAccessibility, jm_doAccessibleAction,
|
||||
[self axContextWithEnv:(env)], index, fComponent);
|
||||
CHECK_EXCEPTION();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#import "JavaComponentAccessibility.h"
|
||||
#import "CommonComponentAccessibility.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
@interface SpinboxAccessibility : CommonComponentAccessibility <NSAccessibilityStepper> {
|
||||
|
||||
};
|
||||
|
||||
- (nullable NSString *)accessibilityLabel;
|
||||
- (nullable id)accessibilityValue;
|
||||
- (BOOL)accessibilityPerformDecrement;
|
||||
- (BOOL)accessibilityPerformIncrement;
|
||||
@end
|
||||
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
#import "SpinboxAccessibility.h"
|
||||
|
||||
#define INCREMENT 0
|
||||
#define DECREMENT 1
|
||||
|
||||
/*
|
||||
* Implementation of the accessibility peer for the spinner role
|
||||
*/
|
||||
@implementation SpinboxAccessibility
|
||||
- (nullable NSString *)accessibilityLabel
|
||||
{
|
||||
return [self accessibilityTitleAttribute];
|
||||
}
|
||||
|
||||
- (nullable id)accessibilityValue
|
||||
{
|
||||
return [self accessibilityValueAttribute];
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityPerformIncrement
|
||||
{
|
||||
return [self performAccessibleAction:INCREMENT];
|
||||
}
|
||||
|
||||
|
||||
- (BOOL)accessibilityPerformDecrement
|
||||
{
|
||||
return [self performAccessibleAction:DECREMENT];
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
x
Reference in New Issue
Block a user