Skip to content

Commit d1df469

Browse files
committed
Merge
2 parents 07eac08 + 2f51d80 commit d1df469

21 files changed

+679
-224
lines changed

make/conf/javadoc.conf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020, Oracle and/or its affiliates. All rights reserved.
1+
# Copyright (c) 2020, 2021, Oracle and/or its affiliates. All rights reserved.
22
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
33
#
44
# This code is free software; you can redistribute it and/or modify it
@@ -23,9 +23,9 @@
2323
#
2424

2525
# URLs
26-
JAVADOC_BASE_URL=https://docs.oracle.com/pls/topic/lookup?ctx=javase$(VERSION_NUMBER)&id=homepage
26+
JAVADOC_BASE_URL=https://docs.oracle.com/pls/topic/lookup?ctx=javase$(VERSION_FEATURE)&id=homepage
2727
BUG_SUBMIT_URL=https://bugreport.java.com/bugreport/
2828
COPYRIGHT_URL=legal/copyright.html
29-
LICENSE_URL=https://www.oracle.com/java/javase/terms/license/java$(VERSION_NUMBER)speclicense.html
29+
LICENSE_URL=https://www.oracle.com/java/javase/terms/license/java$(VERSION_FEATURE)speclicense.html
3030
REDISTRIBUTION_URL=https://www.oracle.com/technetwork/java/redist-137594.html
3131
OTHER_JDK_VERSIONS_URL=https://docs.oracle.com/en/java/javase/index.html

src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java

Lines changed: 69 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import java.util.Set;
4242
import java.util.concurrent.Callable;
4343
import java.util.Arrays;
44+
import java.util.function.Function;
4445

4546
import javax.accessibility.Accessible;
4647
import javax.accessibility.AccessibleAction;
@@ -658,21 +659,29 @@ public boolean[] call() throws Exception {
658659
@Native static final int JAVA_AX_SELECTED_CHILDREN = -2;
659660
@Native static final int JAVA_AX_VISIBLE_CHILDREN = -3;
660661

662+
private static Object[] getTableRowChildrenAndRoles(Accessible a, Component c, int whichChildren, boolean allowIgnored, int tableRowIndex) {
663+
return invokeGetChildrenAndRoles(a, c, whichChildren, allowIgnored, ChildrenOperations.createForTableRow(tableRowIndex));
664+
}
665+
661666
// Each child takes up two entries in the array: one for itself and one for its role
662-
public static Object[] getChildrenAndRoles(final Accessible a, final Component c, final int whichChildren, final boolean allowIgnored) {
667+
private static Object[] getChildrenAndRoles(final Accessible a, final Component c, final int whichChildren, final boolean allowIgnored) {
668+
return invokeGetChildrenAndRoles(a, c, whichChildren, allowIgnored, ChildrenOperations.COMMON);
669+
}
670+
671+
private static Object[] invokeGetChildrenAndRoles(Accessible a, Component c, int whichChildren, boolean allowIgnored, ChildrenOperations ops) {
663672
if (a == null) return null;
664673
return invokeAndWait(new Callable<Object[]>() {
665674
public Object[] call() throws Exception {
666-
return getChildrenAndRolesImpl(a, c, whichChildren, allowIgnored);
675+
return getChildrenAndRolesImpl(a, c, whichChildren, allowIgnored, ops);
667676
}
668677
}, c);
669678
}
670679

671-
private static Object[] getChildrenAndRolesImpl(final Accessible a, final Component c, final int whichChildren, final boolean allowIgnored) {
680+
private static Object[] getChildrenAndRolesImpl(Accessible a, Component c, int whichChildren, boolean allowIgnored, ChildrenOperations ops) {
672681
if (a == null) return null;
673682

674683
ArrayList<Object> childrenAndRoles = new ArrayList<Object>();
675-
_addChildren(a, whichChildren, allowIgnored, childrenAndRoles);
684+
_addChildren(a, whichChildren, allowIgnored, childrenAndRoles, ops);
676685

677686
/* In case of fetching a selection, we need to check if
678687
* the active descendant is at the beginning of the list, or
@@ -743,7 +752,7 @@ public Object[] call() throws Exception {
743752
while (!parentStack.isEmpty()) {
744753
Accessible p = parentStack.get(parentStack.size() - 1);
745754

746-
currentLevelChildren.addAll(Arrays.asList(getChildrenAndRolesImpl(p, c, JAVA_AX_ALL_CHILDREN, allowIgnored)));
755+
currentLevelChildren.addAll(Arrays.asList(getChildrenAndRolesImpl(p, c, JAVA_AX_ALL_CHILDREN, allowIgnored, ChildrenOperations.COMMON)));
747756
if ((currentLevelChildren.size() == 0) || (index >= currentLevelChildren.size())) {
748757
if (!parentStack.isEmpty()) parentStack.remove(parentStack.size() - 1);
749758
if (!indexses.isEmpty()) index = indexses.remove(indexses.size() - 1);
@@ -855,20 +864,70 @@ private static AccessibleRole getAccessibleRole(Accessible a) {
855864
return role;
856865
}
857866

867+
private interface ChildrenOperations {
868+
boolean isContextValid(AccessibleContext accessibleContext);
869+
int getChildrenCount(AccessibleContext accessibleContext);
870+
Accessible getAccessibleChild(AccessibleContext accessibleContext, int childIndex);
871+
872+
static ChildrenOperations COMMON = createForCommon();
873+
874+
static ChildrenOperations createForCommon() {
875+
return new ChildrenOperations() {
876+
@Override
877+
public boolean isContextValid(AccessibleContext accessibleContext) {
878+
return accessibleContext != null;
879+
}
880+
881+
@Override
882+
public int getChildrenCount(AccessibleContext accessibleContext) {
883+
assert isContextValid(accessibleContext);
884+
return accessibleContext.getAccessibleChildrenCount();
885+
}
886+
887+
@Override
888+
public Accessible getAccessibleChild(AccessibleContext accessibleContext, int childIndex) {
889+
assert isContextValid(accessibleContext);
890+
return accessibleContext.getAccessibleChild(childIndex);
891+
}
892+
};
893+
}
894+
895+
static ChildrenOperations createForTableRow(int tableRowIndex) {
896+
return new ChildrenOperations() {
897+
@Override
898+
public boolean isContextValid(AccessibleContext accessibleContext) {
899+
return accessibleContext instanceof AccessibleTable;
900+
}
901+
902+
@Override
903+
public int getChildrenCount(AccessibleContext accessibleContext) {
904+
assert isContextValid(accessibleContext);
905+
return ((AccessibleTable)accessibleContext).getAccessibleColumnCount();
906+
}
907+
908+
@Override
909+
public Accessible getAccessibleChild(AccessibleContext accessibleContext, int childIndex) {
910+
assert isContextValid(accessibleContext);
911+
return ((AccessibleTable)accessibleContext).getAccessibleAt(tableRowIndex, childIndex);
912+
}
913+
};
914+
}
915+
}
916+
858917

859918
// Either gets the immediate children of a, or recursively gets all unignored children of a
860-
private static void _addChildren(final Accessible a, final int whichChildren, final boolean allowIgnored, final ArrayList<Object> childrenAndRoles) {
919+
private static void _addChildren(Accessible a, int whichChildren, boolean allowIgnored, ArrayList<Object> childrenAndRoles, ChildrenOperations ops) {
861920
if (a == null) return;
862921

863922
final AccessibleContext ac = a.getAccessibleContext();
864-
if (ac == null) return;
923+
if (!ops.isContextValid(ac)) return;
865924

866-
final int numChildren = ac.getAccessibleChildrenCount();
925+
final int numChildren = ops.getChildrenCount(ac);
867926

868927
// each child takes up two entries in the array: itself, and its role
869928
// so the array holds alternating Accessible and AccessibleRole objects
870929
for (int i = 0; i < numChildren; i++) {
871-
final Accessible child = ac.getAccessibleChild(i);
930+
final Accessible child = ops.getAccessibleChild(ac, i);
872931
if (child == null) continue;
873932

874933
final AccessibleContext context = child.getAccessibleContext();
@@ -890,7 +949,7 @@ private static void _addChildren(final Accessible a, final int whichChildren, fi
890949
final AccessibleRole role = context.getAccessibleRole();
891950
if (role != null && ignoredRoles != null && ignoredRoles.contains(roleKey(role))) {
892951
// Get the child's unignored children.
893-
_addChildren(child, whichChildren, false, childrenAndRoles);
952+
_addChildren(child, whichChildren, false, childrenAndRoles, ChildrenOperations.COMMON);
894953
} else {
895954
childrenAndRoles.add(child);
896955
childrenAndRoles.add(getAccessibleRole(child));

src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ public static CAccessible getCAccessible(final Accessible a) {
7474
private static native void treeNodeExpanded(long ptr);
7575
private static native void treeNodeCollapsed(long ptr);
7676
private static native void selectedCellsChanged(long ptr);
77+
private static native void tableContentCacheClear(long ptr);
7778

7879
private Accessible accessible;
7980

@@ -124,6 +125,13 @@ public void propertyChange(PropertyChangeEvent e) {
124125
selectionChanged(ptr);
125126
} else if (name.compareTo(ACCESSIBLE_TABLE_MODEL_CHANGED) == 0) {
126127
valueChanged(ptr);
128+
if (CAccessible.getSwingAccessible(CAccessible.this) != null) {
129+
Accessible a = CAccessible.getSwingAccessible(CAccessible.this);
130+
AccessibleContext ac = a.getAccessibleContext();
131+
if ((ac != null) && (ac.getAccessibleRole() == AccessibleRole.TABLE)) {
132+
tableContentCacheClear(ptr);
133+
}
134+
}
127135
} else if (name.compareTo(ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY) == 0 ) {
128136
if (newValue instanceof AccessibleContext) {
129137
activeDescendant = (AccessibleContext)newValue;
@@ -156,24 +164,18 @@ public void propertyChange(PropertyChangeEvent e) {
156164
treeNodeCollapsed(ptr);
157165
}
158166

159-
// At least for now don't handle combo box menu state changes.
160-
// This may change when later fixing issues which currently
161-
// exist for combo boxes, but for now the following is only
162-
// for JPopupMenus, not for combobox menus.
163-
if (parentRole != AccessibleRole.COMBO_BOX) {
164-
if (thisRole == AccessibleRole.POPUP_MENU) {
165-
if ( newValue != null &&
166-
((AccessibleState)newValue) == AccessibleState.VISIBLE ) {
167-
menuOpened(ptr);
168-
} else if ( oldValue != null &&
169-
((AccessibleState)oldValue) == AccessibleState.VISIBLE ) {
170-
menuClosed(ptr);
171-
}
172-
} else if (thisRole == AccessibleRole.MENU_ITEM) {
173-
if ( newValue != null &&
174-
((AccessibleState)newValue) == AccessibleState.FOCUSED ) {
175-
menuItemSelected(ptr);
176-
}
167+
if (thisRole == AccessibleRole.POPUP_MENU) {
168+
if ( newValue != null &&
169+
((AccessibleState)newValue) == AccessibleState.VISIBLE ) {
170+
menuOpened(ptr);
171+
} else if ( oldValue != null &&
172+
((AccessibleState)oldValue) == AccessibleState.VISIBLE ) {
173+
menuClosed(ptr);
174+
}
175+
} else if (thisRole == AccessibleRole.MENU_ITEM) {
176+
if ( newValue != null &&
177+
((AccessibleState)newValue) == AccessibleState.FOCUSED ) {
178+
menuItemSelected(ptr);
177179
}
178180
}
179181

src/java.desktop/macosx/native/libawt_lwawt/awt/JavaComponentAccessibility.m

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1516,54 +1516,6 @@ - (id)accessibilityFocusedUIElement
15161516
JNI_COCOA_EXIT(env);
15171517
}
15181518

1519-
/*
1520-
* Class: sun_lwawt_macosx_CAccessible
1521-
* Method: menuOpened
1522-
* Signature: (I)V
1523-
*/
1524-
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuOpened
1525-
(JNIEnv *env, jclass jklass, jlong element)
1526-
{
1527-
JNI_COCOA_ENTER(env);
1528-
[ThreadUtilities performOnMainThread:@selector(postMenuOpened)
1529-
on:(JavaComponentAccessibility *)jlong_to_ptr(element)
1530-
withObject:nil
1531-
waitUntilDone:NO];
1532-
JNI_COCOA_EXIT(env);
1533-
}
1534-
1535-
/*
1536-
* Class: sun_lwawt_macosx_CAccessible
1537-
* Method: menuClosed
1538-
* Signature: (I)V
1539-
*/
1540-
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuClosed
1541-
(JNIEnv *env, jclass jklass, jlong element)
1542-
{
1543-
JNI_COCOA_ENTER(env);
1544-
[ThreadUtilities performOnMainThread:@selector(postMenuClosed)
1545-
on:(JavaComponentAccessibility *)jlong_to_ptr(element)
1546-
withObject:nil
1547-
waitUntilDone:NO];
1548-
JNI_COCOA_EXIT(env);
1549-
}
1550-
1551-
/*
1552-
* Class: sun_lwawt_macosx_CAccessible
1553-
* Method: menuItemSelected
1554-
* Signature: (I)V
1555-
*/
1556-
JNIEXPORT void JNICALL Java_sun_lwawt_macosx_CAccessible_menuItemSelected
1557-
(JNIEnv *env, jclass jklass, jlong element)
1558-
{
1559-
JNI_COCOA_ENTER(env);
1560-
[ThreadUtilities performOnMainThread:@selector(postMenuItemSelected)
1561-
on:(JavaComponentAccessibility *)jlong_to_ptr(element)
1562-
withObject:nil
1563-
waitUntilDone:NO];
1564-
JNI_COCOA_EXIT(env);
1565-
}
1566-
15671519
/*
15681520
* Class: sun_lwawt_macosx_CAccessible
15691521
* Method: unregisterFromCocoaAXSystem

src/java.desktop/macosx/native/libawt_lwawt/awt/a11y/ColumnAccessibility.m

Lines changed: 0 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -49,61 +49,6 @@ - (NSAccessibilityRole)accessibilityRole
4949
return NSAccessibilityColumnRole;
5050
}
5151

52-
- (NSArray *)accessibilityChildren
53-
{
54-
NSArray *children = [super accessibilityChildren];
55-
if (children == NULL) {
56-
JNIEnv *env = [ThreadUtilities getJNIEnv];
57-
CommonComponentAccessibility *parent = [self accessibilityParent];
58-
if (parent->fAccessible == NULL) return nil;
59-
GET_CHILDRENANDROLES_METHOD_RETURN(nil);
60-
jobjectArray jchildrenAndRoles = (jobjectArray)(*env)->CallStaticObjectMethod(env, sjc_CAccessibility, jm_getChildrenAndRoles,
61-
parent->fAccessible, parent->fComponent, sun_lwawt_macosx_CAccessibility_JAVA_AX_ALL_CHILDREN, NO);
62-
CHECK_EXCEPTION();
63-
if (jchildrenAndRoles == NULL) return nil;
64-
65-
jsize arrayLen = (*env)->GetArrayLength(env, jchildrenAndRoles);
66-
NSMutableArray *childrenCells = [NSMutableArray arrayWithCapacity:arrayLen/2];
67-
68-
NSUInteger childIndex = fIndex;
69-
70-
int inc = [(TableAccessibility *)[self accessibilityParent] accessibilityRowCount] * 2;
71-
NSInteger i = childIndex * 2;
72-
for(i; i < arrayLen; i += inc)
73-
{
74-
jobject /* Accessible */ jchild = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i);
75-
jobject /* String */ jchildJavaRole = (*env)->GetObjectArrayElement(env, jchildrenAndRoles, i+1);
76-
77-
NSString *childJavaRole = nil;
78-
if (jchildJavaRole != NULL) {
79-
DECLARE_CLASS_RETURN(sjc_AccessibleRole, "javax/accessibility/AccessibleRole", nil);
80-
DECLARE_FIELD_RETURN(sjf_key, sjc_AccessibleRole, "key", "Ljava/lang/String;", nil);
81-
jobject jkey = (*env)->GetObjectField(env, jchildJavaRole, sjf_key);
82-
CHECK_EXCEPTION();
83-
childJavaRole = JavaStringToNSString(env, jkey);
84-
(*env)->DeleteLocalRef(env, jkey);
85-
}
86-
87-
CellAccessibility *child = [[CellAccessibility alloc] initWithParent:self
88-
withEnv:env
89-
withAccessible:jchild
90-
withIndex:childIndex
91-
withView:self->fView
92-
withJavaRole:childJavaRole];
93-
[childrenCells addObject:[[child retain] autorelease]];
94-
95-
(*env)->DeleteLocalRef(env, jchild);
96-
(*env)->DeleteLocalRef(env, jchildJavaRole);
97-
98-
childIndex += (inc / 2);
99-
}
100-
(*env)->DeleteLocalRef(env, jchildrenAndRoles);
101-
return childrenCells;
102-
} else {
103-
return children;
104-
}
105-
}
106-
10752
- (NSInteger)accessibilityIndex
10853
{
10954
return fIndex;

0 commit comments

Comments
 (0)