- Deprecate Accessibility.java
- Replace the Accessibility calls with the new ARIA API calls
- Fix some warnings with missing @Override annotations

Review at http://gwt-code-reviews.appspot.com/1668803


git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10922 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/user/client/ui/Accessibility.java b/user/src/com/google/gwt/user/client/ui/Accessibility.java
index b523f17..7bd19b5 100644
--- a/user/src/com/google/gwt/user/client/ui/Accessibility.java
+++ b/user/src/com/google/gwt/user/client/ui/Accessibility.java
@@ -39,8 +39,13 @@
  * somewhat in flux. As a result, this API is subject to change as the
  * specification stabilizes; we will do our best to keep the community
  * updated on changes.</p>
+ *
+ * @deprecated Use the new GWT ARIA library with the factory class for the ARIA roles
+ * {@link com.google.gwt.aria.client.Roles}. There are getters for all ARIA roles. For each
+ * role there are get/set/remove methods defined for all (own and inherited) supported states
+ * and properties.
  */
-
+@Deprecated
 public final class Accessibility {
 
   public static final String ROLE_TREE = "tree";
@@ -60,7 +65,7 @@
   public static final String STATE_LEVEL = "aria-level";
   public static final String STATE_HASPOPUP = "aria-haspopup";
   public static final String STATE_PRESSED = "aria-pressed";
-  
+
   private static final String ATTR_NAME_ROLE = "role";
 
   /**
diff --git a/user/src/com/google/gwt/user/client/ui/CustomButton.java b/user/src/com/google/gwt/user/client/ui/CustomButton.java
index 7cbe936..ad437f7 100644
--- a/user/src/com/google/gwt/user/client/ui/CustomButton.java
+++ b/user/src/com/google/gwt/user/client/ui/CustomButton.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2008 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -16,6 +16,8 @@
 
 package com.google.gwt.user.client.ui;
 
+import com.google.gwt.aria.client.CommonAttributeTypes.BooleanAndUndefined;
+import com.google.gwt.aria.client.Roles;
 import com.google.gwt.dom.client.Document;
 import com.google.gwt.dom.client.NativeEvent;
 import com.google.gwt.event.dom.client.ClickEvent;
@@ -29,69 +31,69 @@
 /**
  * CustomButton is a base button class with built in support for a set number
  * of button faces.
- * 
+ *
  * Each face has its own style modifier. For example, the state for down and
  * hovering is assigned the CSS modifier <i>down-hovering</i>. So, if the
  * button's overall style name is <i>gwt-PushButton</i> then when showing the
  * <code>down-hovering</code> face, the button's style is <i>
  * gwt-PushButton-down-hovering</i>. The overall style name can be used to
  * change the style of the button irrespective of the current face.
- * 
+ *
  * <p>
  * Each button face can be assigned is own image, text, or html contents. If no
  * content is defined for a face, then the face will use the contents of another
  * face. For example, if <code>down-hovering</code> does not have defined
  * contents, it will use the contents defined by the <code>down</code> face.
  * </p>
- * 
+ *
  * <p>
  * The supported faces are defined below:
  * </p>
  * <p>
  * <table border="4">
  * <tr>
- * 
+ *
  * <td><b>CSS style name</b></td>
  * <td><b>Getter method</b></td>
  * <td><b>description of face</b></td>
  * <td><b>defaults to contents of face</b></td>
  * </tr>
- * 
+ *
  * <tr>
  * <td>up</td>
  * <td> {@link #getUpFace()}</td>
  * <td>face shown when button is up</td>
  * <td>none</td>
  * </tr>
- * 
+ *
  * <tr>
  * <td>down</td>
  * <td> {@link #getDownFace()}</td>
  * <td>face shown when button is down</td>
  * <td>up</td>
  * </tr>
- * 
+ *
  * <tr>
  * <td>up-hovering</td>
  * <td> {@link #getUpHoveringFace()}</td>
  * <td>face shown when button is up and hovering</td>
  * <td>up</td>
  * </tr>
- * 
+ *
  * <tr>
  * <td>up-disabled</td>
  * <td> {@link #getUpDisabledFace()}</td>
  * <td>face shown when button is up and disabled</td>
  * <td>up</td>
  * </tr>
- * 
+ *
  * <tr>
  * <td>down-hovering</td>
  * <td> {@link #getDownHoveringFace()}</td>
  * <td>face shown when button is down and hovering</td>
  * <td>down</td>
  * </tr>
- * 
+ *
  * <tr>
  * <td>down-disabled</td>
  * <td> {@link #getDownDisabledFace()}</td>
@@ -100,10 +102,10 @@
  * </tr>
  * </table>
  * </p>
- * 
+ *
  * <h3>Use in UiBinder Templates</h3>
- * 
- * When working with CustomButton subclasses in 
+ *
+ * When working with CustomButton subclasses in
  * {@link com.google.gwt.uibinder.client.UiBinder UiBinder} templates, you
  * can set text and assign ImageResources for their various faces via
  * child elements:
@@ -116,7 +118,7 @@
  * <dt>&lt;g:upDisabledFace>
  * <dt>&lt;g:downDisabledFace>
  * </dl>
- * 
+ *
  * Each face element can take an optional <code>image</code> attribute
  * and an html body. For example:<pre>
  * &lt;ui:image field='downButton'/> &lt;!-- define an {@link com.google.gwt.resources.client.ImageResource ImageResource} -->
@@ -128,7 +130,7 @@
  *   &lt;g:upHoveringFace>
  *     &lt;b>Click ME!&lt;/b>
  *   &lt;/gwt:upHoveringFace>
- *   
+ *
  *   &lt;g:downFace image='{downButton}'/>
  *   &lt;g:downHoveringFace image='{downButton}'/>
  * &lt;/g:PushButton>
@@ -147,7 +149,7 @@
     /**
      * Constructor for <code>Face</code>. Creates a new face that delegates to
      * the supplied face.
-     * 
+     *
      * @param delegateTo default content provider
      */
     private Face(Face delegateTo) {
@@ -156,20 +158,22 @@
 
     /**
      * Gets the face's contents as html.
-     * 
+     *
      * @return face's contents as html
-     * 
+     *
      */
+    @Override
     public String getHTML() {
       return DOM.getInnerHTML(getFace());
     }
 
     /**
      * Gets the face's contents as text.
-     * 
+     *
      * @return face's contents as text
-     * 
+     *
      */
+    @Override
     public String getText() {
       return DOM.getInnerText(getFace());
     }
@@ -179,6 +183,7 @@
      *
      * @param html html to set as face's contents html
      */
+    @Override
     public void setHTML(SafeHtml html) {
       setHTML(html.asString());
     }
@@ -189,6 +194,7 @@
      * @param html html to set as face's contents html
      *
      */
+    @Override
     public void setHTML(String html) {
       face = DOM.createDiv();
       UIObject.setStyleName(face, STYLENAME_HTML_FACE, true);
@@ -198,7 +204,7 @@
 
     /**
      * Set the face's contents as an image.
-     * 
+     *
      * @param image image to set as face contents
      */
     public final void setImage(Image image) {
@@ -211,6 +217,7 @@
      *
      * @param text text to set as face's contents
      */
+    @Override
     public final void setText(String text) {
       face = DOM.createDiv();
       UIObject.setStyleName(face, STYLENAME_HTML_FACE, true);
@@ -234,7 +241,7 @@
      * <code>CustomButton</code> style. <p/> For instance, if the
      * <code>CustomButton</code> style is "gwt-PushButton" and the face name is
      * "up", then the CSS class name will be "gwt-PushButton-up".
-     * 
+     *
      * @return the face's name
      */
     abstract String getName();
@@ -368,7 +375,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upImage image for the default (up) face of the button
    */
   public CustomButton(Image upImage) {
@@ -378,7 +385,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upImage image for the default (up) face of the button
    * @param handler the click handler
    */
@@ -389,7 +396,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upImage image for the default (up) face of the button
    * @param listener the click listener
    * @deprecated Use {@link #CustomButton(Image, ClickHandler)} instead
@@ -402,7 +409,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upImage image for the default (up) face of the button
    * @param downImage image for the down face of the button
    */
@@ -413,7 +420,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upImage image for the default (up) face of the button
    * @param downImage image for the down face of the button
    * @param handler clickListener
@@ -425,7 +432,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upImage image for the default (up) face of the button
    * @param downImage image for the down face of the button
    * @param listener clickListener
@@ -439,7 +446,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upText the text for the default (up) face of the button
    */
   public CustomButton(String upText) {
@@ -449,7 +456,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upText the text for the default (up) face of the button
    * @param handler the click handler
    */
@@ -460,7 +467,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upText the text for the default (up) face of the button
    * @param listener the click listener
    * @deprecated Use {@link #CustomButton(String, ClickListener)} instead
@@ -473,7 +480,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upText the text for the default (up) face of the button
    * @param downText the text for the down face of the button
    */
@@ -484,7 +491,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upText the text for the default (up) face of the button
    * @param downText the text for the down face of the button
    * @param handler the click handler
@@ -496,7 +503,7 @@
 
   /**
    * Constructor for <code>CustomButton</code>.
-   * 
+   *
    * @param upText the text for the default (up) face of the button
    * @param downText the text for the down face of the button
    * @param listener the click listener
@@ -521,12 +528,12 @@
     setStyleName(STYLENAME_DEFAULT);
 
     // Add a11y role "button"
-    Accessibility.setRole(getElement(), Accessibility.ROLE_BUTTON);
+    Roles.getButtonRole().set(getElement());
   }
 
   /**
    * Gets the downDisabled face of the button.
-   * 
+   *
    * @return the downDisabled face
    */
   public final Face getDownDisabledFace() {
@@ -539,7 +546,7 @@
 
   /**
    * Gets the down face of the button.
-   * 
+   *
    * @return the down face
    */
   public final Face getDownFace() {
@@ -551,7 +558,7 @@
 
   /**
    * Gets the downHovering face of the button.
-   * 
+   *
    * @return the downHovering face
    */
   public final Face getDownHoveringFace() {
@@ -564,7 +571,7 @@
 
   /**
    * Gets the current face's html.
-   * 
+   *
    * @return current face's html
    */
   @Override
@@ -579,7 +586,7 @@
 
   /**
    * Gets the current face's text.
-   * 
+   *
    * @return current face's text
    */
   @Override
@@ -589,7 +596,7 @@
 
   /**
    * Gets the upDisabled face of the button.
-   * 
+   *
    * @return the upDisabled face
    */
   public final Face getUpDisabledFace() {
@@ -601,7 +608,7 @@
 
   /**
    * Gets the up face of the button.
-   * 
+   *
    * @return the up face
    */
   public final Face getUpFace() {
@@ -610,7 +617,7 @@
 
   /**
    * Gets the upHovering face of the button.
-   * 
+   *
    * @return the upHovering face
    */
   public final Face getUpHoveringFace() {
@@ -730,7 +737,7 @@
 
   /**
    * Sets whether this button is enabled.
-   * 
+   *
    * @param enabled <code>true</code> to enable the button, <code>false</code>
    * to disable it
    */
@@ -741,7 +748,7 @@
       super.setEnabled(enabled);
       if (!enabled) {
         cleanupCaptureState();
-        Accessibility.removeState(getElement(), Accessibility.STATE_PRESSED);
+        Roles.getButtonRole().removeAriaPressedState(getElement());
       } else {
         setAriaPressed(getCurrentFace());
       }
@@ -779,7 +786,7 @@
 
   /**
    * Sets the current face's text.
-   * 
+   *
    * @param text text to set
    */
   @Override
@@ -789,7 +796,7 @@
 
   /**
    * Is this button down?
-   * 
+   *
    * @return <code>true</code> if the button is down
    */
   protected boolean isDown() {
@@ -857,7 +864,7 @@
 
   /**
    * Sets whether this button is down.
-   * 
+   *
    * @param down <code>true</code> to press the button, <code>false</code>
    * otherwise
    */
@@ -884,7 +891,7 @@
 
   /**
    * Gets the current face of the button.
-   * 
+   *
    * @return the current face
    */
 
@@ -899,7 +906,7 @@
 
   /**
    * Is the mouse hovering over this button?
-   * 
+   *
    * @return <code>true</code> if the mouse is hovering
    */
   final boolean isHovering() {
@@ -926,7 +933,7 @@
 
   /**
    * Sets whether this button is hovering.
-   * 
+   *
    * @param hovering is this button hovering?
    */
   final void setHovering(boolean hovering) {
@@ -992,13 +999,12 @@
 
   private void setAriaPressed(Face newFace) {
     boolean pressed = (newFace.getFaceID() & DOWN_ATTRIBUTE) == 1;
-    Accessibility.setState(getElement(), Accessibility.STATE_PRESSED,
-        pressed ? "true" : "false");
+    Roles.getButtonRole().setAriaPressedState(getElement(), BooleanAndUndefined.of(pressed));
   }
 
   /**
    * Sets the current face based on the faceID.
-   * 
+   *
    * @param faceID sets the new face of the button
    */
   private void setCurrentFace(int faceID) {
@@ -1018,7 +1024,7 @@
 
   /**
    * Sets the downDisabled face of the button.
-   * 
+   *
    * @param downDisabled downDisabled face
    */
   private void setDownDisabledFace(Face downDisabled) {
@@ -1027,7 +1033,7 @@
 
   /**
    * Sets the down face of the button.
-   * 
+   *
    * @param down the down face
    */
   private void setDownFace(Face down) {
@@ -1036,7 +1042,7 @@
 
   /**
    * Sets the downHovering face of the button.
-   * 
+   *
    * @param downHovering hoverDown face
    */
   private void setDownHoveringFace(Face downHovering) {
@@ -1045,7 +1051,7 @@
 
   /**
    * Sets the upDisabled face of the button.
-   * 
+   *
    * @param upDisabled upDisabled face
    */
   private void setUpDisabledFace(Face upDisabled) {
@@ -1054,7 +1060,7 @@
 
   /**
    * Sets the up face of the button.
-   * 
+   *
    * @param up up face
    */
   private void setUpFace(Face up) {
@@ -1063,7 +1069,7 @@
 
   /**
    * Sets the upHovering face of the button.
-   * 
+   *
    * @param upHovering upHovering face
    */
   private void setUpHoveringFace(Face upHovering) {
diff --git a/user/src/com/google/gwt/user/client/ui/MenuBar.java b/user/src/com/google/gwt/user/client/ui/MenuBar.java
index 829127c..a4801da 100644
--- a/user/src/com/google/gwt/user/client/ui/MenuBar.java
+++ b/user/src/com/google/gwt/user/client/ui/MenuBar.java
@@ -15,6 +15,8 @@
  */
 package com.google.gwt.user.client.ui;
 
+import com.google.gwt.aria.client.CommonAttributeTypes.IdReference;
+import com.google.gwt.aria.client.Roles;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.core.client.Scheduler;
 import com.google.gwt.dom.client.EventTarget;
@@ -260,6 +262,7 @@
     this(false, resources);
   }
 
+  @Override
   public HandlerRegistration addCloseHandler(CloseHandler<PopupPanel> handler) {
     return addHandler(handler, CloseEvent.getType());
   }
@@ -527,6 +530,7 @@
     return separator;
   }
 
+  @Override
   public boolean isAnimationEnabled() {
     return isAnimationEnabled;
   }
@@ -673,6 +677,7 @@
    *
    * @deprecated Use {@link #addCloseHandler(CloseHandler)} instead
    */
+  @Override
   @Deprecated
   public void onPopupClosed(PopupPanel sender, boolean autoClosed) {
     // If the menu popup was auto-closed, close all of its parents as well.
@@ -756,14 +761,14 @@
         }
       }
 
-      Accessibility.setState(getElement(),
-          Accessibility.STATE_ACTIVEDESCENDANT, DOM.getElementAttribute(
-              item.getElement(), "id"));
+      Roles.getMenubarRole().setAriaActivedescendantProperty(getElement(),
+          IdReference.of(DOM.getElementAttribute(item.getElement(), "id")));
     }
 
     selectedItem = item;
   }
 
+  @Override
   public void setAnimationEnabled(boolean enable) {
     isAnimationEnabled = enable;
   }
@@ -890,6 +895,7 @@
       // loop or popup blockers will prevent popups from opening.
       final Command cmd = item.getCommand();
       Scheduler.get().scheduleFinally(new Scheduler.ScheduledCommand() {
+        @Override
         public void execute() {
           cmd.execute();
         }
@@ -1085,7 +1091,7 @@
     DOM.appendChild(outer, table);
     setElement(outer);
 
-    Accessibility.setRole(getElement(), Accessibility.ROLE_MENUBAR);
+    Roles.getMenubarRole().set(getElement());
 
     sinkEvents(Event.ONCLICK | Event.ONMOUSEOVER | Event.ONMOUSEOUT
         | Event.ONFOCUS | Event.ONKEYDOWN);
@@ -1105,6 +1111,7 @@
 
     // Deselect items when blurring without a child menu.
     addDomHandler(new BlurHandler() {
+      @Override
       public void onBlur(BlurEvent event) {
         if (shownChildMenu == null) {
           selectItem(null);
@@ -1234,6 +1241,7 @@
     // of the popup's.
     popup.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
 
+      @Override
       public void setPosition(int offsetWidth, int offsetHeight) {
 
         // depending on the bidi direction position a menu on the left or right
diff --git a/user/src/com/google/gwt/user/client/ui/MenuItem.java b/user/src/com/google/gwt/user/client/ui/MenuItem.java
index 49ee22c..94d79d2 100644
--- a/user/src/com/google/gwt/user/client/ui/MenuItem.java
+++ b/user/src/com/google/gwt/user/client/ui/MenuItem.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2008 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,13 +15,14 @@
  */
 package com.google.gwt.user.client.ui;
 
+import com.google.gwt.aria.client.Roles;
 import com.google.gwt.safehtml.client.HasSafeHtml;
 import com.google.gwt.safehtml.shared.SafeHtml;
 import com.google.gwt.user.client.Command;
 import com.google.gwt.user.client.DOM;
 
 /**
- * An entry in a 
+ * An entry in a
  * {@link com.google.gwt.user.client.ui.MenuBar}. Menu items can either fire a
  * {@link com.google.gwt.user.client.Command} when they are clicked, or open a
  * cascading sub-menu.
@@ -40,7 +41,7 @@
 
   /**
    * Constructs a new menu item that fires a command when it is selected.
-   * 
+   *
    * @param html the item's html text
    */
   public MenuItem(SafeHtml html) {
@@ -49,7 +50,7 @@
 
   /**
    * Constructs a new menu item that fires a command when it is selected.
-   * 
+   *
    * @param html the item's text
    * @param cmd the command to be fired when it is selected
    */
@@ -59,7 +60,7 @@
 
   /**
    * Constructs a new menu item that cascades to a sub-menu when it is selected.
-   * 
+   *
    * @param html the item's text
    * @param subMenu the sub-menu to be displayed when it is selected
    */
@@ -69,7 +70,7 @@
 
   /**
    * Constructs a new menu item that fires a command when it is selected.
-   * 
+   *
    * @param text the item's text
    * @param asHTML <code>true</code> to treat the specified text as html
    * @param cmd the command to be fired when it is selected
@@ -81,7 +82,7 @@
 
   /**
    * Constructs a new menu item that cascades to a sub-menu when it is selected.
-   * 
+   *
    * @param text the item's text
    * @param asHTML <code>true</code> to treat the specified text as html
    * @param subMenu the sub-menu to be displayed when it is selected
@@ -93,7 +94,7 @@
 
   /**
    * Constructs a new menu item that fires a command when it is selected.
-   * 
+   *
    * @param text the item's text
    * @param cmd the command to be fired when it is selected
    */
@@ -104,7 +105,7 @@
 
   /**
    * Constructs a new menu item that cascades to a sub-menu when it is selected.
-   * 
+   *
    * @param text the item's text
    * @param subMenu the sub-menu to be displayed when it is selected
    */
@@ -126,25 +127,26 @@
 
     DOM.setElementAttribute(getElement(), "id", DOM.createUniqueId());
     // Add a11y role "menuitem"
-    Accessibility.setRole(getElement(), Accessibility.ROLE_MENUITEM);
+    Roles.getMenuitemRole().set(getElement());
   }
 
   /**
    * Gets the command associated with this item.
-   * 
+   *
    * @return this item's command, or <code>null</code> if none exists
    */
   public Command getCommand() {
     return command;
   }
 
+  @Override
   public String getHTML() {
     return DOM.getInnerHTML(getElement());
   }
 
   /**
    * Gets the menu that contains this item.
-   * 
+   *
    * @return the parent menu, or <code>null</code> if none exists.
    */
   public MenuBar getParentMenu() {
@@ -153,30 +155,33 @@
 
   /**
    * Gets the sub-menu associated with this item.
-   * 
+   *
    * @return this item's sub-menu, or <code>null</code> if none exists
    */
   public MenuBar getSubMenu() {
     return subMenu;
   }
 
+  @Override
   public String getText() {
     return DOM.getInnerText(getElement());
   }
 
+  @Override
   public boolean isEnabled() {
     return enabled;
   }
 
   /**
    * Sets the command associated with this item.
-   * 
+   *
    * @param cmd the command to be associated with this item
    */
   public void setCommand(Command cmd) {
     command = cmd;
   }
 
+  @Override
   public void setEnabled(boolean enabled) {
     if (enabled) {
       removeStyleDependentName(DEPENDENT_STYLENAME_DISABLED_ITEM);
@@ -186,17 +191,19 @@
     this.enabled = enabled;
   }
 
+  @Override
   public void setHTML(SafeHtml html) {
     setHTML(html.asString());
   }
 
+  @Override
   public void setHTML(String html) {
     DOM.setInnerHTML(getElement(), html);
   }
 
   /**
    * Sets the sub-menu associated with this item.
-   * 
+   *
    * @param subMenu this item's new sub-menu
    */
   public void setSubMenu(MenuBar subMenu) {
@@ -211,15 +218,14 @@
       FocusPanel.impl.setTabIndex(subMenu.getElement(), -1);
 
       // Update a11y role "haspopup"
-      Accessibility.setState(this.getElement(), Accessibility.STATE_HASPOPUP,
-          "true");
+      Roles.getMenuitemRole().setAriaHaspopupProperty(getElement(), true);
     } else {
       // Update a11y role "haspopup"
-      Accessibility.setState(this.getElement(), Accessibility.STATE_HASPOPUP,
-          "false");
+      Roles.getMenuitemRole().setAriaHaspopupProperty(getElement(), false);
     }
   }
 
+  @Override
   public void setText(String text) {
     DOM.setInnerText(getElement(), text);
   }
@@ -227,7 +233,7 @@
   /**
    * Also sets the Debug IDs of MenuItems in the submenu of this
    * {@link MenuItem} if a submenu exists.
-   * 
+   *
    * @see UIObject#onEnsureDebugId(String)
    */
   @Override
diff --git a/user/src/com/google/gwt/user/client/ui/TabBar.java b/user/src/com/google/gwt/user/client/ui/TabBar.java
index 19367ea..d33fb54 100644
--- a/user/src/com/google/gwt/user/client/ui/TabBar.java
+++ b/user/src/com/google/gwt/user/client/ui/TabBar.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2008 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.user.client.ui;
 
+import com.google.gwt.aria.client.Roles;
 import com.google.gwt.event.dom.client.ClickEvent;
 import com.google.gwt.event.dom.client.ClickHandler;
 import com.google.gwt.event.dom.client.HasAllKeyHandlers;
@@ -66,14 +67,14 @@
 
   /**
    * Set of characteristic interfaces supported by {@link TabBar} tabs.
-   * 
+   *
    * Note that this set might expand over time, so implement this interface at
    * your own risk.
    */
   public interface Tab extends HasAllKeyHandlers, HasClickHandlers, HasWordWrap {
     /**
      * Check if the underlying widget implements {@link HasWordWrap}.
-     *  
+     *
      * @return true if the widget implements {@link HasWordWrap}
      */
     boolean hasWordWrap();
@@ -104,18 +105,22 @@
       sinkEvents(Event.ONCLICK | Event.ONKEYDOWN);
     }
 
+    @Override
     public HandlerRegistration addClickHandler(ClickHandler handler) {
       return addHandler(handler, ClickEvent.getType());
     }
 
+    @Override
     public HandlerRegistration addKeyDownHandler(KeyDownHandler handler) {
       return addHandler(handler, KeyDownEvent.getType());
     }
 
+    @Override
     public HandlerRegistration addKeyPressHandler(KeyPressHandler handler) {
       return addDomHandler(handler, KeyPressEvent.getType());
     }
 
+    @Override
     public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
       return addDomHandler(handler, KeyUpEvent.getType());
     }
@@ -124,6 +129,7 @@
       return focusablePanel;
     }
 
+    @Override
     public boolean getWordWrap() {
       if (hasWordWrap()) {
         return ((HasWordWrap) focusablePanel.getWidget()).getWordWrap();
@@ -132,6 +138,7 @@
           "Widget does not implement HasWordWrap");
     }
 
+    @Override
     public boolean hasWordWrap() {
       return focusablePanel.getWidget() instanceof HasWordWrap;
     }
@@ -168,6 +175,7 @@
       this.enabled = enabled;
     }
 
+    @Override
     public void setWordWrap(boolean wrap) {
       if (hasWordWrap()) {
         ((HasWordWrap) focusablePanel.getWidget()).setWordWrap(wrap);
@@ -191,7 +199,7 @@
     setStyleName("gwt-TabBar");
 
     // Add a11y role "tablist"
-    Accessibility.setRole(panel.getElement(), Accessibility.ROLE_TABLIST);
+    Roles.getTablistRole().set(panel.getElement());
 
     panel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
 
@@ -211,28 +219,28 @@
     setStyleName(rest.getElement().getParentElement(), "gwt-TabBarRest-wrapper");
   }
 
-  public HandlerRegistration addBeforeSelectionHandler(
-      BeforeSelectionHandler<Integer> handler) {
+  @Override
+  public HandlerRegistration addBeforeSelectionHandler(BeforeSelectionHandler<Integer> handler) {
     return addHandler(handler, BeforeSelectionEvent.getType());
   }
 
-  public HandlerRegistration addSelectionHandler(
-      SelectionHandler<Integer> handler) {
+  @Override
+  public HandlerRegistration addSelectionHandler(SelectionHandler<Integer> handler) {
     return addHandler(handler, SelectionEvent.getType());
   }
 
   /**
    * Adds a new tab with the specified text.
-   * 
+   *
    * @param html the new tab's html
    */
   public void addTab(SafeHtml html) {
     addTab(html.asString(), true);
   }
-  
+
   /**
    * Adds a new tab with the specified text.
-   * 
+   *
    * @param text the new tab's text
    */
   public void addTab(String text) {
@@ -241,7 +249,7 @@
 
   /**
    * Adds a new tab with the specified text.
-   * 
+   *
    * @param text the new tab's text
    * @param asHTML <code>true</code> to treat the specified text as html
    */
@@ -251,7 +259,7 @@
 
   /**
    * Adds a new tab with the specified widget.
-   * 
+   *
    * @param widget the new tab's widget
    */
   public void addTab(Widget widget) {
@@ -259,9 +267,10 @@
   }
 
   /**
-   * @deprecated Use {@link #addBeforeSelectionHandler(BeforeSelectionHandler)} 
+   * @deprecated Use {@link #addBeforeSelectionHandler(BeforeSelectionHandler)}
    * and {@link #addSelectionHandler(SelectionHandler)} instead
    */
+  @Override
   @Deprecated
   public void addTabListener(TabListener listener) {
     ListenerWrapper.WrappedTabListener.add(this, listener);
@@ -269,7 +278,7 @@
 
   /**
    * Gets the tab that is currently selected.
-   * 
+   *
    * @return the selected tab
    */
   public int getSelectedTab() {
@@ -281,11 +290,11 @@
 
   /**
    * Gets the given tab.
-   * 
+   *
    * This method is final because the Tab interface will expand. Therefore
    * it is highly likely that subclasses which implemented this method would end up
    * breaking.
-   * 
+   *
    * @param index the tab's index
    * @return the tab wrapper
    */
@@ -299,7 +308,7 @@
 
   /**
    * Gets the number of tabs present.
-   * 
+   *
    * @return the tab count
    */
   public int getTabCount() {
@@ -308,7 +317,7 @@
 
   /**
    * Gets the specified tab's HTML.
-   * 
+   *
    * @param index the index of the tab whose HTML is to be retrieved
    * @return the tab's HTML
    */
@@ -331,17 +340,17 @@
 
   /**
    * Inserts a new tab at the specified index.
-   * 
+   *
    * @param html the new tab's html
    * @param beforeIndex the index before which this tab will be inserted
    */
   public void insertTab(SafeHtml html, int beforeIndex) {
     insertTab(html.asString(), true, beforeIndex);
   }
-  
+
   /**
    * Inserts a new tab at the specified index.
-   * 
+   *
    * @param text the new tab's text
    * @param asHTML <code>true</code> to treat the specified text as HTML
    * @param beforeIndex the index before which this tab will be inserted
@@ -362,7 +371,7 @@
 
   /**
    * Inserts a new tab at the specified index.
-   * 
+   *
    * @param text the new tab's text
    * @param beforeIndex the index before which this tab will be inserted
    */
@@ -372,7 +381,7 @@
 
   /**
    * Inserts a new tab at the specified index.
-   * 
+   *
    * @param widget widget to be used in the new tab
    * @param beforeIndex the index before which this tab will be inserted
    */
@@ -383,7 +392,7 @@
   /**
    * Check if a tab is enabled or disabled. If disabled, the user cannot select
    * the tab.
-   * 
+   *
    * @param index the index of the tab
    * @return true if the tab is enabled, false if disabled
    */
@@ -398,6 +407,7 @@
    * you need to access to the individual tabs, add a click handler to each
    * {@link Tab} element instead.
    */
+  @Override
   @Deprecated
   public void onClick(Widget sender) {
   }
@@ -406,6 +416,7 @@
    * @deprecated add a key down handler to the individual {@link Tab} objects
    *  instead.
    */
+  @Override
   @Deprecated
   public void onKeyDown(Widget sender, char keyCode, int modifiers) {
   }
@@ -415,6 +426,7 @@
    * if what you wanted to do was to listen to key press events on tabs, add the
    * key press handler to the individual tab wrappers instead.
    */
+  @Override
   @Deprecated
   public void onKeyPress(Widget sender, char keyCode, int modifiers) {
   }
@@ -423,15 +435,16 @@
    * @deprecated this method has been doing nothing for the entire last release,
    * if what you wanted to do was to listen to key up events on tabs, add the
    * key up handler to the individual tab wrappers instead.
-   * 
+   *
    */
+  @Override
   @Deprecated
   public void onKeyUp(Widget sender, char keyCode, int modifiers) {
   }
 
   /**
    * Removes the tab at the specified index.
-   * 
+   *
    * @param index the index of the tab to be removed
    */
   public void removeTab(int index) {
@@ -449,6 +462,7 @@
    * @deprecated Instead use the {@link HandlerRegistration#removeHandler}
    * call on the object returned by an add*Handler method
    */
+  @Override
   @Deprecated
   public void removeTabListener(TabListener listener) {
     ListenerWrapper.WrappedTabListener.remove(this, listener);
@@ -457,7 +471,7 @@
   /**
    * Programmatically selects the specified tab and fires events. Use index -1
    * to specify that no tab should be selected.
-   * 
+   *
    * @param index the index of the tab to be selected
    * @return <code>true</code> if successful, <code>false</code> if the change
    * is denied by the {@link BeforeSelectionHandler}.
@@ -469,7 +483,7 @@
   /**
    * Programmatically selects the specified tab. Use index -1 to specify that no
    * tab should be selected.
-   * 
+   *
    * @param index the index of the tab to be selected
    * @param fireEvents true to fire events, false not to
    * @return <code>true</code> if successful, <code>false</code> if the change
@@ -502,7 +516,7 @@
 
   /**
    * Enable or disable a tab. When disabled, users cannot select the tab.
-   * 
+   *
    * @param index the index of the tab to enable or disable
    * @param enabled true to enable, false to disable
    */
@@ -519,12 +533,12 @@
 
   /**
    * Sets a tab's contents via HTML.
-   * 
+   *
    * Use care when setting an object's HTML; it is an easy way to expose
    * script-based security problems. Consider using
    * {@link #setTabText(int, String)} or {@link #setTabHTML(int, SafeHtml)}
    * whenever possible.
-   * 
+   *
    * @param index the index of the tab whose HTML is to be set
    * @param html the tab new HTML
    */
@@ -538,17 +552,17 @@
 
   /**
    * Sets a tab's contents via safe html.
-   * 
+   *
    * @param index the index of the tab whose HTML is to be set
    * @param html the tab new HTML
    */
   public void setTabHTML(int index, SafeHtml html) {
     setTabHTML(index, html.asString());
   }
-  
+
   /**
    * Sets a tab's text contents.
-   * 
+   *
    * @param index the index of the tab whose text is to be set
    * @param text the object's new text
    */
@@ -567,7 +581,7 @@
   /**
    * Create a {@link SimplePanel} that will wrap the contents in a tab.
    * Subclasses can use this method to wrap tabs in decorator panels.
-   * 
+   *
    * @return a {@link SimplePanel} to wrap the tab contents, or null to leave
    * tabs unwrapped
    */
@@ -577,7 +591,7 @@
 
   /**
    * Inserts a new tab at the specified index.
-   * 
+   *
    * @param widget widget to be used in the new tab
    * @param beforeIndex the index before which this tab will be inserted
    */
@@ -589,7 +603,7 @@
 
     // Add a11y role "tab"
     SimplePanel focusablePanel = delWidget.getFocusablePanel();
-    Accessibility.setRole(focusablePanel.getElement(), Accessibility.ROLE_TAB);
+    Roles.getTabRole().set(focusablePanel.getElement());
 
     panel.insert(delWidget, beforeIndex + 1);
 
@@ -603,7 +617,7 @@
    * <li>-tab# = The element containing the contents of the tab.</li>
    * <li>-tab-wrapper# = The cell containing the tab at the index.</li>
    * </ul>
-   * 
+   *
    * @see UIObject#onEnsureDebugId(String)
    */
   @Override
@@ -636,7 +650,7 @@
    * Selects the tab corresponding to the widget for the tab. To be clear the
    * widget for the tab is not the widget INSIDE of the tab; it is the widget
    * used to represent the tab itself.
-   * 
+   *
    * @param tabWidget The widget for the tab to be selected
    * @return true if the tab corresponding to the widget for the tab could
    * located and selected, false otherwise
diff --git a/user/src/com/google/gwt/user/client/ui/TabPanel.java b/user/src/com/google/gwt/user/client/ui/TabPanel.java
index fc609e9..b09cf49 100644
--- a/user/src/com/google/gwt/user/client/ui/TabPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/TabPanel.java
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.user.client.ui;
 
+import com.google.gwt.aria.client.Roles;
 import com.google.gwt.event.logical.shared.BeforeSelectionEvent;
 import com.google.gwt.event.logical.shared.BeforeSelectionHandler;
 import com.google.gwt.event.logical.shared.HasBeforeSelectionHandlers;
@@ -216,7 +217,7 @@
     setStyleName("gwt-TabPanel");
     deck.setStyleName("gwt-TabPanelBottom");
     // Add a11y role "tabpanel"
-    Accessibility.setRole(deck.getElement(), Accessibility.ROLE_TABPANEL);
+    Roles.getTabpanelRole().set(deck.getElement());
   }
 
   /**
@@ -240,6 +241,7 @@
     add(asWidgetOrNull(w), tabText, asHTML);
   }
 
+  @Override
   public void add(Widget w) {
     throw new UnsupportedOperationException(
         "A tabText parameter must be specified with add().");
@@ -279,11 +281,13 @@
     insert(w, tabWidget, getWidgetCount());
   }
 
+  @Override
   public HandlerRegistration addBeforeSelectionHandler(
       BeforeSelectionHandler<Integer> handler) {
     return addHandler(handler, BeforeSelectionEvent.getType());
   }
 
+  @Override
   public HandlerRegistration addSelectionHandler(
       SelectionHandler<Integer> handler) {
     return addHandler(handler, SelectionEvent.getType());
@@ -293,11 +297,13 @@
    * @deprecated Use {@link #addBeforeSelectionHandler} and {@link
    * #addSelectionHandler} instead
    */
+  @Override
   @Deprecated
   public void addTabListener(TabListener listener) {
     ListenerWrapper.WrappedTabListener.add(this, listener);
   }
 
+  @Override
   public void clear() {
     while (getWidgetCount() > 0) {
       remove(getWidget(0));
@@ -325,10 +331,12 @@
     return tabBar;
   }
 
+  @Override
   public Widget getWidget(int index) {
     return deck.getWidget(index);
   }
 
+  @Override
   public int getWidgetCount() {
     return deck.getWidgetCount();
   }
@@ -336,10 +344,12 @@
   /**
    * Convenience overload to allow {@link IsWidget} to be used directly.
    */
+  @Override
   public int getWidgetIndex(IsWidget child) {
     return getWidgetIndex(asWidgetOrNull(child));
   }
 
+  @Override
   public int getWidgetIndex(Widget widget) {
     return deck.getWidgetIndex(widget);
   }
@@ -406,10 +416,12 @@
     deck.insertProtected(widget, tabWidget, beforeIndex);
   }
 
+  @Override
   public boolean isAnimationEnabled() {
     return deck.isAnimationEnabled();
   }
 
+  @Override
   public Iterator<Widget> iterator() {
     // The Iterator returned by DeckPanel supports removal and will invoke
     // TabbedDeckPanel.remove(), which is an active function.
@@ -419,6 +431,7 @@
   /**
    * @deprecated Use {@link BeforeSelectionHandler#onBeforeSelection} instead
    */
+  @Override
   @Deprecated
   public boolean onBeforeTabSelected(SourcesTabEvents sender, int tabIndex) {
     BeforeSelectionEvent<Integer> event = BeforeSelectionEvent.fire(this, tabIndex);
@@ -428,12 +441,14 @@
   /**
    * @deprecated Use {@link SelectionHandler#onSelection} instead
    */
+  @Override
   @Deprecated
   public void onTabSelected(SourcesTabEvents sender, int tabIndex) {
     deck.showWidget(tabIndex);
     SelectionEvent.fire(this, tabIndex);
   }
 
+  @Override
   public boolean remove(int index) {
     // Delegate updates to the TabBar to our DeckPanel implementation
     return deck.remove(index);
@@ -444,6 +459,7 @@
    *
    * @param widget the widget to be removed
    */
+  @Override
   public boolean remove(Widget widget) {
     // Delegate updates to the TabBar to our DeckPanel implementation
     return deck.remove(widget);
@@ -453,6 +469,7 @@
    * @deprecated Use the {@link HandlerRegistration#removeHandler}
    * method on the object returned by and add*Handler method instead
    */
+  @Override
   @Deprecated
   public void removeTabListener(TabListener listener) {
     ListenerWrapper.WrappedTabListener.remove(this, listener);
@@ -477,6 +494,7 @@
     tabBar.selectTab(index, fireEvents);
   }
 
+  @Override
   public void setAnimationEnabled(boolean enable) {
     deck.setAnimationEnabled(enable);
   }
diff --git a/user/src/com/google/gwt/user/client/ui/Tree.java b/user/src/com/google/gwt/user/client/ui/Tree.java
index 1bb3ef1..e87c57d 100644
--- a/user/src/com/google/gwt/user/client/ui/Tree.java
+++ b/user/src/com/google/gwt/user/client/ui/Tree.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2008 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,6 +15,9 @@
  */
 package com.google.gwt.user.client.ui;
 
+import com.google.gwt.aria.client.CommonAttributeTypes.BooleanAndUndefined;
+import com.google.gwt.aria.client.CommonAttributeTypes.IdReference;
+import com.google.gwt.aria.client.Roles;
 import com.google.gwt.core.client.GWT;
 import com.google.gwt.event.dom.client.BlurEvent;
 import com.google.gwt.event.dom.client.BlurHandler;
@@ -89,7 +92,7 @@
  * </p>
  */
 @SuppressWarnings("deprecation")
-public class Tree extends Widget implements HasTreeItems.ForIsWidget, HasWidgets.ForIsWidget, 
+public class Tree extends Widget implements HasTreeItems.ForIsWidget, HasWidgets.ForIsWidget,
     SourcesTreeEvents, HasFocus, HasAnimation, HasAllKeyHandlers,
     HasAllFocusHandlers, HasSelectionHandlers<TreeItem>,
     HasOpenHandlers<TreeItem>, HasCloseHandlers<TreeItem>, SourcesMouseEvents,
@@ -250,7 +253,7 @@
 
   /**
    * Constructs a tree that uses the specified ClientBundle for images.
-   * 
+   *
    * @param resources a bundle that provides tree specific images
    */
   public Tree(Resources resources) {
@@ -261,7 +264,7 @@
    * Constructs a tree that uses the specified ClientBundle for images. If this
    * tree does not use leaf images, the width of the Resources's leaf image will
    * control the leaf indent.
-   * 
+   *
    * @param resources a bundle that provides tree specific images
    * @param useLeafImages use leaf images from bundle
    */
@@ -271,7 +274,7 @@
 
   /**
    * Constructs a tree that uses the specified image bundle for images.
-   * 
+   *
    * @param images a bundle that provides tree specific images
    * @deprecated replaced by {@link #Tree(Resources)}
    */
@@ -284,7 +287,7 @@
    * Constructs a tree that uses the specified image bundle for images. If this
    * tree does not use leaf images, the width of the TreeImage's leaf image will
    * control the leaf indent.
-   * 
+   *
    * @param images a bundle that provides tree specific images
    * @param useLeafImages use leaf images from bundle
    * @deprecated replaced by {@link #Tree(Resources, boolean)}
@@ -296,7 +299,7 @@
 
   /**
    * Adds the widget as a root tree item.
-   * 
+   *
    * @see com.google.gwt.user.client.ui.HasWidgets#add(com.google.gwt.user.client.ui.Widget)
    * @param widget widget to add.
    */
@@ -304,10 +307,10 @@
   public void add(Widget widget) {
     addItem(widget);
   }
-  
+
   /**
    * Overloaded version for IsWidget.
-   * 
+   *
    * @see #add(Widget)
    */
   @Override
@@ -338,10 +341,10 @@
   public void addFocusListener(FocusListener listener) {
     ListenerWrapper.WrappedFocusListener.add(this, listener);
   }
-  
+
   /**
    * Adds a simple tree item containing the specified html.
-   * 
+   *
    * @param itemHtml the text of the item to be added
    * @return the item that was added
    * @deprecated use {@link #addItem(SafeHtml)} instead
@@ -353,7 +356,7 @@
 
   /**
    * Adds a simple tree item containing the specified html.
-   * 
+   *
    * @param itemHtml the html of the item to be added
    * @return the item that was added
    */
@@ -364,17 +367,17 @@
 
   /**
    * Adds an item to the root level of this tree.
-   * 
+   *
    * @param item the item to be added
    */
   @Override
   public void addItem(TreeItem item) {
     root.addItem(item);
   }
-  
+
   /**
    * Adds an item to the root level of this tree.
-   * 
+   *
    * @param isItem the wrapper of item to be added
    */
   @Override
@@ -384,7 +387,7 @@
 
   /**
    * Adds a new tree item containing the specified widget.
-   * 
+   *
    * @param widget the widget to be added
    * @return the new item
    */
@@ -392,10 +395,10 @@
   public TreeItem addItem(Widget widget) {
     return root.addItem(widget);
   }
-  
+
   /**
    * Overloaded version for IsWidget.
-   * 
+   *
    * @see #addItem(Widget)
    */
   @Override
@@ -479,10 +482,10 @@
       SelectionHandler<TreeItem> handler) {
     return addHandler(handler, SelectionEvent.getType());
   }
-  
+
   /**
    * Adds a simple tree item containing the specified text.
-   * 
+   *
    * @param itemText the text of the item to be added
    * @return the item that was added
    */
@@ -530,7 +533,7 @@
 
   /**
    * Gets the top-level tree item at the specified index.
-   * 
+   *
    * @param index the index to be retrieved
    * @return the item at that index
    */
@@ -540,7 +543,7 @@
 
   /**
    * Gets the number of items contained at the root of this tree.
-   * 
+   *
    * @return this tree's item count
    */
   public int getItemCount() {
@@ -549,7 +552,7 @@
 
   /**
    * Gets the currently selected item.
-   * 
+   *
    * @return the selected item
    */
   public TreeItem getSelectedItem() {
@@ -564,7 +567,7 @@
   /**
    * Inserts a child tree item at the specified index containing the specified
    * html.
-   * 
+   *
    * @param beforeIndex the index where the item will be inserted
    * @param itemHtml the html to be added
    * @return the item that was added
@@ -579,7 +582,7 @@
   /**
    * Inserts a child tree item at the specified index containing the specified
    * html.
-   * 
+   *
    * @param beforeIndex the index where the item will be inserted
    * @param itemHtml the html of the item to be added
    * @return the item that was added
@@ -591,7 +594,7 @@
 
   /**
    * Inserts an item into the root level of this tree.
-   * 
+   *
    * @param beforeIndex the index where the item will be inserted
    * @param item the item to be added
    * @throws IndexOutOfBoundsException if the index is out of range
@@ -603,7 +606,7 @@
   /**
    * Inserts a child tree item at the specified index containing the specified
    * widget.
-   * 
+   *
    * @param beforeIndex the index where the item will be inserted
    * @param widget the widget to be added
    * @return the item that was added
@@ -745,10 +748,10 @@
     item.setWidget(null);
     return true;
   }
-  
+
   /**
    * Overloaded version for IsWidget.
-   * 
+   *
    * @see #remove(Widget)
    */
   @Override
@@ -768,22 +771,22 @@
 
   /**
    * Removes an item from the root level of this tree.
-   * 
+   *
    * @param item the item to be removed
    */
   @Override
   public void removeItem(TreeItem item) {
     root.removeItem(item);
   }
-  
+
   /**
    * Removes an item from the root level of this tree.
-   * 
+   *
    * @param isItem the wrapper of item to be removed
    */
   @Override
   public void removeItem(IsTreeItem isItem) {
-    if (isItem != null) { 
+    if (isItem != null) {
       TreeItem item = isItem.asTreeItem();
       removeItem(item);
     }
@@ -850,7 +853,7 @@
 
   /**
    * Selects a specified item.
-   * 
+   *
    * @param item the item to be selected, or <code>null</code> to deselect all
    *          items
    */
@@ -860,7 +863,7 @@
 
   /**
    * Selects a specified item.
-   * 
+   *
    * @param item the item to be selected, or <code>null</code> to deselect all
    *          items
    * @param fireEvents <code>true</code> to allow selection events to be fired
@@ -885,7 +888,7 @@
 
   /**
    * Iterator of tree items.
-   * 
+   *
    * @return the iterator
    */
   public Iterator<TreeItem> treeItemIterator() {
@@ -918,7 +921,7 @@
    * Indicates if keyboard navigation is enabled for the Tree and for a given
    * TreeItem. Subclasses of Tree can override this function to selectively
    * enable or disable keyboard navigation.
-   * 
+   *
    * @param currentItem the currently selected TreeItem
    * @return <code>true</code> if the Tree will response to arrow keys by
    *         changing the currently selected item
@@ -932,7 +935,7 @@
    * <ul>
    * <li>-root = The root {@link TreeItem}.</li>
    * </ul>
-   * 
+   *
    * @see UIObject#onEnsureDebugId(String)
    */
   @Override
@@ -1005,7 +1008,7 @@
   /**
    * Called only from {@link TreeItem}: Shows the closed image on that tree
    * item.
-   * 
+   *
    * @param treeItem the tree item
    */
   void showClosedImage(TreeItem treeItem) {
@@ -1014,7 +1017,7 @@
 
   /**
    * Called only from {@link TreeItem}: Shows the leaf image on a tree item.
-   * 
+   *
    * @param treeItem the tree item
    */
   void showLeafImage(TreeItem treeItem) {
@@ -1029,7 +1032,7 @@
 
   /**
    * Called only from {@link TreeItem}: Shows the open image on a tree item.
-   * 
+   *
    * @param treeItem the tree item
    */
   void showOpenImage(TreeItem treeItem) {
@@ -1099,7 +1102,7 @@
   /**
    * Get the top parent above this {@link TreeItem} that is in closed state. In
    * other words, get the parent that is guaranteed to be visible.
-   * 
+   *
    * @param item
    * @return the closed parent, or null if all parents are opened
    */
@@ -1149,8 +1152,7 @@
     setStyleName("gwt-Tree");
 
     // Add a11y role "tree"
-    Accessibility.setRole(getElement(), Accessibility.ROLE_TREE);
-    Accessibility.setRole(focusable, Accessibility.ROLE_TREEITEM);
+    Roles.getTreeRole().set(focusable);
   }
 
   private void keyboardNavigation(Event event) {
@@ -1386,8 +1388,7 @@
       ++curSelectionLevel;
     }
 
-    Accessibility.setState(curSelectionContentElem, Accessibility.STATE_LEVEL,
-        String.valueOf(curSelectionLevel + 1));
+    Roles.getTreeitemRole().setAriaLevelProperty(curSelectionContentElem, curSelectionLevel + 1);
 
     // Set the 'aria-setsize' and 'aria-posinset' states. To do this, we need to
     // compute the the number of siblings that the currently selected item has,
@@ -1398,41 +1399,40 @@
       curSelectionParent = root;
     }
 
-    Accessibility.setState(curSelectionContentElem,
-        Accessibility.STATE_SETSIZE,
-        String.valueOf(curSelectionParent.getChildCount()));
+    Roles.getTreeitemRole().setAriaSetsizeProperty(curSelectionContentElem,
+        curSelectionParent.getChildCount());
 
     int curSelectionIndex = curSelectionParent.getChildIndex(curSelection);
 
-    Accessibility.setState(curSelectionContentElem,
-        Accessibility.STATE_POSINSET, String.valueOf(curSelectionIndex + 1));
+    Roles.getTreeitemRole().setAriaPosinsetProperty(curSelectionContentElem,
+        curSelectionIndex + 1);
 
     // Set the 'aria-expanded' state. This depends on the state of the currently
     // selected item.
     // If the item has no children, we remove the 'aria-expanded' state.
 
     if (curSelection.getChildCount() == 0) {
-      Accessibility.removeState(curSelectionContentElem,
-          Accessibility.STATE_EXPANDED);
+      Roles.getTreeitemRole().removeAriaExpandedState(curSelectionContentElem);
+
     } else {
       if (curSelection.getState()) {
-        Accessibility.setState(curSelectionContentElem,
-            Accessibility.STATE_EXPANDED, "true");
+        Roles.getTreeitemRole().setAriaExpandedState(curSelectionContentElem,
+            BooleanAndUndefined.of(true));
       } else {
-        Accessibility.setState(curSelectionContentElem,
-            Accessibility.STATE_EXPANDED, "false");
+        Roles.getTreeitemRole().setAriaExpandedState(curSelectionContentElem,
+            BooleanAndUndefined.of(false));
       }
     }
 
     // Make sure that 'aria-selected' is true.
 
-    Accessibility.setState(curSelectionContentElem,
-        Accessibility.STATE_SELECTED, "true");
+    Roles.getTreeitemRole().setAriaSelectedState(curSelectionContentElem,
+        BooleanAndUndefined.of(true));
 
     // Update the 'aria-activedescendant' state for the focusable element to
     // match the id of the currently selected item
 
-    Accessibility.setState(focusable, Accessibility.STATE_ACTIVEDESCENDANT,
-        DOM.getElementAttribute(curSelectionContentElem, "id"));
+    Roles.getTreeRole().setAriaActivedescendantProperty(focusable,
+        IdReference.of(DOM.getElementAttribute(curSelectionContentElem, "id")));
   }
 }
diff --git a/user/src/com/google/gwt/user/client/ui/TreeItem.java b/user/src/com/google/gwt/user/client/ui/TreeItem.java
index 01ae2ec..d65a2f2 100644
--- a/user/src/com/google/gwt/user/client/ui/TreeItem.java
+++ b/user/src/com/google/gwt/user/client/ui/TreeItem.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2008 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -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.Style.Unit;
 import com.google.gwt.i18n.client.LocaleInfo;
@@ -30,10 +31,10 @@
 /**
  * An item that can be contained within a
  * {@link com.google.gwt.user.client.ui.Tree}.
- * 
+ *
  * Each tree item is assigned a unique DOM id in order to support ARIA. See
  * {@link com.google.gwt.user.client.ui.Accessibility} for more information.
- * 
+ *
  * <p>
  * <h3>Example</h3>
  * {@example com.google.gwt.examples.TreeExample}
@@ -44,7 +45,7 @@
   /*
    * For compatibility with UiBinder interface HasTreeItems should be declared
    * before HasHTML, so that children items and widgets are processed before
-   * interpreting HTML. 
+   * interpreting HTML.
    */
 
   /**
@@ -103,7 +104,7 @@
         // Simulates padding from table element.
         DOM.setStyleAttribute(BASE_BARE_ELEM, "padding", "3px");
         DOM.appendChild(BASE_BARE_ELEM, contentElem);
-        Accessibility.setRole(contentElem, Accessibility.ROLE_TREEITEM);
+        Roles.getTreeitemRole().set(contentElem);
       }
     }
   }
@@ -143,7 +144,7 @@
 
     /**
      * Open the specified {@link TreeItem}.
-     * 
+     *
      * @param item the {@link TreeItem} to open
      * @param animate true to animate, false to open instantly
      */
@@ -286,7 +287,7 @@
 
   /**
    * Constructs a tree item with the given HTML.
-   * 
+   *
    * @param html the item's HTML
    * @deprecated use {@link #TreeItem(SafeHtml)} instead
    */
@@ -295,10 +296,10 @@
     this();
     setHTML(html);
   }
-  
+
   /**
    * Constructs a tree item with the given HTML.
-   * 
+   *
    * @param html the item's HTML
    */
   public TreeItem(SafeHtml html) {
@@ -307,7 +308,7 @@
 
   /**
    * Constructs a tree item with the given <code>Widget</code>.
-   * 
+   *
    * @param widget the item's widget
    */
   public TreeItem(Widget widget) {
@@ -317,7 +318,7 @@
 
   /**
    * Creates an empty tree item.
-   * 
+   *
    * @param isRoot true if this item is the root of a tree
    */
   TreeItem(boolean isRoot) {
@@ -335,7 +336,7 @@
 
   /**
    * Adds a child tree item containing the specified html.
-   * 
+   *
    * @param itemHtml the text to be added
    * @return the item that was added
    * @deprecated use {@link #addItem(SafeHtml)} instead
@@ -349,7 +350,7 @@
 
   /**
    * Adds a child tree item containing the specified html.
-   * 
+   *
    * @param itemHtml the item's HTML
    * @return the item that was added
    */
@@ -362,7 +363,7 @@
 
   /**
    * Adds another item as a child to this one.
-   * 
+   *
    * @param item the item to be added
    */
   @Override
@@ -372,10 +373,10 @@
     maybeRemoveItemFromParent(item);
     insertItem(getChildCount(), item);
   }
-  
+
   /**
    * Adds another item as a child to this one.
-   * 
+   *
    * @param isItem the wrapper of item to be added
    */
   @Override
@@ -386,7 +387,7 @@
 
   /**
    * Adds a child tree item containing the specified widget.
-   * 
+   *
    * @param widget the widget to be added
    * @return the item that was added
    */
@@ -396,10 +397,10 @@
     addItem(ret);
     return ret;
   }
-  
+
   /**
    * Adds a child tree item containing the specified text.
-   * 
+   *
    * @param itemText the text of the item to be added
    * @return the item that was added
    */
@@ -410,7 +411,7 @@
     addItem(ret);
     return ret;
   }
-  
+
   @Override
   public TreeItem asTreeItem() {
     return this;
@@ -418,7 +419,7 @@
 
   /**
    * Gets the child at the specified index.
-   * 
+   *
    * @param index the index to be retrieved
    * @return the item at that index
    */
@@ -433,7 +434,7 @@
 
   /**
    * Gets the number of children contained in this item.
-   * 
+   *
    * @return this item's child count.
    */
 
@@ -446,7 +447,7 @@
 
   /**
    * Gets the index of the specified child item.
-   * 
+   *
    * @param child the child item to be found
    * @return the child's index, or <code>-1</code> if none is found
    */
@@ -465,7 +466,7 @@
 
   /**
    * Gets this item's parent.
-   * 
+   *
    * @return the parent item
    */
   public TreeItem getParentItem() {
@@ -474,7 +475,7 @@
 
   /**
    * Gets whether this item's children are displayed.
-   * 
+   *
    * @return <code>true</code> if the item is open
    */
   public boolean getState() {
@@ -488,7 +489,7 @@
 
   /**
    * Gets the tree that contains this item.
-   * 
+   *
    * @return the containing tree
    */
   public final Tree getTree() {
@@ -497,7 +498,7 @@
 
   /**
    * Gets the user-defined object associated with this item.
-   * 
+   *
    * @return the item's user-defined object
    */
   public Object getUserObject() {
@@ -506,7 +507,7 @@
 
   /**
    * Gets the <code>Widget</code> associated with this tree item.
-   * 
+   *
    * @return the widget
    */
   public Widget getWidget() {
@@ -516,7 +517,7 @@
   /**
    * Inserts a child tree item at the specified index containing the specified
    * html.
-   * 
+   *
    * @param beforeIndex the index where the item will be inserted
    * @param itemHtml the html that the item will contain
    * @return the item that was added
@@ -534,7 +535,7 @@
   /**
    * Inserts a child tree item at the specified index containing the specified
    * html.
-   * 
+   *
    * @param beforeIndex the index where the item will be inserted
    * @param itemHtml the item's HTML
    * @return the item that was added
@@ -549,7 +550,7 @@
 
   /**
    * Inserts an item as a child to this one.
-   * 
+   *
    * @param beforeIndex the index where the item will be inserted
    * @param item the item to be added
    * @throws IndexOutOfBoundsException if the index is out of range
@@ -603,7 +604,7 @@
   /**
    * Inserts a child tree item at the specified index containing the specified
    * widget.
-   * 
+   *
    * @param beforeIndex the index where the item will be inserted
    * @param widget the widget to be added
    * @return the item that was added
@@ -634,7 +635,7 @@
 
   /**
    * Determines whether this item is currently selected.
-   * 
+   *
    * @return <code>true</code> if it is selected
    */
   public boolean isSelected() {
@@ -657,7 +658,7 @@
 
   /**
    * Removes one of this item's children.
-   * 
+   *
    * @param item the item to be removed
    */
   @Override
@@ -686,15 +687,15 @@
       updateState(false, false);
     }
   }
-  
+
   /**
    * Removes one of this item's children.
-   * 
+   *
    * @param isItem the wrapper of item to be removed
    */
   @Override
   public void removeItem(IsTreeItem isItem) {
-    if (isItem != null) { 
+    if (isItem != null) {
       TreeItem item = isItem.asTreeItem();
       removeItem(item);
     }
@@ -720,10 +721,10 @@
   public void setHTML(SafeHtml html) {
     setHTML(html.asString());
   }
-  
+
   /**
    * Selects or deselects this item.
-   * 
+   *
    * @param selected <code>true</code> to select the item, <code>false</code> to
    *          deselect it
    */
@@ -737,7 +738,7 @@
 
   /**
    * Sets whether this item's children are displayed.
-   * 
+   *
    * @param open whether the item is open
    */
   public void setState(boolean open) {
@@ -746,7 +747,7 @@
 
   /**
    * Sets whether this item's children are displayed.
-   * 
+   *
    * @param open whether the item is open
    * @param fireEvents <code>true</code> to allow open/close events to be
    */
@@ -774,7 +775,7 @@
 
   /**
    * Sets the user-defined object associated with this item.
-   * 
+   *
    * @param userObj the item's user-defined object
    */
   public void setUserObject(Object userObj) {
@@ -783,7 +784,7 @@
 
   /**
    * Sets the current widget. Any existing child widget will be removed.
-   * 
+   *
    * @param newWidget Widget to set
    */
   public void setWidget(Widget newWidget) {
@@ -834,10 +835,10 @@
    * is selected. The tree maintains focus if this method returns null. By
    * default, if the tree item contains a focusable widget, that widget is
    * returned.
-   * 
+   *
    * Note, the {@link Tree} will ignore this value if the user clicked on an
    * input element such as a button or text area when selecting this item.
-   * 
+   *
    * @return the focusable item
    */
   protected Focusable getFocusable() {
@@ -854,7 +855,7 @@
   /**
    * Returns the widget, if any, that should be focused on if this TreeItem is
    * selected.
-   * 
+   *
    * @return widget to be focused.
    * @deprecated use {@link #getFocusable()} instead
    */
@@ -874,7 +875,7 @@
    * <li>-content = The text or {@link Widget} next to the image.</li>
    * <li>-child# = The child at the specified index.</li>
    * </ul>
-   * 
+   *
    * @see UIObject#onEnsureDebugId(String)
    */
   @Override
@@ -937,7 +938,7 @@
 
   /**
    * Remove a tree item from its parent if it has one.
-   * 
+   *
    * @param item the tree item to remove from its parent
    */
   void maybeRemoveItemFromParent(TreeItem item) {
diff --git a/user/test/com/google/gwt/user/client/ui/MenuItemTest.java b/user/test/com/google/gwt/user/client/ui/MenuItemTest.java
index 5be7e4c..818e463 100644
--- a/user/test/com/google/gwt/user/client/ui/MenuItemTest.java
+++ b/user/test/com/google/gwt/user/client/ui/MenuItemTest.java
@@ -1,12 +1,12 @@
 /*
  * Copyright 2010 Google Inc.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License"); you may not
  * use this file except in compliance with the License. You may obtain a copy of
  * the License at
- * 
+ *
  * http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -15,6 +15,7 @@
  */
 package com.google.gwt.user.client.ui;
 
+import com.google.gwt.aria.client.Roles;
 import com.google.gwt.junit.client.GWTTestCase;
 import com.google.gwt.safehtml.shared.SafeHtmlUtils;
 import com.google.gwt.user.client.Command;
@@ -33,17 +34,19 @@
 
   public void testSafeHtmlWithCommand() {
     Command command = new Command() {
+      @Override
       public void execute() {
       }
     };
     MenuItem item = new MenuItem(SafeHtmlUtils.fromSafeConstant(html), command);
-    
+
     assertEquals(html, item.getHTML().toLowerCase());
     assertEquals(command, item.getCommand());
   }
 
   public void testSetCommandWithMenuBar() {
     Command command = new Command() {
+      @Override
       public void execute() {
       }
     };
@@ -61,13 +64,14 @@
   public void testSafeHtmlWithSubMenu() {
     MenuBar subMenu = new MenuBar();
     MenuItem item = new MenuItem(SafeHtmlUtils.fromSafeConstant(html), subMenu);
-    
+
     assertEquals(html, item.getHTML().toLowerCase());
     assertEquals(subMenu, item.getSubMenu());
   }
 
   public void testSetCommandWithoutMenuBar() {
     Command command = new Command() {
+      @Override
       public void execute() {
       }
     };
@@ -83,12 +87,13 @@
 
   public void testSetSafeHtml() {
     Command command = new Command() {
+      @Override
       public void execute() {
       }
     };
     MenuItem item = new MenuItem("foo", command);
     item.setHTML(SafeHtmlUtils.fromSafeConstant(html));
-    
+
     assertEquals(html, item.getHTML().toLowerCase());
     assertEquals(command, item.getCommand());
   }
@@ -99,18 +104,16 @@
     MenuItem item = bar.addItem("test", submenu);
     assertEquals(submenu, item.getSubMenu());
     assertEquals(-1, FocusPanel.impl.getTabIndex(submenu.getElement()));
-    assertEquals("true", Accessibility.getState(item.getElement(),
-        Accessibility.STATE_HASPOPUP));
+
+    assertEquals("true", Roles.getMenuitemRole().getAriaHaspopupProperty(item.getElement()));
 
     item.setSubMenu(null);
     assertNull(item.getSubMenu());
-    assertEquals("false", Accessibility.getState(item.getElement(),
-        Accessibility.STATE_HASPOPUP));
+    assertEquals("false", Roles.getMenuitemRole().getAriaHaspopupProperty(item.getElement()));
 
     item.setSubMenu(submenu);
     assertEquals(submenu, item.getSubMenu());
-    assertEquals("true", Accessibility.getState(item.getElement(),
-        Accessibility.STATE_HASPOPUP));
+    assertEquals("true", Roles.getMenuitemRole().getAriaHaspopupProperty(item.getElement()));
   }
 
   public void testSetSubMenuWithoutMenuBar() {
@@ -118,17 +121,14 @@
     MenuItem item = new MenuItem("test", submenu);
     assertEquals(submenu, item.getSubMenu());
     assertEquals(-1, FocusPanel.impl.getTabIndex(submenu.getElement()));
-    assertEquals("true", Accessibility.getState(item.getElement(),
-        Accessibility.STATE_HASPOPUP));
+    assertEquals("true", Roles.getMenuitemRole().getAriaHaspopupProperty(item.getElement()));
 
     item.setSubMenu(null);
     assertNull(item.getSubMenu());
-    assertEquals("false", Accessibility.getState(item.getElement(),
-        Accessibility.STATE_HASPOPUP));
+    assertEquals("false", Roles.getMenuitemRole().getAriaHaspopupProperty(item.getElement()));
 
     item.setSubMenu(submenu);
     assertEquals(submenu, item.getSubMenu());
-    assertEquals("true", Accessibility.getState(item.getElement(),
-        Accessibility.STATE_HASPOPUP));
+    assertEquals("true", Roles.getMenuitemRole().getAriaHaspopupProperty(item.getElement()));
   }
 }