Skip to content
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

Improving accessability - added aria presentation role for layout tables #10108

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions user/src/com/google/gwt/user/client/ui/CellPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.gwt.user.client.ui;

import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;
import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant;
Expand Down Expand Up @@ -72,6 +73,8 @@ public abstract class CellPanel extends ComplexPanel {

public CellPanel() {
table = DOM.createTable();
// aria role to indicate it is a plain layout table
Roles.getPresentationRole().set(table);
body = DOM.createTBody();
DOM.appendChild(table, body);
setElement(table);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.gwt.user.client.ui;

import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.DOM;

Expand Down Expand Up @@ -81,6 +82,8 @@ public DecoratedStackPanel() {
Element createHeaderElem() {
// Create the table
Element table = DOM.createTable();
// aria role to indicate it is a plain layout table
Roles.getPresentationRole().set(table);
Element tbody = DOM.createTBody();
DOM.appendChild(table, tbody);
table.getStyle().setProperty("width", "100%");
Expand Down
4 changes: 4 additions & 0 deletions user/src/com/google/gwt/user/client/ui/DecoratorPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.gwt.user.client.ui;

import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.i18n.client.LocaleInfo;
import com.google.gwt.user.client.DOM;
Expand Down Expand Up @@ -164,6 +165,9 @@ public DecoratorPanel() {

// Add a tbody
Element table = getElement();
// aria role to indicate it is a plain layout table
Roles.getPresentationRole().set(table);

tbody = DOM.createTBody();
DOM.appendChild(table, tbody);
table.setPropertyInt("cellSpacing", 0);
Expand Down
4 changes: 4 additions & 0 deletions user/src/com/google/gwt/user/client/ui/DisclosurePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package com.google.gwt.user.client.ui;

import com.google.gwt.animation.client.Animation;
import com.google.gwt.aria.client.Roles;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Element;
import com.google.gwt.event.logical.shared.CloseEvent;
Expand Down Expand Up @@ -230,6 +231,9 @@ private DefaultHeader(Imager imager, String text) {

// I do not need any Widgets here, just a DOM structure.
Element root = DOM.createTable();
// aria role to indicate it is a plain layout table
Roles.getPresentationRole().set(root);

Element tbody = DOM.createTBody();
Element tr = DOM.createTR();
final Element imageTD = DOM.createTD();
Expand Down
3 changes: 3 additions & 0 deletions user/src/com/google/gwt/user/client/ui/MenuBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,9 @@ private void init(boolean vertical, AbstractImagePrototype subMenuIcon) {
this.subMenuIcon = subMenuIcon;

Element table = DOM.createTable();
// aria role to indicate it is a plain layout table
Roles.getPresentationRole().set(table);

body = DOM.createTBody();
DOM.appendChild(table, body);

Expand Down
3 changes: 3 additions & 0 deletions user/src/com/google/gwt/user/client/ui/StackPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package com.google.gwt.user.client.ui;

import com.google.gwt.aria.client.Roles;
import com.google.gwt.dom.client.Element;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.annotations.IsSafeHtml;
Expand Down Expand Up @@ -63,6 +64,8 @@ public class StackPanel extends ComplexPanel implements InsertPanel.ForIsWidget
*/
public StackPanel() {
Element table = DOM.createTable();
// aria role to indicate it is a plain layout table
Roles.getPresentationRole().set(table);
setElement(table);

body = DOM.createTBody();
Expand Down
2 changes: 2 additions & 0 deletions user/src/com/google/gwt/user/client/ui/TreeItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ void initializeClonableElements() {
if (GWT.isClient()) {
// Create the base table element that will be cloned.
BASE_INTERNAL_ELEM = DOM.createTable();
// aria role to indicate it is a plain layout table
Roles.getPresentationRole().set(BASE_INTERNAL_ELEM);
Element contentElem = DOM.createDiv();
Element tbody = DOM.createTBody(), tr = DOM.createTR();
Element tdImg = DOM.createTD(), tdContent = DOM.createTD();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,12 @@ public void testDefaultStyles() {
// Check the container element
assertTrue(panel.getCellElement(1, 1) == panel.getContainerElement());
}

public void testPresentationRole() {
DecoratorPanel panel = createPanel();
assertNotNull(panel.getElement());
assertEquals("presentation", panel.getElement().getAttribute("role"));
}

@Override
protected DecoratorPanel createPanel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,12 @@ public void testRemoveNullAsIsWidget() {
panel.remove(widget);
// ta da...
}

public void testPresentationRole() {
DisclosurePanel panel = createEmptyDisclourePanel();
assertNotNull(panel.getElement());
assertEquals("presentation", panel.getElement().getAttribute("role"));
}

private DisclosurePanel createEmptyDisclourePanel() {
return new DisclosurePanel();
Expand Down
7 changes: 6 additions & 1 deletion user/test/com/google/gwt/user/client/ui/DockPanelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
/**
* Tests the DockPanel widget.
*/
@SuppressWarnings("deprecation")
public class DockPanelTest extends GWTTestCase {

static class Adder implements HasWidgetsTester.WidgetAdder {
Expand Down Expand Up @@ -125,6 +124,12 @@ public void testAddAsIsWidget() {
assertPhysicalPaternity(panel,widget);
}

public void testPresentationRole() {
DockPanel panel = createDockPanel();
assertNotNull(panel.getElement());
assertEquals("presentation", panel.getElement().getAttribute("role"));
}

public void testAttachDetachOrder() {
HasWidgetsTester.testAll(new DockPanel(), new Adder(), true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public void testInsertMultipleTimes() {
assertEquals(0, p.getWidgetIndex(tb));
assertEquals(1, p.getWidgetIndex(l));
}

public void testPresentationRole() {
CellPanel panel = createCellPanel();
assertNotNull(panel.getElement());
assertEquals("presentation", panel.getElement().getAttribute("role"));
}

@Override
protected CellPanel createCellPanel() {
Expand Down
7 changes: 6 additions & 1 deletion user/test/com/google/gwt/user/client/ui/MenuBarTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,6 @@ public void testClearSelectionAfterCommand() {
MenuItem item1 = bar.addItem("item1", BLANK_COMMAND);
RootPanel.get().add(bar);


bar.itemOver(item1, true);
assertNotNull(bar.getSelectedItem());

Expand Down Expand Up @@ -605,4 +604,10 @@ public void testTabKey() {
assertNull(l0.getSelectedItem());
assertNull(l1.getPopup());
}

public void testPresentationRole() {
MenuBar menu = new MenuBar();
assertNotNull(menu.getElement());
assertEquals("presentation", menu.getElement().getAttribute("role"));
}
}
6 changes: 6 additions & 0 deletions user/test/com/google/gwt/user/client/ui/StackPanelTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,12 @@ private static void assertDoesNotContainStyleName(Element element, String styleN
assertFalse("Style name '" + styleName + "' was found in '" + element.getClassName() + "'",
element.hasClassName(styleName));
}

public void testPresentationRole() {
StackPanel stackpanel = createStackPanel();
assertNotNull(stackpanel.getElement());
assertEquals("presentation", stackpanel.getElement().getAttribute("role"));
}

/**
* Create a new stack panel.
Expand Down
6 changes: 6 additions & 0 deletions user/test/com/google/gwt/user/client/ui/TreeItemTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,4 +261,10 @@ public void testSetWidgetNullWithError() {
// Detach the panel.
RootPanel.get().remove(tree);
}

public void testPresentationRole() {
TreeItem item = new TreeItem();
assertNotNull(item.getElement());
assertEquals("presentation", item.getElement().getAttribute("role"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@ public void testInsertMultipleTimes() {
assertEquals(0, p.getWidgetIndex(tb));
assertEquals(1, p.getWidgetIndex(l));
}

public void testPresentationRole() {
CellPanel panel = createCellPanel();
assertNotNull(panel.getElement());
assertEquals("presentation", panel.getElement().getAttribute("role"));
}

@Override
protected CellPanel createCellPanel() {
Expand Down