Skip to content
Permalink
Browse files
8256110: Create implementation for NSAccessibilityStepper protocol
Reviewed-by: pbansal, serb
  • Loading branch information
Alexander Zuev committed Jan 17, 2021
1 parent 5f2e280 commit 5dc5d9401e7a176da53a14293fb59e97b644b31a
@@ -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 @@ - (nullable NSString *)accessibilityLabel

- (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 @@ + (void) initializeRolesMap {
/*
* 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 @@ + (void) initializeRolesMap {
+ (JavaComponentAccessibility *) getComponentAccessibility:(NSString *)role
{
AWT_ASSERT_APPKIT_THREAD;

if (rolesMap == nil) {
[self initializeRolesMap];
}
@@ -97,4 +98,20 @@ - (nullable id)accessibilityParent
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

1 comment on commit 5dc5d94

@openjdk-notifier

This comment has been minimized.

Copy link

@openjdk-notifier openjdk-notifier bot commented on 5dc5d94 Jan 17, 2021

Please sign in to comment.