Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8087557: [Win] [Accessibility, Dialogs] Alert Dialog content is not f…
…ully read by Screen Reader

Reviewed-by: kcr, aghaisas
  • Loading branch information
arapte committed Aug 22, 2022
1 parent bee2dfb commit b951503
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 2 deletions.
Expand Up @@ -53,6 +53,7 @@
import javafx.css.StyleableStringProperty;
import javafx.event.ActionEvent;
import javafx.geometry.Pos;
import javafx.scene.AccessibleRole;
import javafx.scene.Node;
import javafx.scene.control.ButtonBar.ButtonData;
import javafx.scene.image.Image;
Expand Down Expand Up @@ -209,6 +210,7 @@ static Label createContentLabel(String text) {
*/
public DialogPane() {
getStyleClass().add("dialog-pane");
setAccessibleRole(AccessibleRole.DIALOG);

headerTextPanel = new GridPane();
getChildren().add(headerTextPanel);
Expand Down
Expand Up @@ -25,13 +25,13 @@
package test.javafx.scene.control;

import com.sun.javafx.tk.Toolkit;
import javafx.scene.AccessibleRole;
import javafx.scene.control.ButtonType;
import javafx.scene.control.Dialog;
import javafx.scene.layout.StackPane;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import static org.junit.Assert.assertEquals;

/** Tests for the {@link Dialog} class. */
Expand Down Expand Up @@ -80,6 +80,11 @@ public void testDialogMinHeight() {
assertEquals(minHeight, dialog.getDialogPane().getMinHeight(), 0);
}

@Test
public void testAccessibleRole() {
assertEquals(AccessibleRole.DIALOG, dialog.getDialogPane().getAccessibleRole());
}

@Test
public void testDialogPrefHeight() {
int prefHeight = 400;
Expand Down
Expand Up @@ -1299,6 +1299,7 @@ private MacVariant accessibilityAttributeValue(long attribute) {
case PAGE_ITEM: result = "page"; break;
case TAB_ITEM: result = "tab"; break;
case LIST_VIEW: result = "list"; break;
case DIALOG: result = "dialog"; break;
default:
MacRole macRole = getRole(role);
MacSubrole subRole = MacSubrole.getRole(role);
Expand Down
Expand Up @@ -105,6 +105,7 @@ final class WinAccessible extends Accessible {
private static final int UIA_ToggleToggleStatePropertyId = 30086;
private static final int UIA_AriaRolePropertyId = 30101;
private static final int UIA_ProviderDescriptionPropertyId = 30107;
private static final int UIA_IsDialogPropertyId = 30174;

/* Control Pattern Identifiers */
private static final int UIA_InvokePatternId = 10000;
Expand Down Expand Up @@ -795,6 +796,7 @@ private WinVariant GetPropertyValue(int propertyId) {
switch (role) {
case TITLED_PANE: description = "title pane"; break;
case PAGE_ITEM: description = "page"; break;
case DIALOG: description = "dialog"; break;
default:
}
}
Expand Down Expand Up @@ -834,6 +836,12 @@ private WinVariant GetPropertyValue(int propertyId) {
variant.boolVal = focus != null ? focus : false;
break;
}
case UIA_IsDialogPropertyId: {
AccessibleRole role = (AccessibleRole) getAttribute(ROLE);
variant = new WinVariant();
variant.vt = WinVariant.VT_BOOL;
variant.boolVal = (role == AccessibleRole.DIALOG);
} break;
case UIA_IsContentElementPropertyId:
case UIA_IsControlElementPropertyId: {
//TODO how to handle ControlElement versus ContentElement
Expand Down
Expand Up @@ -822,4 +822,18 @@ public enum AccessibleRole {
* </ul>
*/
TREE_VIEW,

/**
* Dialog role.
* <p>
* Attributes:
* <ul>
* <li> {@link AccessibleAttribute#TEXT} </li>
* <li> {@link AccessibleAttribute#ROLE_DESCRIPTION} </li>
* <li> {@link AccessibleAttribute#CHILDREN} </li>
* </ul>
*
* @since 20
*/
DIALOG
}
Expand Up @@ -6522,7 +6522,13 @@ Accessible getAccessible() {
}
return getRoot();//not sure
}
case ROLE: return AccessibleRole.PARENT;
case ROLE: {
if (getRoot() != null && getRoot().getAccessibleRole() == AccessibleRole.DIALOG) {
return AccessibleRole.DIALOG;
} else {
return AccessibleRole.PARENT;
}
}
case SCENE: return Scene.this;
case FOCUS_NODE: {
if (transientFocusContainer != null) {
Expand Down

1 comment on commit b951503

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

Please sign in to comment.