Skip to content

8284542: [Accessibility] [Win] Missing attribute for toggle state of CheckBox in CheckBoxTreeItem #1088

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

arapte
Copy link
Member

@arapte arapte commented Apr 12, 2023

Issue:
CheckBoxTreeItem extends TreeItem and adds a CheckBox.
The state of this CheckBox is not visible to an accessibility client application.
If we analyze a simple program that contains a CheckBoxTreeItem using a windows application "Accessibility Insights for Window", we can notice that toggle state of CheckBox is not exposed.

Fix:
Include the Toggle Control Pattern in Accessibility information of a CheckBoxTreeItem in addition to the patterns that are used for a TreeItem.

Verification:
On Windows: Do the following with and without the fix.

  1. Run the sample program attached to JBS issue.
  2. Launch "Accessibility Insights for Window"
  3. Observe that patterns section for each item
  4. Select / de-select the CheckBoxes and observe the patterns section for correctness of toggle state.

Progress

  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8305939 to be approved
  • Change must be properly reviewed (2 reviews required, with at least 1 Reviewer, 1 Author)

Issues

  • JDK-8284542: [Accessibility] [Win] Missing attribute for toggle state of CheckBox in CheckBoxTreeItem
  • JDK-8305939: [Accessibility] [Win] Missing attribute for toggle state of CheckBox in CheckBoxTreeItem (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jfx.git pull/1088/head:pull/1088
$ git checkout pull/1088

Update a local copy of the PR:
$ git checkout pull/1088
$ git pull https://git.openjdk.org/jfx.git pull/1088/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 1088

View PR using the GUI difftool:
$ git pr show -t 1088

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jfx/pull/1088.diff

Webrev

Link to Webrev Comment

@bridgekeeper
Copy link

bridgekeeper bot commented Apr 12, 2023

👋 Welcome back arapte! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added the rfr Ready for review label Apr 12, 2023
@mlbridge
Copy link

mlbridge bot commented Apr 12, 2023

Webrevs

@kevinrushforth kevinrushforth self-requested a review April 12, 2023 16:15
@kevinrushforth
Copy link
Member

@azuev-java @andy-goryachev-oracle can you take a look at this as well?

@kevinrushforth
Copy link
Member

/reviewers 2
/csr

@openjdk
Copy link

openjdk bot commented Apr 12, 2023

@kevinrushforth
The total number of required reviews for this PR (including the jcheck configuration and the last /reviewers command) is now set to 2 (with at least 1 Reviewer, 1 Author).

@openjdk openjdk bot added the csr Need approved CSR to integrate pull request label Apr 12, 2023
@openjdk
Copy link

openjdk bot commented Apr 12, 2023

@kevinrushforth has indicated that a compatibility and specification (CSR) request is needed for this pull request.

@arapte please create a CSR request for issue JDK-8284542 with the correct fix version. This pull request cannot be integrated until the CSR request is approved.

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I echo Andy's question about using an enum for the new AccessibleAttribute. More importantly, I think the values of that new attribute need to be a platform-independent. See inline comments.

@arapte arapte changed the title 8284542: Missing attribute for state of CheckBox in CheckBoxTreeItem 8284542: [Accessibility] [Win] Missing attribute for toggle state of CheckBox in CheckBoxTreeItem May 12, 2023
@andy-goryachev-oracle
Copy link
Contributor

Testing with VoiceOver on Mac M1 Ventura 13.3.1(a): undetermined checkbox is pronounced as "mixed checkbox" - is this expected behavior?

Also, probably unrelated to this PR: the outlines placed by VoiceOver are shifted to the wrong positions on the secondary monitor, for all nodes in the javafx window. For Chrome, the positioning is correct which makes me believe there might be a problem with FX. Also, the VoiceOver popup (black thing with white outline) inexplicably spans two monitors, though I think it might be a problem with VoiceOver:

Screenshot 2023-05-12 at 12 46 03

my setup is: secondary monitor (scale=1) is above the primary (scale=2)

} else if (checkBox.isSelected()) {
state = ToggleState.CHECKED;
}
return state;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very minor, a question of style. i would avoid double assignment by doing this:

if (checkBox.isIndeterminate()) {
  return ToggleState.INDETERMINATE;
} else if (checkBox.isSelected()) {
  return ToggleState.CHECKED;
} else {
  return ToggleState.UNCHECKED;
}

AccessibleRole.TABLE_ROW,
AccessibleRole.TREE_ITEM,
AccessibleRole.CHECK_BOX_TREE_ITEM,
AccessibleRole.TREE_TABLE_ROW
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[question] is the order of elements significant in any way?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The order does not matter, the roles are accessed by value on the native side code. (initEnum())

@@ -748,8 +758,9 @@ public void sendNotification(AccessibleAttribute notification) {
}

AccessibleRole role = (AccessibleRole) getAttribute(ROLE);
if (role == AccessibleRole.TREE_ITEM || role == AccessibleRole.TREE_TABLE_ROW) {
AccessibleRole containerRole = role == AccessibleRole.TREE_ITEM ? AccessibleRole.TREE_VIEW : AccessibleRole.TREE_TABLE_VIEW;
if (role == AccessibleRole.TREE_ITEM || role == AccessibleRole.CHECK_BOX_TREE_ITEM || role == AccessibleRole.TREE_TABLE_ROW) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could a switch statement be used here instead?

@@ -299,14 +299,16 @@ public void sendNotification(AccessibleAttribute notification) {
break;
}
case INDETERMINATE: {
if (getAttribute(ROLE) == AccessibleRole.CHECK_BOX) {
if (getAttribute(ROLE) == AccessibleRole.CHECK_BOX
|| getAttribute(ROLE) == AccessibleRole.CHECK_BOX_TREE_ITEM) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same Q.: could we use a switch statement to avoid double getter call? (I don't know if JVM will optimize that away anyway, but switch makes a cleaner code, in my opinion)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the proposed change is less intrusive than a switch, but I don't mind either way. It might make sense to use a local variable to avoid calling getAttribute twice.

notifyToggleState();
}
break;
}
case SELECTED: {
Object role = getAttribute(ROLE);
if (role == AccessibleRole.CHECK_BOX || role == AccessibleRole.TOGGLE_BUTTON) {
if (role == AccessibleRole.CHECK_BOX || role == AccessibleRole.TOGGLE_BUTTON
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't bother.

@@ -431,6 +433,7 @@ private Accessible getContainer() {
case LIST_ITEM: return getContainerAccessible(AccessibleRole.LIST_VIEW);
case TAB_ITEM: return getContainerAccessible(AccessibleRole.TAB_PANE);
case PAGE_ITEM: return getContainerAccessible(AccessibleRole.PAGINATION);
case CHECK_BOX_TREE_ITEM:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would recommend reformatting the switch cases here for clarity:

    private Accessible getContainer() {
        if (isDisposed()) {
            return null;
        }
        AccessibleRole role = (AccessibleRole)getAttribute(ROLE);
        if (role != null) {
            switch (role) {
            case TABLE_ROW:
            case TABLE_CELL:
                return getContainerAccessible(AccessibleRole.TABLE_VIEW);
            case LIST_ITEM:
                return getContainerAccessible(AccessibleRole.LIST_VIEW);
            case TAB_ITEM:
                return getContainerAccessible(AccessibleRole.TAB_PANE);
            case PAGE_ITEM:
                return getContainerAccessible(AccessibleRole.PAGINATION);
            case CHECK_BOX_TREE_ITEM:
            case TREE_ITEM:
                return getContainerAccessible(AccessibleRole.TREE_VIEW);
            case TREE_TABLE_ROW:
            case TREE_TABLE_CELL:
                return getContainerAccessible(AccessibleRole.TREE_TABLE_VIEW);
            }
        }
        return null;
    }

(and below also. but again, this is just my preference)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer to avoid these sort of unrelated changes to minimize the diffs. Either way is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in this particular case, with many fall-throughs, I think the code would benefit from reformatting.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minimal diff eases in tracing regression and in review. May be we can take up the cleanup as a separate issue, there seems to be multiple of such instances. (of switch/replacing if with switch)

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The additional changes to add the enum look good to me. I'll test it and review the javadoc.

@@ -299,14 +299,16 @@ public void sendNotification(AccessibleAttribute notification) {
break;
}
case INDETERMINATE: {
if (getAttribute(ROLE) == AccessibleRole.CHECK_BOX) {
if (getAttribute(ROLE) == AccessibleRole.CHECK_BOX
|| getAttribute(ROLE) == AccessibleRole.CHECK_BOX_TREE_ITEM) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the proposed change is less intrusive than a switch, but I don't mind either way. It might make sense to use a local variable to avoid calling getAttribute twice.

notifyToggleState();
}
break;
}
case SELECTED: {
Object role = getAttribute(ROLE);
if (role == AccessibleRole.CHECK_BOX || role == AccessibleRole.TOGGLE_BUTTON) {
if (role == AccessibleRole.CHECK_BOX || role == AccessibleRole.TOGGLE_BUTTON
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't bother.

@@ -431,6 +433,7 @@ private Accessible getContainer() {
case LIST_ITEM: return getContainerAccessible(AccessibleRole.LIST_VIEW);
case TAB_ITEM: return getContainerAccessible(AccessibleRole.TAB_PANE);
case PAGE_ITEM: return getContainerAccessible(AccessibleRole.PAGINATION);
case CHECK_BOX_TREE_ITEM:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I usually prefer to avoid these sort of unrelated changes to minimize the diffs. Either way is fine.

@kevinrushforth
Copy link
Member

Testing with VoiceOver on Mac M1 Ventura 13.3.1(a): undetermined checkbox is pronounced as "mixed checkbox" - is this expected behavior?

This is a Windows-only fix, so the behavior should be unchanged on Mac from before this fix. The only change on Mac is to react to the new AccessibleRole value (to do what it would have done before).

@andy-goryachev-oracle
Copy link
Contributor

it looks like the behavior on Mac is unchanged.

@andy-goryachev-oracle
Copy link
Contributor

I can't find anything like VoiceOver on Windows 11. Do you need JAWS or similar to test?

Copy link
Member

@kevinrushforth kevinrushforth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing looks (and sounds) good to me. I'll reapprove if you make the suggested formatting or doc changes. Go ahead and update the CSR when ready.

@kevinrushforth
Copy link
Member

I can't find anything like VoiceOver on Windows 11. Do you need JAWS or similar to test?

You can use Windows Narrator.

@kevinrushforth
Copy link
Member

Also, probably unrelated to this PR: the outlines placed by VoiceOver are shifted to the wrong positions on the secondary monitor

Definitely unrelated, but it should be filed as a bug. I remember seeing this before, but I don't see a bug for it.

@azuev-java
Copy link
Member

I can't find anything like VoiceOver on Windows 11. Do you need JAWS or similar to test?

On Windows 10/11 it is called Narrator and is in Start->All Apps->Accessibility->Narrator
Unlike AWT/Swing JavaFX does not require JAWS or NVDA.

Copy link
Member

@azuev-java azuev-java left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Member

@azuev-java azuev-java left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Copy link
Contributor

@andy-goryachev-oracle andy-goryachev-oracle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks and sounds good.

@andy-goryachev-oracle
Copy link
Contributor

andy-goryachev-oracle commented May 16, 2023

Is JDK-8087651 a duplicate of this issue? or related?

@andy-goryachev-oracle
Copy link
Contributor

Definitely unrelated, but it should be filed as a bug. I remember seeing this before, but I don't see a bug for it.

created JDK-8308191
[macOS] VoiceOver decorations are shifted on second monitor

@openjdk
Copy link

openjdk bot commented May 17, 2023

@arapte This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8284542: [Accessibility] [Win] Missing attribute for toggle state of CheckBox in CheckBoxTreeItem

Reviewed-by: kcr, kizune, angorya

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 5 new commits pushed to the master branch:

  • bff41c2: 8308114: Bump minimum version of macOS for x64 to 11.0 (matching aarch64)
  • c1a1179: 8245919: Region#padding property rendering error
  • e7974bc: 8308028: Replace more uses of System.getProperty("os.name") with PlatformUtil calls
  • 8aff525: 8307960: Create Table Column PopupMenu lazily
  • 7095364: 8307807: Replace use of System.getProperty("os.name") with PlatformUtil calls

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added ready Ready to be integrated and removed csr Need approved CSR to integrate pull request labels May 17, 2023
@arapte
Copy link
Member Author

arapte commented May 17, 2023

/integrate

@openjdk
Copy link

openjdk bot commented May 17, 2023

Going to push as commit bdadcb2.
Since your change was applied there have been 6 commits pushed to the master branch:

  • 6aeaff3: 8295078: TextField blurry when inside an TitledPane -> AnchorPane
  • bff41c2: 8308114: Bump minimum version of macOS for x64 to 11.0 (matching aarch64)
  • c1a1179: 8245919: Region#padding property rendering error
  • e7974bc: 8308028: Replace more uses of System.getProperty("os.name") with PlatformUtil calls
  • 8aff525: 8307960: Create Table Column PopupMenu lazily
  • 7095364: 8307807: Replace use of System.getProperty("os.name") with PlatformUtil calls

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label May 17, 2023
@openjdk openjdk bot closed this May 17, 2023
@openjdk openjdk bot removed ready Ready to be integrated rfr Ready for review labels May 17, 2023
@openjdk
Copy link

openjdk bot commented May 17, 2023

@arapte Pushed as commit bdadcb2.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

@arapte arapte deleted the a11y-8284542-CheckBoxTreeItem branch October 23, 2023 12:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants