Bug 672514 - Smooth out nsIAccessible keyboard shortcuts methods, r=surkov
authorOussama BADR <oussamabadr@gmail.com>
Sat, 09 Jun 2012 18:49:21 +0900
changeset 96248 38dfc0d628b41c84e7b6bf09f7160ab18e8ea8ec
parent 96247 8ca3fe2207098e67385c41bd728a9abe086c648e
child 96249 6ec11aada3926362df4ac796e3bab20561b60c97
push id22883
push userryanvm@gmail.com
push dateSun, 10 Jun 2012 02:04:57 +0000
treeherdermozilla-central@dc410944aabc [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs672514
milestone16.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 672514 - Smooth out nsIAccessible keyboard shortcuts methods, r=surkov
accessible/public/nsIAccessible.idl
accessible/src/generic/Accessible.cpp
accessible/tests/mochitest/actions/test_keys.html
accessible/tests/mochitest/actions/test_keys_menu.xul
--- a/accessible/public/nsIAccessible.idl
+++ b/accessible/public/nsIAccessible.idl
@@ -18,17 +18,17 @@ interface nsIAccessibleRelation;
  * accessibility APIs like MSAA and ATK. Contains the sum of what's needed
  * to support IAccessible as well as ATK's generic accessibility objects.
  * Can also be used by in-process accessibility clients to get information
  * about objects in the accessible tree. The accessible tree is a subset of 
  * nodes in the DOM tree -- such as documents, focusable elements and text.
  * Mozilla creates the implementations of nsIAccessible on demand.
  * See http://www.mozilla.org/projects/ui/accessibility for more information.
  */
-[scriptable, uuid(45ce2c92-4d92-49d2-bff1-855934443261)]
+[scriptable, uuid(45600c50-b06a-11e1-afa6-0800200c9a66)]
 interface nsIAccessible : nsISupports
 {
   /**
    * Parent node in accessible tree.
    */
   readonly attribute nsIAccessible parent;
 
   /**
@@ -110,31 +110,23 @@ interface nsIAccessible : nsISupports
    */
   readonly attribute AString description;
 
   /**
    * Provides localized string of accesskey name, such as Alt+D.
    * The modifier may be affected by user and platform preferences.
    * Usually alt+letter, or just the letter alone for menu items. 
    */
-  readonly attribute AString keyboardShortcut;
+  readonly attribute AString accessKey;
 
   /**
    * Provides localized string of global keyboard accelerator for default
    * action, such as Ctrl+O for Open file
    */
-  readonly attribute AString defaultKeyBinding;
-
-  /**
-   * Provides array of localized string of global keyboard accelerator for
-   * the given action index supported by accessible.
-   *
-   * @param aActionIndex - index of the given action
-   */
-  nsIDOMDOMStringList getKeyBindings(in PRUint8 aActionIndex);
+  readonly attribute AString keyboardShortcut;
 
   /**
    * Enumerated accessible role (see the constants defined in nsIAccessibleRole).
    *
    * @note  The values might depend on platform because of variations. Widgets
    *        can use ARIA role attribute to force the final role.
    */
   readonly attribute unsigned long role;
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -340,17 +340,17 @@ Accessible::Description(nsString& aDescr
             aDescription.Truncate();
         }
       }
     }
     aDescription.CompressWhitespace();
 }
 
 NS_IMETHODIMP
-Accessible::GetKeyboardShortcut(nsAString& aAccessKey)
+Accessible::GetAccessKey(nsAString& aAccessKey)
 {
   aAccessKey.Truncate();
 
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
   AccessKey().ToString(aAccessKey);
   return NS_OK;
@@ -1748,47 +1748,26 @@ Accessible::SetCurrentValue(double aValu
 /* void setName (in DOMString name); */
 NS_IMETHODIMP
 Accessible::SetName(const nsAString& aName)
 {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
 NS_IMETHODIMP
-Accessible::GetDefaultKeyBinding(nsAString& aKeyBinding)
+Accessible::GetKeyboardShortcut(nsAString& aKeyBinding)
 {
   aKeyBinding.Truncate();
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
   KeyboardShortcut().ToString(aKeyBinding);
   return NS_OK;
 }
 
-NS_IMETHODIMP
-Accessible::GetKeyBindings(PRUint8 aActionIndex,
-                             nsIDOMDOMStringList** aKeyBindings)
-{
-  // Currently we support only unique key binding on element for default action.
-  NS_ENSURE_TRUE(aActionIndex == 0, NS_ERROR_INVALID_ARG);
-
-  nsAccessibleDOMStringList* keyBindings = new nsAccessibleDOMStringList();
-  NS_ENSURE_TRUE(keyBindings, NS_ERROR_OUT_OF_MEMORY);
-
-  nsAutoString defaultKey;
-  nsresult rv = GetDefaultKeyBinding(defaultKey);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  if (!defaultKey.IsEmpty())
-    keyBindings->Add(defaultKey);
-
-  NS_ADDREF(*aKeyBindings = keyBindings);
-  return NS_OK;
-}
-
 role
 Accessible::ARIATransformRole(role aRole)
 {
   // XXX: these unfortunate exceptions don't fit into the ARIA table. This is
   // where the accessible role depends on both the role and ARIA state.
   if (aRole == roles::PUSHBUTTON) {
     if (nsAccUtils::HasDefinedARIAToken(mContent, nsGkAtoms::aria_pressed)) {
       // For simplicity, any existing pressed attribute except "" or "undefined"
--- a/accessible/tests/mochitest/actions/test_keys.html
+++ b/accessible/tests/mochitest/actions/test_keys.html
@@ -8,31 +8,31 @@
 
   <script type="application/javascript"
           src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
 
   <script type="application/javascript"
           src="../common.js"></script>
 
   <script type="application/javascript">
-    function testKeyboardShortcut(aAccOrElmOrID, aKey)
+    function testAcessKey(aAccOrElmOrID, aKey)
     {
       var acc = getAccessible(aAccOrElmOrID);
       if (!acc)
         return;
 
-      is(acc.keyboardShortcut, aKey,
+      is(acc.accessKey, aKey,
          "Wrong keyboard shortcut on " + prettyName(aAccOrElmOrID));
     }
 
     function doTest()
     {
-      testKeyboardShortcut("input1", "");
-      testKeyboardShortcut("input2", MAC ? "⌃⌥b" : "Alt+Shift+b");
-      testKeyboardShortcut("link", MAC ? "⌃⌥l" : "Alt+Shift+l");
+      testAcessKey("input1", "");
+      testAcessKey("input2", MAC ? "⌃⌥b" : "Alt+Shift+b");
+      testAcessKey("link", MAC ? "⌃⌥l" : "Alt+Shift+l");
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
 
--- a/accessible/tests/mochitest/actions/test_keys_menu.xul
+++ b/accessible/tests/mochitest/actions/test_keys_menu.xul
@@ -29,23 +29,23 @@
       {
         // Show menu.
         this.menuNode.open = true;
       }
 
       this.finalCheck = function openMenu_finalCheck()
       {
         var menu = getAccessible(aMenuID);
-        is(menu.keyboardShortcut, (MAC ? "u" : "Alt+u"),
+        is(menu.accessKey, (MAC ? "u" : "Alt+u"),
            "Wrong accesskey on " + prettyName(this.menuitemNode));
 
         var menuitem = getAccessible(aMenuitemID);
-        is(menuitem.keyboardShortcut, "p",
+        is(menuitem.accessKey, "p",
            "Wrong accesskey on " + prettyName(this.menuitemNode));
-        is(menuitem.defaultKeyBinding, (MAC ? "⌃l" : "Ctrl+l"),
+        is(menuitem.keyboardShortcut, (MAC ? "⌃l" : "Ctrl+l"),
            "Wrong keyboard shortcut on " + prettyName(this.menuitemNode));
       }
 
       this.getID = function openMenu_getID()
       {
         return "menuitem accesskey and shortcut test " +
           prettyName(this.menuItemNode);
       }