--- old/src/java.desktop/share/classes/javax/swing/JList.java 2020-07-14 15:26:03.613703090 +0530 +++ new/src/java.desktop/share/classes/javax/swing/JList.java 2020-07-14 15:26:03.337565104 +0530 @@ -3317,7 +3317,6 @@ } s.add(AccessibleState.SELECTABLE); - s.add(AccessibleState.VISIBLE); if (parent.isFocusOwner() && (indexInParent == parent.getLeadSelectionIndex())) { s.add(AccessibleState.ACTIVE); @@ -3330,6 +3329,11 @@ } else if (s.contains(AccessibleState.SHOWING)) { s.remove(AccessibleState.SHOWING); } + if (this.isVisible()) { + s.add(AccessibleState.VISIBLE); + } else if (s.contains(AccessibleState.VISIBLE)) { + s.remove(AccessibleState.VISIBLE); + } s.add(AccessibleState.TRANSIENT); // cell-rendered return s; } --- old/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java 2020-07-14 15:26:04.622207038 +0530 +++ new/src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java 2020-07-14 15:26:04.342067052 +0530 @@ -1457,38 +1457,6 @@ return null; } - private int getNonVisibleChildrenCountTillIndex(AccessibleContext parentAC, int index) { - if (parentAC != null && index >= 0 && index < parentAC.getAccessibleChildrenCount()) { - int nonVisibleChildrenCount = 0; - for (int i = 0; i <= index; i++) { - if (!parentAC.getAccessibleChild(i).getAccessibleContext().getAccessibleStateSet().contains(AccessibleState.VISIBLE)) { - nonVisibleChildrenCount++; - } - } - return nonVisibleChildrenCount; - } - return 0; - } - - private Accessible getVisibleChildAtIndex(AccessibleContext parentAC, int index) { - if (parentAC != null && index >= 0 && index < parentAC.getAccessibleChildrenCount()) { - int visibleIndex = -1; - int childrenCount = parentAC.getAccessibleChildrenCount(); - for (int i = 0; i <= childrenCount; i++) { - Accessible child = parentAC.getAccessibleChild(i); - if (child != null) { - AccessibleContext ac = child.getAccessibleContext(); - if (ac != null && ac.getAccessibleStateSet().contains(AccessibleState.VISIBLE)) { - visibleIndex++; - } - if (visibleIndex == index) { - return child; - } - } - } - } - return null; - } /** * returns the AccessibleParent from an AccessibleContext */ @@ -1519,12 +1487,7 @@ return InvocationUtils.invokeAndWait(new Callable() { @Override public Integer call() throws Exception { - int indexInParent = ac.getAccessibleIndexInParent(); - Accessible parent = ac.getAccessibleParent(); - if (parent != null) { - indexInParent -= getNonVisibleChildrenCountTillIndex(parent.getAccessibleContext(), indexInParent); - } - return indexInParent; + return ac.getAccessibleIndexInParent(); } }, ac); } @@ -1538,8 +1501,7 @@ return InvocationUtils.invokeAndWait(new Callable() { @Override public Integer call() throws Exception { - int childrenCount = ac.getAccessibleChildrenCount(); - return childrenCount - getNonVisibleChildrenCountTillIndex(ac, childrenCount - 1); + return ac.getAccessibleChildrenCount(); } }, ac); } @@ -1575,7 +1537,7 @@ return InvocationUtils.invokeAndWait(new Callable() { @Override public AccessibleContext call() throws Exception { - Accessible a = getVisibleChildAtIndex(ac, index); + Accessible a = ac.getAccessibleChild(index); if (a != null) { return a.getAccessibleContext(); } @@ -3555,11 +3517,7 @@ AccessibleRelation[] relations = ars.toArray(); if (relations != null && i >= 0 && i < relations.length) { Object[] targets = relations[i].getTarget(); - if (targets != null) { - int targetCount = targets.length - - getNonVisibleTargetCountTillIndex(targets, targets.length - 1); - return targetCount; - } + return targets.length; } } } @@ -3585,7 +3543,7 @@ if (relations != null && i >= 0 && i < relations.length) { Object[] targets = relations[i].getTarget(); if (targets != null && j >= 0 & j < targets.length) { - Object o = getVisibleTargetAtIndex(targets, j); + Object o = targets[j]; if (o instanceof Accessible) { return ((Accessible) o).getAccessibleContext(); } @@ -3598,40 +3556,6 @@ }, ac); } - private Object getVisibleTargetAtIndex(Object[] targets, int index) { - if (index >= 0 && index < targets.length) { - int visibleTargetIndex = -1; - for (int i = 0; i < targets.length; i++) { - if (targets[i] instanceof Accessible) { - AccessibleContext ac = ((Accessible) targets[i]).getAccessibleContext(); - if (ac != null && ac.getAccessibleStateSet().contains(AccessibleState.VISIBLE)) { - visibleTargetIndex++; - } - if (visibleTargetIndex == index) { - return targets[i]; - } - } - } - } - return null; - } - - private int getNonVisibleTargetCountTillIndex(Object[] targets, int index) { - if (index >= 0 && index < targets.length) { - int nonVisibleTargetsCount = 0; - for (int i = 0; i <= index; i++) { - if (targets[i] instanceof Accessible) { - AccessibleContext ac = ((Accessible) targets[i]).getAccessibleContext(); - if (ac != null && !ac.getAccessibleStateSet().contains(AccessibleState.VISIBLE)) { - nonVisibleTargetsCount++; - } - } - } - return nonVisibleTargetsCount; - } - return 0; - } - // ========= AccessibleHypertext ========= private Map hyperTextContextMap = new WeakHashMap<>();