RFR: 8317771 [macos14] Expand/collapse a JTree using keyboard freezes the application in macOS 14 Sonoma
Artem Semenov
asemenov at openjdk.org
Mon Dec 25 12:30:48 UTC 2023
On Thu, 21 Dec 2023 21:13:14 GMT, Alexander Zuev <kizune at openjdk.org> wrote:
>> NSAccessibility Outline is an accessibility representation of trees.
>> This representation requires that the visible children be represented as a flat array.
>> The child linearization algorithm available in ```CAccessibility.getChildrenAndRolesRecursive()``` is universal, i.e. suitable for any object with the role of a tree, but is not efficient, since it traverses the entire tree and selects suitable children.
>> For JTree, this algorithm can be optimized by using TreePath, but the old algorithm will have to be retained to maintain versatility.
>
> src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java line 799:
>
>> 797: for (int i = 0; i < count; i++) {
>> 798: TreePath path = tree.getPathForRow(i);
>> 799: Accessible an = createAccessibleTreeNode(tree, path);
>
> I see that you are creating the accessible tree node with reflection calling its constructor. Can you just elaborate if it is the only way to get hold of it and why getting a tree.getAccessible().getAccessibleChild(i) does not work or what kind of problem getting the tree node this way creates?
A little lower, the access algorithm is implemented in the way you showed.
But to speed things up, I want to avoid recursion through the native and for this it is easier to initialize those nodes that are present in the tree path through the constructor. Why do I propose to use reflection? Otherwise, you will either have to make the constructor of a double-nested class public, or create a chain of methods that allow you to instantiate this class through a new call in CAccessibility.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/17165#discussion_r1436078711
More information about the client-libs-dev
mailing list