mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-26 03:09:41 +01:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
cc754d6d76 | ||
|
|
0c3b4bf9b7 | ||
|
|
216bf92575 | ||
|
|
4c6f3e4510 | ||
|
|
8d74e8e30b | ||
|
|
f4a8e51d4a | ||
|
|
db9032755a | ||
|
|
db017fbd56 | ||
|
|
479ceadb35 | ||
|
|
ad1d5061a9 | ||
|
|
ff0a538ebd | ||
|
|
c81adfed61 | ||
|
|
2ccf6b65a7 | ||
|
|
a34eeb7735 | ||
|
|
ba6b9c085e |
@@ -1354,18 +1354,109 @@ static int _print_module(const char* fname, address base_address,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static errno_t convert_to_UTF16(char const* source_str, UINT source_encoding, LPWSTR* dest_utf16_str) {
|
||||
const int flag_source_str_is_null_terminated = -1;
|
||||
const int flag_estimate_chars_count = 0;
|
||||
int utf16_chars_count_estimated = MultiByteToWideChar(source_encoding,
|
||||
MB_ERR_INVALID_CHARS,
|
||||
source_str, flag_source_str_is_null_terminated,
|
||||
NULL, flag_estimate_chars_count);
|
||||
if (utf16_chars_count_estimated == 0) {
|
||||
// Probably source_str contains characters that cannot be represented in the source_encoding given.
|
||||
*dest_utf16_str = NULL;
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
*dest_utf16_str = NEW_C_HEAP_ARRAY(WCHAR, utf16_chars_count_estimated, mtInternal);
|
||||
|
||||
int utf16_chars_count_real = MultiByteToWideChar(source_encoding,
|
||||
MB_ERR_INVALID_CHARS,
|
||||
source_str, flag_source_str_is_null_terminated,
|
||||
*dest_utf16_str, utf16_chars_count_estimated);
|
||||
assert(utf16_chars_count_real == utf16_chars_count_estimated, "length already checked above");
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
// Converts a string in the "platform" encoding to UTF16.
|
||||
static errno_t convert_to_UTF16(char const* platform_str, LPWSTR* utf16_str) {
|
||||
return convert_to_UTF16(platform_str, CP_ACP, utf16_str);
|
||||
}
|
||||
|
||||
static errno_t convert_UTF8_to_UTF16(char const* utf8_str, LPWSTR* utf16_str) {
|
||||
return convert_to_UTF16(utf8_str, CP_UTF8, utf16_str);
|
||||
}
|
||||
|
||||
// Converts a wide-character string in UTF-16 encoding to the 8-bit "platform" encoding.
|
||||
// Unless the platform encoding is UTF-8, not all characters in the source string can be represented in the dest string.
|
||||
// The function succeeds in this case anyway and just replaces these with a certain character.
|
||||
static errno_t convert_UTF16_to_platform(LPWSTR source_utf16_str, char*& dest_str) {
|
||||
const int flag_source_str_is_null_terminated = -1;
|
||||
const int flag_estimate_chars_count = 0;
|
||||
int chars_count_estimated = WideCharToMultiByte(CP_ACP,
|
||||
0,
|
||||
source_utf16_str, flag_source_str_is_null_terminated,
|
||||
NULL, flag_estimate_chars_count, NULL, NULL);
|
||||
if (chars_count_estimated == 0) {
|
||||
dest_str = NULL;
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
dest_str = NEW_C_HEAP_ARRAY(CHAR, chars_count_estimated, mtInternal);
|
||||
|
||||
int chars_count_real = WideCharToMultiByte(CP_ACP,
|
||||
0,
|
||||
source_utf16_str, flag_source_str_is_null_terminated,
|
||||
dest_str, chars_count_estimated, NULL, NULL);
|
||||
assert(chars_count_real == chars_count_estimated, "length already checked above");
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
class MemoryReleaserW : public StackObj {
|
||||
private:
|
||||
WCHAR* _object_ptr;
|
||||
|
||||
public:
|
||||
MemoryReleaserW(WCHAR * object_ptr) : _object_ptr(object_ptr) {}
|
||||
~MemoryReleaserW() { if (_object_ptr != NULL) FREE_C_HEAP_ARRAY(WCHAR, _object_ptr); }
|
||||
};
|
||||
|
||||
class MemoryReleaser : public StackObj {
|
||||
private:
|
||||
CHAR* _object_ptr;
|
||||
|
||||
public:
|
||||
MemoryReleaser(CHAR * object_ptr) : _object_ptr(object_ptr) {}
|
||||
~MemoryReleaser() { if (_object_ptr != NULL) FREE_C_HEAP_ARRAY(CHAR, _object_ptr); }
|
||||
};
|
||||
|
||||
// Loads .dll/.so and
|
||||
// in case of error it checks if .dll/.so was built for the
|
||||
// same architecture as Hotspot is running on
|
||||
void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
|
||||
log_info(os)("attempting shared library load of %s", name);
|
||||
// The name given is in UTF-8.
|
||||
void * os::dll_load(const char *utf8_name, char *ebuf, int ebuflen) {
|
||||
LPWSTR utf16_name = NULL;
|
||||
errno_t err = convert_UTF8_to_UTF16(utf8_name, &utf16_name);
|
||||
MemoryReleaserW release_utf16_name(utf16_name);
|
||||
if (err != ERROR_SUCCESS) {
|
||||
errno = err;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* platform_name = NULL; // name of the library converted to the "platform" encoding for use in log messages
|
||||
errno_t ignored_err = convert_UTF16_to_platform(utf16_name, platform_name);
|
||||
MemoryReleaser release_platform_name(platform_name);
|
||||
|
||||
log_info(os)("attempting shared library load of %s", platform_name);
|
||||
|
||||
void * result = LoadLibraryW(utf16_name);
|
||||
|
||||
void * result = LoadLibrary(name);
|
||||
if (result != NULL) {
|
||||
Events::log(NULL, "Loaded shared library %s", name);
|
||||
Events::log(NULL, "Loaded shared library %s", platform_name);
|
||||
// Recalculate pdb search path if a DLL was loaded successfully.
|
||||
SymbolEngine::recalc_search_path();
|
||||
log_info(os)("shared library load of %s was successful", name);
|
||||
log_info(os)("shared library load of %s was successful", platform_name);
|
||||
return result;
|
||||
}
|
||||
DWORD errcode = GetLastError();
|
||||
@@ -1373,8 +1464,8 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
|
||||
// It may or may not be overwritten below (in the for loop and just above)
|
||||
lasterror(ebuf, (size_t) ebuflen);
|
||||
ebuf[ebuflen - 1] = '\0';
|
||||
Events::log(NULL, "Loading shared library %s failed, error code %lu", name, errcode);
|
||||
log_info(os)("shared library load of %s failed, error code %lu", name, errcode);
|
||||
Events::log(NULL, "Loading shared library %s failed, error code %lu", platform_name, errcode);
|
||||
log_info(os)("shared library load of %s failed, error code %lu", platform_name, errcode);
|
||||
|
||||
if (errcode == ERROR_MOD_NOT_FOUND) {
|
||||
strncpy(ebuf, "Can't find dependent libraries", ebuflen - 1);
|
||||
@@ -1387,7 +1478,7 @@ void * os::dll_load(const char *name, char *ebuf, int ebuflen) {
|
||||
// for an architecture other than Hotspot is running in
|
||||
// - then print to buffer "DLL was built for a different architecture"
|
||||
// else call os::lasterror to obtain system error message
|
||||
int fd = ::open(name, O_RDONLY | O_BINARY, 0);
|
||||
int fd = ::wopen(utf16_name, O_RDONLY | O_BINARY, 0);
|
||||
if (fd < 0) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -4246,27 +4337,6 @@ static void file_attribute_data_to_stat(struct stat* sbuf, WIN32_FILE_ATTRIBUTE_
|
||||
}
|
||||
}
|
||||
|
||||
static errno_t convert_to_unicode(char const* char_path, LPWSTR* unicode_path) {
|
||||
// Get required buffer size to convert to Unicode
|
||||
int unicode_path_len = MultiByteToWideChar(CP_ACP,
|
||||
MB_ERR_INVALID_CHARS,
|
||||
char_path, -1,
|
||||
NULL, 0);
|
||||
if (unicode_path_len == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
*unicode_path = NEW_C_HEAP_ARRAY(WCHAR, unicode_path_len, mtInternal);
|
||||
|
||||
int result = MultiByteToWideChar(CP_ACP,
|
||||
MB_ERR_INVALID_CHARS,
|
||||
char_path, -1,
|
||||
*unicode_path, unicode_path_len);
|
||||
assert(result == unicode_path_len, "length already checked above");
|
||||
|
||||
return ERROR_SUCCESS;
|
||||
}
|
||||
|
||||
static errno_t get_full_path(LPCWSTR unicode_path, LPWSTR* full_path) {
|
||||
// Get required buffer size to convert to full path. The return
|
||||
// value INCLUDES the terminating null character.
|
||||
@@ -4327,7 +4397,7 @@ static wchar_t* wide_abs_unc_path(char const* path, errno_t & err, int additiona
|
||||
set_path_prefix(buf, &prefix, &prefix_off, &needs_fullpath);
|
||||
|
||||
LPWSTR unicode_path = NULL;
|
||||
err = convert_to_unicode(buf, &unicode_path);
|
||||
err = convert_to_UTF16(buf, &unicode_path);
|
||||
FREE_C_HEAP_ARRAY(char, buf);
|
||||
if (err != ERROR_SUCCESS) {
|
||||
return NULL;
|
||||
|
||||
@@ -3442,6 +3442,7 @@ JVM_END
|
||||
|
||||
// Library support ///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// The name of the library is in UTF8
|
||||
JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name))
|
||||
//%note jvm_ct
|
||||
JVMWrapper("JVM_LoadLibrary");
|
||||
@@ -3455,14 +3456,10 @@ JVM_ENTRY_NO_ENV(void*, JVM_LoadLibrary(const char* name))
|
||||
if (load_result == NULL) {
|
||||
char msg[1024];
|
||||
jio_snprintf(msg, sizeof msg, "%s: %s", name, ebuf);
|
||||
// Since 'ebuf' may contain a string encoded using
|
||||
// platform encoding scheme, we need to pass
|
||||
// Exceptions::unsafe_to_utf8 to the new_exception method
|
||||
// as the last argument. See bug 6367357.
|
||||
Handle h_exception =
|
||||
Exceptions::new_exception(thread,
|
||||
vmSymbols::java_lang_UnsatisfiedLinkError(),
|
||||
msg, Exceptions::unsafe_to_utf8);
|
||||
msg);
|
||||
|
||||
THROW_HANDLE_0(h_exception);
|
||||
}
|
||||
|
||||
@@ -113,6 +113,7 @@ inline int g_isfinite(jdouble f) { return _finite(f); }
|
||||
// Visual Studio 2005 deprecates POSIX names - use ISO C++ names instead
|
||||
#if _MSC_VER >= 1400
|
||||
#define open _open
|
||||
#define wopen _wopen
|
||||
#define close _close
|
||||
#define read _read
|
||||
#define write _write
|
||||
|
||||
@@ -338,7 +338,6 @@ JNIEXPORT jboolean JNICALL
|
||||
Java_java_lang_ClassLoader_00024NativeLibrary_load0
|
||||
(JNIEnv *env, jobject this, jstring name, jboolean isBuiltin)
|
||||
{
|
||||
const char *cname;
|
||||
jint jniVersion;
|
||||
jthrowable cause;
|
||||
void * handle;
|
||||
@@ -347,7 +346,8 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load0
|
||||
if (!initIDs(env))
|
||||
return JNI_FALSE;
|
||||
|
||||
cname = JNU_GetStringPlatformChars(env, name, 0);
|
||||
char cname_buf[128];
|
||||
char * cname = getUTF(env, name, cname_buf, sizeof(cname_buf));
|
||||
if (cname == 0)
|
||||
return JNI_FALSE;
|
||||
handle = isBuiltin ? procHandle : JVM_LoadLibrary(cname);
|
||||
@@ -400,7 +400,9 @@ Java_java_lang_ClassLoader_00024NativeLibrary_load0
|
||||
loaded = JNI_TRUE;
|
||||
|
||||
done:
|
||||
JNU_ReleaseStringPlatformChars(env, name, cname);
|
||||
if (cname != NULL && cname != cname_buf) {
|
||||
free(cname);
|
||||
}
|
||||
return loaded;
|
||||
}
|
||||
|
||||
|
||||
@@ -189,7 +189,10 @@ public final class CFont extends PhysicalFont implements FontSubstitution, FontW
|
||||
|
||||
protected synchronized long getNativeFontPtr() {
|
||||
if (nativeFontPtr == 0L) {
|
||||
nativeFontPtr = createNativeFont(nativeFontName, style);
|
||||
/* Do not try to create native italic font when isFakeItalic
|
||||
* is true, otherwise we can make it italic twice */
|
||||
nativeFontPtr = createNativeFont(nativeFontName, style &
|
||||
(isFakeItalic ? ~Font.ITALIC : -1));
|
||||
}
|
||||
return nativeFontPtr;
|
||||
}
|
||||
|
||||
@@ -467,7 +467,7 @@ class CAccessibility implements PropertyChangeListener {
|
||||
}, c);
|
||||
}
|
||||
|
||||
public static void requestSelection(final Accessible a, final Component c) {
|
||||
public static void requestSelection(final Accessible a, final Component c, final boolean selected) {
|
||||
if (a == null) return;
|
||||
invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
@@ -480,7 +480,15 @@ class CAccessibility implements PropertyChangeListener {
|
||||
if (pac == null) return;
|
||||
AccessibleSelection as = pac.getAccessibleSelection();
|
||||
if (as == null) return;
|
||||
as.addAccessibleSelection(i);
|
||||
if (parent instanceof JList) {
|
||||
((JList) parent).setSelectedIndex(i);
|
||||
return;
|
||||
}
|
||||
if (selected) {
|
||||
as.addAccessibleSelection(i);
|
||||
} else {
|
||||
as.removeAccessibleSelection(i);
|
||||
}
|
||||
}
|
||||
}, c);
|
||||
}
|
||||
|
||||
@@ -246,7 +246,7 @@ final class CPlatformResponder {
|
||||
testCharIgnoringModifiers = charsIgnoringModifiersAndShift.charAt(0);
|
||||
}
|
||||
|
||||
int useNationalLayouts = (KeyEventProcessing.useNationalLayouts && !isCyrillicKeyboardLayout()) ? 1 : 0;
|
||||
int useNationalLayouts = (!KeyEventProcessing.useNationalLayouts || isCyrillicKeyboardLayout()) ? 0 : 1;
|
||||
int[] in = new int[] {testCharIgnoringModifiers, isDeadChar ? 1 : 0, modifierFlags, keyCode, useNationalLayouts};
|
||||
int[] out = new int[3]; // [jkeyCode, jkeyLocation, deadChar]
|
||||
|
||||
|
||||
@@ -745,6 +745,8 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
execute(CPlatformWindow::nativeSetNSWindowLocationByPlatform);
|
||||
}
|
||||
|
||||
this.visible = visible;
|
||||
|
||||
// Actually show or hide the window
|
||||
LWWindowPeer blocker = (peer == null)? null : peer.getBlocker();
|
||||
if (blocker == null || !visible) {
|
||||
@@ -796,7 +798,6 @@ public class CPlatformWindow extends CFRetainedResource implements PlatformWindo
|
||||
});
|
||||
});
|
||||
}
|
||||
this.visible = visible;
|
||||
|
||||
// Manage the extended state when showing
|
||||
if (visible) {
|
||||
|
||||
@@ -785,7 +785,7 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
|
||||
- (id)getAxData:(JNIEnv*)env
|
||||
{
|
||||
jobject jcomponent = [self awtComponent:env];
|
||||
id ax = [[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:jcomponent withIndex:-1 withView:self withJavaRole:nil] autorelease];
|
||||
id ax = [[[[JavaComponentAccessibility alloc] initWithParent:self withEnv:env withAccessible:jcomponent withIndex:-1 withView:self withJavaRole:nil] platformAxElement] autorelease];
|
||||
(*env)->DeleteLocalRef(env, jcomponent);
|
||||
return ax;
|
||||
}
|
||||
@@ -818,9 +818,9 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
|
||||
return [super accessibilityAttributeValue:attribute];
|
||||
}
|
||||
}
|
||||
- (BOOL)accessibilityIsIgnored
|
||||
{
|
||||
return YES;
|
||||
|
||||
- (BOOL)isAccessibilityElement {
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (id)accessibilityHitTest:(NSPoint)point
|
||||
@@ -830,7 +830,7 @@ extern bool isSystemShortcut_NextWindowInApplication(NSUInteger modifiersMask, N
|
||||
|
||||
(*env)->PushLocalFrame(env, 4);
|
||||
|
||||
id result = [[self getAxData:env] accessibilityHitTest:point withEnv:env];
|
||||
id result = [[self getAxData:env] accessibilityHitTest:point];
|
||||
|
||||
(*env)->PopLocalFrame(env, NULL);
|
||||
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
#import <AppKit/AppKit.h>
|
||||
#import <jni.h>
|
||||
|
||||
extern NSMutableDictionary *sActions;
|
||||
extern NSMutableDictionary *sActionSelectores;
|
||||
extern NSMutableArray *sAllActionSelectores;
|
||||
void initializeActions();
|
||||
|
||||
@protocol JavaAccessibilityAction
|
||||
|
||||
|
||||
@@ -28,11 +28,18 @@
|
||||
|
||||
#import "ThreadUtilities.h"
|
||||
|
||||
NSMutableDictionary *sActions = nil;
|
||||
NSMutableDictionary *sActionSelectores = nil;
|
||||
NSMutableArray *sAllActionSelectores = nil;
|
||||
void initializeActions();
|
||||
|
||||
@implementation JavaAxAction
|
||||
|
||||
- (id)initWithEnv:(JNIEnv *)env withAccessibleAction:(jobject)accessibleAction withIndex:(jint)index withComponent:(jobject)component
|
||||
{
|
||||
if (sActions == nil) {
|
||||
initializeActions();
|
||||
}
|
||||
self = [super init];
|
||||
if (self) {
|
||||
fAccessibleAction = JNFNewWeakGlobalRef(env, accessibleAction);
|
||||
@@ -130,3 +137,31 @@
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
void initializeActions() {
|
||||
int actionsCount = 5;
|
||||
|
||||
sActions = [[NSMutableDictionary alloc] initWithCapacity:actionsCount];
|
||||
|
||||
[sActions setObject:NSAccessibilityPressAction forKey:@"click"];
|
||||
[sActions setObject:NSAccessibilityIncrementAction forKey:@"increment"];
|
||||
[sActions setObject:NSAccessibilityDecrementAction forKey:@"decrement"];
|
||||
[sActions setObject:NSAccessibilityShowMenuAction forKey:@"toggle popup"];
|
||||
[sActions setObject:NSAccessibilityPressAction forKey:@"toggleexpand"];
|
||||
|
||||
sActionSelectores = [[NSMutableDictionary alloc] initWithCapacity:actionsCount];
|
||||
|
||||
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformPress)) forKey:NSAccessibilityPressAction];
|
||||
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformShowMenu)) forKey:NSAccessibilityShowMenuAction];
|
||||
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformDecrement)) forKey:NSAccessibilityDecrementAction];
|
||||
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformIncrement)) forKey:NSAccessibilityIncrementAction];
|
||||
[sActionSelectores setObject:NSStringFromSelector(@selector(accessibilityPerformPick)) forKey:NSAccessibilityPickAction];
|
||||
|
||||
sAllActionSelectores = [[NSMutableArray alloc] initWithCapacity:actionsCount];
|
||||
|
||||
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformPick))];
|
||||
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformIncrement))];
|
||||
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformDecrement))];
|
||||
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformShowMenu))];
|
||||
[sAllActionSelectores addObject:NSStringFromSelector(@selector(accessibilityPerformPress))];
|
||||
}
|
||||
|
||||
@@ -1,90 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
//#define JAVA_AX_DEBUG 1
|
||||
//#define JAVA_AX_NO_IGNORES 1
|
||||
//#define JAVA_AX_DEBUG_PARMS 1
|
||||
|
||||
// these constants are duplicated in CAccessibility.java
|
||||
#define JAVA_AX_ALL_CHILDREN (-1)
|
||||
#define JAVA_AX_SELECTED_CHILDREN (-2)
|
||||
#define JAVA_AX_VISIBLE_CHILDREN (-3)
|
||||
// If the value is >=0, it's an index
|
||||
|
||||
@class JavaBaseAccessibility;
|
||||
|
||||
@protocol JavaBaseProvider
|
||||
|
||||
@property (nonatomic, retain) JavaBaseAccessibility *javaBase;
|
||||
|
||||
@end
|
||||
|
||||
@protocol PlatformAxElementProvider
|
||||
@required
|
||||
|
||||
- (NSString *)getPlatformAxElementClassName;
|
||||
|
||||
@property (nonatomic, retain) NSObject <JavaBaseProvider> *platformAxElement;
|
||||
|
||||
@end
|
||||
|
||||
@interface JavaBaseAccessibility : NSObject <JavaBaseProvider, PlatformAxElementProvider> {
|
||||
NSView *fView;
|
||||
NSObject *fParent;
|
||||
|
||||
NSString *fNSRole;
|
||||
NSString *fJavaRole;
|
||||
|
||||
jint fIndex;
|
||||
jobject fAccessible;
|
||||
jobject fComponent;
|
||||
}
|
||||
|
||||
- (id)initWithParent:(NSObject*)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole;
|
||||
- (void)unregisterFromCocoaAXSystem;
|
||||
- (void)postValueChanged;
|
||||
- (void)postSelectedTextChanged;
|
||||
- (void)postSelectionChanged;
|
||||
- (BOOL)isEqual:(id)anObject;
|
||||
- (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible;
|
||||
|
||||
+ (void)postFocusChanged:(id)message;
|
||||
|
||||
+ (NSArray *)childrenOfParent:(JavaBaseAccessibility *) parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored;
|
||||
+ (NSArray *)childrenOfParent:(JavaBaseAccessibility *) parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored recursive:(BOOL)recursive;
|
||||
+ (JavaBaseAccessibility *) createWithParent:(JavaBaseAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view;
|
||||
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)role index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view;
|
||||
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view;
|
||||
|
||||
// If the isWraped parameter is true, then the object passed as a parent was created based on the same java component,
|
||||
// but performs a different NSAccessibilityRole of a table cell, or a list row, or tree row,
|
||||
// and we need to create an element whose role corresponds to the role in Java.
|
||||
+ (JavaBaseAccessibility *) createWithParent:(JavaBaseAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view isWrapped:(BOOL)wrapped;
|
||||
|
||||
// The current parameter is used to bypass the check for an item's index on the parent so that the item is created. This is necessary,
|
||||
// for example, for AccessibleJTreeNode, whose currentComponent has index -1
|
||||
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view isCurrent:(BOOL)current;
|
||||
|
||||
@property(readonly) jobject accessible;
|
||||
@property(readonly) jobject component;
|
||||
@property(readonly) jint index;
|
||||
|
||||
- (jobject)axContextWithEnv:(JNIEnv *)env;
|
||||
- (NSView*)view;
|
||||
- (NSWindow*)window;
|
||||
- (id)parent;
|
||||
-(void)setParent:(id)javaBaseAccessibilityParent;
|
||||
- (NSString *)javaRole;
|
||||
- (NSString *)nsRole;
|
||||
- (BOOL)isMenu;
|
||||
- (BOOL)isSelected:(JNIEnv *)env;
|
||||
- (BOOL)isSelectable:(JNIEnv *)env;
|
||||
- (BOOL)isVisible:(JNIEnv *)env;
|
||||
- (NSSize)getSize;
|
||||
- (NSRect)getBounds;
|
||||
- (id)getFocusedElement;
|
||||
|
||||
@end
|
||||
@@ -1,724 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaBaseAccessibility.h"
|
||||
|
||||
#import "sun_lwawt_macosx_CAccessibility.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
|
||||
|
||||
#import <dlfcn.h>
|
||||
|
||||
#import "JavaBaseAccessibility.h"
|
||||
#import "JavaAccessibilityAction.h"
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "JavaListAccessibility.h"
|
||||
#import "JavaTableAccessibility.h"
|
||||
#import "JavaListRowAccessibility.h"
|
||||
#import "JavaTableRowAccessibility.h"
|
||||
#import "JavaCellAccessibility.h"
|
||||
#import "JavaOutlineAccessibility.h"
|
||||
#import "JavaOutlineRowAccessibility.h"
|
||||
#import "JavaStaticTextAccessibility.h"
|
||||
#import "JavaNavigableTextAccessibility.h"
|
||||
#import "JavaScrollAreaAccessibility.h"
|
||||
#import "JavaTabGroupAccessibility.h"
|
||||
#import "JavaComboBoxAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import "AWTView.h"
|
||||
|
||||
// getChildrenAndRolesRecursive
|
||||
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZ)[Ljava/lang/Object;");
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRolesRecursive, sjc_CAccessibility, "getChildrenAndRolesRecursive", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZI)[Ljava/lang/Object;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleComponent, sjc_CAccessibility, "getAccessibleComponent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleComponent;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleValue, sjc_CAccessibility, "getAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleValue;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_isFocusTraversable, sjc_CAccessibility, "isFocusTraversable", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleIndexInParent, sjc_CAccessibility, "getAccessibleIndexInParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible");
|
||||
|
||||
static JNF_MEMBER_CACHE(jf_ptr, sjc_CAccessible, "ptr", "J");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessible", "(Ljavax/accessibility/Accessible;)Lsun/lwawt/macosx/CAccessible;");
|
||||
|
||||
static jobject sAccessibilityClass = NULL;
|
||||
|
||||
@implementation JavaBaseAccessibility
|
||||
|
||||
@synthesize platformAxElement;
|
||||
@synthesize javaBase;
|
||||
|
||||
- (id)init
|
||||
{
|
||||
self = [super init];
|
||||
if (self) {
|
||||
NSString *className = [self getPlatformAxElementClassName];
|
||||
self.platformAxElement = className != NULL ? [[NSClassFromString(className) alloc] init] : self; // defaults to [self]
|
||||
self.platformAxElement.javaBase = self;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
// to override in subclasses
|
||||
- (NSString *)getPlatformAxElementClassName
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole
|
||||
{
|
||||
self = [self init];
|
||||
if (self) {
|
||||
fParent = [parent retain];
|
||||
fView = [view retain];
|
||||
fJavaRole = [javaRole retain];
|
||||
|
||||
fAccessible = (*env)->NewWeakGlobalRef(env, accessible);
|
||||
(*env)->ExceptionClear(env); // in case of OOME
|
||||
jobject jcomponent = [(AWTView *)fView awtComponent:env];
|
||||
fComponent = (*env)->NewWeakGlobalRef(env, jcomponent);
|
||||
(*env)->DeleteLocalRef(env, jcomponent);
|
||||
|
||||
fIndex = index;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)unregisterFromCocoaAXSystem
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
static dispatch_once_t initialize_unregisterUniqueId_once;
|
||||
static void (*unregisterUniqueId)(id);
|
||||
dispatch_once(&initialize_unregisterUniqueId_once, ^{
|
||||
void *jrsFwk = dlopen("/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport", RTLD_LAZY | RTLD_LOCAL);
|
||||
unregisterUniqueId = dlsym(jrsFwk, "JRSAccessibilityUnregisterUniqueIdForUIElement");
|
||||
});
|
||||
if (unregisterUniqueId) unregisterUniqueId(self);
|
||||
}
|
||||
|
||||
- (void)dealloc
|
||||
{
|
||||
[self unregisterFromCocoaAXSystem];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
|
||||
|
||||
(*env)->DeleteWeakGlobalRef(env, fAccessible);
|
||||
fAccessible = NULL;
|
||||
|
||||
(*env)->DeleteWeakGlobalRef(env, fComponent);
|
||||
fComponent = NULL;
|
||||
|
||||
[fParent release];
|
||||
fParent = nil;
|
||||
|
||||
[fNSRole release];
|
||||
fNSRole = nil;
|
||||
|
||||
[fJavaRole release];
|
||||
fJavaRole = nil;
|
||||
|
||||
[fView release];
|
||||
fView = nil;
|
||||
|
||||
if (self.platformAxElement != self) {
|
||||
[self.platformAxElement dealloc];
|
||||
}
|
||||
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void)postValueChanged
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
NSAccessibilityPostNotification(self.platformAxElement, NSAccessibilityValueChangedNotification);
|
||||
}
|
||||
|
||||
- (void)postSelectedTextChanged
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
NSAccessibilityPostNotification(self.platformAxElement, NSAccessibilitySelectedTextChangedNotification);
|
||||
}
|
||||
|
||||
- (void)postSelectionChanged
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
NSAccessibilityPostNotification(self.platformAxElement, NSAccessibilitySelectedChildrenChangedNotification);
|
||||
}
|
||||
|
||||
- (void)postMenuOpened
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
NSAccessibilityPostNotification(self.platformAxElement, (NSString *)kAXMenuOpenedNotification);
|
||||
}
|
||||
|
||||
- (void)postMenuClosed
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
NSAccessibilityPostNotification(self.platformAxElement, (NSString *)kAXMenuClosedNotification);
|
||||
}
|
||||
|
||||
- (void)postMenuItemSelected
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
NSAccessibilityPostNotification(self.platformAxElement, (NSString *)kAXMenuItemSelectedNotification);
|
||||
}
|
||||
|
||||
- (BOOL)isEqual:(id)anObject
|
||||
{
|
||||
if (![anObject isKindOfClass:[self class]]) return NO;
|
||||
JavaBaseAccessibility *accessibility = (JavaBaseAccessibility *)anObject;
|
||||
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
return (*env)->IsSameObject(env, accessibility->fAccessible, fAccessible);
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible
|
||||
{
|
||||
return (*env)->IsSameObject(env, fAccessible, accessible);
|
||||
}
|
||||
|
||||
+ (void)initialize
|
||||
{
|
||||
if (sRoles == nil) {
|
||||
initializeRoles();
|
||||
}
|
||||
|
||||
if (sAccessibilityClass == NULL) {
|
||||
JNF_STATIC_MEMBER_CACHE(jm_getAccessibility, sjc_CAccessibility, "getAccessibility", "([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;");
|
||||
|
||||
#ifdef JAVA_AX_NO_IGNORES
|
||||
NSArray *ignoredKeys = [NSArray array];
|
||||
#else
|
||||
NSArray *ignoredKeys = [sRoles allKeysForObject:JavaAccessibilityIgnore];
|
||||
#endif
|
||||
jobjectArray result = NULL;
|
||||
jsize count = [ignoredKeys count];
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
static JNF_CLASS_CACHE(jc_String, "java/lang/String");
|
||||
result = JNFNewObjectArray(env, &jc_String, count);
|
||||
if (!result) {
|
||||
NSLog(@"In %s, can't create Java array of String objects", __FUNCTION__);
|
||||
return;
|
||||
}
|
||||
|
||||
NSInteger i;
|
||||
for (i = 0; i < count; i++) {
|
||||
jstring jString = JNFNSToJavaString(env, [ignoredKeys objectAtIndex:i]);
|
||||
(*env)->SetObjectArrayElement(env, result, i, jString);
|
||||
(*env)->DeleteLocalRef(env, jString);
|
||||
}
|
||||
|
||||
sAccessibilityClass = JNFCallStaticObjectMethod(env, jm_getAccessibility, result); // AWT_THREADING Safe (known object)
|
||||
}
|
||||
}
|
||||
|
||||
+ (void)postFocusChanged:(id)message
|
||||
{
|
||||
AWT_ASSERT_APPKIT_THREAD;
|
||||
NSAccessibilityPostNotification([NSApp accessibilityFocusedUIElement], NSAccessibilityFocusedUIElementChangedNotification);
|
||||
}
|
||||
|
||||
+ (jobject) getCAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env {
|
||||
if (JNFIsInstanceOf(env, jaccessible, &sjc_CAccessible)) {
|
||||
return jaccessible;
|
||||
} else if (JNFIsInstanceOf(env, jaccessible, &sjc_Accessible)) {
|
||||
return JNFCallStaticObjectMethod(env, sjm_getCAccessible, jaccessible);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
+ (NSArray *) childrenOfParent:(JavaBaseAccessibility *)parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored
|
||||
{
|
||||
return [JavaBaseAccessibility childrenOfParent:parent withEnv:env withChildrenCode:whichChildren allowIgnored:allowIgnored recursive:NO];
|
||||
}
|
||||
|
||||
+ (NSArray *) childrenOfParent:(JavaBaseAccessibility *)parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored recursive:(BOOL)recursive
|
||||
{
|
||||
if ([parent isKindOfClass:[JavaTableAccessibility class]]) {
|
||||
if (whichChildren == JAVA_AX_SELECTED_CHILDREN) {
|
||||
NSArray<NSNumber *> *selectedRowIndexses = [(JavaTableAccessibility *)parent selectedAccessibleRows];
|
||||
NSMutableArray *children = [NSMutableArray arrayWithCapacity:[selectedRowIndexses count]];
|
||||
for (NSNumber *index in selectedRowIndexses) {
|
||||
[children addObject:[[JavaTableRowAccessibility alloc] initWithParent:parent
|
||||
withEnv:env
|
||||
withAccessible:NULL
|
||||
withIndex:index.unsignedIntValue
|
||||
withView:[parent view]
|
||||
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
|
||||
}
|
||||
return [NSArray arrayWithArray:children];
|
||||
} else if (whichChildren == JAVA_AX_ALL_CHILDREN) {
|
||||
int rowCount = [(JavaTableAccessibility *)parent accessibleRowCount];
|
||||
NSMutableArray *children = [NSMutableArray arrayWithCapacity:rowCount];
|
||||
for (int i = 0; i < rowCount; i++) {
|
||||
[children addObject:[[JavaTableRowAccessibility alloc] initWithParent:parent
|
||||
withEnv:env
|
||||
withAccessible:NULL
|
||||
withIndex:i
|
||||
withView:[parent view]
|
||||
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
|
||||
}
|
||||
return [NSArray arrayWithArray:children];
|
||||
} else {
|
||||
return [NSArray arrayWithObject:[[JavaTableRowAccessibility alloc] initWithParent:parent
|
||||
withEnv:env
|
||||
withAccessible:NULL
|
||||
withIndex:whichChildren
|
||||
withView:[parent view]
|
||||
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
|
||||
}
|
||||
}
|
||||
if (parent->fAccessible == NULL) return nil;
|
||||
jobjectArray jchildrenAndRoles = NULL;
|
||||
if (recursive) {
|
||||
jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRolesRecursive, parent->fAccessible, parent->fComponent, whichChildren, allowIgnored, 1);
|
||||
} else {
|
||||
jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
|
||||
}
|
||||
if (jchildrenAndRoles == NULL) return nil;
|
||||
|
||||
jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
|
||||
NSMutableArray *children = [NSMutableArray arrayWithCapacity:arrayLen/2]; //childrenAndRoles array contains two elements (child, role) for each child
|
||||
|
||||
NSInteger i;
|
||||
NSUInteger childIndex = (whichChildren >= 0) ? whichChildren : 0; // if we're getting one particular child, make sure to set its index correctly
|
||||
int inc = recursive ? 3 : 2;
|
||||
for(i = 0; i < arrayLen; i += inc)
|
||||
{
|
||||
jobject /* Accessible */ jchild = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i);
|
||||
jobject /* String */ jchildJavaRole = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i+1);
|
||||
|
||||
NSString *childJavaRole = nil;
|
||||
if (jchildJavaRole != NULL) {
|
||||
jobject jkey = JNFGetObjectField(env, jchildJavaRole, sjf_key);
|
||||
childJavaRole = JNFJavaToNSString(env, jkey);
|
||||
(*env)->DeleteLocalRef(env, jkey);
|
||||
}
|
||||
|
||||
JavaBaseAccessibility *child = [self createWithParent:parent accessible:jchild role:childJavaRole index:childIndex withEnv:env withView:parent->fView];
|
||||
if ([child isKindOfClass:[JavaOutlineRowAccessibility class]]) {
|
||||
jobject jLevel = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i+2);
|
||||
NSString *sLevel = nil;
|
||||
if (jLevel != NULL) {
|
||||
sLevel = JNFJavaToNSString(env, jLevel);
|
||||
(*env)->DeleteLocalRef(env, jLevel);
|
||||
int level = sLevel.intValue;
|
||||
[(JavaOutlineRowAccessibility *)child setAccessibleLevel:level];
|
||||
}
|
||||
}
|
||||
|
||||
[children addObject:child.platformAxElement];
|
||||
|
||||
(*env)->DeleteLocalRef(env, jchild);
|
||||
(*env)->DeleteLocalRef(env, jchildJavaRole);
|
||||
|
||||
childIndex++;
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, jchildrenAndRoles);
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view
|
||||
{
|
||||
return [JavaBaseAccessibility createWithAccessible:jaccessible withEnv:env withView:view isCurrent:NO];
|
||||
}
|
||||
|
||||
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view isCurrent:(BOOL)current
|
||||
{
|
||||
JavaBaseAccessibility *ret = nil;
|
||||
jobject jcomponent = [(AWTView *)view awtComponent:env];
|
||||
jint index = JNFCallStaticIntMethod(env, sjm_getAccessibleIndexInParent, jaccessible, jcomponent);
|
||||
NSString *javaRole = getJavaRole(env, jaccessible, jcomponent);
|
||||
if ((index >= 0) || current) {
|
||||
ret = [self createWithAccessible:jaccessible role:javaRole index:index withEnv:env withView:view];
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, jcomponent);
|
||||
return ret;
|
||||
}
|
||||
|
||||
+ (JavaBaseAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
|
||||
{
|
||||
return [self createWithParent:nil accessible:jaccessible role:javaRole index:index withEnv:env withView:view];
|
||||
}
|
||||
|
||||
+ (JavaBaseAccessibility *) createWithParent:(JavaBaseAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
|
||||
{
|
||||
return [JavaBaseAccessibility createWithParent:parent accessible:jaccessible role:javaRole index:index withEnv:env withView:view isWrapped:NO];
|
||||
}
|
||||
|
||||
+ (JavaBaseAccessibility *) createWithParent:(JavaBaseAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view isWrapped:(BOOL)wrapped
|
||||
{
|
||||
// try to fetch the jCAX from Java, and return autoreleased
|
||||
jobject jCAX = [JavaBaseAccessibility getCAccessible:jaccessible withEnv:env];
|
||||
if (jCAX == NULL) return nil;
|
||||
if (!wrapped) { // If wrapped is true, then you don't need to get an existing instance, you need to create a new one
|
||||
JavaBaseAccessibility *value = (JavaBaseAccessibility *) jlong_to_ptr(JNFGetLongField(env, jCAX, jf_ptr));
|
||||
if (value != nil) {
|
||||
(*env)->DeleteLocalRef(env, jCAX);
|
||||
return [[value retain] autorelease];
|
||||
}
|
||||
}
|
||||
|
||||
// otherwise, create a new instance
|
||||
JavaBaseAccessibility *newChild = nil;
|
||||
if ([[sRoles objectForKey:[parent javaRole]] isEqualToString:NSAccessibilityListRole]) {
|
||||
newChild = [JavaListRowAccessibility alloc];
|
||||
} else if ([parent isKindOfClass:[JavaOutlineAccessibility class]]) {
|
||||
newChild = [JavaOutlineRowAccessibility alloc];
|
||||
} else if ([javaRole isEqualToString:@"pagetablist"]) {
|
||||
newChild = [JavaTabGroupAccessibility alloc];
|
||||
} else if ([javaRole isEqualToString:@"scrollpane"]) {
|
||||
newChild = [JavaScrollAreaAccessibility alloc];
|
||||
} else {
|
||||
NSString *nsRole = [sRoles objectForKey:javaRole];
|
||||
if ([nsRole isEqualToString:NSAccessibilityStaticTextRole]) {
|
||||
newChild = [JavaStaticTextAccessibility alloc];
|
||||
} else if ([nsRole isEqualToString:NSAccessibilityTextAreaRole] || [nsRole isEqualToString:NSAccessibilityTextFieldRole]) {
|
||||
newChild = [JavaNavigableTextAccessibility alloc];
|
||||
} else if ([nsRole isEqualToString:NSAccessibilityListRole]) {
|
||||
newChild = [JavaListAccessibility alloc];
|
||||
} else if ([nsRole isEqualToString:NSAccessibilityTableRole]) {
|
||||
newChild = [JavaTableAccessibility alloc];
|
||||
} else if ([nsRole isEqualToString:NSAccessibilityOutlineRole]) {
|
||||
newChild = [JavaOutlineAccessibility alloc];
|
||||
} else if ([nsRole isEqualToString:NSAccessibilityComboBoxRole]) {
|
||||
newChild = [JavaComboBoxAccessibility alloc];
|
||||
} else {
|
||||
newChild = [JavaComponentAccessibility alloc];
|
||||
}
|
||||
}
|
||||
|
||||
// must init freshly -alloc'd object
|
||||
[newChild initWithParent:parent withEnv:env withAccessible:jCAX withIndex:index withView:view withJavaRole:javaRole]; // must init new instance
|
||||
|
||||
// If creating a JPopupMenu (not a combobox popup list) need to fire menuOpened.
|
||||
// This is the only way to know if the menu is opening; visible state change
|
||||
// can't be caught because the listeners are not set up in time.
|
||||
if ( [javaRole isEqualToString:@"popupmenu"] &&
|
||||
![[parent javaRole] isEqualToString:@"combobox"] ) {
|
||||
[newChild postMenuOpened];
|
||||
}
|
||||
|
||||
// must hard retain pointer poked into Java object
|
||||
[newChild retain];
|
||||
JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild));
|
||||
|
||||
// the link is removed in the wrapper
|
||||
if (!wrapped) {
|
||||
(*env)->DeleteLocalRef(env, jCAX);
|
||||
}
|
||||
|
||||
// return autoreleased instance
|
||||
return [newChild autorelease];
|
||||
}
|
||||
|
||||
- (jobject)axContextWithEnv:(JNIEnv *)env
|
||||
{
|
||||
return getAxContext(env, fAccessible, fComponent);
|
||||
}
|
||||
|
||||
- (id)parent
|
||||
{
|
||||
static JNF_CLASS_CACHE(sjc_Window, "java/awt/Window");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleParent, sjc_CAccessibility, "getAccessibleParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getSwingAccessible, sjc_CAccessible, "getSwingAccessible", "(Ljavax/accessibility/Accessible;)Ljavax/accessibility/Accessible;");
|
||||
|
||||
if(fParent == nil) {
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
jobject jparent = JNFCallStaticObjectMethod(env, sjm_getAccessibleParent, fAccessible, fComponent);
|
||||
|
||||
if (jparent == NULL) {
|
||||
fParent = fView;
|
||||
} else {
|
||||
AWTView *view = fView;
|
||||
jobject jax = JNFCallStaticObjectMethod(env, sjm_getSwingAccessible, fAccessible);
|
||||
|
||||
if (JNFIsInstanceOf(env, jax, &sjc_Window)) {
|
||||
// In this case jparent is an owner toplevel and we should retrieve its own view
|
||||
view = [AWTView awtView:env ofAccessible:jparent];
|
||||
}
|
||||
if (view != nil) {
|
||||
fParent = [JavaBaseAccessibility createWithAccessible:jparent withEnv:env withView:view];
|
||||
}
|
||||
if (fParent == nil) {
|
||||
fParent = fView;
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, jparent);
|
||||
(*env)->DeleteLocalRef(env, jax );
|
||||
}
|
||||
[fParent retain];
|
||||
}
|
||||
return fParent;
|
||||
}
|
||||
|
||||
- (NSView *)view
|
||||
{
|
||||
return fView;
|
||||
}
|
||||
|
||||
- (NSWindow *)window
|
||||
{
|
||||
return [[self view] window];
|
||||
}
|
||||
|
||||
- (NSString *)javaRole
|
||||
{
|
||||
if(fJavaRole == nil) {
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
fJavaRole = getJavaRole(env, fAccessible, fComponent);
|
||||
[fJavaRole retain];
|
||||
}
|
||||
return fJavaRole;
|
||||
}
|
||||
|
||||
- (BOOL)isMenu
|
||||
{
|
||||
id role = [self accessibilityRoleAttribute];
|
||||
return [role isEqualToString:NSAccessibilityMenuBarRole] || [role isEqualToString:NSAccessibilityMenuRole] || [role isEqualToString:NSAccessibilityMenuItemRole];
|
||||
}
|
||||
|
||||
- (BOOL)isSelected:(JNIEnv *)env
|
||||
{
|
||||
if (fIndex == -1) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
return isChildSelected(env, ((JavaBaseAccessibility *)[self parent])->fAccessible, fIndex, fComponent);
|
||||
}
|
||||
|
||||
- (BOOL)isSelectable:(JNIEnv *)env
|
||||
{
|
||||
jobject axContext = [self axContextWithEnv:env];
|
||||
BOOL selectable = isSelectable(env, axContext, fComponent);
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
return selectable;
|
||||
}
|
||||
|
||||
- (BOOL)isVisible:(JNIEnv *)env
|
||||
{
|
||||
if (fIndex == -1) {
|
||||
return NO;
|
||||
}
|
||||
|
||||
jobject axContext = [self axContextWithEnv:env];
|
||||
BOOL showing = isShowing(env, axContext, fComponent);
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
return showing;
|
||||
}
|
||||
|
||||
- (NSSize)getSize
|
||||
{
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
NSSize size = getAxComponentSize(env, axComponent, fComponent);
|
||||
(*env)->DeleteLocalRef(env, axComponent);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
- (NSRect)getBounds
|
||||
{
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
|
||||
// NSAccessibility wants the bottom left point of the object in
|
||||
// bottom left based screen coords
|
||||
|
||||
// Get the java screen coords, and make a NSPoint of the bottom left of the AxComponent.
|
||||
NSSize size = getAxComponentSize(env, axComponent, fComponent);
|
||||
NSPoint point = getAxComponentLocationOnScreen(env, axComponent, fComponent);
|
||||
(*env)->DeleteLocalRef(env, axComponent);
|
||||
|
||||
point.y += size.height;
|
||||
// Now make it into Cocoa screen coords.
|
||||
point.y = [[[[self view] window] screen] frame].size.height - point.y;
|
||||
|
||||
return NSMakeRect(point.x, point.y, size.width, size.height);
|
||||
}
|
||||
|
||||
- (id)getFocusedElement
|
||||
{
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getFocusOwner, sjc_CAccessibility, "getFocusOwner", "(Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
id value = nil;
|
||||
|
||||
NSWindow* hostWindow = [[self->fView window] retain];
|
||||
jobject focused = JNFCallStaticObjectMethod(env, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
[hostWindow release];
|
||||
|
||||
if (focused != NULL) {
|
||||
if (JNFIsInstanceOf(env, focused, &sjc_Accessible)) {
|
||||
value = [JavaComponentAccessibility createWithAccessible:focused withEnv:env withView:fView];
|
||||
value = ((JavaBaseAccessibility *)value).platformAxElement;
|
||||
}
|
||||
(*env)->DeleteLocalRef(env, focused);
|
||||
}
|
||||
|
||||
if (value == nil) {
|
||||
value = self;
|
||||
}
|
||||
#ifdef JAVA_AX_DEBUG
|
||||
NSLog(@"%s: %@", __FUNCTION__, value);
|
||||
#endif
|
||||
return value;
|
||||
}
|
||||
|
||||
- (jobject)accessible {
|
||||
return fAccessible;
|
||||
}
|
||||
|
||||
- (jobject)component {
|
||||
return fComponent;
|
||||
}
|
||||
|
||||
-(jint)index {
|
||||
return fIndex;
|
||||
}
|
||||
|
||||
- (void)setParent:(id)javaBaseAccessibilityParent {
|
||||
fParent = javaBaseAccessibilityParent;
|
||||
}
|
||||
|
||||
- (NSString *)nsRole {
|
||||
return fNSRole;
|
||||
}
|
||||
|
||||
- (NSUInteger)accessibilityIndexOfChild:(id)child {
|
||||
|
||||
if ([child isKindOfClass:[PlatformAxElement class]]) {
|
||||
child = [child javaBase];
|
||||
}
|
||||
jint returnValue = JNFCallStaticIntMethod( [ThreadUtilities getJNIEnv],
|
||||
sjm_getAccessibleIndexInParent,
|
||||
[child accessible],
|
||||
[child component]);
|
||||
return (returnValue == -1) ? NSNotFound : returnValue;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CAccessibility
|
||||
* Method: focusChanged
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessibility_focusChanged
|
||||
(JNIEnv *env, jobject jthis)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(postFocusChanged:) on:[JavaBaseAccessibility class] withObject:nil waitUntilDone:NO];
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CAccessible
|
||||
* Method: valueChanged
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_valueChanged
|
||||
(JNIEnv *env, jclass jklass, jlong element)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(postValueChanged) on:(JavaBaseAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CAccessible
|
||||
* Method: selectedTextChanged
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectedTextChanged
|
||||
(JNIEnv *env, jclass jklass, jlong element)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(postSelectedTextChanged)
|
||||
on:(JavaBaseAccessibility *)jlong_to_ptr(element)
|
||||
withObject:nil
|
||||
waitUntilDone:NO];
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CAccessible
|
||||
* Method: selectionChanged
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectionChanged
|
||||
(JNIEnv *env, jclass jklass, jlong element)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(postSelectionChanged) on:(JavaBaseAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CAccessible
|
||||
* Method: menuOpened
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuOpened
|
||||
(JNIEnv *env, jclass jklass, jlong element)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(postMenuOpened)
|
||||
on:(JavaBaseAccessibility *)jlong_to_ptr(element)
|
||||
withObject:nil
|
||||
waitUntilDone:NO];
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CAccessible
|
||||
* Method: menuClosed
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuClosed
|
||||
(JNIEnv *env, jclass jklass, jlong element)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(postMenuClosed)
|
||||
on:(JavaBaseAccessibility *)jlong_to_ptr(element)
|
||||
withObject:nil
|
||||
waitUntilDone:NO];
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CAccessible
|
||||
* Method: menuItemSelected
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuItemSelected
|
||||
(JNIEnv *env, jclass jklass, jlong element)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(postMenuItemSelected)
|
||||
on:(JavaBaseAccessibility *)jlong_to_ptr(element)
|
||||
withObject:nil
|
||||
waitUntilDone:NO];
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
|
||||
/*
|
||||
* Class: sun_lwawt_macosx_CAccessible
|
||||
* Method: unregisterFromCocoaAXSystem
|
||||
* Signature: (I)V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_unregisterFromCocoaAXSystem
|
||||
(JNIEnv *env, jclass jklass, jlong element)
|
||||
{
|
||||
JNF_COCOA_ENTER(env);
|
||||
[ThreadUtilities performOnMainThread:@selector(unregisterFromCocoaAXSystem) on:(JavaBaseAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
|
||||
JNF_COCOA_EXIT(env);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaCellAccessibility : JavaElementAccessibility
|
||||
@interface JavaCellAccessibility : JavaComponentAccessibility
|
||||
@end
|
||||
|
||||
@interface PlatformAxCell : PlatformAxElement
|
||||
|
||||
@@ -20,13 +20,13 @@
|
||||
- (NSArray *)accessibilityChildren {
|
||||
NSArray *children = [super accessibilityChildren];
|
||||
if (children == NULL) {
|
||||
NSString *javaRole = [[self javaBase] javaRole];
|
||||
JavaBaseAccessibility *newChild = [JavaBaseAccessibility createWithParent:[self javaBase]
|
||||
accessible:[[self javaBase] accessible]
|
||||
NSString *javaRole = [[self javaComponent] javaRole];
|
||||
JavaComponentAccessibility *newChild = [JavaComponentAccessibility createWithParent:[self javaComponent]
|
||||
accessible:[[self javaComponent] accessible]
|
||||
role:javaRole
|
||||
index:[[self javaBase] index]
|
||||
index:[[self javaComponent] index]
|
||||
withEnv:[ThreadUtilities getJNIEnv]
|
||||
withView:[[self javaBase] view]
|
||||
withView:[[self javaComponent] view]
|
||||
isWrapped:YES];
|
||||
return [NSArray arrayWithObject:newChild.platformAxElement];
|
||||
} else {
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaColumnAccessibility : JavaElementAccessibility
|
||||
@interface JavaColumnAccessibility : JavaComponentAccessibility
|
||||
@end
|
||||
|
||||
@interface PlatformAxColumn : PlatformAxElement
|
||||
|
||||
@@ -30,8 +30,8 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
NSArray *children = [super accessibilityChildren];
|
||||
if (children == NULL) {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
if ([[[self accessibilityParent] javaBase] accessible] == NULL) return nil;
|
||||
jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, [[[self accessibilityParent] javaBase] accessible], [[[self accessibilityParent] javaBase] component], JAVA_AX_ALL_CHILDREN, NO);
|
||||
if ([[[self accessibilityParent] javaComponent] accessible] == NULL) return nil;
|
||||
jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, [[[self accessibilityParent] javaComponent] accessible], [[[self accessibilityParent] javaComponent] component], JAVA_AX_ALL_CHILDREN, NO);
|
||||
if (jchildrenAndRoles == NULL) return nil;
|
||||
|
||||
jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
|
||||
@@ -39,8 +39,8 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
|
||||
NSUInteger childIndex = [self columnNumberInTable];
|
||||
|
||||
JavaColumnAccessibility *selfRow = [self javaBase];
|
||||
int inc = [(JavaTableAccessibility *)[[self accessibilityParent] javaBase] accessibleColCount] * 2;
|
||||
JavaColumnAccessibility *selfRow = [self javaComponent];
|
||||
int inc = [(JavaTableAccessibility *) [[self accessibilityParent] javaComponent] accessibleColCount] * 2;
|
||||
NSInteger i = childIndex * 2;
|
||||
for(NSInteger i; i < arrayLen; i += inc)
|
||||
{
|
||||
@@ -75,7 +75,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
}
|
||||
|
||||
- (NSUInteger)columnNumberInTable {
|
||||
return [[self javaBase] index];
|
||||
return [[self javaComponent] index];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaComboBoxAccessibility : JavaElementAccessibility
|
||||
@interface JavaComboBoxAccessibility : JavaComponentAccessibility
|
||||
|
||||
@property(readonly) NSString *accessibleSelectedText;
|
||||
|
||||
- (void)accessibleShowMenu;
|
||||
|
||||
@end
|
||||
|
||||
@interface PlatformAxComboBox : PlatformAxElement
|
||||
|
||||
@@ -37,39 +37,12 @@ static const char* ACCESSIBLE_JCOMBOBOX_NAME = "javax.swing.JComboBox$Accessible
|
||||
return selectedText;
|
||||
}
|
||||
|
||||
- (void)accessibleShowMenu {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleAction, sjc_CAccessibility, "getAccessibleAction", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleAction;");
|
||||
|
||||
// On MacOSX, text doesn't have actions, in java it does.
|
||||
// cmcnote: NOT TRUE - Editable text has AXShowMenu. Textfields have AXConfirm. Static text has no actions.
|
||||
jobject axAction = JNFCallStaticObjectMethod(env, jm_getAccessibleAction, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
|
||||
if (axAction != NULL) {
|
||||
//+++gdb NOTE: In MacOSX, there is just a single Action, not multiple. In java,
|
||||
// the first one seems to be the most basic, so this will be used.
|
||||
// cmcnote: NOT TRUE - Sometimes there are multiple actions, eg sliders have AXDecrement AND AXIncrement (radr://3893192)
|
||||
JavaAxAction *action = [[JavaAxAction alloc] initWithEnv:env withAccessibleAction:axAction withIndex:0 withComponent:fComponent];
|
||||
[action perform];
|
||||
[action release];
|
||||
(*env)->DeleteLocalRef(env, axAction);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PlatformAxComboBox
|
||||
|
||||
- (id)accessibilityValue {
|
||||
return [(JavaComboBoxAccessibility *)[self javaBase] accessibleSelectedText];
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityPerformPress {
|
||||
[(JavaComboBoxAccessibility *)[self javaBase] accessibleShowMenu];
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibilityEnabled {
|
||||
return YES;
|
||||
return [(JavaComboBoxAccessibility *) [self javaComponent] accessibleSelectedText];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,106 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2016, 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.
|
||||
*/
|
||||
|
||||
#include "jni.h"
|
||||
|
||||
#import <AppKit/AppKit.h>
|
||||
#import "JavaBaseAccessibility.h"
|
||||
|
||||
@interface JavaComponentAccessibility : JavaBaseAccessibility {
|
||||
//#define JAVA_AX_DEBUG 1
|
||||
//#define JAVA_AX_NO_IGNORES 1
|
||||
//#define JAVA_AX_DEBUG_PARMS 1
|
||||
|
||||
// these constants are duplicated in CAccessibility.java
|
||||
#define JAVA_AX_ALL_CHILDREN (-1)
|
||||
#define JAVA_AX_SELECTED_CHILDREN (-2)
|
||||
#define JAVA_AX_VISIBLE_CHILDREN (-3)
|
||||
// If the value is >=0, it's an index
|
||||
|
||||
@class JavaComponentAccessibility;
|
||||
|
||||
@protocol JavaComponentProvider
|
||||
|
||||
@property (nonatomic, retain) JavaComponentAccessibility *javaComponent;
|
||||
|
||||
@end
|
||||
|
||||
@interface PlatformAxElement : NSAccessibilityElement <JavaComponentProvider>
|
||||
|
||||
// begin of NSAccessibility protocol methods
|
||||
- (BOOL)isAccessibilityElement;
|
||||
- (NSString *)accessibilityLabel;
|
||||
- (NSArray *)accessibilityChildren;
|
||||
- (NSArray *)accessibilitySelectedChildren;
|
||||
- (NSRect)accessibilityFrame;
|
||||
- (id)accessibilityParent;
|
||||
- (BOOL)isAccessibilityEnabled;
|
||||
- (id)accessibilityApplicationFocusedUIElement;
|
||||
- (id)getAccessibilityWindow;
|
||||
// end of NSAccessibility protocol methods
|
||||
|
||||
@end
|
||||
|
||||
@protocol PlatformAxElementProvider
|
||||
@required
|
||||
|
||||
- (NSString *)getPlatformAxElementClassName;
|
||||
|
||||
@property (nonatomic, retain) PlatformAxElement *platformAxElement;
|
||||
|
||||
@end
|
||||
|
||||
@interface JavaComponentAccessibility : NSObject <PlatformAxElementProvider> {
|
||||
NSView *fView;
|
||||
NSObject *fParent;
|
||||
|
||||
NSString *fNSRole;
|
||||
NSString *fJavaRole;
|
||||
|
||||
jint fIndex;
|
||||
jobject fAccessible;
|
||||
jobject fComponent;
|
||||
|
||||
NSMutableDictionary *fActions;
|
||||
NSMutableArray *fActionSElectors;
|
||||
NSObject *fActionsLOCK;
|
||||
}
|
||||
|
||||
- (NSDictionary*)getActions:(JNIEnv *)env;
|
||||
- (id)initWithParent:(NSObject*)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole;
|
||||
- (void)unregisterFromCocoaAXSystem;
|
||||
- (void)postValueChanged;
|
||||
- (void)postSelectedTextChanged;
|
||||
- (void)postSelectionChanged;
|
||||
- (BOOL)isEqual:(id)anObject;
|
||||
- (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible;
|
||||
|
||||
+ (void)postFocusChanged:(id)message;
|
||||
|
||||
+ (NSArray *)childrenOfParent:(JavaComponentAccessibility *) parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored;
|
||||
+ (NSArray *)childrenOfParent:(JavaComponentAccessibility *) parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored recursive:(BOOL)recursive;
|
||||
+ (JavaComponentAccessibility *) createWithParent:(JavaComponentAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view;
|
||||
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)role index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view;
|
||||
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view;
|
||||
|
||||
// If the isWraped parameter is true, then the object passed as a parent was created based on the same java component,
|
||||
// but performs a different NSAccessibilityRole of a table cell, or a list row, or tree row,
|
||||
// and we need to create an element whose role corresponds to the role in Java.
|
||||
+ (JavaComponentAccessibility *) createWithParent:(JavaComponentAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view isWrapped:(BOOL)wrapped;
|
||||
|
||||
// The current parameter is used to bypass the check for an item's index on the parent so that the item is created. This is necessary,
|
||||
// for example, for AccessibleJTreeNode, whose currentComponent has index -1
|
||||
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view isCurrent:(BOOL)current;
|
||||
|
||||
@property(readonly) jobject accessible;
|
||||
@property(readonly) jobject component;
|
||||
@property(readonly) jint index;
|
||||
@property(readonly, copy) NSArray *actionSelectores;;
|
||||
|
||||
- (jobject)axContextWithEnv:(JNIEnv *)env;
|
||||
- (NSView*)view;
|
||||
- (NSWindow*)window;
|
||||
- (id)parent;
|
||||
- (void)setParent:(id)javaComponentAccessibilityParent;
|
||||
- (NSString *)javaRole;
|
||||
- (NSString *)nsRole;
|
||||
- (BOOL)isMenu;
|
||||
- (BOOL)isSelected:(JNIEnv *)env;
|
||||
- (BOOL)isSelectable:(JNIEnv *)env;
|
||||
- (BOOL)isVisible:(JNIEnv *)env;
|
||||
- (NSSize)getSize;
|
||||
- (NSRect)getBounds;
|
||||
- (id)getFocusedElement;
|
||||
|
||||
@property(readonly) int accessibleIndexOfParent;
|
||||
@property(readonly) BOOL accessibleEnabled;
|
||||
@property(readwrite) BOOL accessibleFocused;
|
||||
@property(readonly) NSNumber *accessibleMaxValue;
|
||||
@property(readonly) NSNumber *accessibleMinValue;
|
||||
@property(readonly) id accessibleOrientation;
|
||||
@property(readonly) NSValue *accessiblePosition;
|
||||
@property(readonly) NSString *accessibleRole;
|
||||
@property(readonly) NSString *accessibleRoleDescription;
|
||||
@property(readonly) id accessibleParent;
|
||||
@property(readwrite, copy) NSNumber *accessibleSelected;
|
||||
@property(readonly) id accessibleValue;;
|
||||
@property(readonly) NSMutableDictionary *getActions;
|
||||
|
||||
- (id)accessibleHitTest:(NSPoint)point;
|
||||
- (void)getActionsWithEnv:(JNIEnv *)env;
|
||||
|
||||
// attribute names
|
||||
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
|
||||
- (NSArray *)accessibilityAttributeNames;
|
||||
|
||||
// attributes
|
||||
- (id)accessibilityAttributeValue:(NSString *)attribute;
|
||||
- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute;
|
||||
- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute;
|
||||
|
||||
- (NSArray *)accessibilityChildrenAttribute;
|
||||
- (BOOL)accessibilityIsChildrenAttributeSettable;
|
||||
- (NSUInteger)accessibilityIndexOfChild:(id)child;
|
||||
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute
|
||||
index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
|
||||
- (NSNumber *)accessibilityEnabledAttribute;
|
||||
- (BOOL)accessibilityIsEnabledAttributeSettable;
|
||||
- (NSNumber *)accessibilityFocusedAttribute;
|
||||
- (BOOL)accessibilityIsFocusedAttributeSettable;
|
||||
- (void)accessibilitySetFocusedAttribute:(id)value;
|
||||
- (NSString *)accessibilityHelpAttribute;
|
||||
- (BOOL)accessibilityIsHelpAttributeSettable;
|
||||
- (NSValue *)accessibilityIndexAttribute;
|
||||
- (BOOL)accessibilityIsIndexAttributeSettable;
|
||||
- (id)accessibilityMaxValueAttribute;
|
||||
- (BOOL)accessibilityIsMaxValueAttributeSettable;
|
||||
- (id)accessibilityMinValueAttribute;
|
||||
- (BOOL)accessibilityIsMinValueAttributeSettable;
|
||||
- (id)accessibilityOrientationAttribute;
|
||||
- (BOOL)accessibilityIsOrientationAttributeSettable;
|
||||
- (id)accessibilityParentAttribute;
|
||||
- (BOOL)accessibilityIsParentAttributeSettable;
|
||||
- (NSValue *)accessibilityPositionAttribute;
|
||||
- (BOOL)accessibilityIsPositionAttributeSettable;
|
||||
- (NSString *)accessibilityRoleAttribute;
|
||||
- (BOOL)accessibilityIsRoleAttributeSettable;
|
||||
- (NSString *)accessibilityRoleDescriptionAttribute;
|
||||
- (BOOL)accessibilityIsRoleDescriptionAttributeSettable;
|
||||
- (NSArray *)accessibilitySelectedChildrenAttribute;
|
||||
- (BOOL)accessibilityIsSelectedChildrenAttributeSettable;
|
||||
- (NSNumber *)accessibilitySelectedAttribute;
|
||||
- (BOOL)accessibilityIsSelectedAttributeSettable;
|
||||
- (void)accessibilitySetSelectedAttribute:(id)value;
|
||||
- (NSValue *)accessibilitySizeAttribute;
|
||||
- (BOOL)accessibilityIsSizeAttributeSettable;
|
||||
- (NSString *)accessibilitySubroleAttribute;
|
||||
- (BOOL)accessibilityIsSubroleAttributeSettable;
|
||||
- (NSString *)accessibilityTitleAttribute;
|
||||
- (BOOL)accessibilityIsTitleAttributeSettable;
|
||||
- (NSWindow *)accessibilityTopLevelUIElementAttribute;
|
||||
- (BOOL)accessibilityIsTopLevelUIElementAttributeSettable;
|
||||
- (id)accessibilityValueAttribute;
|
||||
- (BOOL)accessibilityIsValueAttributeSettable;
|
||||
- (void)accessibilitySetValueAttribute:(id)value;
|
||||
- (NSArray *)accessibilityVisibleChildrenAttribute;
|
||||
- (BOOL)accessibilityIsVisibleChildrenAttributeSettable;
|
||||
- (id)accessibilityWindowAttribute;
|
||||
- (BOOL)accessibilityIsWindowAttributeSettable;
|
||||
|
||||
// actions
|
||||
- (NSArray *)accessibilityActionNames;
|
||||
- (NSString *)accessibilityActionDescription:(NSString *)action;
|
||||
- (void)accessibilityPerformAction:(NSString *)action;
|
||||
|
||||
- (BOOL)accessibilityIsIgnored;
|
||||
- (id)accessibilityHitTest:(NSPoint)point withEnv:(JNIEnv *)env;
|
||||
- (id)accessibilityFocusedUIElement;
|
||||
- (BOOL)accessiblePerformAction:(NSAccessibilityActionName)actionName;
|
||||
|
||||
@end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,26 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaBaseAccessibility.h"
|
||||
|
||||
@interface JavaElementAccessibility : JavaBaseAccessibility
|
||||
|
||||
@property(readonly) int accessibleIndexOfParent;
|
||||
|
||||
@end
|
||||
|
||||
@interface PlatformAxElement : NSAccessibilityElement <JavaBaseProvider>
|
||||
|
||||
// begin of NSAccessibility protocol methods
|
||||
- (BOOL)isAccessibilityElement;
|
||||
- (NSString *)accessibilityLabel;
|
||||
- (NSArray *)accessibilityChildren;
|
||||
- (NSArray *)accessibilitySelectedChildren;
|
||||
- (NSRect)accessibilityFrame;
|
||||
- (id)accessibilityParent;
|
||||
- (BOOL)accessibilityIsIgnored;
|
||||
- (BOOL)isAccessibilityEnabled;
|
||||
- (id)accessibilityApplicationFocusedUIElement;
|
||||
- (id)getAccessibilityWindow;
|
||||
// end of NSAccessibility protocol methods
|
||||
|
||||
@end
|
||||
@@ -1,137 +0,0 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
|
||||
|
||||
static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible");
|
||||
static JNF_MEMBER_CACHE(jm_getAccessibleContext, sjc_CAccessible, "getAccessibleContext", "()Ljavax/accessibility/AccessibleContext;");
|
||||
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleIndexInParent, sjc_CAccessibility, "getAccessibleIndexInParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
|
||||
|
||||
static void RaiseMustOverrideException(NSString *method)
|
||||
{
|
||||
@throw [NSException exceptionWithName:NSInternalInconsistencyException
|
||||
reason:[NSString stringWithFormat:@"You must override %@ in a subclass", method]
|
||||
userInfo:nil];
|
||||
};
|
||||
|
||||
@implementation JavaElementAccessibility
|
||||
|
||||
- (NSString *)getPlatformAxElementClassName
|
||||
{
|
||||
RaiseMustOverrideException(@"getPlatformAxElementClassName");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- (int)accessibleIndexOfParent {
|
||||
return (int)JNFCallStaticIntMethod ([ThreadUtilities getJNIEnv], sjm_getAccessibleIndexInParent, fAccessible, fComponent);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation PlatformAxElement
|
||||
|
||||
@synthesize javaBase;
|
||||
|
||||
- (BOOL)isAccessibilityElement
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (NSString *)accessibilityLabel
|
||||
{
|
||||
// RaiseMustOverrideException(@"accessibilityLabel");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, [javaBase accessible], [javaBase component]);
|
||||
NSString* str = JNFJavaToNSString(env, axName);
|
||||
(*env)->DeleteLocalRef(env, axName);
|
||||
return str;
|
||||
}
|
||||
|
||||
- (NSString *)accessibilityHelp {
|
||||
// RaiseMustOverrideException(@"accessibilityLabel");
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axName = JNFCallStaticObjectMethod(env, sjm_getAccessibleDescription, [javaBase accessible], [javaBase component]);
|
||||
NSString* str = JNFJavaToNSString(env, axName);
|
||||
(*env)->DeleteLocalRef(env, axName);
|
||||
return str;
|
||||
}
|
||||
|
||||
- (NSArray *)accessibilityChildren
|
||||
{
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
NSArray *children = [JavaBaseAccessibility childrenOfParent:self.javaBase
|
||||
withEnv:env
|
||||
withChildrenCode:JAVA_AX_ALL_CHILDREN
|
||||
allowIgnored:([[self accessibilityRole] isEqualToString:NSAccessibilityListRole] || [[self accessibilityRole] isEqualToString:NSAccessibilityTableRole] || [[self accessibilityRole] isEqualToString:NSAccessibilityOutlineRole])
|
||||
recursive:[[self accessibilityRole] isEqualToString:NSAccessibilityOutlineRole]];
|
||||
if ([children count] > 0) {
|
||||
return children;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- (NSArray *)accessibilitySelectedChildren
|
||||
{
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
NSArray *selectedChildren = [JavaBaseAccessibility childrenOfParent:self.javaBase
|
||||
withEnv:env
|
||||
withChildrenCode:JAVA_AX_SELECTED_CHILDREN
|
||||
allowIgnored:([[self accessibilityRole] isEqualToString:NSAccessibilityListRole] || [[self accessibilityRole] isEqualToString:NSAccessibilityTableRole] || [[self accessibilityRole] isEqualToString:NSAccessibilityOutlineRole])
|
||||
recursive:[[self accessibilityRole] isEqualToString:NSAccessibilityOutlineRole]];
|
||||
if ([selectedChildren count] > 0) {
|
||||
return selectedChildren;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- (NSRect)accessibilityFrame
|
||||
{
|
||||
return [self.javaBase getBounds];
|
||||
}
|
||||
|
||||
- (id)accessibilityParent
|
||||
{
|
||||
id parent = [self.javaBase parent];
|
||||
// Checking for protocol compliance can slow down at runtime. See: https://developer.apple.com/documentation/objectivec/nsobject/1418893-conformstoprotocol?language=objc
|
||||
return [parent respondsToSelector:@selector(platformAxElement)] ? [parent platformAxElement] : parent;
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityIsIgnored
|
||||
{
|
||||
RaiseMustOverrideException(@"accessibilityIsIgnored");
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibilityEnabled
|
||||
{
|
||||
RaiseMustOverrideException(@"isAccessibilityEnabled");
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (id)accessibilityApplicationFocusedUIElement
|
||||
{
|
||||
return [self.javaBase getFocusedElement];
|
||||
}
|
||||
|
||||
- (id)getAccessibilityWindow
|
||||
{
|
||||
return [self.javaBase window];
|
||||
}
|
||||
|
||||
- (void)setAccessibilityParent:(id)accessibilityParent {
|
||||
[[self javaBase] setParent:accessibilityParent];
|
||||
}
|
||||
|
||||
- (NSUInteger)accessibilityIndexOfChild:(id)child {
|
||||
return [[self javaBase] accessibilityIndexOfChild:child];
|
||||
}
|
||||
|
||||
- (NSAccessibilityRole)accessibilityRole {
|
||||
return [sRoles objectForKey:[[self javaBase] javaRole]];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1,14 +1,9 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#ifndef NATIVE_JAVALISTACCESSIBILITY_H
|
||||
#define NATIVE_JAVALISTACCESSIBILITY_H
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
#endif // NATIVE_JAVALISTACCESSIBILITY_H
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
|
||||
@interface JavaListAccessibility : JavaElementAccessibility
|
||||
@interface JavaListAccessibility : JavaComponentAccessibility
|
||||
@end
|
||||
|
||||
@interface PlatformAxList : PlatformAxElement <NSAccessibilityList>
|
||||
@end
|
||||
@end
|
||||
|
||||
@@ -15,13 +15,11 @@
|
||||
|
||||
@implementation PlatformAxList
|
||||
|
||||
- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilityRows
|
||||
{
|
||||
- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilityRows {
|
||||
return [self accessibilityChildren];
|
||||
}
|
||||
|
||||
- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilitySelectedRows
|
||||
{
|
||||
- (nullable NSArray<id<NSAccessibilityRow>> *)accessibilitySelectedRows {
|
||||
return [self accessibilitySelectedChildren];
|
||||
}
|
||||
|
||||
@@ -30,23 +28,15 @@
|
||||
return [super accessibilityLabel] == NULL ? @"list" : [super accessibilityLabel];
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityIsIgnored
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibilityEnabled
|
||||
{
|
||||
return YES;
|
||||
}
|
||||
|
||||
// to avoid warning (why?): method in protocol 'NSAccessibilityElement' not implemented
|
||||
|
||||
- (NSRect)accessibilityFrame
|
||||
{
|
||||
return [super accessibilityFrame];
|
||||
}
|
||||
|
||||
// to avoid warning (why?): method in protocol 'NSAccessibilityElement' not implemented
|
||||
|
||||
- (id)accessibilityParent
|
||||
{
|
||||
return [super accessibilityParent];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaListRowAccessibility : JavaElementAccessibility
|
||||
@interface JavaListRowAccessibility : JavaComponentAccessibility
|
||||
@end
|
||||
|
||||
@interface PlatformAxListRow : PlatformAxElement <NSAccessibilityRow>
|
||||
|
||||
@@ -22,12 +22,12 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
- (NSArray *)accessibilityChildren {
|
||||
NSArray *children = [super accessibilityChildren];
|
||||
if (children == NULL) {
|
||||
JavaBaseAccessibility *newChild = [JavaBaseAccessibility createWithParent:[self javaBase]
|
||||
accessible:[[self javaBase] accessible]
|
||||
role:[[self javaBase] javaRole]
|
||||
index:[[self javaBase] index]
|
||||
JavaComponentAccessibility *newChild = [JavaComponentAccessibility createWithParent:[self javaComponent]
|
||||
accessible:[[self javaComponent] accessible]
|
||||
role:[[self javaComponent] javaRole]
|
||||
index:[[self javaComponent] index]
|
||||
withEnv:[ThreadUtilities getJNIEnv]
|
||||
withView:[[self javaBase] view]
|
||||
withView:[[self javaComponent] view]
|
||||
isWrapped:YES];
|
||||
return [NSArray arrayWithObject:[newChild autorelease].platformAxElement];
|
||||
} else {
|
||||
@@ -36,7 +36,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
}
|
||||
|
||||
- (NSInteger)accessibilityIndex {
|
||||
return [super accessibilityIndex];
|
||||
return [[self accessibilityParent] accessibilityIndexOfChild:self];
|
||||
}
|
||||
|
||||
- (id)accessibilityParent
|
||||
@@ -44,4 +44,8 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
return [super accessibilityParent];
|
||||
}
|
||||
|
||||
- (NSRect)accessibilityFrame {
|
||||
return [super accessibilityFrame];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -185,66 +185,66 @@ static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAc
|
||||
@implementation PlatformAxNavigableText
|
||||
|
||||
- (NSRect)accessibilityFrameForRange:(NSRange)range {
|
||||
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleBoundsForRange:range] rectValue];
|
||||
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleBoundsForRange:range] rectValue];
|
||||
}
|
||||
|
||||
- (NSInteger)accessibilityLineForIndex:(NSInteger)index {
|
||||
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleLineForIndex:index] integerValue];
|
||||
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleLineForIndex:index] integerValue];
|
||||
}
|
||||
|
||||
- (NSRange)accessibilityRangeForLine:(NSInteger)line {
|
||||
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleRangeForLine:line] rangeValue];
|
||||
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleRangeForLine:line] rangeValue];
|
||||
}
|
||||
|
||||
- (NSString *)accessibilityStringForRange:(NSRange)range {
|
||||
return [(JavaNavigableTextAccessibility *)[self javaBase] accessibleStringForRange:range];
|
||||
return [(JavaNavigableTextAccessibility *) [self javaComponent] accessibleStringForRange:range];
|
||||
}
|
||||
|
||||
- (id)accessibilityValue {
|
||||
return [(JavaNavigableTextAccessibility *)[self javaBase] accessibleValue];
|
||||
return [(JavaNavigableTextAccessibility *) [self javaComponent] accessibleValue];
|
||||
}
|
||||
|
||||
- (NSAccessibilitySubrole)accessibilitySubrole {
|
||||
if ([(JavaNavigableTextAccessibility *)[self javaBase] accessibleIsPasswordText]) {
|
||||
if ([(JavaNavigableTextAccessibility *) [self javaComponent] accessibleIsPasswordText]) {
|
||||
return NSAccessibilitySecureTextFieldSubrole;
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (NSRange)accessibilityRangeForIndex:(NSInteger)index {
|
||||
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleRangeForIndex:index] rangeValue];
|
||||
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleRangeForIndex:index] rangeValue];
|
||||
}
|
||||
|
||||
- (NSAccessibilityRole)accessibilityRole {
|
||||
return [sRoles objectForKey:[self javaBase].javaRole];
|
||||
return [sRoles objectForKey:[self javaComponent].javaRole];
|
||||
}
|
||||
|
||||
- (NSRange)accessibilityRangeForPosition:(NSPoint)point {
|
||||
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleRangeForPosition:point] rangeValue];
|
||||
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleRangeForPosition:point] rangeValue];
|
||||
}
|
||||
|
||||
- (NSString *)accessibilitySelectedText {
|
||||
return [(JavaNavigableTextAccessibility *)[self javaBase] accessibleSelectedText];
|
||||
return [(JavaNavigableTextAccessibility *) [self javaComponent] accessibleSelectedText];
|
||||
}
|
||||
|
||||
- (NSRange)accessibilitySelectedTextRange {
|
||||
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleSelectedTextRange] rangeValue];
|
||||
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleSelectedTextRange] rangeValue];
|
||||
}
|
||||
|
||||
- (NSInteger)accessibilityNumberOfCharacters {
|
||||
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleNumberOfCharacters] integerValue];
|
||||
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleNumberOfCharacters] integerValue];
|
||||
}
|
||||
|
||||
- (NSInteger)accessibilityInsertionPointLineNumber {
|
||||
return [[(JavaNavigableTextAccessibility *)[self javaBase] accessibleInsertionPointLineNumber] integerValue];
|
||||
return [[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleInsertionPointLineNumber] integerValue];
|
||||
}
|
||||
|
||||
- (void)setAccessibilitySelectedText:(NSString *)accessibilitySelectedText {
|
||||
[(JavaNavigableTextAccessibility *)[self javaBase] accessibleSetSelectedText:accessibilitySelectedText];
|
||||
[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleSetSelectedText:accessibilitySelectedText];
|
||||
}
|
||||
|
||||
- (void)setAccessibilitySelectedTextRange:(NSRange)accessibilitySelectedTextRange {
|
||||
[(JavaNavigableTextAccessibility *)[self javaBase] accessibleSetSelectedTextRange:accessibilitySelectedTextRange];
|
||||
[(JavaNavigableTextAccessibility *) [self javaComponent] accessibleSetSelectedTextRange:accessibilitySelectedTextRange];
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibilityEdited {
|
||||
|
||||
@@ -41,25 +41,29 @@ static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessi
|
||||
|
||||
- (NSArray *)accessibilityChildren {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject currentAccessible = [(JavaOutlineRowAccessibility *)[self javaBase] currentAccessibleWithENV:env];
|
||||
jobject currentAccessible = [(JavaOutlineRowAccessibility *) [self javaComponent] currentAccessibleWithENV:env];
|
||||
if (currentAccessible == NULL) {
|
||||
return nil;
|
||||
}
|
||||
JavaBaseAccessibility *currentElement = [JavaBaseAccessibility createWithAccessible:currentAccessible withEnv:env withView:[[self javaBase] view] isCurrent:YES];
|
||||
NSArray *children = [JavaBaseAccessibility childrenOfParent:currentElement withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
|
||||
JavaComponentAccessibility *currentElement = [JavaComponentAccessibility createWithAccessible:currentAccessible withEnv:env withView:[[self javaComponent] view] isCurrent:YES];
|
||||
NSArray *children = [JavaComponentAccessibility childrenOfParent:currentElement withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
|
||||
if ([children count] == 0) {
|
||||
return [NSArray arrayWithObject:[JavaBaseAccessibility createWithParent:[self javaBase] accessible:[[self javaBase] accessible] role:[[self javaBase] javaRole] index:[[self javaBase] index] withEnv:env withView:[[self javaBase] view] isWrapped:YES].platformAxElement];
|
||||
return [NSArray arrayWithObject:[JavaComponentAccessibility createWithParent:[self javaComponent] accessible:[[self javaComponent] accessible] role:[[self javaComponent] javaRole] index:[[self javaComponent] index] withEnv:env withView:[[self javaComponent] view] isWrapped:YES].platformAxElement];
|
||||
} else {
|
||||
return children;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSInteger)accessibilityDisclosureLevel {
|
||||
return [(JavaOutlineRowAccessibility *)[self javaBase] accessibleLevel];
|
||||
return [(JavaOutlineRowAccessibility *) [self javaComponent] accessibleLevel];
|
||||
}
|
||||
|
||||
- (BOOL)isAccessibilityDisclosed {
|
||||
return isExpanded([ThreadUtilities getJNIEnv], [[self javaBase] axContextWithEnv:[ThreadUtilities getJNIEnv]], [[self javaBase] component]);
|
||||
return isExpanded([ThreadUtilities getJNIEnv], [[self javaComponent] axContextWithEnv:[ThreadUtilities getJNIEnv]], [[self javaComponent] component]);
|
||||
}
|
||||
|
||||
- (NSAccessibilitySubrole)accessibilitySubrole {
|
||||
return NSAccessibilityOutlineRowSubrole;;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaScrollAreaAccessibility : JavaElementAccessibility
|
||||
@interface JavaScrollAreaAccessibility : JavaComponentAccessibility
|
||||
|
||||
@property(readonly) NSArray *accessibleContents;
|
||||
@property(readonly) id accessibleVerticalScrollBar;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#import "JavaAccessibilityUtilities.h"
|
||||
#import "ThreadUtilities.h"
|
||||
#import <JavaNativeFoundation/JavaNativeFoundation.h>
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@implementation JavaScrollAreaAccessibility
|
||||
|
||||
@@ -14,7 +13,7 @@
|
||||
|
||||
- (NSArray *)accessibleContents {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
NSArray *children = [JavaBaseAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
|
||||
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
|
||||
|
||||
if ([children count] <= 0) return nil;
|
||||
NSArray *contents = [NSMutableArray arrayWithCapacity:[children count]];
|
||||
@@ -23,7 +22,7 @@
|
||||
NSEnumerator *enumerator = [children objectEnumerator];
|
||||
id aElement;
|
||||
while ((aElement = [enumerator nextObject])) {
|
||||
NSString *nsRole = [aElement isKindOfClass:[JavaComponentAccessibility class]] ? [aElement accessibilityRoleAttribute] : [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
|
||||
NSString *nsRole = [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
|
||||
if (![nsRole isEqualToString:NSAccessibilityScrollBarRole]) {
|
||||
// no scroll bars in contents
|
||||
[(NSMutableArray *) contents addObject:aElement];
|
||||
@@ -36,16 +35,16 @@
|
||||
- (id)accessibleVerticalScrollBar {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
NSArray *children = [JavaBaseAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
|
||||
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
|
||||
if ([children count] <= 0) return nil;
|
||||
|
||||
// The scroll bars are in the children.
|
||||
NSEnumerator *enumerator = [children objectEnumerator];
|
||||
id aElement;
|
||||
while ((aElement = (PlatformAxElement *)[enumerator nextObject])) {
|
||||
NSString *nsRole = [aElement isKindOfClass:[JavaComponentAccessibility class]] ? [aElement accessibilityRoleAttribute] : [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
|
||||
NSString *nsRole = [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
|
||||
if ([nsRole isEqualToString:NSAccessibilityScrollBarRole]) {
|
||||
jobject elementAxContext = [[aElement javaBase] axContextWithEnv:env];
|
||||
jobject elementAxContext = [[aElement javaComponent] axContextWithEnv:env];
|
||||
if (isVertical(env, elementAxContext, fComponent)) {
|
||||
(*env)->DeleteLocalRef(env, elementAxContext);
|
||||
return aElement;
|
||||
@@ -60,16 +59,16 @@
|
||||
- (id)accessibleHorizontalScrollBar {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
|
||||
NSArray *children = [JavaBaseAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
|
||||
NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
|
||||
if ([children count] <= 0) return nil;
|
||||
|
||||
// The scroll bars are in the children.
|
||||
id aElement;
|
||||
NSEnumerator *enumerator = [children objectEnumerator];
|
||||
while ((aElement = [enumerator nextObject])) {
|
||||
NSString *nsRole = [aElement isKindOfClass:[JavaComponentAccessibility class]] ? [aElement accessibilityRoleAttribute] : [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
|
||||
NSString *nsRole = [aElement accessibilityRole]; // todo: Remove this solution when JavaComponentAccessibility is removed
|
||||
if ([nsRole isEqualToString:NSAccessibilityScrollBarRole]) {
|
||||
jobject elementAxContext = [[aElement javaBase] axContextWithEnv:env];
|
||||
jobject elementAxContext = [[aElement javaComponent] axContextWithEnv:env];
|
||||
if (isHorizontal(env, elementAxContext, fComponent)) {
|
||||
(*env)->DeleteLocalRef(env, elementAxContext);
|
||||
return aElement;
|
||||
@@ -86,15 +85,15 @@
|
||||
@implementation PlatformAxScrollArea
|
||||
|
||||
- (NSArray *)accessibilityContents {
|
||||
return [(JavaScrollAreaAccessibility *)[self javaBase] accessibleContents];
|
||||
return [(JavaScrollAreaAccessibility *) [self javaComponent] accessibleContents];
|
||||
}
|
||||
|
||||
- (id)accessibilityVerticalScrollBar {
|
||||
return [(JavaScrollAreaAccessibility *)[self javaBase] accessibleVerticalScrollBar];
|
||||
return [(JavaScrollAreaAccessibility *) [self javaComponent] accessibleVerticalScrollBar];
|
||||
}
|
||||
|
||||
- (id)accessibilityHorizontalScrollBar {
|
||||
return [(JavaScrollAreaAccessibility *)[self javaBase] accessibleHorizontalScrollBar];
|
||||
return [(JavaScrollAreaAccessibility *) [self javaComponent] accessibleHorizontalScrollBar];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaStaticTextAccessibility : JavaElementAccessibility
|
||||
@interface JavaStaticTextAccessibility : JavaComponentAccessibility
|
||||
|
||||
/*
|
||||
* Converts an int array to an NSRange wrapped inside an NSValue
|
||||
|
||||
@@ -42,7 +42,7 @@ static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAc
|
||||
@implementation PlatformAxStaticText
|
||||
|
||||
- (id)accessibilityValue {
|
||||
return [(JavaStaticTextAccessibility *)[self javaBase] accessibleValue];
|
||||
return [(JavaStaticTextAccessibility *) [self javaComponent] accessibleValue];
|
||||
}
|
||||
|
||||
- (NSRect)accessibilityFrame {
|
||||
@@ -54,7 +54,7 @@ static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAc
|
||||
}
|
||||
|
||||
- (NSRange)accessibilityVisibleCharacterRange {
|
||||
return [[(JavaStaticTextAccessibility *)[self javaBase] accessibleVisibleCharacterRange] rangeValue];
|
||||
return [[(JavaStaticTextAccessibility *) [self javaComponent] accessibleVisibleCharacterRange] rangeValue];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaTabButtonAccessibility : JavaElementAccessibility {
|
||||
@interface JavaTabButtonAccessibility : JavaComponentAccessibility {
|
||||
jobject fTabGroupAxContext;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ static BOOL javaObjectEquals(JNIEnv *env, jobject a, jobject b, jobject componen
|
||||
- (jobject)tabGroup {
|
||||
if (fTabGroupAxContext == NULL) {
|
||||
JNIEnv* env = [ThreadUtilities getJNIEnv];
|
||||
jobject tabGroupAxContext = [(JavaBaseAccessibility *)[self parent] axContextWithEnv:env];
|
||||
jobject tabGroupAxContext = [(JavaComponentAccessibility *)[self parent] axContextWithEnv:env];
|
||||
fTabGroupAxContext = JNFNewWeakGlobalRef(env, tabGroupAxContext);
|
||||
(*env)->DeleteLocalRef(env, tabGroupAxContext);
|
||||
}
|
||||
@@ -65,11 +65,11 @@ static BOOL javaObjectEquals(JNIEnv *env, jobject a, jobject b, jobject componen
|
||||
}
|
||||
|
||||
- (id)accessibilityValue {
|
||||
return [(JavaTabButtonAccessibility *)[self javaBase] accessibleValue];
|
||||
return [(JavaTabButtonAccessibility *) [self javaComponent] accessibleValue];
|
||||
}
|
||||
|
||||
- (BOOL)accessibilityPerformPress {
|
||||
[(JavaTabButtonAccessibility *)[self javaBase] performPressAction];
|
||||
[(JavaTabButtonAccessibility *) [self javaComponent] performPressAction];
|
||||
return YES;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaTabGroupAccessibility : JavaElementAccessibility {
|
||||
@interface JavaTabGroupAccessibility : JavaComponentAccessibility {
|
||||
NSInteger _numTabs;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,10 +23,10 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
|
||||
// Go through the tabs and find selAccessible
|
||||
_numTabs = [tabs count];
|
||||
JavaBaseAccessibility *aTab;
|
||||
JavaComponentAccessibility *aTab;
|
||||
NSInteger i;
|
||||
for (i = 0; i < _numTabs; i++) {
|
||||
aTab = [(PlatformAxElement *)[tabs objectAtIndex:i] javaBase];
|
||||
aTab = [(PlatformAxElement *) [tabs objectAtIndex:i] javaComponent];
|
||||
if ([aTab isAccessibleWithEnv:env forAccessible:selAccessible]) {
|
||||
(*env)->DeleteLocalRef(env, selAccessible);
|
||||
return [aTab platformAxElement];
|
||||
@@ -61,7 +61,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
NSUInteger tabIndex = (whichTabs >= 0) ? whichTabs : 0; // if we're getting one particular child, make sure to set its index correctly
|
||||
for(i = 0; i < arrayLen; i+=2) {
|
||||
jobject jtab = (*env)->GetObjectArrayElement(env, jtabsAndRoles, i);
|
||||
JavaBaseAccessibility *tab = [[[JavaTabButtonAccessibility alloc] initWithParent:self withEnv:env withAccessible:jtab withIndex:tabIndex withTabGroup:axContext withView:[self view] withJavaRole:tabJavaRole] autorelease];
|
||||
JavaComponentAccessibility *tab = [[[JavaTabButtonAccessibility alloc] initWithParent:self withEnv:env withAccessible:jtab withIndex:tabIndex withTabGroup:axContext withView:[self view] withJavaRole:tabJavaRole] autorelease];
|
||||
(*env)->DeleteLocalRef(env, jtab);
|
||||
[tabs addObject:[tab platformAxElement]];
|
||||
tabIndex++;
|
||||
@@ -75,7 +75,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
PlatformAxElement *currentTab = [self currentTabWithEnv:env withAxContext:axContext];
|
||||
if (currentTab == nil) return nil;
|
||||
|
||||
NSArray *contents = [JavaBaseAccessibility childrenOfParent:[currentTab javaBase] withEnv:env withChildrenCode:whichTabs allowIgnored:allowIgnored];
|
||||
NSArray *contents = [JavaComponentAccessibility childrenOfParent:[currentTab javaComponent] withEnv:env withChildrenCode:whichTabs allowIgnored:allowIgnored];
|
||||
if ([contents count] <= 0) return nil;
|
||||
return contents;
|
||||
}
|
||||
@@ -113,15 +113,15 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
@implementation PlatformAxTabGroup
|
||||
|
||||
- (NSArray *)accessibilityTabs {
|
||||
return [(JavaTabGroupAccessibility *)[self javaBase] accessibleTabs];
|
||||
return [(JavaTabGroupAccessibility *) [self javaComponent] accessibleTabs];
|
||||
}
|
||||
|
||||
- (NSArray *)accessibilityContents {
|
||||
return [(JavaTabGroupAccessibility *)[self javaBase] accessibleContents];
|
||||
return [(JavaTabGroupAccessibility *) [self javaComponent] accessibleContents];
|
||||
}
|
||||
|
||||
- (id)accessibilityValue {
|
||||
return [(JavaTabGroupAccessibility *)[self javaBase] accessibleValue];
|
||||
return [(JavaTabGroupAccessibility *) [self javaComponent] accessibleValue];
|
||||
}
|
||||
|
||||
- (NSArray *)accessibilityChildren {
|
||||
@@ -141,20 +141,20 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
if ( (maxCount == 1) && [attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
|
||||
// Children codes for ALL, SELECTED, VISIBLE are <0. If the code is >=0, we treat it as an index to a single child
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axContext = [(JavaTabGroupAccessibility *)[self javaBase] axContextWithEnv:env];
|
||||
jobject axContext = [(JavaTabGroupAccessibility *) [self javaComponent] axContextWithEnv:env];
|
||||
|
||||
//children = AXTabs + AXContents
|
||||
NSArray *children = [(JavaTabGroupAccessibility *)[self javaBase] tabButtonsWithEnv:env
|
||||
withTabGroupAxContext:axContext
|
||||
withTabCode:index
|
||||
allowIgnored:NO]; // first look at the tabs
|
||||
NSArray *children = [(JavaTabGroupAccessibility *) [self javaComponent] tabButtonsWithEnv:env
|
||||
withTabGroupAxContext:axContext
|
||||
withTabCode:index
|
||||
allowIgnored:NO]; // first look at the tabs
|
||||
if ([children count] > 0) {
|
||||
result = children;
|
||||
} else {
|
||||
children= [(JavaTabGroupAccessibility *)[self javaBase] contentsWithEnv:env
|
||||
withTabGroupAxContext:axContext
|
||||
withTabCode:(index-[(JavaTabGroupAccessibility *)[self javaBase] numTabs])
|
||||
allowIgnored:NO];
|
||||
children= [(JavaTabGroupAccessibility *) [self javaComponent] contentsWithEnv:env
|
||||
withTabGroupAxContext:axContext
|
||||
withTabCode:(index-[(JavaTabGroupAccessibility *) [self javaComponent] numTabs])
|
||||
allowIgnored:NO];
|
||||
if ([children count] > 0) {
|
||||
result = children;
|
||||
}
|
||||
@@ -172,7 +172,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
jobject axContext = [self axContextWithEnv:env];
|
||||
setAxContextSelection(env, axContext, [[self javaBase] index], [[self javaBase] component]);
|
||||
setAxContextSelection(env, axContext, [[self javaComponent] index], [[self javaComponent] component]);
|
||||
(*env)->DeleteLocalRef(env, axContext);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaTableAccessibility : JavaElementAccessibility
|
||||
@interface JavaTableAccessibility : JavaComponentAccessibility
|
||||
|
||||
@property(readonly) int accessibleRowCount;
|
||||
@property(readonly) int accessibleColCount;
|
||||
|
||||
@@ -145,28 +145,28 @@ static const char* ACCESSIBLE_JTABLE_NAME = "javax.swing.JTable$AccessibleJTable
|
||||
}
|
||||
|
||||
- (nullable NSArray *)accessibilityColumns {
|
||||
int colCount = [(JavaTableAccessibility *)[self javaBase] accessibleColCount];
|
||||
int colCount = [(JavaTableAccessibility *) [self javaComponent] accessibleColCount];
|
||||
NSMutableArray *columns = [NSMutableArray arrayWithCapacity:colCount];
|
||||
for (int i = 0; i < colCount; i++) {
|
||||
[columns addObject:[[JavaColumnAccessibility alloc] initWithParent:[self javaBase]
|
||||
[columns addObject:[[JavaColumnAccessibility alloc] initWithParent:[self javaComponent]
|
||||
withEnv:[ThreadUtilities getJNIEnv]
|
||||
withAccessible:NULL
|
||||
withIndex:i
|
||||
withView:[[self javaBase] view]
|
||||
withView:[[self javaComponent] view]
|
||||
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
|
||||
}
|
||||
return [NSArray arrayWithArray:columns];
|
||||
}
|
||||
|
||||
- (nullable NSArray *)accessibilitySelectedColumns {
|
||||
NSArray<NSNumber *> *indexes = [(JavaTableAccessibility *)[self javaBase] selectedAccessibleColumns];
|
||||
NSArray<NSNumber *> *indexes = [(JavaTableAccessibility *) [self javaComponent] selectedAccessibleColumns];
|
||||
NSMutableArray *columns = [NSMutableArray arrayWithCapacity:[indexes count]];
|
||||
for (NSNumber *i in indexes) {
|
||||
[columns addObject:[[JavaColumnAccessibility alloc] initWithParent:[self javaBase]
|
||||
[columns addObject:[[JavaColumnAccessibility alloc] initWithParent:[self javaComponent]
|
||||
withEnv:[ThreadUtilities getJNIEnv]
|
||||
withAccessible:NULL
|
||||
withIndex:i.unsignedIntValue
|
||||
withView:[[self javaBase] view]
|
||||
withView:[[self javaComponent] view]
|
||||
withJavaRole:JavaAccessibilityIgnore].platformAxElement];
|
||||
}
|
||||
return [NSArray arrayWithArray:columns];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
|
||||
#import "JavaElementAccessibility.h"
|
||||
#import "JavaComponentAccessibility.h"
|
||||
|
||||
@interface JavaTableRowAccessibility : JavaElementAccessibility
|
||||
@interface JavaTableRowAccessibility : JavaComponentAccessibility
|
||||
@end
|
||||
|
||||
@interface PlatformAxTableRow : PlatformAxElement <NSAccessibilityRow>
|
||||
|
||||
@@ -24,17 +24,17 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
NSArray *children = [super accessibilityChildren];
|
||||
if (children == NULL) {
|
||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||
if ([[[self accessibilityParent] javaBase] accessible] == NULL) return nil;
|
||||
jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, [[[self accessibilityParent] javaBase] accessible], [[[self accessibilityParent] javaBase] component], JAVA_AX_ALL_CHILDREN, NO);
|
||||
if ([[[self accessibilityParent] javaComponent] accessible] == NULL) return nil;
|
||||
jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, [[[self accessibilityParent] javaComponent] accessible], [[[self accessibilityParent] javaComponent] component], JAVA_AX_ALL_CHILDREN, NO);
|
||||
if (jchildrenAndRoles == NULL) return nil;
|
||||
|
||||
jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
|
||||
NSMutableArray *childrenCells = [NSMutableArray arrayWithCapacity:arrayLen/2];
|
||||
|
||||
NSUInteger childIndex = [self rowNumberInTable] * [(JavaTableAccessibility *)[[self accessibilityParent] javaBase] accessibleColCount];
|
||||
NSUInteger childIndex = [self rowNumberInTable] * [(JavaTableAccessibility *) [[self accessibilityParent] javaComponent] accessibleColCount];
|
||||
NSInteger i = childIndex * 2;
|
||||
NSInteger n = ([self rowNumberInTable] + 1) * [(JavaTableAccessibility *)[[self accessibilityParent] javaBase] accessibleColCount] * 2;
|
||||
JavaTableRowAccessibility *selfRow = [self javaBase];
|
||||
NSInteger n = ([self rowNumberInTable] + 1) * [(JavaTableAccessibility *) [[self accessibilityParent] javaComponent] accessibleColCount] * 2;
|
||||
JavaTableRowAccessibility *selfRow = [self javaComponent];
|
||||
for(i; i < n; i+=2)
|
||||
{
|
||||
jobject /* Accessible */ jchild = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i);
|
||||
@@ -68,7 +68,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
}
|
||||
|
||||
- (NSInteger)accessibilityIndex {
|
||||
return [[self javaBase] index];
|
||||
return [[self accessibilityParent] accessibilityIndexOfChild:self];
|
||||
}
|
||||
|
||||
- (NSString *)accessibilityLabel {
|
||||
@@ -89,7 +89,7 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
}
|
||||
|
||||
- (NSUInteger)rowNumberInTable {
|
||||
return [[self javaBase] index];
|
||||
return [[self javaComponent] index];
|
||||
}
|
||||
|
||||
- (NSRect)accessibilityFrame {
|
||||
@@ -102,5 +102,9 @@ static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getC
|
||||
return NSMakeRect(point.x, point.y, width, height);
|
||||
}
|
||||
|
||||
- (NSAccessibilitySubrole)accessibilitySubrole {
|
||||
return NSAccessibilityTableRowSubrole;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@@ -603,8 +603,8 @@ public abstract class Toolkit {
|
||||
toolkit = new HeadlessToolkit(toolkit);
|
||||
}
|
||||
}
|
||||
} catch (final ReflectiveOperationException ignored) {
|
||||
throw new AWTError("Could not create Toolkit: " + nm);
|
||||
} catch (final ReflectiveOperationException e) {
|
||||
newAWTError(e, "Could not create Toolkit: " + nm);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1062,7 +1062,9 @@ public class XBaseWindow {
|
||||
buttonState = xbe.get_state() & XConstants.ALL_BUTTONS_MASK;
|
||||
|
||||
boolean isWheel = (theButton == XConstants.MouseWheelUp ||
|
||||
theButton == XConstants.MouseWheelDown);
|
||||
theButton == XConstants.MouseWheelDown ||
|
||||
theButton == XConstants.ScrollLeft ||
|
||||
theButton == XConstants.ScrollRight);
|
||||
|
||||
// don't give focus if it's just the mouse wheel turning
|
||||
if (!isWheel) {
|
||||
|
||||
@@ -211,6 +211,8 @@ public final class XConstants {
|
||||
// as it may be possible to remap them via x11 configuration files
|
||||
public static final int MouseWheelUp = buttons[3];
|
||||
public static final int MouseWheelDown = buttons[4];
|
||||
public static final int ScrollLeft = buttons[5];
|
||||
public static final int ScrollRight = buttons[6];
|
||||
|
||||
/* Notify modes */
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright 2021 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @bug 8195129
|
||||
* @summary regression test for 8195129,
|
||||
* verifies the ability to System.load() from a location containing non-Latin characters
|
||||
* @requires os.family == "win" | os.family == "mac" | os.family == "linux"
|
||||
* @library /test/lib
|
||||
* @run main/native LoadLibraryUnicode
|
||||
*/
|
||||
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
import jdk.test.lib.Platform;
|
||||
import jdk.test.lib.Asserts;
|
||||
|
||||
public class LoadLibraryUnicode {
|
||||
|
||||
static native int giveANumber();
|
||||
|
||||
private static final String NON_LATIN_PATH_NAME = "ka-\u1889-omega-\u03c9";
|
||||
|
||||
public static void verifySystemLoad() throws Exception {
|
||||
String osDependentLibraryFileName = null;
|
||||
if (Platform.isLinux()) {
|
||||
osDependentLibraryFileName = "libLoadLibraryUnicode.so";
|
||||
} else if (Platform.isOSX()) {
|
||||
osDependentLibraryFileName = "libLoadLibraryUnicode.dylib";
|
||||
} else if (Platform.isWindows()) {
|
||||
osDependentLibraryFileName = "LoadLibraryUnicode.dll";
|
||||
} else {
|
||||
throw new Error("Unsupported OS");
|
||||
}
|
||||
|
||||
String testNativePath = getSystemProperty("test.nativepath");
|
||||
Path origLibraryPath = Paths.get(testNativePath).resolve(osDependentLibraryFileName);
|
||||
|
||||
Path currentDirPath = Paths.get(".").toAbsolutePath();
|
||||
Path newLibraryPath = currentDirPath.resolve(NON_LATIN_PATH_NAME);
|
||||
Files.createDirectory(newLibraryPath);
|
||||
newLibraryPath = newLibraryPath.resolve(osDependentLibraryFileName);
|
||||
|
||||
System.out.println(String.format("Copying '%s' to '%s'", origLibraryPath, newLibraryPath));
|
||||
Files.copy(origLibraryPath, newLibraryPath);
|
||||
|
||||
System.out.println(String.format("Loading '%s'", newLibraryPath));
|
||||
System.load(newLibraryPath.toString());
|
||||
|
||||
final int retval = giveANumber();
|
||||
Asserts.assertEquals(retval, 42);
|
||||
}
|
||||
|
||||
public static void verifyExceptionMessage() throws Exception {
|
||||
Path currentDirPath = Paths.get(".").toAbsolutePath();
|
||||
Path newLibraryPath = currentDirPath.resolve(NON_LATIN_PATH_NAME).resolve("non-existent-library");
|
||||
|
||||
System.out.println(String.format("Loading '%s'", newLibraryPath));
|
||||
try {
|
||||
System.load(newLibraryPath.toString());
|
||||
} catch(UnsatisfiedLinkError e) {
|
||||
// The name of the library may have been corrupted by encoding/decoding it improperly.
|
||||
// Verify that it is still the same.
|
||||
Asserts.assertTrue(e.getMessage().contains(NON_LATIN_PATH_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
verifySystemLoad();
|
||||
verifyExceptionMessage();
|
||||
}
|
||||
|
||||
// Utility method to retrieve and validate system properties
|
||||
private static String getSystemProperty(String propertyName) throws Error {
|
||||
String systemProperty = System.getProperty(propertyName, "").trim();
|
||||
System.out.println(propertyName + " = " + systemProperty);
|
||||
if (systemProperty.isEmpty()) {
|
||||
throw new Error("TESTBUG: property " + propertyName + " is empty");
|
||||
}
|
||||
return systemProperty;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2021 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
Java_LoadLibraryUnicode_giveANumber(JNIEnv *env) {
|
||||
return 42;
|
||||
}
|
||||
@@ -28,9 +28,6 @@
|
||||
* @summary Checks that JComboBox as JTable cell editor processes key events
|
||||
* even where setSurrendersFocusOnKeystroke flag in JTable is false and
|
||||
* that it does not lose the first key press where the flag is true.
|
||||
* @library ../../regtesthelpers
|
||||
* @build Util
|
||||
* @author Alexey Ivanov
|
||||
* @run main bug8032878
|
||||
*/
|
||||
|
||||
@@ -86,6 +83,7 @@ public class bug8032878 implements Runnable {
|
||||
|
||||
frame.pack();
|
||||
frame.setVisible(true);
|
||||
frame.setLocationRelativeTo(null);
|
||||
}
|
||||
|
||||
private void test(final boolean flag) throws Exception {
|
||||
@@ -93,11 +91,13 @@ public class bug8032878 implements Runnable {
|
||||
surrender = flag;
|
||||
SwingUtilities.invokeAndWait(this);
|
||||
|
||||
robot.waitForIdle();
|
||||
robot.delay(1000);
|
||||
runTest();
|
||||
checkResult();
|
||||
} finally {
|
||||
if (frame != null) {
|
||||
frame.dispose();
|
||||
SwingUtilities.invokeAndWait(() -> frame.dispose());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -105,12 +105,20 @@ public class bug8032878 implements Runnable {
|
||||
private void runTest() throws Exception {
|
||||
robot.waitForIdle();
|
||||
// Select 'one'
|
||||
Util.hitKeys(robot, KeyEvent.VK_TAB);
|
||||
robot.keyPress(KeyEvent.VK_TAB);
|
||||
robot.keyRelease(KeyEvent.VK_TAB);
|
||||
robot.waitForIdle();
|
||||
Util.hitKeys(robot, KeyEvent.VK_1);
|
||||
Util.hitKeys(robot, KeyEvent.VK_2);
|
||||
Util.hitKeys(robot, KeyEvent.VK_3);
|
||||
Util.hitKeys(robot, KeyEvent.VK_ENTER);
|
||||
robot.keyPress(KeyEvent.VK_1);
|
||||
robot.keyRelease(KeyEvent.VK_1);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_2);
|
||||
robot.keyRelease(KeyEvent.VK_2);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_3);
|
||||
robot.keyRelease(KeyEvent.VK_3);
|
||||
robot.waitForIdle();
|
||||
robot.keyPress(KeyEvent.VK_ENTER);
|
||||
robot.keyRelease(KeyEvent.VK_ENTER);
|
||||
robot.waitForIdle();
|
||||
}
|
||||
|
||||
|
||||
165
test/jdk/jb/java/awt/Toolkit/ToolkitExceptionTest.java
Normal file
165
test/jdk/jb/java/awt/Toolkit/ToolkitExceptionTest.java
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright 2000-2021 JetBrains s.r.o.
|
||||
* 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.
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/* @test
|
||||
* @summary regression test on JBR-3295 Fix error handling in Toolkit — do not ignore error and pass it as a cause
|
||||
* @run main/othervm -Dawt.toolkit=ToolkitExceptionTest ToolkitExceptionTest
|
||||
*/
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.datatransfer.Clipboard;
|
||||
import java.awt.font.TextAttribute;
|
||||
import java.awt.im.InputMethodHighlight;
|
||||
import java.awt.image.ColorModel;
|
||||
import java.awt.image.ImageObserver;
|
||||
import java.awt.image.ImageProducer;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.net.URL;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
public class ToolkitExceptionTest extends Toolkit {
|
||||
|
||||
public static void main (String[] args) {
|
||||
try {
|
||||
Toolkit.getDefaultToolkit();
|
||||
} catch (Throwable e) {
|
||||
ByteArrayOutputStream bos = new ByteArrayOutputStream();
|
||||
e.printStackTrace(new PrintStream(bos));
|
||||
if (!bos.toString().contains("MyToolkitException")) {
|
||||
throw new RuntimeException("Failed");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public ToolkitExceptionTest() {
|
||||
throw new RuntimeException("MyToolkitException");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dimension getScreenSize() throws HeadlessException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getScreenResolution() throws HeadlessException {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ColorModel getColorModel() throws HeadlessException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getFontList() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public FontMetrics getFontMetrics(Font font) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sync() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(String filename) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image getImage(URL url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image createImage(String filename) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image createImage(URL url) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean prepareImage(Image image, int width, int height, ImageObserver observer) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int checkImage(Image image, int width, int height, ImageObserver observer) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image createImage(ImageProducer producer) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Image createImage(byte[] imagedata, int imageoffset, int imagelength) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintJob getPrintJob(Frame frame, String jobtitle, Properties props) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beep() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Clipboard getSystemClipboard() throws HeadlessException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected EventQueue getSystemEventQueueImpl() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModalityTypeSupported(Dialog.ModalityType modalityType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModalExclusionTypeSupported(Dialog.ModalExclusionType modalExclusionType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<TextAttribute, ?> mapInputMethodHighlight(InputMethodHighlight highlight) throws HeadlessException {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
87
test/jdk/jb/java/awt/Window/SiblingOrderTest.java
Normal file
87
test/jdk/jb/java/awt/Window/SiblingOrderTest.java
Normal file
@@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright 2021 JetBrains s.r.o.
|
||||
* 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.
|
||||
*
|
||||
* 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 javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.InputEvent;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @summary Regression test for JBR-3353 Sibling popup window is shown below dialog on macOS
|
||||
* @key headful
|
||||
*/
|
||||
|
||||
public class SiblingOrderTest {
|
||||
private static Robot robot;
|
||||
private static JFrame frame;
|
||||
private static final CompletableFuture<Boolean> popupButtonPressed = new CompletableFuture<>();
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
robot = new Robot();
|
||||
try {
|
||||
SwingUtilities.invokeAndWait(SiblingOrderTest::initUI);
|
||||
click(); // button in frame
|
||||
click(); // button in dialog
|
||||
click(); // button in popup
|
||||
popupButtonPressed.get(3, TimeUnit.SECONDS);
|
||||
} finally {
|
||||
SwingUtilities.invokeAndWait(SiblingOrderTest::disposeUI);
|
||||
}
|
||||
}
|
||||
|
||||
private static void initUI() {
|
||||
frame = new JFrame("SiblingOrderTest");
|
||||
JButton b = new JButton("Dialog");
|
||||
b.addActionListener(e -> {
|
||||
JDialog d = new JDialog(frame, "Dialog");
|
||||
JButton b1 = new JButton("Popup");
|
||||
b1.addActionListener(e1 -> {
|
||||
JWindow w = new JWindow(frame);
|
||||
JButton b2 = new JButton("Finish");
|
||||
b2.addActionListener(e2 -> popupButtonPressed.complete(true));
|
||||
w.add(b2);
|
||||
w.setBounds(150, 150, 100, 100);
|
||||
w.setVisible(true);
|
||||
});
|
||||
d.add(b1);
|
||||
d.setBounds(100, 100, 200, 200);
|
||||
d.setVisible(true);
|
||||
});
|
||||
frame.add(b);
|
||||
frame.setBounds(50, 50, 300, 300);
|
||||
frame.setVisible(true);
|
||||
}
|
||||
|
||||
private static void disposeUI() {
|
||||
if (frame != null) frame.dispose();
|
||||
}
|
||||
|
||||
private static void click() {
|
||||
robot.delay(1000);
|
||||
robot.mouseMove(200, 200);
|
||||
robot.mousePress(InputEvent.BUTTON1_DOWN_MASK);
|
||||
robot.mouseRelease(InputEvent.BUTTON1_DOWN_MASK);
|
||||
}
|
||||
}
|
||||
62
test/jdk/jb/java/jcef/HandleJSQueryTest3314.sh
Normal file
62
test/jdk/jb/java/jcef/HandleJSQueryTest3314.sh
Normal file
@@ -0,0 +1,62 @@
|
||||
#!/bin/bash
|
||||
|
||||
#
|
||||
# Copyright 2000-2021 JetBrains s.r.o.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
# @test
|
||||
# @summary Regression test for JBR-3314
|
||||
# It executes the test HandleJSQueryTest.java in a loop till a crash happens or number of iterations
|
||||
# exceeds a limit.
|
||||
# Number of iterations can be specified via the environment variable RUN_NUMBER, by default it is set to 100.
|
||||
# @run shell/timeout=300 HandleJSQueryTest3314.sh
|
||||
|
||||
RUNS_NUMBER=${RUN_NUMBER:-50}
|
||||
echo "number of iterations: $RUNS_NUMBER"
|
||||
|
||||
if [ -z "${TESTSRC}" ]; then
|
||||
echo "TESTSRC undefined: set to ."
|
||||
TESTSRC=.
|
||||
fi
|
||||
|
||||
if [ -z "${TESTCLASSES}" ]; then
|
||||
echo "TESTCLASSES undefined: set to ."
|
||||
TESTCLASSES=.
|
||||
fi
|
||||
|
||||
if [ -z "${TESTJAVA}" ]; then
|
||||
echo "TESTJAVA undefined: testing cancelled"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
curdir=$(pwd)
|
||||
cd ${TESTSRC}
|
||||
${TESTJAVA}/bin/javac -d ${TESTCLASSES} HandleJSQueryTest.java
|
||||
cd $curdir
|
||||
|
||||
i=0
|
||||
while [ "$i" -le "$RUNS_NUMBER" ]; do
|
||||
echo "iteration - $i"
|
||||
${TESTJAVA}/bin/java -cp ${TESTCLASSES} HandleJSQueryTest
|
||||
exit_code=$?
|
||||
echo "exit_xode=$exit_code"
|
||||
if [ $exit_code -ne "0" ]; then
|
||||
[[ $exit_code -eq "134" ]] && echo "FAILED: Test crashed" && exit $exit_code
|
||||
echo "Test failed because of not a crash. Execution is being conituned"
|
||||
fi
|
||||
i=$(( i + 1 ))
|
||||
done
|
||||
echo "PASSED: Test did never crash during 100 iterations"
|
||||
exit 0
|
||||
Reference in New Issue
Block a user