< prev index next >
src/jdk.accessibility/windows/classes/com/sun/java/accessibility/internal/AccessBridge.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 2005, 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 2005, 2020, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 1455,1464 ****
--- 1455,1496 ----
}
debugString("[ERROR]: getAccessibleStatesStringFromContext; ac = null");
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
*/
private AccessibleContext getAccessibleParentFromContext(final AccessibleContext ac) {
if (ac==null)
*** 1485,1495 ****
if (ac==null)
return -1;
return InvocationUtils.invokeAndWait(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
! return ac.getAccessibleIndexInParent();
}
}, ac);
}
/**
--- 1517,1532 ----
if (ac==null)
return -1;
return InvocationUtils.invokeAndWait(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
! int indexInParent = ac.getAccessibleIndexInParent();
! Accessible parent = ac.getAccessibleParent();
! if (parent != null) {
! indexInParent -= getNonVisibleChildrenCountTillIndex(parent.getAccessibleContext(), indexInParent);
! }
! return indexInParent;
}
}, ac);
}
/**
*** 1499,1509 ****
if (ac==null)
return -1;
return InvocationUtils.invokeAndWait(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
! return ac.getAccessibleChildrenCount();
}
}, ac);
}
/**
--- 1536,1547 ----
if (ac==null)
return -1;
return InvocationUtils.invokeAndWait(new Callable<Integer>() {
@Override
public Integer call() throws Exception {
! int childrenCount = ac.getAccessibleChildrenCount();
! return childrenCount - getNonVisibleChildrenCountTillIndex(ac, childrenCount - 1);
}
}, ac);
}
/**
*** 1535,1545 ****
if (table == null) {
return InvocationUtils.invokeAndWait(new Callable<AccessibleContext>() {
@Override
public AccessibleContext call() throws Exception {
! Accessible a = ac.getAccessibleChild(index);
if (a != null) {
return a.getAccessibleContext();
}
return null;
}
--- 1573,1583 ----
if (table == null) {
return InvocationUtils.invokeAndWait(new Callable<AccessibleContext>() {
@Override
public AccessibleContext call() throws Exception {
! Accessible a = getVisibleChildAtIndex(ac, index);
if (a != null) {
return a.getAccessibleContext();
}
return null;
}
*** 3515,3525 ****
AccessibleRelationSet ars = ac.getAccessibleRelationSet();
if (ars != null) {
AccessibleRelation[] relations = ars.toArray();
if (relations != null && i >= 0 && i < relations.length) {
Object[] targets = relations[i].getTarget();
! return targets.length;
}
}
}
return -1;
}
--- 3553,3567 ----
AccessibleRelationSet ars = ac.getAccessibleRelationSet();
if (ars != null) {
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 -1;
}
*** 3541,3551 ****
if (ars != null) {
AccessibleRelation[] relations = ars.toArray();
if (relations != null && i >= 0 && i < relations.length) {
Object[] targets = relations[i].getTarget();
if (targets != null && j >= 0 & j < targets.length) {
! Object o = targets[j];
if (o instanceof Accessible) {
return ((Accessible) o).getAccessibleContext();
}
}
}
--- 3583,3593 ----
if (ars != null) {
AccessibleRelation[] relations = ars.toArray();
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);
if (o instanceof Accessible) {
return ((Accessible) o).getAccessibleContext();
}
}
}
*** 3554,3563 ****
--- 3596,3639 ----
return null;
}
}, 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<AccessibleHypertext, AccessibleContext> hyperTextContextMap = new WeakHashMap<>();
private Map<AccessibleHyperlink, AccessibleContext> hyperLinkContextMap = new WeakHashMap<>();
< prev index next >