Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9d1de83

Browse files
author
duke
committed
Backport 9c6457f222e702b60fef4247c3e241c669eb9491
1 parent3e349b4 commit9d1de83

File tree

52 files changed

+4776
-230
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+4776
-230
lines changed

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

Lines changed: 166 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@
3434
importjava.awt.event.KeyEvent;
3535
importjava.beans.PropertyChangeEvent;
3636
importjava.beans.PropertyChangeListener;
37+
importjava.lang.annotation.Native;
3738
importjava.lang.reflect.InvocationTargetException;
3839
importjava.util.ArrayList;
3940
importjava.util.HashSet;
4041
importjava.util.Set;
4142
importjava.util.concurrent.Callable;
43+
importjava.util.Arrays;
4244

4345
importjavax.accessibility.Accessible;
4446
importjavax.accessibility.AccessibleAction;
@@ -57,6 +59,8 @@
5759
importjavax.swing.JLabel;
5860
importjavax.swing.JMenuItem;
5961
importjavax.swing.JTextArea;
62+
importjavax.swing.JList;
63+
importjavax.swing.JTree;
6064
importjavax.swing.KeyStroke;
6165

6266
importsun.awt.AWTAccessor;
@@ -116,12 +120,7 @@ public void propertyChange(final PropertyChangeEvent evt) {
116120
privatenativevoidfocusChanged();
117121

118122
static <T>TinvokeAndWait(finalCallable<T>callable,finalComponentc) {
119-
if (c !=null) {
120-
try {
121-
returnLWCToolkit.invokeAndWait(callable,c);
122-
}catch (finalExceptione) {e.printStackTrace(); }
123-
}
124-
returnnull;
123+
returninvokeAndWait(callable,c,null);
125124
}
126125

127126
static <T>TinvokeAndWait(finalCallable<T>callable,finalComponentc,finalTdefValue) {
@@ -551,6 +550,10 @@ public void run() {
551550
if (pac ==null)return;
552551
AccessibleSelectionas =pac.getAccessibleSelection();
553552
if (as ==null)return;
553+
if (parentinstanceofJList) {
554+
((JList)parent).setSelectedIndex(i);
555+
return;
556+
}
554557
as.addAccessibleSelection(i);
555558
}
556559
},c);
@@ -651,77 +654,148 @@ public boolean[] call() throws Exception {
651654

652655
// Duplicated from JavaComponentAccessibility
653656
// Note that values >=0 are indexes into the child array
654-
staticfinalintJAVA_AX_ALL_CHILDREN = -1;
655-
staticfinalintJAVA_AX_SELECTED_CHILDREN = -2;
656-
staticfinalintJAVA_AX_VISIBLE_CHILDREN = -3;
657+
@NativestaticfinalintJAVA_AX_ALL_CHILDREN = -1;
658+
@NativestaticfinalintJAVA_AX_SELECTED_CHILDREN = -2;
659+
@NativestaticfinalintJAVA_AX_VISIBLE_CHILDREN = -3;
657660

658661
// Each child takes up two entries in the array: one for itself and one for its role
659662
publicstaticObject[]getChildrenAndRoles(finalAccessiblea,finalComponentc,finalintwhichChildren,finalbooleanallowIgnored) {
660663
if (a ==null)returnnull;
661664
returninvokeAndWait(newCallable<Object[]>() {
662665
publicObject[]call()throwsException {
663-
ArrayList<Object>childrenAndRoles =newArrayList<Object>();
664-
_addChildren(a,whichChildren,allowIgnored,childrenAndRoles);
665-
666-
/* In the case of fetching a selection, need to check to see if
667-
* the active descendant is at the beginning of the list. If it
668-
* is not it needs to be moved to the beginning of the list so
669-
* VoiceOver will annouce it correctly. The list returned
670-
* from Java is always in order from top to bottom, but when shift
671-
* selecting downward (extending the list) or multi-selecting using
672-
* the VO keys control+option+command+return the active descendant
673-
* is not at the top of the list in the shift select down case and
674-
* may not be in the multi select case.
675-
*/
676-
if (whichChildren ==JAVA_AX_SELECTED_CHILDREN) {
677-
if (!childrenAndRoles.isEmpty()) {
678-
AccessibleContextactiveDescendantAC =
679-
CAccessible.getActiveDescendant(a);
680-
if (activeDescendantAC !=null) {
681-
StringactiveDescendantName =
682-
activeDescendantAC.getAccessibleName();
683-
AccessibleRoleactiveDescendantRole =
684-
activeDescendantAC.getAccessibleRole();
685-
// Move active descendant to front of list.
686-
// List contains pairs of each selected item's
687-
// Accessible and AccessibleRole.
688-
ArrayList<Object>newArray =newArrayList<Object>();
689-
intcount =childrenAndRoles.size();
690-
AccessiblecurrentAccessible =null;
691-
AccessibleContextcurrentAC =null;
692-
StringcurrentName =null;
693-
AccessibleRolecurrentRole =null;
694-
for (inti =0;i <count;i+=2) {
695-
// Is this the active descendant?
696-
currentAccessible = (Accessible)childrenAndRoles.get(i);
697-
currentAC =currentAccessible.getAccessibleContext();
698-
currentName =currentAC.getAccessibleName();
699-
currentRole = (AccessibleRole)childrenAndRoles.get(i+1);
700-
if (currentName !=null &&currentName.equals(activeDescendantName) &&
701-
currentRole.equals(activeDescendantRole) ) {
702-
newArray.add(0,currentAccessible);
703-
newArray.add(1,currentRole);
704-
}else {
705-
newArray.add(currentAccessible);
706-
newArray.add(currentRole);
707-
}
708-
}
709-
childrenAndRoles =newArray;
666+
returngetChildrenAndRolesImpl(a,c,whichChildren,allowIgnored);
667+
}
668+
},c);
669+
}
670+
671+
privatestaticObject[]getChildrenAndRolesImpl(finalAccessiblea,finalComponentc,finalintwhichChildren,finalbooleanallowIgnored) {
672+
if (a ==null)returnnull;
673+
674+
ArrayList<Object>childrenAndRoles =newArrayList<Object>();
675+
_addChildren(a,whichChildren,allowIgnored,childrenAndRoles);
676+
677+
/* In case of fetching a selection, we need to check if
678+
* the active descendant is at the beginning of the list, or
679+
* otherwise move it, so that VoiceOver announces it correctly.
680+
* The java list is always in order from top to bottom, but when
681+
* (1) shift-selecting downward (extending the list) or (2) multi-selecting with
682+
* the VO keys (CTRL+ALT+CMD+RETURN) the active descendant
683+
* is not at the top of the list in the 1st case and may not be in the 2nd.
684+
*/
685+
if (whichChildren ==JAVA_AX_SELECTED_CHILDREN) {
686+
if (!childrenAndRoles.isEmpty()) {
687+
AccessibleContextactiveDescendantAC =
688+
CAccessible.getActiveDescendant(a);
689+
if (activeDescendantAC !=null) {
690+
StringactiveDescendantName =
691+
activeDescendantAC.getAccessibleName();
692+
AccessibleRoleactiveDescendantRole =
693+
activeDescendantAC.getAccessibleRole();
694+
// Move active descendant to front of list.
695+
// List contains pairs of each selected item's
696+
// Accessible and AccessibleRole.
697+
ArrayList<Object>newArray =newArrayList<Object>();
698+
intcount =childrenAndRoles.size();
699+
AccessiblecurrentAccessible =null;
700+
AccessibleContextcurrentAC =null;
701+
StringcurrentName =null;
702+
AccessibleRolecurrentRole =null;
703+
for (inti =0;i <count;i +=2) {
704+
// Is this the active descendant?
705+
currentAccessible = (Accessible)childrenAndRoles.get(i);
706+
currentAC =currentAccessible.getAccessibleContext();
707+
currentName =currentAC.getAccessibleName();
708+
currentRole = (AccessibleRole)childrenAndRoles.get(i +1);
709+
if (currentName !=null &&currentName.equals(activeDescendantName) &&
710+
currentRole.equals(activeDescendantRole)) {
711+
newArray.add(0,currentAccessible);
712+
newArray.add(1,currentRole);
713+
}else {
714+
newArray.add(currentAccessible);
715+
newArray.add(currentRole);
710716
}
711717
}
718+
childrenAndRoles =newArray;
712719
}
720+
}
721+
}
722+
723+
if ((whichChildren <0) || (whichChildren *2 >=childrenAndRoles.size())) {
724+
returnchildrenAndRoles.toArray();
725+
}
726+
727+
returnnewObject[]{childrenAndRoles.get(whichChildren *2),childrenAndRoles.get((whichChildren *2) +1)};
728+
}
729+
730+
// This method is called from the native
731+
// Each child takes up three entries in the array: one for itself, one for its role, and one for the recursion level
732+
privatestaticObject[]getChildrenAndRolesRecursive(finalAccessiblea,finalComponentc,finalintwhichChildren,finalbooleanallowIgnored,finalintlevel) {
733+
if (a ==null)returnnull;
734+
returninvokeAndWait(newCallable<Object[]>() {
735+
publicObject[]call()throwsException {
736+
ArrayList<Object>currentLevelChildren =newArrayList<Object>();
737+
ArrayList<Object>allChildren =newArrayList<Object>();
738+
ArrayList<Accessible>parentStack =newArrayList<Accessible>();
739+
parentStack.add(a);
740+
ArrayList<Integer>indexses =newArrayList<Integer>();
741+
Integerindex =0;
742+
intcurrentLevel =level;
743+
while (!parentStack.isEmpty()) {
744+
Accessiblep =parentStack.get(parentStack.size() -1);
745+
746+
currentLevelChildren.addAll(Arrays.asList(getChildrenAndRolesImpl(p,c,JAVA_AX_ALL_CHILDREN,allowIgnored)));
747+
if ((currentLevelChildren.size() ==0) || (index >=currentLevelChildren.size())) {
748+
if (!parentStack.isEmpty())parentStack.remove(parentStack.size() -1);
749+
if (!indexses.isEmpty())index =indexses.remove(indexses.size() -1);
750+
currentLevel -=1;
751+
currentLevelChildren.clear();
752+
continue;
753+
}
754+
755+
Accessibleca =null;
756+
Objectobj =currentLevelChildren.get(index);
757+
if (!(objinstanceofAccessible)) {
758+
index +=2;
759+
currentLevelChildren.clear();
760+
continue;
761+
}
762+
ca = (Accessible)obj;
763+
Objectrole =currentLevelChildren.get(index +1);
764+
currentLevelChildren.clear();
765+
766+
AccessibleContextcac =ca.getAccessibleContext();
767+
if (cac ==null) {
768+
index +=2;
769+
continue;
770+
}
771+
772+
if ((cac.getAccessibleStateSet().contains(AccessibleState.SELECTED) && (whichChildren ==JAVA_AX_SELECTED_CHILDREN)) ||
773+
(cac.getAccessibleStateSet().contains(AccessibleState.VISIBLE) && (whichChildren ==JAVA_AX_VISIBLE_CHILDREN)) ||
774+
(whichChildren ==JAVA_AX_ALL_CHILDREN)) {
775+
allChildren.add(ca);
776+
allChildren.add(role);
777+
allChildren.add(String.valueOf(currentLevel));
778+
}
779+
780+
index +=2;
781+
782+
if (cac.getAccessibleStateSet().contains(AccessibleState.EXPANDED)) {
783+
parentStack.add(ca);
784+
indexses.add(index);
785+
index =0;
786+
currentLevel +=1;
787+
continue;
788+
}
713789

714-
if ((whichChildren <0) || (whichChildren *2 >=childrenAndRoles.size())) {
715-
returnchildrenAndRoles.toArray();
716790
}
717791

718-
returnnewObject[] {childrenAndRoles.get(whichChildren *2),childrenAndRoles.get((whichChildren *2) +1) };
792+
returnallChildren.toArray();
719793
}
720794
},c);
721795
}
722796

723-
privatestaticfinalintJAVA_AX_ROWS =1;
724-
privatestaticfinalintJAVA_AX_COLS =2;
797+
@NativeprivatestaticfinalintJAVA_AX_ROWS =1;
798+
@NativeprivatestaticfinalintJAVA_AX_COLS =2;
725799

726800
publicstaticintgetTableInfo(finalAccessiblea,finalComponentc,
727801
finalintinfo) {
@@ -740,6 +814,23 @@ public static int getTableInfo(final Accessible a, final Component c,
740814
},c);
741815
}
742816

817+
privatestaticint[]getTableSelectedInfo(finalAccessiblea,finalComponentc,
818+
finalintinfo) {
819+
if (a ==null)returnnull;
820+
returninvokeAndWait(() -> {
821+
AccessibleContextac =a.getAccessibleContext();
822+
AccessibleTabletable =ac.getAccessibleTable();
823+
if (table !=null) {
824+
if (info ==JAVA_AX_COLS) {
825+
returntable.getSelectedAccessibleColumns();
826+
}elseif (info ==JAVA_AX_ROWS) {
827+
returntable.getSelectedAccessibleRows();
828+
}
829+
}
830+
returnnull;
831+
},c);
832+
}
833+
743834
privatestaticAccessibleRolegetAccessibleRoleForLabel(JLabell,AccessibleRolefallback) {
744835
Stringtext =l.getText();
745836
if (text !=null &&text.length() >0) {
@@ -858,4 +949,18 @@ public Long call() throws Exception {
858949
}
859950
}, (Component)ax);
860951
}
952+
953+
privatestaticbooleanisTreeRootVisible(Accessiblea,Componentc) {
954+
if (a ==null)returnfalse;
955+
956+
returninvokeAndWait(newCallable<Boolean>() {
957+
publicBooleancall()throwsException {
958+
Accessiblesa =CAccessible.getSwingAccessible(a);
959+
if (sainstanceofJTree) {
960+
return ((JTree)sa).isRootVisible();
961+
}
962+
returnfalse;
963+
}
964+
},c);
965+
}
861966
}

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

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,7 @@
3131

3232
importjavax.accessibility.Accessible;
3333
importjavax.accessibility.AccessibleContext;
34-
importjavax.swing.JProgressBar;
3534
importjavax.swing.JTabbedPane;
36-
importjavax.swing.JSlider;
37-
importjavax.swing.event.ChangeEvent;
38-
importjavax.swing.event.ChangeListener;
3935

4036
importstaticjavax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT_PROPERTY;
4137
importstaticjavax.accessibility.AccessibleContext.ACCESSIBLE_CARET_PROPERTY;
@@ -75,6 +71,8 @@ public static CAccessible getCAccessible(final Accessible a) {
7571
privatestaticnativevoidmenuOpened(longptr);
7672
privatestaticnativevoidmenuClosed(longptr);
7773
privatestaticnativevoidmenuItemSelected(longptr);
74+
privatestaticnativevoidtreeNodeExpanded(longptr);
75+
privatestaticnativevoidtreeNodeCollapsed(longptr);
7876

7977
privateAccessibleaccessible;
8078

@@ -137,6 +135,13 @@ public void propertyChange(PropertyChangeEvent e) {
137135
if (parentAccessible !=null) {
138136
parentRole =parentAccessible.getAccessibleContext().getAccessibleRole();
139137
}
138+
139+
if (newValue ==AccessibleState.EXPANDED) {
140+
treeNodeExpanded(ptr);
141+
}elseif (newValue ==AccessibleState.COLLAPSED) {
142+
treeNodeCollapsed(ptr);
143+
}
144+
140145
// At least for now don't handle combo box menu state changes.
141146
// This may change when later fixing issues which currently
142147
// exist for combo boxes, but for now the following is only

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp