src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m
author aghaisas
Wed, 20 Feb 2019 17:00:40 +0530
branchmetal-prototype-branch
changeset 57196 a95707a39ff5
parent 52842 d3f785c4969c
permissions -rw-r--r--
Description : Metal Rendering Pipeline - initial implementation of line and quad rendering Contributed-by: jdv, aghaisas
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     1
/*
50650
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
     2
 * Copyright (c) 2011, 2018, Oracle and/or its affiliates. All rights reserved.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     4
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    10
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    15
 * accompanied this code).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    16
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    20
 *
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    23
 * questions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    24
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    25
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    26
// External Java Accessibility links:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    27
//
38388
84ab1f133f16 8143346: Broken link in java.beans.XMLEncoder
serb
parents: 26751
diff changeset
    28
// <https://docs.oracle.com/javase/8/docs/technotes/guides/access/index.html>
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    29
// <http://www-106.ibm.com/developerworks/library/j-access/?n-j-10172>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    30
// <http://archives.java.sun.com/archives/java-access.html> (Sun's mailing list for Java accessibility)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    31
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    32
#import "JavaComponentAccessibility.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    33
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    34
#import "sun_lwawt_macosx_CAccessibility.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    35
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    36
#import <AppKit/AppKit.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    37
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    38
#import <JavaNativeFoundation/JavaNativeFoundation.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    39
#import <JavaRuntimeSupport/JavaRuntimeSupport.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    40
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    41
#import <dlfcn.h>
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    42
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    43
#import "JavaAccessibilityAction.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    44
#import "JavaAccessibilityUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    45
#import "JavaTextAccessibility.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    46
#import "ThreadUtilities.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    47
#import "AWTView.h"
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    48
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    49
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    50
// these constants are duplicated in CAccessibility.java
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    51
#define JAVA_AX_ALL_CHILDREN (-1)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    52
#define JAVA_AX_SELECTED_CHILDREN (-2)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    53
#define JAVA_AX_VISIBLE_CHILDREN (-3)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    54
// If the value is >=0, it's an index
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    55
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    56
static JNF_STATIC_MEMBER_CACHE(jm_getChildrenAndRoles, sjc_CAccessibility, "getChildrenAndRoles", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;IZ)[Ljava/lang/Object;");
52260
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
    57
static JNF_STATIC_MEMBER_CACHE(jm_getTableInfo, sjc_CAccessibility, "getTableInfo", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;I)I");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    58
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleComponent, sjc_CAccessibility, "getAccessibleComponent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleComponent;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    59
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleValue, sjc_CAccessibility, "getAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleValue;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    60
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleName, sjc_CAccessibility, "getAccessibleName", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    61
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleDescription, sjc_CAccessibility, "getAccessibleDescription", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    62
static JNF_STATIC_MEMBER_CACHE(sjm_isFocusTraversable, sjc_CAccessibility, "isFocusTraversable", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    63
static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleIndexInParent, sjc_CAccessibility, "getAccessibleIndexInParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)I");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    64
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    65
static JNF_CLASS_CACHE(sjc_CAccessible, "sun/lwawt/macosx/CAccessible");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    66
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    67
static JNF_MEMBER_CACHE(jf_ptr, sjc_CAccessible, "ptr", "J");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    68
static JNF_STATIC_MEMBER_CACHE(sjm_getCAccessible, sjc_CAccessible, "getCAccessible", "(Ljavax/accessibility/Accessible;)Lsun/lwawt/macosx/CAccessible;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    69
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    70
static jobject sAccessibilityClass = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    71
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    72
// sAttributeNamesForRoleCache holds the names of the attributes to which each java
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    73
// AccessibleRole responds (see AccessibleRole.java).
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    74
// This cache is queried before attempting to access a given attribute for a particular role.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    75
static NSMutableDictionary *sAttributeNamesForRoleCache = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    76
static NSObject *sAttributeNamesLOCK = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    77
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    78
@interface TabGroupAccessibility : JavaComponentAccessibility {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    79
    NSInteger _numTabs;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    80
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    81
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    82
- (id)currentTabWithEnv:(JNIEnv *)env withAxContext:(jobject)axContext;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    83
- (NSArray *)tabControlsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    84
- (NSArray *)contentsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    85
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    86
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    87
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    88
- (NSArray *)accessibilityChildrenAttribute;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    89
- (id) accessibilityTabsAttribute;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    90
- (BOOL)accessibilityIsTabsAttributeSettable;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    91
- (NSArray *)accessibilityContentsAttribute;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    92
- (BOOL)accessibilityIsContentsAttributeSettable;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    93
- (id) accessibilityValueAttribute;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    94
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    95
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    96
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    97
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    98
@interface TabGroupControlAccessibility : JavaComponentAccessibility {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
    99
    jobject fTabGroupAxContext;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   100
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   101
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withTabGroup:(jobject)tabGroup withView:(NSView *)view withJavaRole:(NSString *)javaRole;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   102
- (jobject)tabGroup;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   103
- (void)getActionsWithEnv:(JNIEnv *)env;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   104
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   105
- (id)accessibilityValueAttribute;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   106
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   107
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   108
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   109
@interface ScrollAreaAccessibility : JavaComponentAccessibility {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   110
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   111
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   112
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   113
- (NSArray *)accessibilityContentsAttribute;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   114
- (BOOL)accessibilityIsContentsAttributeSettable;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   115
- (id)accessibilityVerticalScrollBarAttribute;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   116
- (BOOL)accessibilityIsVerticalScrollBarAttributeSettable;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   117
- (id)accessibilityHorizontalScrollBarAttribute;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   118
- (BOOL)accessibilityIsHorizontalScrollBarAttributeSettable;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   119
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   120
52260
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   121
@interface TableAccessibility : JavaComponentAccessibility {
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   122
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   123
}
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   124
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env;
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   125
- (NSArray *)accessibilityRowsAttribute;
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   126
- (NSArray *)accessibilityColumnsAttribute;
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   127
@end
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   128
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   129
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   130
@implementation JavaComponentAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   131
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   132
- (NSString *)description
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   133
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   134
    return [NSString stringWithFormat:@"%@(title:'%@', desc:'%@', value:'%@')", [self accessibilityRoleAttribute],
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   135
        [self accessibilityTitleAttribute], [self accessibilityRoleDescriptionAttribute], [self accessibilityValueAttribute]];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   136
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   137
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   138
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   139
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   140
    self = [super init];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   141
    if (self)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   142
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   143
        fParent = [parent retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   144
        fView = [view retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   145
        fJavaRole = [javaRole retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   146
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   147
        fAccessible = (*env)->NewWeakGlobalRef(env, accessible);
43725
1f3f487b7f56 8170493: JNI exception pending in JavaComponentAccessibility.m
prr
parents: 41780
diff changeset
   148
        (*env)->ExceptionClear(env); // in case of OOME
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   149
        jobject jcomponent = [(AWTView *)fView awtComponent:env];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   150
        fComponent = (*env)->NewWeakGlobalRef(env, jcomponent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   151
        (*env)->DeleteLocalRef(env, jcomponent);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   152
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   153
        fIndex = index;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   154
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   155
        fActions = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   156
        fActionsLOCK = [[NSObject alloc] init];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   157
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   158
    return self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   159
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   160
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   161
- (void)unregisterFromCocoaAXSystem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   162
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   163
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   164
    static dispatch_once_t initialize_unregisterUniqueId_once;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   165
    static void (*unregisterUniqueId)(id);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   166
    dispatch_once(&initialize_unregisterUniqueId_once, ^{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   167
        void *jrsFwk = dlopen("/System/Library/Frameworks/JavaVM.framework/Frameworks/JavaRuntimeSupport.framework/JavaRuntimeSupport", RTLD_LAZY | RTLD_LOCAL);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   168
        unregisterUniqueId = dlsym(jrsFwk, "JRSAccessibilityUnregisterUniqueIdForUIElement");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   169
    });
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   170
    if (unregisterUniqueId) unregisterUniqueId(self);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   171
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   172
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   173
- (void)dealloc
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   174
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   175
    [self unregisterFromCocoaAXSystem];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   176
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   177
    JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   178
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   179
    (*env)->DeleteWeakGlobalRef(env, fAccessible);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   180
    fAccessible = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   181
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   182
    (*env)->DeleteWeakGlobalRef(env, fComponent);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   183
    fComponent = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   184
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   185
    [fParent release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   186
    fParent = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   187
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   188
    [fNSRole release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   189
    fNSRole = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   190
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   191
    [fJavaRole release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   192
    fJavaRole = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   193
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   194
    [fView release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   195
    fView = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   196
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   197
    [fActions release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   198
    fActions = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   199
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   200
    [fActionsLOCK release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   201
    fActionsLOCK = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   202
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   203
    [super dealloc];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   204
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   205
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   206
- (void)postValueChanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   207
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   208
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   209
    NSAccessibilityPostNotification(self, NSAccessibilityValueChangedNotification);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   210
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   211
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   212
- (void)postSelectedTextChanged
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   213
{
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   214
    AWT_ASSERT_APPKIT_THREAD;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   215
    NSAccessibilityPostNotification(self, NSAccessibilitySelectedTextChangedNotification);
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   216
}
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   217
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   218
- (void)postSelectionChanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   219
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   220
    AWT_ASSERT_APPKIT_THREAD;
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   221
    NSAccessibilityPostNotification(self, NSAccessibilitySelectedChildrenChangedNotification);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   222
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   223
52842
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
   224
-(void)postTitleChanged
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
   225
{
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
   226
    AWT_ASSERT_APPKIT_THREAD;
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
   227
    NSAccessibilityPostNotification(self, NSAccessibilityTitleChangedNotification);
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
   228
}
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
   229
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   230
- (void)postMenuOpened
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   231
{
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   232
    AWT_ASSERT_APPKIT_THREAD;
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   233
    NSAccessibilityPostNotification(self, (NSString *)kAXMenuOpenedNotification);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   234
}
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   235
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   236
- (void)postMenuClosed
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   237
{
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   238
    AWT_ASSERT_APPKIT_THREAD;
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   239
    NSAccessibilityPostNotification(self, (NSString *)kAXMenuClosedNotification);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   240
}
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   241
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   242
- (void)postMenuItemSelected
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   243
{
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   244
    AWT_ASSERT_APPKIT_THREAD;
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   245
    NSAccessibilityPostNotification(self, (NSString *)kAXMenuItemSelectedNotification);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   246
}
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   247
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   248
- (BOOL)isEqual:(id)anObject
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   249
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   250
    if (![anObject isKindOfClass:[self class]]) return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   251
    JavaComponentAccessibility *accessibility = (JavaComponentAccessibility *)anObject;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   252
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   253
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   254
    return (*env)->IsSameObject(env, accessibility->fAccessible, fAccessible);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   255
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   256
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   257
- (BOOL)isAccessibleWithEnv:(JNIEnv *)env forAccessible:(jobject)accessible
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   258
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   259
    return (*env)->IsSameObject(env, fAccessible, accessible);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   260
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   261
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   262
+ (void)initialize
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   263
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   264
    if (sAttributeNamesForRoleCache == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   265
        sAttributeNamesLOCK = [[NSObject alloc] init];
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   266
        sAttributeNamesForRoleCache = [[NSMutableDictionary alloc] initWithCapacity:60];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   267
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   268
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   269
    if (sRoles == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   270
        initializeRoles();
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   271
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   272
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   273
    if (sAccessibilityClass == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   274
        JNF_STATIC_MEMBER_CACHE(jm_getAccessibility, sjc_CAccessibility, "getAccessibility", "([Ljava/lang/String;)Lsun/lwawt/macosx/CAccessibility;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   275
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   276
#ifdef JAVA_AX_NO_IGNORES
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   277
        NSArray *ignoredKeys = [NSArray array];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   278
#else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   279
        NSArray *ignoredKeys = [sRoles allKeysForObject:JavaAccessibilityIgnore];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   280
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   281
        jobjectArray result = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   282
        jsize count = [ignoredKeys count];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   283
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   284
        JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   285
24140
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   286
        static JNF_CLASS_CACHE(jc_String, "java/lang/String");
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   287
        result = JNFNewObjectArray(env, &jc_String, count);
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   288
        if (!result) {
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   289
            NSLog(@"In %s, can't create Java array of String objects", __FUNCTION__);
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   290
            return;
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   291
        }
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   292
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   293
        NSInteger i;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   294
        for (i = 0; i < count; i++) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   295
            jstring jString = JNFNSToJavaString(env, [ignoredKeys objectAtIndex:i]);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   296
            (*env)->SetObjectArrayElement(env, result, i, jString);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   297
            (*env)->DeleteLocalRef(env, jString);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   298
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   299
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   300
        sAccessibilityClass = JNFCallStaticObjectMethod(env, jm_getAccessibility, result); // AWT_THREADING Safe (known object)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   301
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   302
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   303
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   304
+ (void)postFocusChanged:(id)message
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   305
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   306
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   307
    NSAccessibilityPostNotification([NSApp accessibilityFocusedUIElement], NSAccessibilityFocusedUIElementChangedNotification);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   308
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   309
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   310
+ (jobject) getCAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   311
    if (JNFIsInstanceOf(env, jaccessible, &sjc_CAccessible)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   312
        return jaccessible;
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   313
    } else if (JNFIsInstanceOf(env, jaccessible, &sjc_Accessible)) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   314
        return JNFCallStaticObjectMethod(env, sjm_getCAccessible, jaccessible);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   315
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   316
    return NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   317
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   318
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   319
+ (NSArray *)childrenOfParent:(JavaComponentAccessibility *)parent withEnv:(JNIEnv *)env withChildrenCode:(NSInteger)whichChildren allowIgnored:(BOOL)allowIgnored
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   320
{
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   321
    if (parent->fAccessible == NULL) return nil;
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   322
    jobjectArray jchildrenAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, parent->fAccessible, parent->fComponent, whichChildren, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   323
    if (jchildrenAndRoles == NULL) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   324
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   325
    jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   326
    NSMutableArray *children = [NSMutableArray arrayWithCapacity:arrayLen/2]; //childrenAndRoles array contains two elements (child, role) for each child
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   327
24140
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   328
    NSInteger i;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   329
    NSUInteger childIndex = (whichChildren >= 0) ? whichChildren : 0; // if we're getting one particular child, make sure to set its index correctly
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   330
    for(i = 0; i < arrayLen; i+=2)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   331
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   332
        jobject /* Accessible */ jchild = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   333
        jobject /* String */ jchildJavaRole = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i+1);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   334
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   335
        NSString *childJavaRole = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   336
        if (jchildJavaRole != NULL) {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   337
            jobject jkey = JNFGetObjectField(env, jchildJavaRole, sjf_key);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   338
            childJavaRole = JNFJavaToNSString(env, jkey);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   339
            (*env)->DeleteLocalRef(env, jkey);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   340
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   341
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   342
        JavaComponentAccessibility *child = [self createWithParent:parent accessible:jchild role:childJavaRole index:childIndex withEnv:env withView:parent->fView];
50650
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
   343
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   344
        (*env)->DeleteLocalRef(env, jchild);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   345
        (*env)->DeleteLocalRef(env, jchildJavaRole);
50650
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
   346
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   347
        [children addObject:child];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   348
        childIndex++;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   349
    }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   350
    (*env)->DeleteLocalRef(env, jchildrenAndRoles);
50650
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
   351
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   352
    return children;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   353
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   354
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   355
+ (JavaComponentAccessibility *)createWithAccessible:(jobject)jaccessible withEnv:(JNIEnv *)env withView:(NSView *)view
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   356
{
41400
71893f19fd7f 8165829: Android Studio 2.x crashes with NPE at sun.lwawt.macosx.CAccessibility.getAccessibleIndexInParent
ant
parents: 39873
diff changeset
   357
    JavaComponentAccessibility *ret = nil;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   358
    jobject jcomponent = [(AWTView *)view awtComponent:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   359
    jint index = JNFCallStaticIntMethod(env, sjm_getAccessibleIndexInParent, jaccessible, jcomponent);
41400
71893f19fd7f 8165829: Android Studio 2.x crashes with NPE at sun.lwawt.macosx.CAccessibility.getAccessibleIndexInParent
ant
parents: 39873
diff changeset
   360
    if (index >= 0) {
71893f19fd7f 8165829: Android Studio 2.x crashes with NPE at sun.lwawt.macosx.CAccessibility.getAccessibleIndexInParent
ant
parents: 39873
diff changeset
   361
      NSString *javaRole = getJavaRole(env, jaccessible, jcomponent);
71893f19fd7f 8165829: Android Studio 2.x crashes with NPE at sun.lwawt.macosx.CAccessibility.getAccessibleIndexInParent
ant
parents: 39873
diff changeset
   362
      ret = [self createWithAccessible:jaccessible role:javaRole index:index withEnv:env withView:view];
71893f19fd7f 8165829: Android Studio 2.x crashes with NPE at sun.lwawt.macosx.CAccessibility.getAccessibleIndexInParent
ant
parents: 39873
diff changeset
   363
    }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   364
    (*env)->DeleteLocalRef(env, jcomponent);
41400
71893f19fd7f 8165829: Android Studio 2.x crashes with NPE at sun.lwawt.macosx.CAccessibility.getAccessibleIndexInParent
ant
parents: 39873
diff changeset
   365
    return ret;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   366
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   367
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   368
+ (JavaComponentAccessibility *) createWithAccessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   369
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   370
    return [self createWithParent:nil accessible:jaccessible role:javaRole index:index withEnv:env withView:view];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   371
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   372
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   373
+ (JavaComponentAccessibility *) createWithParent:(JavaComponentAccessibility *)parent accessible:(jobject)jaccessible role:(NSString *)javaRole index:(jint)index withEnv:(JNIEnv *)env withView:(NSView *)view
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   374
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   375
    // try to fetch the jCAX from Java, and return autoreleased
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   376
    jobject jCAX = [JavaComponentAccessibility getCAccessible:jaccessible withEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   377
    if (jCAX == NULL) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   378
    JavaComponentAccessibility *value = (JavaComponentAccessibility *) jlong_to_ptr(JNFGetLongField(env, jCAX, jf_ptr));
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   379
    if (value != nil) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   380
        (*env)->DeleteLocalRef(env, jCAX);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   381
        return [[value retain] autorelease];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   382
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   383
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   384
    // otherwise, create a new instance
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   385
    JavaComponentAccessibility *newChild = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   386
    if ([javaRole isEqualToString:@"pagetablist"]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   387
        newChild = [TabGroupAccessibility alloc];
52260
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   388
    } else if ([javaRole isEqualToString:@"table"]) {
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   389
        newChild = [TableAccessibility alloc];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   390
    } else if ([javaRole isEqualToString:@"scrollpane"]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   391
        newChild = [ScrollAreaAccessibility alloc];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   392
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   393
        NSString *nsRole = [sRoles objectForKey:javaRole];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   394
        if ([nsRole isEqualToString:NSAccessibilityStaticTextRole] || [nsRole isEqualToString:NSAccessibilityTextAreaRole] || [nsRole isEqualToString:NSAccessibilityTextFieldRole]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   395
            newChild = [JavaTextAccessibility alloc];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   396
        } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   397
            newChild = [JavaComponentAccessibility alloc];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   398
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   399
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   400
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   401
    // must init freshly -alloc'd object
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   402
    [newChild initWithParent:parent withEnv:env withAccessible:jCAX withIndex:index withView:view withJavaRole:javaRole]; // must init new instance
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   403
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   404
    // If creating a JPopupMenu (not a combobox popup list) need to fire menuOpened.
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   405
    // This is the only way to know if the menu is opening; visible state change
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   406
    // can't be caught because the listeners are not set up in time.
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   407
    if ( [javaRole isEqualToString:@"popupmenu"] &&
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   408
         ![[parent javaRole] isEqualToString:@"combobox"] ) {
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   409
        [newChild postMenuOpened];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   410
    }
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   411
23651
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23010
diff changeset
   412
    // must hard retain pointer poked into Java object
e41298d0da2f 8037099: [macosx] Remove all references to GC from native OBJ-C code
pchelko
parents: 23010
diff changeset
   413
    [newChild retain];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   414
    JNFSetLongField(env, jCAX, jf_ptr, ptr_to_jlong(newChild));
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   415
    (*env)->DeleteLocalRef(env, jCAX);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   416
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   417
    // return autoreleased instance
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   418
    return [newChild autorelease];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   419
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   420
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   421
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   422
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   423
    static JNF_STATIC_MEMBER_CACHE(jm_getInitialAttributeStates, sjc_CAccessibility, "getInitialAttributeStates", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)[Z");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   424
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   425
    NSMutableArray *attributeNames = [NSMutableArray arrayWithCapacity:20];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   426
    [attributeNames retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   427
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   428
    // all elements respond to parent, role, role description, window, topLevelUIElement, help
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   429
    [attributeNames addObject:NSAccessibilityParentAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   430
    [attributeNames addObject:NSAccessibilityRoleAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   431
    [attributeNames addObject:NSAccessibilityRoleDescriptionAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   432
    [attributeNames addObject:NSAccessibilityHelpAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   433
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   434
    // cmcnote: AXMenu usually doesn't respond to window / topLevelUIElement. But menus within a Java app's window
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   435
    // probably should. Should we use some role other than AXMenu / AXMenuBar for Java menus?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   436
    [attributeNames addObject:NSAccessibilityWindowAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   437
    [attributeNames addObject:NSAccessibilityTopLevelUIElementAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   438
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   439
    // set accessible subrole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   440
    NSString *javaRole = [self javaRole];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   441
    if (javaRole != nil && [javaRole isEqualToString:@"passwordtext"]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   442
        //cmcnote: should turn this into a constant
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   443
        [attributeNames addObject:NSAccessibilitySubroleAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   444
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   445
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   446
    // Get all the other accessibility attributes states we need in one swell foop.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   447
    // javaRole isn't pulled in because we need protected access to AccessibleRole.key
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   448
    jbooleanArray attributeStates = (jbooleanArray)JNFCallStaticObjectMethod(env, jm_getInitialAttributeStates, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
24140
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   449
    if (attributeStates == NULL) return nil;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   450
    jboolean *attributeStatesArray = (*env)->GetBooleanArrayElements(env, attributeStates, 0);
24140
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   451
    if (attributeStatesArray == NULL) {
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   452
        // Note: Java will not be on the stack here so a java exception can't happen and no need to call ExceptionCheck.
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   453
        NSLog(@"%s failed calling GetBooleanArrayElements", __FUNCTION__);
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   454
        return nil;
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
   455
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   456
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   457
    // if there's a component, it can be enabled and it has a size/position
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   458
    if (attributeStatesArray[0]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   459
        [attributeNames addObject:NSAccessibilityEnabledAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   460
        [attributeNames addObject:NSAccessibilitySizeAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   461
        [attributeNames addObject:NSAccessibilityPositionAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   462
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   463
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   464
    // According to javadoc, a component that is focusable will return true from isFocusTraversable,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   465
    // as well as having AccessibleState.FOCUSABLE in it's AccessibleStateSet.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   466
    // We use the former heuristic; if the component focus-traversable, add a focused attribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   467
    // See also: accessibilityIsFocusedAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   468
    if (attributeStatesArray[1])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   469
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   470
        [attributeNames addObject:NSAccessibilityFocusedAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   471
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   472
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   473
    // if it's a pagetab / radiobutton, it has a value but no min/max value.
52534
356e75119d31 7124293: [macosx] VoiceOver reads percentages rather than the actual values for sliders.
sveerabhadra
parents: 52260
diff changeset
   474
    // if it is a slider, supplying only the value makes it to voice out the value instead of percentages
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   475
    BOOL hasAxValue = attributeStatesArray[2];
52534
356e75119d31 7124293: [macosx] VoiceOver reads percentages rather than the actual values for sliders.
sveerabhadra
parents: 52260
diff changeset
   476
    if ([javaRole isEqualToString:@"pagetab"] || [javaRole isEqualToString:@"radiobutton"] || [javaRole isEqualToString:@"slider"]) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   477
        [attributeNames addObject:NSAccessibilityValueAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   478
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   479
        // if not a pagetab/radio button, and it has a value, it has a min/max/current value.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   480
        if (hasAxValue) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   481
            // er, it has a min/max/current value if it's not a button.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   482
            // See AppKit/NSButtonCellAccessibility.m
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   483
            if (![javaRole isEqualToString:@"pushbutton"]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   484
                //cmcnote: make this (and "passwordtext") constants instead of magic strings
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   485
                [attributeNames addObject:NSAccessibilityMinValueAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   486
                [attributeNames addObject:NSAccessibilityMaxValueAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   487
                [attributeNames addObject:NSAccessibilityValueAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   488
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   489
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   490
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   491
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   492
    // does it have an orientation?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   493
    if (attributeStatesArray[4]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   494
        [attributeNames addObject:NSAccessibilityOrientationAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   495
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   496
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   497
    // name
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   498
    if (attributeStatesArray[5]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   499
        [attributeNames addObject:NSAccessibilityTitleAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   500
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   501
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   502
    // children
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   503
    if (attributeStatesArray[6]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   504
        [attributeNames addObject:NSAccessibilityChildrenAttribute];
52260
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   505
        if ([javaRole isEqualToString:@"list"]
52842
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
   506
                || [javaRole isEqualToString:@"table"]
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
   507
                || [javaRole isEqualToString:@"pagetablist"]) {
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   508
            [attributeNames addObject:NSAccessibilitySelectedChildrenAttribute];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   509
            [attributeNames addObject:NSAccessibilityVisibleChildrenAttribute];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   510
        }
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   511
        // Just above, the below mentioned support has been added back in for lists.
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   512
        // However, the following comments may still be useful for future fixes.
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   513
//        [attributeNames addObject:NSAccessibilitySelectedChildrenAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   514
//        [attributeNames addObject:NSAccessibilityVisibleChildrenAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   515
                //According to AXRoles.txt:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   516
                //VisibleChildren: radio group, list, row, table row subrole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   517
                //SelectedChildren: list
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   518
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   519
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   520
    // Cleanup
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   521
    (*env)->ReleaseBooleanArrayElements(env, attributeStates, attributeStatesArray, JNI_ABORT);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   522
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   523
    return attributeNames;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   524
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   525
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   526
- (NSDictionary *)getActions:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   527
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   528
    @synchronized(fActionsLOCK) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   529
        if (fActions == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   530
            fActions = [[NSMutableDictionary alloc] initWithCapacity:3];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   531
            [self getActionsWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   532
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   533
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   534
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   535
    return fActions;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   536
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   537
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   538
- (void)getActionsWithEnv:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   539
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   540
    static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleAction, sjc_CAccessibility, "getAccessibleAction", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/AccessibleAction;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   541
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   542
    // On MacOSX, text doesn't have actions, in java it does.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   543
    // cmcnote: NOT TRUE - Editable text has AXShowMenu. Textfields have AXConfirm. Static text has no actions.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   544
    jobject axAction = JNFCallStaticObjectMethod(env, jm_getAccessibleAction, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   545
    if (axAction != NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   546
        //+++gdb NOTE: In MacOSX, there is just a single Action, not multiple. In java,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   547
        //  the first one seems to be the most basic, so this will be used.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   548
        // cmcnote: NOT TRUE - Sometimes there are multiple actions, eg sliders have AXDecrement AND AXIncrement (radr://3893192)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   549
        JavaAxAction *action = [[JavaAxAction alloc] initWithEnv:env withAccessibleAction:axAction withIndex:0 withComponent:fComponent];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   550
        [fActions setObject:action forKey:[self isMenu] ? NSAccessibilityPickAction : NSAccessibilityPressAction];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   551
        [action release];
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   552
        (*env)->DeleteLocalRef(env, axAction);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   553
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   554
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   555
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   556
- (jobject)axContextWithEnv:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   557
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   558
    return getAxContext(env, fAccessible, fComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   559
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   560
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   561
- (id)parent
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   562
{
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   563
    static JNF_CLASS_CACHE(sjc_Window, "java/awt/Window");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   564
    static JNF_STATIC_MEMBER_CACHE(sjm_getAccessibleParent, sjc_CAccessibility, "getAccessibleParent", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   565
    static JNF_STATIC_MEMBER_CACHE(sjm_getSwingAccessible, sjc_CAccessible, "getSwingAccessible", "(Ljavax/accessibility/Accessible;)Ljavax/accessibility/Accessible;");
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   566
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   567
    if(fParent == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   568
        JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   569
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   570
        jobject jparent = JNFCallStaticObjectMethod(env, sjm_getAccessibleParent, fAccessible, fComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   571
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   572
        if (jparent == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   573
            fParent = fView;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   574
        } else {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   575
            AWTView *view = fView;
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   576
            jobject jax = JNFCallStaticObjectMethod(env, sjm_getSwingAccessible, fAccessible);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   577
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   578
            if (JNFIsInstanceOf(env, jax, &sjc_Window)) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   579
                // In this case jparent is an owner toplevel and we should retrieve its own view
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   580
                view = [AWTView awtView:env ofAccessible:jparent];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   581
            }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   582
            if (view != nil) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   583
                fParent = [JavaComponentAccessibility createWithAccessible:jparent withEnv:env withView:view];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   584
            }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   585
            if (fParent == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   586
                fParent = fView;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   587
            }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   588
            (*env)->DeleteLocalRef(env, jparent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   589
            (*env)->DeleteLocalRef(env, jax );
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   590
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   591
        [fParent retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   592
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   593
    return fParent;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   594
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   595
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   596
- (NSView *)view
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   597
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   598
    return fView;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   599
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   600
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   601
- (NSWindow *)window
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   602
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   603
    return [[self view] window];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   604
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   605
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   606
- (NSString *)javaRole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   607
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   608
    if(fJavaRole == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   609
        JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   610
        fJavaRole = getJavaRole(env, fAccessible, fComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   611
        [fJavaRole retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   612
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   613
    return fJavaRole;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   614
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   615
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   616
- (BOOL)isMenu
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   617
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   618
    id role = [self accessibilityRoleAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   619
    return [role isEqualToString:NSAccessibilityMenuBarRole] || [role isEqualToString:NSAccessibilityMenuRole] || [role isEqualToString:NSAccessibilityMenuItemRole];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   620
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   621
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   622
- (BOOL)isSelected:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   623
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   624
    if (fIndex == -1) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   625
        return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   626
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   627
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   628
    return isChildSelected(env, ((JavaComponentAccessibility *)[self parent])->fAccessible, fIndex, fComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   629
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   630
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   631
- (BOOL)isSelectable:(JNIEnv *)env
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   632
{
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   633
    jobject axContext = [self axContextWithEnv:env];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   634
    BOOL selectable = isSelectable(env, axContext, fComponent);
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   635
    (*env)->DeleteLocalRef(env, axContext);
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   636
    return selectable;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   637
}
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   638
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   639
- (BOOL)isVisible:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   640
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   641
    if (fIndex == -1) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   642
        return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   643
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   644
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   645
    jobject axContext = [self axContextWithEnv:env];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   646
    BOOL showing = isShowing(env, axContext, fComponent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   647
    (*env)->DeleteLocalRef(env, axContext);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   648
    return showing;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   649
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   650
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   651
// the array of names for each role is cached in the sAttributeNamesForRoleCache
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   652
- (NSArray *)accessibilityAttributeNames
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   653
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   654
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   655
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   656
    @synchronized(sAttributeNamesLOCK) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   657
        NSString *javaRole = [self javaRole];
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   658
        NSArray *names =
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   659
            (NSArray *)[sAttributeNamesForRoleCache objectForKey:javaRole];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   660
        if (names == nil) {
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   661
            names = [self initializeAttributeNamesWithEnv:env];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   662
#ifdef JAVA_AX_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   663
            NSLog(@"Initializing: %s for %@: %@", __FUNCTION__, javaRole, names);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   664
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   665
            [sAttributeNamesForRoleCache setObject:names forKey:javaRole];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   666
        }
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   667
        // The above set of attributes is immutable per role, but some objects, if
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   668
        // they are the child of a list, need to add the selected and index attributes.
50650
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
   669
        if ([self accessibilityIsIgnored]) {
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
   670
            return names;
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
   671
        }
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   672
        id myParent = [self accessibilityParentAttribute];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   673
        if ([myParent isKindOfClass:[JavaComponentAccessibility class]]) {
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   674
            NSString *parentRole = [(JavaComponentAccessibility *)myParent javaRole];
52260
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   675
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   676
            if ([parentRole isEqualToString:@"list"]
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
   677
                    || [parentRole isEqualToString:@"table"]) {
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   678
                NSMutableArray *moreNames =
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   679
                    [[NSMutableArray alloc] initWithCapacity: [names count] + 2];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   680
                [moreNames addObjectsFromArray: names];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   681
                [moreNames addObject:NSAccessibilitySelectedAttribute];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   682
                [moreNames addObject:NSAccessibilityIndexAttribute];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   683
                return moreNames;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   684
            }
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   685
        }
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   686
        // popupmenu's return values not selected children
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   687
        if ( [javaRole isEqualToString:@"popupmenu"] &&
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   688
             ![[[self parent] javaRole] isEqualToString:@"combobox"] ) {
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   689
            NSMutableArray *moreNames =
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   690
                [[NSMutableArray alloc] initWithCapacity: [names count] + 1];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   691
            [moreNames addObjectsFromArray: names];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   692
            [moreNames addObject:NSAccessibilityValueAttribute];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   693
            return moreNames;
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   694
        }
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   695
        return names;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   696
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   697
    }  // end @synchronized
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   698
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   699
#ifdef JAVA_AX_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   700
    NSLog(@"Warning in %s: could not find attribute names for role: %@", __FUNCTION__, [self javaRole]);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   701
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   702
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   703
    return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   704
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   705
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   706
// -- accessibility attributes --
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   707
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   708
- (BOOL)accessibilityShouldUseUniqueId {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   709
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   710
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   711
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   712
- (BOOL)accessibilitySupportsOverriddenAttributes {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   713
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   714
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   715
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   716
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   717
// generic getters & setters
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   718
// cmcnote: it would make more sense if these generic getters/setters were in JavaAccessibilityUtilities
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   719
- (id)accessibilityAttributeValue:(NSString *)attribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   720
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   721
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   722
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   723
    // turns attribute "NSAccessibilityEnabledAttribute" into getter "accessibilityEnabledAttribute",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   724
    // calls getter on self
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   725
    return JavaAccessibilityAttributeValue(self, attribute);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   726
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   727
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   728
- (BOOL)accessibilityIsAttributeSettable:(NSString *)attribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   729
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   730
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   731
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   732
    // turns attribute "NSAccessibilityParentAttribute" into selector "accessibilityIsParentAttributeSettable",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   733
    // calls selector on self
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   734
    return JavaAccessibilityIsAttributeSettable(self, attribute);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   735
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   736
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   737
- (void)accessibilitySetValue:(id)value forAttribute:(NSString *)attribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   738
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   739
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   740
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   741
    if ([self accessibilityIsAttributeSettable:attribute]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   742
        // turns attribute "NSAccessibilityFocusAttribute" into setter "accessibilitySetFocusAttribute",
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   743
        // calls setter on self
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   744
        JavaAccessibilitySetAttributeValue(self, attribute, value);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   745
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   746
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   747
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   748
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   749
// specific attributes, in alphabetical order a la
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   750
// http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Protocols/NSAccessibility.html
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   751
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   752
// Elements that current element contains (NSArray)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   753
- (NSArray *)accessibilityChildrenAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   754
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   755
    JNIEnv* env = [ThreadUtilities getJNIEnv];
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   756
    NSArray *children = [JavaComponentAccessibility childrenOfParent:self
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   757
                                                    withEnv:env
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   758
                                                    withChildrenCode:JAVA_AX_ALL_CHILDREN
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   759
                                                    allowIgnored:NO];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   760
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   761
    NSArray *value = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   762
    if ([children count] > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   763
        value = children;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   764
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   765
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   766
    return value;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   767
}
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
   768
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   769
- (BOOL)accessibilityIsChildrenAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   770
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   771
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   772
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   773
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   774
- (NSUInteger)accessibilityIndexOfChild:(id)child
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   775
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   776
    // Only special-casing for Lists, for now. This allows lists to be accessible, fixing radr://3856139 "JLists are broken".
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   777
    // Will probably want to special-case for Tables when we implement them (radr://3096643 "Accessibility: Table").
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   778
    // In AppKit, NSMatrixAccessibility (which uses NSAccessibilityListRole), NSTableRowAccessibility, and NSTableViewAccessibility are the
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   779
    // only ones that override the default implementation in NSAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   780
    if (![[self accessibilityRoleAttribute] isEqualToString:NSAccessibilityListRole]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   781
        return [super accessibilityIndexOfChild:child];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   782
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   783
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   784
    jint returnValue =
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   785
        JNFCallStaticIntMethod( [ThreadUtilities getJNIEnv],
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   786
                                sjm_getAccessibleIndexInParent,
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   787
                                ((JavaComponentAccessibility *)child)->fAccessible,
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   788
                                ((JavaComponentAccessibility *)child)->fComponent );
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   789
    return (returnValue == -1) ? NSNotFound : returnValue;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   790
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   791
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   792
// Without this optimization accessibilityChildrenAttribute is called in order to get the entire array of children.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   793
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   794
    if ( (maxCount == 1) && [attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   795
        // Children codes for ALL, SELECTED, VISIBLE are <0. If the code is >=0, we treat it as an index to a single child
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   796
        NSArray *child = [JavaComponentAccessibility childrenOfParent:self withEnv:[ThreadUtilities getJNIEnv] withChildrenCode:(NSInteger)index allowIgnored:NO];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   797
        if ([child count] > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   798
            return child;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   799
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   800
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   801
    return [super accessibilityArrayAttributeValues:attribute index:index maxCount:maxCount];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   802
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   803
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   804
// Flag indicating enabled state of element (NSNumber)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   805
- (NSNumber *)accessibilityEnabledAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   806
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   807
    static JNF_STATIC_MEMBER_CACHE(jm_isEnabled, sjc_CAccessibility, "isEnabled", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Z");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   808
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   809
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   810
    NSNumber *value = [NSNumber numberWithBool:JNFCallStaticBooleanMethod(env, jm_isEnabled, fAccessible, fComponent)]; // AWT_THREADING Safe (AWTRunLoop)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   811
    if (value == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   812
        NSLog(@"WARNING: %s called on component that has no accessible component: %@", __FUNCTION__, self);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   813
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   814
    return value;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   815
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   816
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   817
- (BOOL)accessibilityIsEnabledAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   818
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   819
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   820
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   821
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   822
// Flag indicating presence of keyboard focus (NSNumber)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   823
- (NSNumber *)accessibilityFocusedAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   824
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   825
    if ([self accessibilityIsFocusedAttributeSettable]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   826
        return [NSNumber numberWithBool:[self isEqual:[NSApp accessibilityFocusedUIElement]]];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   827
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   828
    return [NSNumber numberWithBool:NO];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   829
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   830
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   831
- (BOOL)accessibilityIsFocusedAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   832
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   833
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   834
    // According to javadoc, a component that is focusable will return true from isFocusTraversable,
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   835
    // as well as having AccessibleState.FOCUSABLE in its AccessibleStateSet.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   836
    // We use the former heuristic; if the component focus-traversable, add a focused attribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   837
    // See also initializeAttributeNamesWithEnv:
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   838
    if (JNFCallStaticBooleanMethod(env, sjm_isFocusTraversable, fAccessible, fComponent)) { // AWT_THREADING Safe (AWTRunLoop)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   839
        return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   840
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   841
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   842
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   843
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   844
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   845
- (void)accessibilitySetFocusedAttribute:(id)value
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   846
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   847
    static JNF_STATIC_MEMBER_CACHE(jm_requestFocus, sjc_CAccessibility, "requestFocus", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   848
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   849
    if ([(NSNumber*)value boolValue])
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   850
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   851
        JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   852
        JNFCallStaticVoidMethod(env, jm_requestFocus, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   853
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   854
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   855
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   856
// Instance description, such as a help tag string (NSString)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   857
- (NSString *)accessibilityHelpAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   858
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   859
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   860
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   861
    jobject val = JNFCallStaticObjectMethod(env, sjm_getAccessibleDescription, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   862
    if (val == NULL) {
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   863
        return nil;
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   864
    }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   865
    NSString* str = JNFJavaToNSString(env, val);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   866
    (*env)->DeleteLocalRef(env, val);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   867
    return str;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   868
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   869
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   870
- (BOOL)accessibilityIsHelpAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   871
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   872
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   873
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   874
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   875
- (NSValue *)accessibilityIndexAttribute
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   876
{
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   877
    NSInteger index = fIndex;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   878
    NSValue *returnValue = [NSValue value:&index withObjCType:@encode(NSInteger)];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   879
    return returnValue;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   880
}
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   881
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   882
- (BOOL)accessibilityIsIndexAttributeSettable
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   883
{
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   884
    return NO;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   885
}
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
   886
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   887
// Element's maximum value (id)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   888
- (id)accessibilityMaxValueAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   889
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   890
    static JNF_STATIC_MEMBER_CACHE(jm_getMaximumAccessibleValue, sjc_CAccessibility, "getMaximumAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   891
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   892
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   893
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   894
    jobject axValue = JNFCallStaticObjectMethod(env, jm_getMaximumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   895
    if (axValue == NULL) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   896
        return [NSNumber numberWithInt:0];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   897
    }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   898
    NSNumber* num = JNFJavaToNSNumber(env, axValue);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   899
    (*env)->DeleteLocalRef(env, axValue);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   900
    return num;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   901
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   902
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   903
- (BOOL)accessibilityIsMaxValueAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   904
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   905
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   906
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   907
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   908
// Element's minimum value (id)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   909
- (id)accessibilityMinValueAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   910
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   911
    static JNF_STATIC_MEMBER_CACHE(jm_getMinimumAccessibleValue, sjc_CAccessibility, "getMinimumAccessibleValue", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/Number;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   912
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   913
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   914
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   915
    jobject axValue = JNFCallStaticObjectMethod(env, jm_getMinimumAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   916
    if (axValue == NULL) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   917
        return [NSNumber numberWithInt:0];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   918
    }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   919
    NSNumber* num = JNFJavaToNSNumber(env, axValue);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   920
    (*env)->DeleteLocalRef(env, axValue);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   921
    return num;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   922
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   923
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   924
- (BOOL)accessibilityIsMinValueAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   925
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   926
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   927
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   928
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   929
- (id)accessibilityOrientationAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   930
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   931
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   932
    jobject axContext = [self axContextWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   933
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   934
    // cmcnote - should batch these two calls into one that returns an array of two bools, one for vertical and one for horiz
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   935
    if (isVertical(env, axContext, fComponent)) {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   936
        (*env)->DeleteLocalRef(env, axContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   937
        return NSAccessibilityVerticalOrientationValue;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   938
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   939
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   940
    if (isHorizontal(env, axContext, fComponent)) {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   941
        (*env)->DeleteLocalRef(env, axContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   942
        return NSAccessibilityHorizontalOrientationValue;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   943
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   944
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   945
    (*env)->DeleteLocalRef(env, axContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   946
    return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   947
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   948
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   949
- (BOOL)accessibilityIsOrientationAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   950
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   951
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   952
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   953
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   954
// Element containing current element (id)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   955
- (id)accessibilityParentAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   956
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   957
    return NSAccessibilityUnignoredAncestor([self parent]);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   958
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   959
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   960
- (BOOL)accessibilityIsParentAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   961
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   962
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   963
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   964
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   965
// Screen position of element's lower-left corner in lower-left relative screen coordinates (NSValue)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   966
- (NSValue *)accessibilityPositionAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   967
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   968
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   969
    jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   970
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   971
    // NSAccessibility wants the bottom left point of the object in
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   972
    // bottom left based screen coords
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   973
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   974
    // Get the java screen coords, and make a NSPoint of the bottom left of the AxComponent.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   975
    NSSize size = getAxComponentSize(env, axComponent, fComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   976
    NSPoint point = getAxComponentLocationOnScreen(env, axComponent, fComponent);
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
   977
    (*env)->DeleteLocalRef(env, axComponent);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   978
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   979
    point.y += size.height;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   980
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   981
    // Now make it into Cocoa screen coords.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   982
    point.y = [[[[self view] window] screen] frame].size.height - point.y;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   983
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   984
    return [NSValue valueWithPoint:point];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   985
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   986
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   987
- (BOOL)accessibilityIsPositionAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   988
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   989
    // In AppKit, position is only settable for a window (NSAccessibilityWindowRole). Our windows are taken care of natively, so we don't need to deal with this here
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   990
    // We *could* make use of Java's AccessibleComponent.setLocation() method. Investigate. radr://3953869
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   991
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   992
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   993
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   994
// Element type, such as NSAccessibilityRadioButtonRole (NSString). See the role table
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   995
// at http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Protocols/NSAccessibility.html
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   996
- (NSString *)accessibilityRoleAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   997
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   998
    if (fNSRole == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
   999
        NSString *javaRole = [self javaRole];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1000
        fNSRole = [sRoles objectForKey:javaRole];
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1001
        // The sRoles NSMutableDictionary maps popupmenu to Mac's popup button.
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1002
        // JComboBox behavior currently relies on this.  However this is not the
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1003
        // proper mapping for a JPopupMenu so fix that.
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1004
        if ( [javaRole isEqualToString:@"popupmenu"] &&
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1005
             ![[[self parent] javaRole] isEqualToString:@"combobox"] ) {
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1006
             fNSRole = NSAccessibilityMenuRole;
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1007
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1008
        if (fNSRole == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1009
            // this component has assigned itself a custom AccessibleRole not in the sRoles array
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1010
            fNSRole = javaRole;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1011
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1012
        [fNSRole retain];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1013
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1014
    return fNSRole;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1015
}
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1016
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1017
- (BOOL)accessibilityIsRoleAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1018
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1019
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1020
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1021
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1022
// Localized, user-readable description of role, such as radio button (NSString)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1023
- (NSString *)accessibilityRoleDescriptionAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1024
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1025
    // first ask AppKit for its accessible role description for a given AXRole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1026
    NSString *value = NSAccessibilityRoleDescription([self accessibilityRoleAttribute], nil);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1027
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1028
    if (value == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1029
        // query java if necessary
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1030
        static JNF_STATIC_MEMBER_CACHE(jm_getAccessibleRoleDisplayString, sjc_CAccessibility, "getAccessibleRoleDisplayString", "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)Ljava/lang/String;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1031
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1032
        JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1033
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1034
        jobject axRole = JNFCallStaticObjectMethod(env, jm_getAccessibleRoleDisplayString, fAccessible, fComponent);
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1035
        if (axRole != NULL) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1036
            value = JNFJavaToNSString(env, axRole);
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1037
            (*env)->DeleteLocalRef(env, axRole);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1038
        } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1039
            value = @"unknown";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1040
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1041
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1042
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1043
    return value;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1044
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1045
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1046
- (BOOL)accessibilityIsRoleDescriptionAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1047
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1048
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1049
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1050
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1051
// Currently selected children (NSArray)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1052
- (NSArray *)accessibilitySelectedChildrenAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1053
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1054
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1055
    NSArray *selectedChildren = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_SELECTED_CHILDREN allowIgnored:NO];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1056
    if ([selectedChildren count] > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1057
        return selectedChildren;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1058
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1059
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1060
    return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1061
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1062
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1063
- (BOOL)accessibilityIsSelectedChildrenAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1064
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1065
    return NO; // cmcnote: actually it should be. so need to write accessibilitySetSelectedChildrenAttribute also
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1066
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1067
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1068
- (NSNumber *)accessibilitySelectedAttribute
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1069
{
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1070
    return [NSNumber numberWithBool:[self isSelected:[ThreadUtilities getJNIEnv]]];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1071
}
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1072
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1073
- (BOOL)accessibilityIsSelectedAttributeSettable
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1074
{
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1075
    if ([self isSelectable:[ThreadUtilities getJNIEnv]]) {
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1076
        return YES;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1077
    } else {
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1078
        return NO;
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1079
    }
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1080
}
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1081
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1082
- (void)accessibilitySetSelectedAttribute:(id)value
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1083
{
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1084
    static JNF_STATIC_MEMBER_CACHE( jm_requestSelection,
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1085
                                    sjc_CAccessibility,
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1086
                                    "requestSelection",
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1087
                                    "(Ljavax/accessibility/Accessible;Ljava/awt/Component;)V" );
50650
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
  1088
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1089
    if ([(NSNumber*)value boolValue]) {
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1090
        JNIEnv* env = [ThreadUtilities getJNIEnv];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1091
        JNFCallStaticVoidMethod(env, jm_requestSelection, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1092
    }
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1093
}
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1094
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1095
// Element size (NSValue)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1096
- (NSValue *)accessibilitySizeAttribute {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1097
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1098
    jobject axComponent = JNFCallStaticObjectMethod(env, sjm_getAccessibleComponent, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1099
    NSValue* size = [NSValue valueWithSize:getAxComponentSize(env, axComponent, fComponent)];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1100
    (*env)->DeleteLocalRef(env, axComponent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1101
    return size;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1102
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1103
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1104
- (BOOL)accessibilityIsSizeAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1105
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1106
    // SIZE is settable in windows if [self styleMask] & NSResizableWindowMask - but windows are heavyweight so we're ok here
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1107
    // SIZE is settable in columns if [[self tableValue] allowsColumnResizing - haven't dealt with columns yet
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1108
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1109
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1110
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1111
// Element subrole type, such as NSAccessibilityTableRowSubrole (NSString). See the subrole attribute table at
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1112
// http://developer.apple.com/documentation/Cocoa/Reference/ApplicationKit/ObjC_classic/Protocols/NSAccessibility.html
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1113
- (NSString *)accessibilitySubroleAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1114
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1115
    NSString *value = nil;
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1116
    if ([[self javaRole] isEqualToString:@"passwordtext"]) {
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1117
        value = NSAccessibilitySecureTextFieldSubrole;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1118
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1119
    /*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1120
    // other subroles. TableRow and OutlineRow may be relevant to us
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1121
     NSAccessibilityCloseButtonSubrole // no, heavyweight window takes care of this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1122
     NSAccessibilityMinimizeButtonSubrole // "
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1123
     NSAccessibilityOutlineRowSubrole    // maybe?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1124
     NSAccessibilitySecureTextFieldSubrole // currently used
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1125
     NSAccessibilityTableRowSubrole        // maybe?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1126
     NSAccessibilityToolbarButtonSubrole // maybe?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1127
     NSAccessibilityUnknownSubrole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1128
     NSAccessibilityZoomButtonSubrole    // no, heavyweight window takes care of this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1129
     NSAccessibilityStandardWindowSubrole// no, heavyweight window takes care of this
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1130
     NSAccessibilityDialogSubrole        // maybe?
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1131
     NSAccessibilitySystemDialogSubrole    // no
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1132
     NSAccessibilityFloatingWindowSubrole // in 1.5 if we implement these, heavyweight will take care of them anyway
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1133
     NSAccessibilitySystemFloatingWindowSubrole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1134
     NSAccessibilityIncrementArrowSubrole  // no
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1135
     NSAccessibilityDecrementArrowSubrole  // no
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1136
     NSAccessibilityIncrementPageSubrole   // no
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1137
     NSAccessibilityDecrementPageSubrole   // no
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1138
     NSAccessibilitySearchFieldSubrole    //no
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1139
     */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1140
    return value;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1141
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1142
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1143
- (BOOL)accessibilityIsSubroleAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1144
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1145
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1146
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1147
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1148
// Title of element, such as button text (NSString)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1149
- (NSString *)accessibilityTitleAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1150
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1151
    // Return empty string for labels, since their value and tile end up being the same thing and this leads to repeated text.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1152
    if ([[self accessibilityRoleAttribute] isEqualToString:NSAccessibilityStaticTextRole]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1153
        return @"";
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1154
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1155
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1156
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1157
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1158
    jobject val = JNFCallStaticObjectMethod(env, sjm_getAccessibleName, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1159
    if (val == NULL) {
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1160
        return nil;
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1161
    }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1162
    NSString* str = JNFJavaToNSString(env, val);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1163
    (*env)->DeleteLocalRef(env, val);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1164
    return str;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1165
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1166
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1167
- (BOOL)accessibilityIsTitleAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1168
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1169
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1170
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1171
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1172
- (NSWindow *)accessibilityTopLevelUIElementAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1173
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1174
    return [self window];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1175
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1176
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1177
- (BOOL)accessibilityIsTopLevelUIElementAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1178
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1179
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1180
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1181
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1182
// Element's value (id)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1183
// note that the appKit meaning of "accessibilityValue" is different from the java
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1184
// meaning of "accessibleValue", which is specific to numerical values
38388
84ab1f133f16 8143346: Broken link in java.beans.XMLEncoder
serb
parents: 26751
diff changeset
  1185
// (https://docs.oracle.com/javase/8/docs/api/javax/accessibility/AccessibleValue.html#setCurrentAccessibleValue-java.lang.Number-)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1186
- (id)accessibilityValueAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1187
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1188
    static JNF_STATIC_MEMBER_CACHE(jm_getCurrentAccessibleValue, sjc_CAccessibility, "getCurrentAccessibleValue", "(Ljavax/accessibility/AccessibleValue;Ljava/awt/Component;)Ljava/lang/Number;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1189
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1190
    JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1191
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1192
    // Need to handle popupmenus differently.
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1193
    //
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1194
    // At least for now don't handle combo box menus.
50650
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
  1195
    // This may change when later fixing issues which currently
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1196
    // exist for combo boxes, but for now the following is only
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1197
    // for JPopupMenus, not for combobox menus.
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1198
    id parent = [self parent];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1199
    if ( [[self javaRole] isEqualToString:@"popupmenu"] &&
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1200
         ![[parent javaRole] isEqualToString:@"combobox"] ) {
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1201
        NSArray *children =
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1202
            [JavaComponentAccessibility childrenOfParent:self
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1203
                                        withEnv:env
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1204
                                        withChildrenCode:JAVA_AX_ALL_CHILDREN
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1205
                                        allowIgnored:YES];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1206
        if ([children count] > 0) {
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1207
            // handle case of AXMenuItem
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1208
            // need to ask menu what is selected
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1209
            NSArray *selectedChildrenOfMenu =
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1210
            	[self accessibilitySelectedChildrenAttribute];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1211
            JavaComponentAccessibility *selectedMenuItem =
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1212
            	[selectedChildrenOfMenu objectAtIndex:0];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1213
            if (selectedMenuItem != nil) {
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1214
                jobject itemValue =
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1215
                	JNFCallStaticObjectMethod( env,
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1216
                                                   sjm_getAccessibleName,
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1217
                                                   selectedMenuItem->fAccessible,
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1218
                                                   selectedMenuItem->fComponent ); // AWT_THREADING Safe (AWTRunLoop)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1219
                if (itemValue == NULL) {
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1220
                    return nil;
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1221
                }
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1222
                NSString* itemString = JNFJavaToNSString(env, itemValue);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1223
                (*env)->DeleteLocalRef(env, itemValue);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1224
                return itemString;
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1225
            } else {
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1226
            	return nil;
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1227
            }
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1228
        }
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1229
    }
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1230
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1231
    // ask Java for the component's accessibleValue. In java, the "accessibleValue" just means a numerical value
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1232
    // a text value is taken care of in JavaTextAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1233
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1234
    // cmcnote should coalesce these calls into one java call
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1235
    NSNumber *num = nil;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1236
    jobject axValue = JNFCallStaticObjectMethod(env, sjm_getAccessibleValue, fAccessible, fComponent); // AWT_THREADING Safe (AWTRunLoop)
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1237
    if (axValue != NULL) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1238
        jobject str = JNFCallStaticObjectMethod(env, jm_getCurrentAccessibleValue, axValue, fComponent);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1239
        if (str != NULL) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1240
            num = JNFJavaToNSNumber(env, str); // AWT_THREADING Safe (AWTRunLoop)
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1241
            (*env)->DeleteLocalRef(env, str);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1242
        }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1243
        (*env)->DeleteLocalRef(env, axValue);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1244
    }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1245
    if (num == nil) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1246
        num = [NSNumber numberWithInt:0];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1247
    }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1248
    return num;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1249
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1250
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1251
- (BOOL)accessibilityIsValueAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1252
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1253
    // according ot AppKit sources, in general the value attribute is not settable, except in the cases
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1254
    // of an NSScroller, an NSSplitView, and text that's both enabled & editable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1255
    BOOL isSettable = NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1256
    NSString *role = [self accessibilityRoleAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1257
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1258
    if ([role isEqualToString:NSAccessibilityScrollBarRole] || // according to NSScrollerAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1259
        [role isEqualToString:NSAccessibilitySplitGroupRole] ) // according to NSSplitViewAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1260
    {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1261
        isSettable = YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1262
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1263
    return isSettable;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1264
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1265
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1266
- (void)accessibilitySetValueAttribute:(id)value
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1267
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1268
#ifdef JAVA_AX_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1269
    NSLog(@"Not yet implemented: %s\n", __FUNCTION__); // radr://3954018
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1270
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1271
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1272
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1273
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1274
// Child elements that are visible (NSArray)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1275
- (NSArray *)accessibilityVisibleChildrenAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1276
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1277
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1278
    NSArray *visibleChildren = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_VISIBLE_CHILDREN allowIgnored:NO];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1279
    if ([visibleChildren count] <= 0) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1280
    return visibleChildren;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1281
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1282
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1283
- (BOOL)accessibilityIsVisibleChildrenAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1284
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1285
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1286
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1287
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1288
// Window containing current element (id)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1289
- (id)accessibilityWindowAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1290
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1291
    return [self window];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1292
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1293
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1294
- (BOOL)accessibilityIsWindowAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1295
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1296
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1297
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1298
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1299
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1300
// -- accessibility actions --
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1301
- (NSArray *)accessibilityActionNames
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1302
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1303
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1304
    return [[self getActions:env] allKeys];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1305
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1306
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1307
- (NSString *)accessibilityActionDescription:(NSString *)action
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1308
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1309
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1310
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1311
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1312
    return [(id <JavaAccessibilityAction>)[[self getActions:env] objectForKey:action] getDescription];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1313
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1314
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1315
- (void)accessibilityPerformAction:(NSString *)action
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1316
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1317
    AWT_ASSERT_APPKIT_THREAD;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1318
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1319
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1320
    [(id <JavaAccessibilityAction>)[[self getActions:env] objectForKey:action] perform];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1321
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1322
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1323
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1324
// -- misc accessibility --
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1325
- (BOOL)accessibilityIsIgnored
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1326
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1327
#ifdef JAVA_AX_NO_IGNORES
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1328
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1329
#else
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1330
    return [[self accessibilityRoleAttribute] isEqualToString:JavaAccessibilityIgnore];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1331
#endif /* JAVA_AX_NO_IGNORES */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1332
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1333
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1334
- (id)accessibilityHitTest:(NSPoint)point withEnv:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1335
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1336
    static JNF_CLASS_CACHE(jc_Container, "java/awt/Container");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1337
    static JNF_STATIC_MEMBER_CACHE(jm_accessibilityHitTest, sjc_CAccessibility, "accessibilityHitTest", "(Ljava/awt/Container;FF)Ljavax/accessibility/Accessible;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1338
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1339
    // Make it into java screen coords
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1340
    point.y = [[[[self view] window] screen] frame].size.height - point.y;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1341
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1342
    jobject jparent = fComponent;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1343
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1344
    id value = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1345
    if (JNFIsInstanceOf(env, jparent, &jc_Container)) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1346
        jobject jaccessible = JNFCallStaticObjectMethod(env, jm_accessibilityHitTest, jparent, (jfloat)point.x, (jfloat)point.y); // AWT_THREADING Safe (AWTRunLoop)
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1347
        if (jaccessible != NULL) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1348
            value = [JavaComponentAccessibility createWithAccessible:jaccessible withEnv:env withView:fView];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1349
            (*env)->DeleteLocalRef(env, jaccessible);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1350
        }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1351
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1352
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1353
    if (value == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1354
        value = self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1355
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1356
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1357
    if ([value accessibilityIsIgnored]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1358
        value = NSAccessibilityUnignoredAncestor(value);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1359
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1360
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1361
#ifdef JAVA_AX_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1362
    NSLog(@"%s: %@", __FUNCTION__, value);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1363
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1364
    return value;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1365
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1366
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1367
- (id)accessibilityFocusedUIElement
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1368
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1369
    static JNF_STATIC_MEMBER_CACHE(jm_getFocusOwner, sjc_CAccessibility, "getFocusOwner", "(Ljava/awt/Component;)Ljavax/accessibility/Accessible;");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1370
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1371
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1372
    id value = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1373
26000
7d2b9a7ae7ce 8032864: [macosx] sigsegv (0Xb) Being Generated When Starting JDev With Voiceover Running
pchelko
parents: 24140
diff changeset
  1374
    NSWindow* hostWindow = [[self->fView window] retain];
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1375
    jobject focused = JNFCallStaticObjectMethod(env, jm_getFocusOwner, fComponent); // AWT_THREADING Safe (AWTRunLoop)
26000
7d2b9a7ae7ce 8032864: [macosx] sigsegv (0Xb) Being Generated When Starting JDev With Voiceover Running
pchelko
parents: 24140
diff changeset
  1376
    [hostWindow release];
50650
b57c4a6581fd 8202768: [macos] Appkit thread slows when any Window Manager active
serb
parents: 47216
diff changeset
  1377
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1378
    if (focused != NULL) {
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1379
        if (JNFIsInstanceOf(env, focused, &sjc_Accessible)) {
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1380
            value = [JavaComponentAccessibility createWithAccessible:focused withEnv:env withView:fView];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1381
        }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1382
        (*env)->DeleteLocalRef(env, focused);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1383
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1384
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1385
    if (value == nil) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1386
        value = self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1387
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1388
#ifdef JAVA_AX_DEBUG
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1389
    NSLog(@"%s: %@", __FUNCTION__, value);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1390
#endif
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1391
    return value;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1392
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1393
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1394
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1395
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1396
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1397
 * Class:     sun_lwawt_macosx_CAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1398
 * Method:    focusChanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1399
 * Signature: ()V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1400
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1401
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessibility_focusChanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1402
(JNIEnv *env, jobject jthis)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1403
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1404
JNF_COCOA_ENTER(env);
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1405
    [ThreadUtilities performOnMainThread:@selector(postFocusChanged:) on:[JavaComponentAccessibility class] withObject:nil waitUntilDone:NO];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1406
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1407
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1408
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1409
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1410
 * Class:     sun_lwawt_macosx_CAccessible
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1411
 * Method:    valueChanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1412
 * Signature: (I)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1413
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1414
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_valueChanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1415
(JNIEnv *env, jclass jklass, jlong element)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1416
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1417
JNF_COCOA_ENTER(env);
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1418
    [ThreadUtilities performOnMainThread:@selector(postValueChanged) on:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1419
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1420
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1421
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1422
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1423
 * Class:     sun_lwawt_macosx_CAccessible
39873
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1424
 * Method:    selectedTextChanged
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1425
 * Signature: (I)V
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1426
 */
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1427
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectedTextChanged
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1428
(JNIEnv *env, jclass jklass, jlong element)
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1429
{
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1430
JNF_COCOA_ENTER(env);
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1431
    [ThreadUtilities performOnMainThread:@selector(postSelectedTextChanged)
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1432
                     on:(JavaComponentAccessibility *)jlong_to_ptr(element)
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1433
                     withObject:nil
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1434
                     waitUntilDone:NO];
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1435
JNF_COCOA_EXIT(env);
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1436
}
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1437
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1438
/*
76907ae1b680 8145207: [macosx] JList, VO can't access non-visible list items
ptbrunet
parents: 38408
diff changeset
  1439
 * Class:     sun_lwawt_macosx_CAccessible
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1440
 * Method:    selectionChanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1441
 * Signature: (I)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1442
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1443
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_selectionChanged
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1444
(JNIEnv *env, jclass jklass, jlong element)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1445
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1446
JNF_COCOA_ENTER(env);
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1447
    [ThreadUtilities performOnMainThread:@selector(postSelectionChanged) on:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1448
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1449
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1450
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1451
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1452
 * Class:     sun_lwawt_macosx_CAccessible
52842
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1453
 * Method:    titleChanged
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1454
 * Signature: (I)V
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1455
 */
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1456
 JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_titleChanged
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1457
 (JNIEnv *env, jclass jklass, jlong element)
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1458
 {
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1459
JNF_COCOA_ENTER(env);
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1460
    [ThreadUtilities performOnMainThread:@selector(postTitleChanged) on:(JavaComponentAccessibility*)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1461
JNF_COCOA_EXIT(env);
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1462
 }
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1463
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1464
/*
d3f785c4969c 7124301: [macosx] When in a tab group if you arrow between tabs there are noVoiceOver announcements.
kaddepalli
parents: 52534
diff changeset
  1465
 * Class:     sun_lwawt_macosx_CAccessible
41780
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1466
 * Method:    menuOpened
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1467
 * Signature: (I)V
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1468
 */
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1469
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuOpened
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1470
(JNIEnv *env, jclass jklass, jlong element)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1471
{
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1472
JNF_COCOA_ENTER(env);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1473
    [ThreadUtilities performOnMainThread:@selector(postMenuOpened)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1474
                     on:(JavaComponentAccessibility *)jlong_to_ptr(element)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1475
                     withObject:nil
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1476
                     waitUntilDone:NO];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1477
JNF_COCOA_EXIT(env);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1478
}
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1479
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1480
/*
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1481
 * Class:     sun_lwawt_macosx_CAccessible
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1482
 * Method:    menuClosed
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1483
 * Signature: (I)V
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1484
 */
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1485
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuClosed
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1486
(JNIEnv *env, jclass jklass, jlong element)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1487
{
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1488
JNF_COCOA_ENTER(env);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1489
    [ThreadUtilities performOnMainThread:@selector(postMenuClosed)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1490
                     on:(JavaComponentAccessibility *)jlong_to_ptr(element)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1491
                     withObject:nil
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1492
                     waitUntilDone:NO];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1493
JNF_COCOA_EXIT(env);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1494
}
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1495
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1496
/*
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1497
 * Class:     sun_lwawt_macosx_CAccessible
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1498
 * Method:    menuItemSelected
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1499
 * Signature: (I)V
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1500
 */
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1501
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuItemSelected
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1502
(JNIEnv *env, jclass jklass, jlong element)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1503
{
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1504
JNF_COCOA_ENTER(env);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1505
    [ThreadUtilities performOnMainThread:@selector(postMenuItemSelected)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1506
                     on:(JavaComponentAccessibility *)jlong_to_ptr(element)
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1507
                     withObject:nil
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1508
                     waitUntilDone:NO];
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1509
JNF_COCOA_EXIT(env);
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1510
}
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1511
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1512
/*
9deca564da25 8160893: [macosx] JMenuItems in JPopupMenu are not accessible
ptbrunet
parents: 41400
diff changeset
  1513
 * Class:     sun_lwawt_macosx_CAccessible
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1514
 * Method:    unregisterFromCocoaAXSystem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1515
 * Signature: (I)V
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1516
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1517
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_unregisterFromCocoaAXSystem
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1518
(JNIEnv *env, jclass jklass, jlong element)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1519
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1520
JNF_COCOA_ENTER(env);
15985
b9e25a486549 8006634: Unify LWCToolkit.invokeAndWait() and sun.awt.datatransfer.ToolkitThreadBlockedHandler
pchelko
parents: 15322
diff changeset
  1521
    [ThreadUtilities performOnMainThread:@selector(unregisterFromCocoaAXSystem) on:(JavaComponentAccessibility *)jlong_to_ptr(element) withObject:nil waitUntilDone:NO];
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1522
JNF_COCOA_EXIT(env);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1523
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1524
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1525
@implementation TabGroupAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1526
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1527
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withView:(NSView *)view withJavaRole:(NSString *)javaRole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1528
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1529
    self = [super initWithParent:parent withEnv:env withAccessible:accessible withIndex:index withView:view withJavaRole:javaRole];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1530
    if (self) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1531
        _numTabs = -1; //flag for uninitialized numTabs
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1532
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1533
    return self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1534
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1535
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1536
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1537
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1538
    NSMutableArray *names = (NSMutableArray *)[super initializeAttributeNamesWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1539
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1540
    [names addObject:NSAccessibilityTabsAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1541
    [names addObject:NSAccessibilityContentsAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1542
    [names addObject:NSAccessibilityValueAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1543
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1544
    return names;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1545
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1546
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1547
- (id)currentTabWithEnv:(JNIEnv *)env withAxContext:(jobject)axContext
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1548
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1549
    NSArray *tabs = [self tabControlsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1550
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1551
    // Looking at the JTabbedPane sources, there is always one AccessibleSelection.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1552
    jobject selAccessible = getAxContextSelection(env, axContext, 0, fComponent);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1553
    if (selAccessible == NULL) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1554
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1555
    // Go through the tabs and find selAccessible
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1556
    _numTabs = [tabs count];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1557
    JavaComponentAccessibility *aTab;
24140
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
  1558
    NSInteger i;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1559
    for (i = 0; i < _numTabs; i++) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1560
        aTab = (JavaComponentAccessibility *)[tabs objectAtIndex:i];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1561
        if ([aTab isAccessibleWithEnv:env forAccessible:selAccessible]) {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1562
            (*env)->DeleteLocalRef(env, selAccessible);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1563
            return aTab;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1564
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1565
    }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1566
    (*env)->DeleteLocalRef(env, selAccessible);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1567
    return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1568
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1569
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1570
- (NSArray *)tabControlsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1571
{
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1572
    jobjectArray jtabsAndRoles = (jobjectArray)JNFCallStaticObjectMethod(env, jm_getChildrenAndRoles, fAccessible, fComponent, whichTabs, allowIgnored); // AWT_THREADING Safe (AWTRunLoop)
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1573
    if(jtabsAndRoles == NULL) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1574
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1575
    jsize arrayLen = (*env)->GetArrayLength(env, jtabsAndRoles);
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1576
    if (arrayLen == 0) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1577
        (*env)->DeleteLocalRef(env, jtabsAndRoles);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1578
        return nil;
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1579
    }
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1580
    NSMutableArray *tabs = [NSMutableArray arrayWithCapacity:(arrayLen/2)];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1581
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1582
    // all of the tabs have the same role, so we can just find out what that is here and use it for all the tabs
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1583
    jobject jtabJavaRole = (*env)->GetObjectArrayElement(env, jtabsAndRoles, 1); // the array entries alternate between tab/role, starting with tab. so the first role is entry 1.
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1584
    if (jtabJavaRole == NULL) {
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1585
        (*env)->DeleteLocalRef(env, jtabsAndRoles);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1586
        return nil;
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1587
    }
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1588
    jobject jkey = JNFGetObjectField(env, jtabJavaRole, sjf_key);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1589
    NSString *tabJavaRole = JNFJavaToNSString(env, jkey);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1590
    (*env)->DeleteLocalRef(env, jkey);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1591
24140
db4b6390d43c 8034118: [parfait] JNI exception pending in macosx/native/sun/awt/JavaComponentAccessibility.m
ptbrunet
parents: 23651
diff changeset
  1592
    NSInteger i;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1593
    NSUInteger tabIndex = (whichTabs >= 0) ? whichTabs : 0; // if we're getting one particular child, make sure to set its index correctly
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1594
    for(i = 0; i < arrayLen; i+=2) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1595
        jobject jtab = (*env)->GetObjectArrayElement(env, jtabsAndRoles, i);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1596
        JavaComponentAccessibility *tab = [[[TabGroupControlAccessibility alloc] initWithParent:self withEnv:env withAccessible:jtab withIndex:tabIndex withTabGroup:axContext withView:[self view] withJavaRole:tabJavaRole] autorelease];
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1597
        (*env)->DeleteLocalRef(env, jtab);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1598
        [tabs addObject:tab];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1599
        tabIndex++;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1600
    }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1601
    (*env)->DeleteLocalRef(env, jtabsAndRoles);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1602
    return tabs;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1603
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1604
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1605
- (NSArray *)contentsWithEnv:(JNIEnv *)env withTabGroupAxContext:(jobject)axContext withTabCode:(NSInteger)whichTabs allowIgnored:(BOOL)allowIgnored
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1606
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1607
    // Contents are the children of the selected tab.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1608
    id currentTab = [self currentTabWithEnv:env withAxContext:axContext];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1609
    if (currentTab == nil) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1610
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1611
    NSArray *contents = [JavaComponentAccessibility childrenOfParent:currentTab withEnv:env withChildrenCode:whichTabs allowIgnored:allowIgnored];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1612
    if ([contents count] <= 0) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1613
    return contents;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1614
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1615
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1616
- (id) accessibilityTabsAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1617
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1618
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1619
    jobject axContext = [self axContextWithEnv:env];
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1620
    id tabs = [self tabControlsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1621
    (*env)->DeleteLocalRef(env, axContext);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1622
    return tabs;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1623
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1624
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1625
- (BOOL)accessibilityIsTabsAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1626
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1627
    return NO; //cmcnote: not sure.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1628
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1629
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1630
- (NSInteger)numTabs
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1631
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1632
    if (_numTabs == -1) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1633
        _numTabs = [[self accessibilityTabsAttribute] count];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1634
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1635
    return _numTabs;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1636
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1637
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1638
- (NSArray *) accessibilityContentsAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1639
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1640
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1641
    jobject axContext = [self axContextWithEnv:env];
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1642
    NSArray* cont = [self contentsWithEnv:env withTabGroupAxContext:axContext withTabCode:JAVA_AX_ALL_CHILDREN allowIgnored:NO];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1643
    (*env)->DeleteLocalRef(env, axContext);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1644
    return cont;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1645
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1646
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1647
- (BOOL)accessibilityIsContentsAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1648
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1649
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1650
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1651
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1652
// axValue is the currently selected tab
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1653
-(id) accessibilityValueAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1654
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1655
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1656
    jobject axContext = [self axContextWithEnv:env];
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1657
    id val = [self currentTabWithEnv:env withAxContext:axContext];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1658
    (*env)->DeleteLocalRef(env, axContext);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1659
    return val;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1660
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1661
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1662
- (BOOL)accessibilityIsValueAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1663
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1664
    return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1665
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1666
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1667
- (void)accessibilitySetValueAttribute:(id)value //cmcnote: not certain this is ever actually called. investigate.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1668
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1669
    // set the current tab
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1670
    NSNumber *number = (NSNumber *)value;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1671
    if (![number boolValue]) return;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1672
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1673
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1674
    jobject axContext = [self axContextWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1675
    setAxContextSelection(env, axContext, fIndex, fComponent);
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1676
    (*env)->DeleteLocalRef(env, axContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1677
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1678
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1679
- (NSArray *)accessibilityChildrenAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1680
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1681
    //children = AXTabs + AXContents
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1682
    NSArray *tabs = [self accessibilityTabsAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1683
    NSArray *contents = [self accessibilityContentsAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1684
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1685
    NSMutableArray *children = [NSMutableArray arrayWithCapacity:[tabs count] + [contents count]];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1686
    [children addObjectsFromArray:tabs];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1687
    [children addObjectsFromArray:contents];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1688
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1689
    return (NSArray *)children;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1690
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1691
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1692
// Without this optimization accessibilityChildrenAttribute is called in order to get the entire array of children.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1693
// See similar optimization in JavaComponentAccessibility. We have to extend the base implementation here, since
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1694
// children of tabs are AXTabs + AXContents
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1695
- (NSArray *)accessibilityArrayAttributeValues:(NSString *)attribute index:(NSUInteger)index maxCount:(NSUInteger)maxCount {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1696
    NSArray *result = nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1697
    if ( (maxCount == 1) && [attribute isEqualToString:NSAccessibilityChildrenAttribute]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1698
        // Children codes for ALL, SELECTED, VISIBLE are <0. If the code is >=0, we treat it as an index to a single child
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1699
        JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1700
        jobject axContext = [self axContextWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1701
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1702
        //children = AXTabs + AXContents
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1703
        NSArray *children = [self tabControlsWithEnv:env withTabGroupAxContext:axContext withTabCode:index allowIgnored:NO]; // first look at the tabs
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1704
        if ([children count] > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1705
            result = children;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1706
         } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1707
            children= [self contentsWithEnv:env withTabGroupAxContext:axContext withTabCode:(index-[self numTabs]) allowIgnored:NO];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1708
            if ([children count] > 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1709
                result = children;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1710
            }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1711
        }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1712
        (*env)->DeleteLocalRef(env, axContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1713
    } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1714
        result = [super accessibilityArrayAttributeValues:attribute index:index maxCount:maxCount];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1715
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1716
    return result;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1717
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1718
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1719
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1720
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1721
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1722
static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component);
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1723
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1724
@implementation TabGroupControlAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1725
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1726
- (id)initWithParent:(NSObject *)parent withEnv:(JNIEnv *)env withAccessible:(jobject)accessible withIndex:(jint)index withTabGroup:(jobject)tabGroup withView:(NSView *)view withJavaRole:(NSString *)javaRole
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1727
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1728
    self = [super initWithParent:parent withEnv:env withAccessible:accessible withIndex:index withView:view withJavaRole:javaRole];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1729
    if (self) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1730
        if (tabGroup != NULL) {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1731
            fTabGroupAxContext = JNFNewWeakGlobalRef(env, tabGroup);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1732
        } else {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1733
            fTabGroupAxContext = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1734
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1735
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1736
    return self;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1737
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1738
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1739
- (void)dealloc
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1740
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1741
    JNIEnv *env = [ThreadUtilities getJNIEnvUncached];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1742
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1743
    if (fTabGroupAxContext != NULL) {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1744
        JNFDeleteWeakGlobalRef(env, fTabGroupAxContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1745
        fTabGroupAxContext = NULL;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1746
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1747
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1748
    [super dealloc];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1749
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1750
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1751
- (id)accessibilityValueAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1752
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1753
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1754
    jobject axContext = [self axContextWithEnv:env];
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1755
    jobject selAccessible = getAxContextSelection(env, [self tabGroup], fIndex, fComponent);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1756
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1757
    // Returns the current selection of the page tab list
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1758
    id val = [NSNumber numberWithBool:ObjectEquals(env, axContext, selAccessible, fComponent)];
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1759
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1760
    (*env)->DeleteLocalRef(env, selAccessible);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1761
    (*env)->DeleteLocalRef(env, axContext);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1762
    return val;
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1763
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1764
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1765
- (void)getActionsWithEnv:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1766
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1767
    TabGroupAction *action = [[TabGroupAction alloc] initWithEnv:env withTabGroup:[self tabGroup] withIndex:fIndex withComponent:fComponent];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1768
    [fActions setObject:action forKey:NSAccessibilityPressAction];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1769
    [action release];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1770
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1771
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1772
- (jobject)tabGroup
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1773
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1774
    if (fTabGroupAxContext == NULL) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1775
        JNIEnv* env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1776
        jobject tabGroupAxContext = [(JavaComponentAccessibility *)[self parent] axContextWithEnv:env];
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1777
        fTabGroupAxContext = JNFNewWeakGlobalRef(env, tabGroupAxContext);
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1778
        (*env)->DeleteLocalRef(env, tabGroupAxContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1779
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1780
    return fTabGroupAxContext;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1781
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1782
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1783
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1784
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1785
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1786
@implementation ScrollAreaAccessibility
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1787
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1788
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1789
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1790
    NSMutableArray *names = (NSMutableArray *)[super initializeAttributeNamesWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1791
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1792
    [names addObject:NSAccessibilityHorizontalScrollBarAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1793
    [names addObject:NSAccessibilityVerticalScrollBarAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1794
    [names addObject:NSAccessibilityContentsAttribute];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1795
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1796
    return names;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1797
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1798
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1799
- (id)accessibilityHorizontalScrollBarAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1800
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1801
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1802
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1803
    NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1804
    if ([children count] <= 0) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1805
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1806
    // The scroll bars are in the children.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1807
    JavaComponentAccessibility *aElement;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1808
    NSEnumerator *enumerator = [children objectEnumerator];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1809
    while ((aElement = (JavaComponentAccessibility *)[enumerator nextObject])) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1810
        if ([[aElement accessibilityRoleAttribute] isEqualToString:NSAccessibilityScrollBarRole]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1811
            jobject elementAxContext = [aElement axContextWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1812
            if (isHorizontal(env, elementAxContext, fComponent)) {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1813
                (*env)->DeleteLocalRef(env, elementAxContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1814
                return aElement;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1815
            }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1816
            (*env)->DeleteLocalRef(env, elementAxContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1817
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1818
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1819
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1820
    return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1821
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1822
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1823
- (BOOL)accessibilityIsHorizontalScrollBarAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1824
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1825
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1826
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1827
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1828
- (id)accessibilityVerticalScrollBarAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1829
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1830
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1831
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1832
    NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1833
    if ([children count] <= 0) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1834
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1835
    // The scroll bars are in the children.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1836
    NSEnumerator *enumerator = [children objectEnumerator];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1837
    JavaComponentAccessibility *aElement;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1838
    while ((aElement = (JavaComponentAccessibility *)[enumerator nextObject])) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1839
        if ([[aElement accessibilityRoleAttribute] isEqualToString:NSAccessibilityScrollBarRole]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1840
            jobject elementAxContext = [aElement axContextWithEnv:env];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1841
            if (isVertical(env, elementAxContext, fComponent)) {
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1842
                (*env)->DeleteLocalRef(env, elementAxContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1843
                return aElement;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1844
            }
37787
de878aeb7ed2 8145984: [macosx] sun.lwawt.macosx.CAccessible leaks
ant
parents: 26751
diff changeset
  1845
            (*env)->DeleteLocalRef(env, elementAxContext);
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1846
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1847
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1848
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1849
    return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1850
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1851
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1852
- (BOOL)accessibilityIsVerticalScrollBarAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1853
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1854
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1855
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1856
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1857
- (NSArray *)accessibilityContentsAttribute
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1858
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1859
    JNIEnv *env = [ThreadUtilities getJNIEnv];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1860
    NSArray *children = [JavaComponentAccessibility childrenOfParent:self withEnv:env withChildrenCode:JAVA_AX_ALL_CHILDREN allowIgnored:YES];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1861
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1862
    if ([children count] <= 0) return nil;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1863
    NSArray *contents = [NSMutableArray arrayWithCapacity:[children count]];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1864
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1865
    // The scroll bars are in the children. children less the scroll bars is the contents
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1866
    NSEnumerator *enumerator = [children objectEnumerator];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1867
    JavaComponentAccessibility *aElement;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1868
    while ((aElement = (JavaComponentAccessibility *)[enumerator nextObject])) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1869
        if (![[aElement accessibilityRoleAttribute] isEqualToString:NSAccessibilityScrollBarRole]) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1870
            // no scroll bars in contents
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1871
            [(NSMutableArray *)contents addObject:aElement];
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1872
        }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1873
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1874
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1875
    return contents;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1876
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1877
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1878
- (BOOL)accessibilityIsContentsAttributeSettable
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1879
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1880
    return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1881
}
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1882
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1883
@end
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1884
52260
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1885
// these constants are duplicated in CAccessibility.java
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1886
#define JAVA_AX_ROWS (1)
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1887
#define JAVA_AX_COLS (2)
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1888
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1889
@implementation TableAccessibility
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1890
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1891
- (NSArray *)initializeAttributeNamesWithEnv:(JNIEnv *)env
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1892
{
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1893
    NSMutableArray *names = (NSMutableArray *)[super initializeAttributeNamesWithEnv:env];
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1894
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1895
    [names addObject:NSAccessibilityRowCountAttribute];
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1896
    [names addObject:NSAccessibilityColumnCountAttribute];
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1897
    return names;
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1898
}
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1899
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1900
- (id)getTableInfo:(jint)info {
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1901
    if (fAccessible == NULL) return 0;
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1902
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1903
    JNIEnv* env = [ThreadUtilities getJNIEnv];
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1904
    jint count = JNFCallStaticIntMethod(env, jm_getTableInfo, fAccessible,
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1905
                                        fComponent, info);
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1906
    NSNumber *index = [NSNumber numberWithInt:count];
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1907
    return index;
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1908
}
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1909
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1910
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1911
- (id)accessibilityRowCountAttribute {
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1912
    return [self getTableInfo:JAVA_AX_ROWS];
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1913
}
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1914
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1915
- (id)accessibilityColumnCountAttribute {
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1916
    return [self getTableInfo:JAVA_AX_COLS];
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1917
}
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1918
@end
1cfc72a40bb8 8133713: [macosx] Accessible JTables always reported as empty
serb
parents: 50650
diff changeset
  1919
12047
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1920
/*
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1921
 * Returns Object.equals for the two items
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1922
 * This may use LWCToolkit.invokeAndWait(); don't call while holding fLock
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1923
 * and try to pass a component so the event happens on the correct thread.
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1924
 */
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1925
static JNF_CLASS_CACHE(sjc_Object, "java/lang/Object");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1926
static BOOL ObjectEquals(JNIEnv *env, jobject a, jobject b, jobject component)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1927
{
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1928
    static JNF_MEMBER_CACHE(jm_equals, sjc_Object, "equals", "(Ljava/lang/Object;)Z");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1929
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1930
    if ((a == NULL) && (b == NULL)) return YES;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1931
    if ((a == NULL) || (b == NULL)) return NO;
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1932
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1933
    if (pthread_main_np() != 0) {
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1934
        // If we are on the AppKit thread
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1935
        static JNF_CLASS_CACHE(sjc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1936
        static JNF_STATIC_MEMBER_CACHE(jm_doEquals, sjc_LWCToolkit, "doEquals", "(Ljava/lang/Object;Ljava/lang/Object;Ljava/awt/Component;)Z");
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1937
        return JNFCallStaticBooleanMethod(env, jm_doEquals, a, b, component); // AWT_THREADING Safe (AWTRunLoopMode)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1938
    }
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1939
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1940
    return JNFCallBooleanMethod(env, a, jm_equals, b); // AWT_THREADING Safe (!appKit)
320a714614e9 7113349: Initial changeset for Macosx port to jdk
michaelm
parents:
diff changeset
  1941
}