Bug 932789 - isolate nsIAccessibleSelectable implementation, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Sat, 02 Nov 2013 21:56:59 -0400
changeset 167839 0803bb0d11d04ec1315789edab3e7d98ab37bd1e
parent 167838 238b3c81f42c11f3f0d9dd9c27d6ed7238523c2b
child 167840 c168e1c69caa4a14eee6ca7d61e7690d92a7f0c0
push id3224
push userlsblakk@mozilla.com
push dateTue, 04 Feb 2014 01:06:49 +0000
treeherdermozilla-beta@60c04d0987f1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs932789
milestone28.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 932789 - isolate nsIAccessibleSelectable implementation, r=tbsaunde
accessible/public/nsIAccessibleSelectable.idl
accessible/src/generic/Accessible.cpp
accessible/src/generic/Accessible.h
accessible/src/xpcom/moz.build
accessible/src/xpcom/xpcAccessibleSelectable.cpp
accessible/src/xpcom/xpcAccessibleSelectable.h
accessible/src/xul/XULTreeGridAccessible.cpp
accessible/tests/mochitest/selectable.js
accessible/tests/mochitest/selectable/test_aria.html
accessible/tests/mochitest/selectable/test_listbox.xul
accessible/tests/mochitest/selectable/test_menulist.xul
accessible/tests/mochitest/selectable/test_select.html
accessible/tests/mochitest/selectable/test_tree.xul
--- a/accessible/public/nsIAccessibleSelectable.idl
+++ b/accessible/public/nsIAccessibleSelectable.idl
@@ -1,72 +1,64 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
 #include "nsISupports.idl"
-#include "nsIAccessible.idl"
-#include "nsIArray.idl"
+
+interface nsIAccessible;
+interface nsIArray;
 
 /**
- * An interface for the accessibility module and in-process accessibility clients
- * for dealing with getting and changing the selection of accessible nodes.
+ * An accessibility interface for selectable widgets.
  */
-[scriptable, uuid(34d268d6-1dd2-11b2-9d63-83a5e0ada290)]
+[scriptable, uuid(3e507fc4-4fcc-4223-a674-a095f591eba1)]
 interface nsIAccessibleSelectable : nsISupports
 {
-    const unsigned long eSelection_Add = 0;
-    const unsigned long eSelection_Remove = 1;
-    const unsigned long eSelection_GetState = 2;
+  /**
+   * Return an nsIArray of selected items within the widget.
+   */
+  readonly attribute nsIArray selectedItems;
 
-    /**
-     * Return an nsIArray of selected nsIAccessible children 
-     */
-    nsIArray GetSelectedChildren();
-    
-    /**
-     * Returns the number of accessible children currently selected.
-     */
-    readonly attribute long selectionCount;
+  /**
+   * Return the number of currently selected items.
+   */
+  readonly attribute unsigned long selectedItemCount;
 
-    /**
-     * Adds the specified accessible child of the object to the
-     * object's selection.
-     * If the specified object is already selected, then it does nothing.
-     * @throws NS_ERROR_FAILURE if the specified object is not selectable.
-     */
-    void addChildToSelection(in long index);
+  /**
+   * Return a nth selected item within the widget.
+   */
+  nsIAccessible getSelectedItemAt(in unsigned long index);
 
-    /**
-     * Removes the specified child of the object from the object's selection.
-     * If the specified object was not selected, then it does nothing.
-     * @throws NS_ERROR_FAILURE if the specified object is not selectable.
-     */
-    void removeChildFromSelection(in long index);
+  /**
+   * Return true if the given item is selected.
+   */
+  [binaryname(ScriptableIsItemSelected)]
+  boolean isItemSelected(in unsigned long index);
 
-    /**
-     * Clears the selection in the object so that no children in the object
-     * are selected.
-     */
-    void clearSelection();
+  /**
+   * Adds the specified item to the widget's selection.
+   */
+  [binaryname(ScriptableAddItemToSelection)]
+  void addItemToSelection(in unsigned long index);
 
-    /**
-     * Returns a reference to the accessible object representing the specified
-     * selected child of the object.
-     * @param index Zero-based selected accessible child index 
-     * @return The nth selected accessible child
-     */
-    nsIAccessible refSelection(in long index);
+  /**
+   * Removes the specified item from the widget's selection.
+   */
+  [binaryname(ScriptableRemoveItemFromSelection)]
+  void removeItemFromSelection(in unsigned long index);
 
-    /**
-      * Determines if the current child of this object is selected
-      * @param The zero-based accessible child index
-      * @return Returns true if the child is selected, false if not.
-      */
-    boolean isChildSelected(in long index);
+  /**
+   * Select all items.
+   *
+   * @return false if the object does not accept multiple selection,
+   *         otherwise true.
+   */
+  [binaryname(ScriptableSelectAll)]
+  boolean selectAll();
 
-    /**
-     * Select all children
-     * @return If the object does not accept multiple selection, return false.
-     *         Otherwise, returns true.
-     */
-    boolean selectAllSelection();
+  /**
+   * Unselect all items.
+   */
+  [binaryname(ScriptableUnselectAll)]
+  void unselectAll();
 };
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -1008,17 +1008,17 @@ NS_IMETHODIMP
 Accessible::TakeSelection()
 {
   if (IsDefunct())
     return NS_ERROR_FAILURE;
 
   Accessible* select = nsAccUtils::GetSelectableContainer(this, State());
   if (select) {
     if (select->State() & states::MULTISELECTABLE)
-      select->ClearSelection();
+      select->UnselectAll();
     return SetSelected(true);
   }
 
   return NS_ERROR_FAILURE;
 }
 
 NS_IMETHODIMP
 Accessible::TakeFocus()
@@ -2327,128 +2327,16 @@ Accessible::ScrollToPoint(uint32_t aCoor
 
   nsIFrame *parentFrame = frame;
   while ((parentFrame = parentFrame->GetParent()))
     nsCoreUtils::ScrollFrameToPoint(parentFrame, frame, coords);
 
   return NS_OK;
 }
 
-// nsIAccessibleSelectable
-NS_IMETHODIMP
-Accessible::GetSelectedChildren(nsIArray** aSelectedAccessibles)
-{
-  NS_ENSURE_ARG_POINTER(aSelectedAccessibles);
-  *aSelectedAccessibles = nullptr;
-
-  if (IsDefunct() || !IsSelect())
-    return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsIArray> items = SelectedItems();
-  if (items) {
-    uint32_t length = 0;
-    items->GetLength(&length);
-    if (length)
-      items.swap(*aSelectedAccessibles);
-  }
-
-  return NS_OK;
-}
-
-// return the nth selected descendant nsIAccessible object
-NS_IMETHODIMP
-Accessible::RefSelection(int32_t aIndex, nsIAccessible** aSelected)
-{
-  NS_ENSURE_ARG_POINTER(aSelected);
-  *aSelected = nullptr;
-
-  if (IsDefunct() || !IsSelect())
-    return NS_ERROR_FAILURE;
-
-  if (aIndex < 0) {
-    return NS_ERROR_INVALID_ARG;
-  }
-
-  *aSelected = GetSelectedItem(aIndex);
-  if (*aSelected) {
-    NS_ADDREF(*aSelected);
-    return NS_OK;
-  }
-
-  return NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP
-Accessible::GetSelectionCount(int32_t* aSelectionCount)
-{
-  NS_ENSURE_ARG_POINTER(aSelectionCount);
-  *aSelectionCount = 0;
-
-  if (IsDefunct() || !IsSelect())
-    return NS_ERROR_FAILURE;
-
-  *aSelectionCount = SelectedItemCount();
-  return NS_OK;
-}
-
-NS_IMETHODIMP Accessible::AddChildToSelection(int32_t aIndex)
-{
-  if (IsDefunct() || !IsSelect())
-    return NS_ERROR_FAILURE;
-
-  return aIndex >= 0 && AddItemToSelection(aIndex) ?
-    NS_OK : NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP Accessible::RemoveChildFromSelection(int32_t aIndex)
-{
-  if (IsDefunct() || !IsSelect())
-    return NS_ERROR_FAILURE;
-
-  return aIndex >=0 && RemoveItemFromSelection(aIndex) ?
-    NS_OK : NS_ERROR_INVALID_ARG;
-}
-
-NS_IMETHODIMP Accessible::IsChildSelected(int32_t aIndex, bool *aIsSelected)
-{
-  NS_ENSURE_ARG_POINTER(aIsSelected);
-  *aIsSelected = false;
-
-  if (IsDefunct() || !IsSelect())
-    return NS_ERROR_FAILURE;
-
-  NS_ENSURE_TRUE(aIndex >= 0, NS_ERROR_FAILURE);
-
-  *aIsSelected = IsItemSelected(aIndex);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::ClearSelection()
-{
-  if (IsDefunct() || !IsSelect())
-    return NS_ERROR_FAILURE;
-
-  UnselectAll();
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-Accessible::SelectAllSelection(bool* aIsMultiSelect)
-{
-  NS_ENSURE_ARG_POINTER(aIsMultiSelect);
-  *aIsMultiSelect = false;
-
-  if (IsDefunct() || !IsSelect())
-    return NS_ERROR_FAILURE;
-
-  *aIsMultiSelect = SelectAll();
-  return NS_OK;
-}
-
 // nsIAccessibleHyperLink
 // Because of new-atk design, any embedded object in text can implement
 // nsIAccessibleHyperLink, which helps determine where it is located
 // within containing text
 
 // readonly attribute long nsIAccessibleHyperLink::anchorCount
 NS_IMETHODIMP
 Accessible::GetAnchorCount(int32_t *aAnchorCount)
--- a/accessible/src/generic/Accessible.h
+++ b/accessible/src/generic/Accessible.h
@@ -8,19 +8,19 @@
 
 #include "mozilla/a11y/AccTypes.h"
 #include "mozilla/a11y/RelationType.h"
 #include "mozilla/a11y/Role.h"
 #include "mozilla/a11y/States.h"
 
 #include "nsIAccessible.h"
 #include "nsIAccessibleHyperLink.h"
-#include "nsIAccessibleSelectable.h"
 #include "nsIAccessibleValue.h"
 #include "nsIAccessibleStates.h"
+#include "xpcAccessibleSelectable.h"
 
 #include "nsIContent.h"
 #include "nsString.h"
 #include "nsTArray.h"
 #include "nsRefPtrHashtable.h"
 
 struct nsRoleMapEntry;
 
@@ -99,29 +99,28 @@ typedef nsRefPtrHashtable<nsPtrHashKey<c
   0x133c8bf4,                                           \
   0x4913,                                               \
   0x4355,                                               \
   { 0xbd, 0x50, 0x42, 0x6b, 0xd1, 0xd6, 0xe1, 0xad }    \
 }
 
 class Accessible : public nsIAccessible,
                    public nsIAccessibleHyperLink,
-                   public nsIAccessibleSelectable,
+                   public xpcAccessibleSelectable,
                    public nsIAccessibleValue
 {
 public:
   Accessible(nsIContent* aContent, DocAccessible* aDoc);
   virtual ~Accessible();
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(Accessible, nsIAccessible)
 
   NS_DECL_NSIACCESSIBLE
   NS_DECL_NSIACCESSIBLEHYPERLINK
-  NS_DECL_NSIACCESSIBLESELECTABLE
   NS_DECL_NSIACCESSIBLEVALUE
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID)
 
   //////////////////////////////////////////////////////////////////////////////
   // Public methods
 
   /**
    * Return the document accessible for this accessible.
--- a/accessible/src/xpcom/moz.build
+++ b/accessible/src/xpcom/moz.build
@@ -1,18 +1,23 @@
 # -*- Mode: python; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 40 -*-
 # vim: set filetype=python:
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 MODULE = 'accessibility'
 
+EXPORTS += [
+    'xpcAccessibleSelectable.h',
+]
+
 SOURCES += [
     'nsAccessibleRelation.cpp',
+    'xpcAccessibleSelectable.cpp',
     'xpcAccessibleTable.cpp',
     'xpcAccessibleTableCell.cpp',
 ]
 
 GENERATED_SOURCES += [
     'xpcAccEvents.cpp',
 ]
 
new file mode 100644
--- /dev/null
+++ b/accessible/src/xpcom/xpcAccessibleSelectable.cpp
@@ -0,0 +1,134 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "xpcAccessibleSelectable.h"
+
+#include "Accessible-inl.h"
+
+using namespace mozilla::a11y;
+
+NS_IMETHODIMP
+xpcAccessibleSelectable::GetSelectedItems(nsIArray** aSelectedItems)
+{
+  NS_ENSURE_ARG_POINTER(aSelectedItems);
+  *aSelectedItems = nullptr;
+
+  Accessible* acc = static_cast<Accessible*>(this);
+  if (acc->IsDefunct())
+    return NS_ERROR_FAILURE;
+  NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+
+  nsCOMPtr<nsIArray> items = acc->SelectedItems();
+  if (items) {
+    uint32_t length = 0;
+    items->GetLength(&length);
+    if (length)
+      items.swap(*aSelectedItems);
+  }
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessibleSelectable::GetSelectedItemCount(uint32_t* aSelectionCount)
+{
+  NS_ENSURE_ARG_POINTER(aSelectionCount);
+  *aSelectionCount = 0;
+
+  Accessible* acc = static_cast<Accessible*>(this);
+  if (acc->IsDefunct())
+    return NS_ERROR_FAILURE;
+  NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+
+  *aSelectionCount = acc->SelectedItemCount();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessibleSelectable::GetSelectedItemAt(uint32_t aIndex,
+                                           nsIAccessible** aSelected)
+{
+  NS_ENSURE_ARG_POINTER(aSelected);
+  *aSelected = nullptr;
+
+  Accessible* acc = static_cast<Accessible*>(this);
+  if (acc->IsDefunct())
+    return NS_ERROR_FAILURE;
+  NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+
+  *aSelected = acc->GetSelectedItem(aIndex);
+  if (*aSelected) {
+    NS_ADDREF(*aSelected);
+    return NS_OK;
+  }
+
+  return NS_ERROR_INVALID_ARG;
+}
+
+NS_IMETHODIMP
+xpcAccessibleSelectable::ScriptableIsItemSelected(uint32_t aIndex,
+                                                  bool* aIsSelected)
+{
+  NS_ENSURE_ARG_POINTER(aIsSelected);
+  *aIsSelected = false;
+
+  Accessible* acc = static_cast<Accessible*>(this);
+  if (acc->IsDefunct())
+    return NS_ERROR_FAILURE;
+  NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+
+  *aIsSelected = acc->IsItemSelected(aIndex);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessibleSelectable::ScriptableAddItemToSelection(uint32_t aIndex)
+{
+  Accessible* acc = static_cast<Accessible*>(this);
+  if (acc->IsDefunct())
+    return NS_ERROR_FAILURE;
+  NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+
+  return acc->AddItemToSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
+}
+
+NS_IMETHODIMP
+xpcAccessibleSelectable::ScriptableRemoveItemFromSelection(uint32_t aIndex)
+{
+  Accessible* acc = static_cast<Accessible*>(this);
+  if (acc->IsDefunct())
+    return NS_ERROR_FAILURE;
+  NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+
+  return acc->RemoveItemFromSelection(aIndex) ? NS_OK : NS_ERROR_INVALID_ARG;
+}
+
+NS_IMETHODIMP
+xpcAccessibleSelectable::ScriptableSelectAll(bool* aIsMultiSelect)
+{
+  NS_ENSURE_ARG_POINTER(aIsMultiSelect);
+  *aIsMultiSelect = false;
+
+  Accessible* acc = static_cast<Accessible*>(this);
+  if (acc->IsDefunct())
+    return NS_ERROR_FAILURE;
+  NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+
+  *aIsMultiSelect = acc->SelectAll();
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+xpcAccessibleSelectable::ScriptableUnselectAll()
+{
+  Accessible* acc = static_cast<Accessible*>(this);
+  if (acc->IsDefunct())
+    return NS_ERROR_FAILURE;
+  NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!");
+
+  acc->UnselectAll();
+  return NS_OK;
+}
new file mode 100644
--- /dev/null
+++ b/accessible/src/xpcom/xpcAccessibleSelectable.h
@@ -0,0 +1,41 @@
+/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set ts=2 et sw=2 tw=80: */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#ifndef mozilla_a11y_xpcAccessibleSelectable_h_
+#define mozilla_a11y_xpcAccessibleSelectable_h_
+
+#include "nsIAccessibleSelectable.h"
+
+class nsIAccessible;
+class nsIArray;
+
+namespace mozilla {
+namespace a11y {
+
+class xpcAccessibleSelectable : public nsIAccessibleSelectable
+{
+public:
+  NS_IMETHOD GetSelectedItems(nsIArray** aSelectedItems) MOZ_FINAL;
+  NS_IMETHOD GetSelectedItemCount(uint32_t* aSelectedItemCount) MOZ_FINAL;
+  NS_IMETHOD GetSelectedItemAt(uint32_t aIndex, nsIAccessible** aItem) MOZ_FINAL;
+  NS_IMETHOD ScriptableIsItemSelected(uint32_t aIndex, bool* aIsSelected) MOZ_FINAL;
+  NS_IMETHOD ScriptableAddItemToSelection(uint32_t aIndex) MOZ_FINAL;
+  NS_IMETHOD ScriptableRemoveItemFromSelection(uint32_t aIndex) MOZ_FINAL;
+  NS_IMETHOD ScriptableSelectAll(bool* aIsMultiSelect) MOZ_FINAL;
+  NS_IMETHOD ScriptableUnselectAll() MOZ_FINAL;
+
+private:
+  xpcAccessibleSelectable() { }
+  friend class Accessible;
+
+  xpcAccessibleSelectable(const xpcAccessibleSelectable&) MOZ_DELETE;
+  xpcAccessibleSelectable& operator =(const xpcAccessibleSelectable&) MOZ_DELETE;
+};
+
+} // namespace a11y
+} // namespace mozilla
+
+#endif
--- a/accessible/src/xul/XULTreeGridAccessible.cpp
+++ b/accessible/src/xul/XULTreeGridAccessible.cpp
@@ -56,31 +56,24 @@ XULTreeGridAccessible::SelectedCellCount
 }
 
 uint32_t
 XULTreeGridAccessible::SelectedColCount()
 {
   // If all the row has been selected, then all the columns are selected,
   // because we can't select a column alone.
 
-  int32_t selectedRowCount = 0;
-  nsresult rv = GetSelectionCount(&selectedRowCount);
-  NS_ENSURE_SUCCESS(rv, 0);
-
+  uint32_t selectedRowCount = SelectedItemCount();
   return selectedRowCount > 0 && selectedRowCount == RowCount() ? ColCount() : 0;
 }
 
 uint32_t
 XULTreeGridAccessible::SelectedRowCount()
 {
-  int32_t selectedRowCount = 0;
-  nsresult rv = GetSelectionCount(&selectedRowCount);
-  NS_ENSURE_SUCCESS(rv, 0);
-
-  return selectedRowCount >= 0 ? selectedRowCount : 0;
+  return SelectedItemCount();
 }
 
 void
 XULTreeGridAccessible::SelectedCells(nsTArray<Accessible*>* aCells)
 {
   uint32_t colCount = ColCount(), rowCount = RowCount();
 
   for (uint32_t rowIdx = 0; rowIdx < rowCount; rowIdx++) {
@@ -159,22 +152,17 @@ XULTreeGridAccessible::ColDescription(ui
   }
 }
 
 bool
 XULTreeGridAccessible::IsColSelected(uint32_t aColIdx)
 {
   // If all the row has been selected, then all the columns are selected.
   // Because we can't select a column alone.
-
-  int32_t selectedrowCount = 0;
-  nsresult rv = GetSelectionCount(&selectedrowCount);
-  NS_ENSURE_SUCCESS(rv, false);
-
-  return selectedrowCount == RowCount();
+  return SelectedItemCount() == RowCount();
 }
 
 bool
 XULTreeGridAccessible::IsRowSelected(uint32_t aRowIdx)
 {
   if (!mTreeView)
     return false;
 
--- a/accessible/tests/mochitest/selectable.js
+++ b/accessible/tests/mochitest/selectable.js
@@ -9,74 +9,72 @@ function testSelectableSelection(aIdenti
   var acc = getAccessible(aIdentifier, [nsIAccessibleSelectable]);
   if (!acc)
     return;
 
   var msg = aMsg ? aMsg : "";
   var len = aSelectedChildren.length;
 
   // getSelectedChildren
-  var selectedChildren = acc.GetSelectedChildren();
+  var selectedChildren = acc.selectedItems;
   is(selectedChildren ? selectedChildren.length : 0, len,
      msg + "getSelectedChildren: wrong selected children count for " +
      prettyName(aIdentifier));
 
   for (var idx = 0; idx < len; idx++) {
     var expectedAcc = getAccessible(aSelectedChildren[idx]);
     var actualAcc = selectedChildren.queryElementAt(idx, nsIAccessible);
     is(actualAcc, expectedAcc,
        msg + "getSelectedChildren: wrong selected child at index " + idx +
        " for " + prettyName(aIdentifier) + " { actual : " +
        prettyName(actualAcc) + ", expected: " + prettyName(expectedAcc) + "}");
   }
 
-  // selectionCount
-  // XXX: nsIAccessibleText and nsIAccessibleSelectable both have
-  // selectionCount property.
-  //is(acc.selectionCount, aSelectedChildren.length,
-  //   "selectionCount: wrong selected children count for " + prettyName(aIdentifier));
+  // selectedItemCount
+  is(acc.selectedItemCount, aSelectedChildren.length,
+     "selectedItemCount: wrong selected children count for " + prettyName(aIdentifier));
 
-  // refSelection
+  // getSelectedItemAt
   for (var idx = 0; idx < len; idx++) {
     var expectedAcc = getAccessible(aSelectedChildren[idx]);
-    is(acc.refSelection(idx), expectedAcc,
-       msg + "refSelection: wrong selected child at index " + idx + " for " +
+    is(acc.getSelectedItemAt(idx), expectedAcc,
+       msg + "getSelectedItemAt: wrong selected child at index " + idx + " for " +
        prettyName(aIdentifier));
   }
 
-  // isChildSelected
-  testIsChildSelected(acc, acc, { value: 0 }, aSelectedChildren, msg);
+  // isItemSelected
+  testIsItemSelected(acc, acc, { value: 0 }, aSelectedChildren, msg);
 }
 
 /**
- * Test isChildSelected method, helper for testSelectableSelection
+ * Test isItemSelected method, helper for testSelectableSelection
  */
-function testIsChildSelected(aSelectAcc, aTraversedAcc, aIndexObj, aSelectedChildren, aMsg)
+function testIsItemSelected(aSelectAcc, aTraversedAcc, aIndexObj, aSelectedChildren, aMsg)
 {
   var childCount = aTraversedAcc.childCount;
   for (var idx = 0; idx < childCount; idx++) {
     var child = aTraversedAcc.getChildAt(idx);
     var [state, extraState] = getStates(child);
     if (state & STATE_SELECTABLE) {
       var isSelected = false;
       var len = aSelectedChildren.length;
       for (var jdx = 0; jdx < len; jdx++) {
         if (child == getAccessible(aSelectedChildren[jdx])) {
           isSelected = true;
           break;
         }
       }
 
-      // isChildSelected
-      is(aSelectAcc.isChildSelected(aIndexObj.value++), isSelected,
-         aMsg + "isChildSelected: wrong selected child " + prettyName(child) +
+      // isItemSelected
+      is(aSelectAcc.isItemSelected(aIndexObj.value++), isSelected,
+         aMsg + "isItemSelected: wrong selected child " + prettyName(child) +
          " for " + prettyName(aSelectAcc));
 
       // selected state
       testStates(child, isSelected ? STATE_SELECTED : 0, 0,
                  !isSelected ? STATE_SELECTED : 0 , 0);
 
       continue;
     }
 
-    testIsChildSelected(aSelectAcc, child, aIndexObj, aSelectedChildren);
+    testIsItemSelected(aSelectAcc, child, aIndexObj, aSelectedChildren);
   }
 }
--- a/accessible/tests/mochitest/selectable/test_aria.html
+++ b/accessible/tests/mochitest/selectable/test_aria.html
@@ -22,20 +22,20 @@
 
   <script type="application/javascript">
     function testSelectable(aID, aSelectableChildren)
     {
       var acc = getAccessible(aID, [nsIAccessibleSelectable]);
 
       testSelectableSelection(acc, []);
 
-      acc.selectAllSelection();
+      acc.selectAll();
       testSelectableSelection(acc, aSelectableChildren);
 
-      acc.clearSelection();
+      acc.unselectAll();
       testSelectableSelection(acc, []);
     }
 
     function doTest()
     {
       //////////////////////////////////////////////////////////////////////////
       // role="tablist"
 
@@ -59,23 +59,23 @@
 
       id = "listbox2";
       ok(isAccessible(id, [nsIAccessibleSelectable]),
          "No selectable accessible for " + id);
 
       testSelectableSelection(id, [ ]);
 
       select = getAccessible(id, [nsIAccessibleSelectable]);
-      select.addChildToSelection(0);
+      select.addItemToSelection(0);
       testSelectableSelection(id, [ "listbox2_item1" ]);
-      select.removeChildFromSelection(0);
+      select.removeItemFromSelection(0);
       testSelectableSelection(id, [ ]);
-      select.selectAllSelection();
+      select.selectAll();
       testSelectableSelection(id, [ "listbox2_item1", "listbox2_item2" ]);
-      select.clearSelection();
+      select.unselectAll();
       testSelectableSelection(id, [ ]);
       
       //////////////////////////////////////////////////////////////////////////
       // role="grid"
 
       id = "grid1";
       ok(isAccessible(id, [nsIAccessibleSelectable]),
          "No selectable accessible for " + id);
--- a/accessible/tests/mochitest/selectable/test_listbox.xul
+++ b/accessible/tests/mochitest/selectable/test_listbox.xul
@@ -36,65 +36,65 @@
 
       var id = "listbox";
       ok(isAccessible(id, [nsIAccessibleSelectable]),
          "No selectable accessible for list of " + id);
 
       var select = getAccessible(id, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ ]);
 
-      select.addChildToSelection(1);
-      testSelectableSelection(select, [ "lb1_item2" ], "addChildToSelect(1): ");
+      select.addItemToSelection(1);
+      testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelect(1): ");
 
-      select.removeChildFromSelection(1);
+      select.removeItemFromSelection(1);
       testSelectableSelection(select, [ ],
-                              "removeChildFromSelection(1): ");
+                              "removeItemFromSelection(1): ");
 
-      todo(select.selectAllSelection() == false,
+      todo(select.selectAll() == false,
            "No way to select all items in listbox '" + id + "'");
-      testSelectableSelection(select, [ "lb1_item1" ], "selectAllSelection: ");
+      testSelectableSelection(select, [ "lb1_item1" ], "selectAll: ");
 
-      select.addChildToSelection(1);
-      select.clearSelection();
-      testSelectableSelection(select, [ ], "clearSelection: ");
+      select.addItemToSelection(1);
+      select.unselectAll();
+      testSelectableSelection(select, [ ], "unselectAll: ");
 
       //////////////////////////////////////////////////////////////////////////
       // multiple selectable listbox
 
       var id = "listbox2";
       ok(isAccessible(id, [nsIAccessibleSelectable]),
          "No selectable accessible for list of " + id);
 
       var select = getAccessible(id, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ ]);
 
-      select.addChildToSelection(1);
-      testSelectableSelection(select, [ "lb2_item2" ], "addChildToSelect(1): ");
+      select.addItemToSelection(1);
+      testSelectableSelection(select, [ "lb2_item2" ], "addItemToSelect(1): ");
 
-      select.removeChildFromSelection(1);
+      select.removeItemFromSelection(1);
       testSelectableSelection(select, [ ],
-                              "removeChildFromSelection(1): ");
+                              "removeItemFromSelection(1): ");
 
-      is(select.selectAllSelection(), true,
+      is(select.selectAll(), true,
          "All items should be selected in listbox '" + id + "'");
       testSelectableSelection(select, [ "lb2_item1", "lb2_item2" ],
-                              "selectAllSelection: ");
+                              "selectAll: ");
 
-      select.clearSelection();
-      testSelectableSelection(select, [ ], "clearSelection: ");
+      select.unselectAll();
+      testSelectableSelection(select, [ ], "unselectAll: ");
 
       //////////////////////////////////////////////////////////////////////////
       // listbox with headers
 
-      // XXX: addChildToSelection/removeChildFromSelection don't work correctly
+      // XXX: addItemToSelection/removeItemFromSelection don't work correctly
       // on listboxes with headers because header is inserted into hierarchy
       // and child indexes that are used in these methods are shifted (see bug
       // 591939).
       todo(false,
-           "Fix addChildToSelection/removeChildFromSelection on listboxes with headers.");
+           "Fix addItemToSelection/removeItemFromSelection on listboxes with headers.");
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
   </script>
--- a/accessible/tests/mochitest/selectable/test_menulist.xul
+++ b/accessible/tests/mochitest/selectable/test_menulist.xul
@@ -38,30 +38,30 @@
       var combobox = getAccessible(id);
       var comboboxList = combobox.firstChild;
       ok(isAccessible(comboboxList, [nsIAccessibleSelectable]),
          "No selectable accessible for list of " + id);
 
       var select = getAccessible(comboboxList, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ "cb1_item1" ]);
 
-      select.addChildToSelection(1);
-      testSelectableSelection(select, [ "cb1_item2" ], "addChildToSelect(1): ");
+      select.addItemToSelection(1);
+      testSelectableSelection(select, [ "cb1_item2" ], "addItemToSelection(1): ");
 
-      select.removeChildFromSelection(1);
+      select.removeItemFromSelection(1);
       testSelectableSelection(select, [ ],
-                              "removeChildFromSelection(1): ");
+                              "removeItemFromSelection(1): ");
 
-      is(select.selectAllSelection(), false,
+      is(select.selectAll(), false,
          "No way to select all items in combobox '" + id + "'");
-      testSelectableSelection(select, [ ], "selectAllSelection: ");
+      testSelectableSelection(select, [ ], "selectAll: ");
 
-      select.addChildToSelection(1);
-      select.clearSelection();
-      testSelectableSelection(select, [ ], "clearSelection: ");
+      select.addItemToSelection(1);
+      select.unselectAll();
+      testSelectableSelection(select, [ ], "unselectAll: ");
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   ]]>
   </script>
--- a/accessible/tests/mochitest/selectable/test_select.html
+++ b/accessible/tests/mochitest/selectable/test_select.html
@@ -32,154 +32,154 @@
       var comboboxList = combobox.firstChild;
       ok(isAccessible(comboboxList, [nsIAccessibleSelectable]),
          "No selectable accessible for list of " + id);
 
       var select = getAccessible(comboboxList, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ "cb1_item1" ]);
 
       // select 2nd item
-      select.addChildToSelection(1);
-      testSelectableSelection(select, [ "cb1_item2" ], "addChildToSelect(1): ");
+      select.addItemToSelection(1);
+      testSelectableSelection(select, [ "cb1_item2" ], "addItemToSelection(1): ");
 
       // unselect 2nd item, 1st item gets selected automatically
-      select.removeChildFromSelection(1);
+      select.removeItemFromSelection(1);
       testSelectableSelection(select, [ "cb1_item1" ],
-                              "removeChildFromSelection(1): ");
+                              "removeItemFromSelection(1): ");
 
       // doesn't change selection
-      is(select.selectAllSelection(), false,
+      is(select.selectAll(), false,
          "No way to select all items in combobox '" + id + "'");
-      testSelectableSelection(select, [ "cb1_item1" ], "selectAllSelection: ");
+      testSelectableSelection(select, [ "cb1_item1" ], "selectAll: ");
 
       // doesn't change selection
-      select.clearSelection();
-      testSelectableSelection(select, [ "cb1_item1" ], "clearSelection: ");
+      select.unselectAll();
+      testSelectableSelection(select, [ "cb1_item1" ], "unselectAll: ");
 
       //////////////////////////////////////////////////////////////////////////
       // select@size="1" with optgroups
 
       id = "combobox2";
       combobox = getAccessible(id);
       comboboxList = combobox.firstChild;
       ok(isAccessible(comboboxList, [nsIAccessibleSelectable]),
          "No selectable accessible for list of " + id);
 
       select = getAccessible(comboboxList, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ "cb2_item1" ]);
 
-      select.addChildToSelection(1);
+      select.addItemToSelection(1);
       testSelectableSelection(select, [ "cb2_item2" ]);
 
-      select.removeChildFromSelection(1);
+      select.removeItemFromSelection(1);
       testSelectableSelection(select, [ "cb2_item1" ]);
 
-      is(select.selectAllSelection(), false,
+      is(select.selectAll(), false,
          "No way to select all items in combobox " + id + "'");
       testSelectableSelection(select, [ "cb2_item1" ]);
 
-      select.clearSelection();
+      select.unselectAll();
       testSelectableSelection(select, [ "cb2_item1" ]);
 
       //////////////////////////////////////////////////////////////////////////
       // select@size="4" aka single selectable listbox
 
       var id = "listbox";
       ok(isAccessible(id, [nsIAccessibleSelectable]),
          "No selectable accessible for " + id);
 
       select = getAccessible(id, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ ]);
 
       // select 2nd item
-      select.addChildToSelection(1);
-      testSelectableSelection(select, [ "lb1_item2" ], "addChildToSelect(1): ");
+      select.addItemToSelection(1);
+      testSelectableSelection(select, [ "lb1_item2" ], "addItemToSelection(1): ");
 
       // unselect 2nd item, 1st item gets selected automatically
-      select.removeChildFromSelection(1);
+      select.removeItemFromSelection(1);
       testSelectableSelection(select, [ ],
-                              "removeChildFromSelection(1): ");
+                              "removeItemFromSelection(1): ");
 
       // doesn't change selection
-      is(select.selectAllSelection(), false,
+      is(select.selectAll(), false,
          "No way to select all items in single selectable listbox '" + id + "'");
-      testSelectableSelection(select, [ ], "selectAllSelection: ");
+      testSelectableSelection(select, [ ], "selectAll: ");
 
       // doesn't change selection
-      select.clearSelection();
-      testSelectableSelection(select, [ ], "clearSelection: ");
+      select.unselectAll();
+      testSelectableSelection(select, [ ], "unselectAll: ");
 
       //////////////////////////////////////////////////////////////////////////
       // select@size="4" with optgroups, single selectable
 
       id = "listbox2";
       ok(isAccessible(id, [nsIAccessibleSelectable]),
          "No selectable accessible for " + id);
 
       select = getAccessible(id, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ ]);
 
-      select.addChildToSelection(1);
+      select.addItemToSelection(1);
       testSelectableSelection(select, [ "lb2_item2" ]);
 
-      select.removeChildFromSelection(1);
+      select.removeItemFromSelection(1);
       testSelectableSelection(select, [ ]);
 
-      is(select.selectAllSelection(), false,
+      is(select.selectAll(), false,
          "No way to select all items in single selectable listbox " + id + "'");
       testSelectableSelection(select, [ ]);
 
-      select.clearSelection();
+      select.unselectAll();
       testSelectableSelection(select, [ ]);
 
       //////////////////////////////////////////////////////////////////////////
       // select@size="4" multiselect aka listbox
 
       id = "listbox3";
       ok(isAccessible(id, [nsIAccessibleSelectable]),
          "No selectable accessible for " + id);
 
       select = getAccessible(id, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ ]);
 
-      select.addChildToSelection(0);
-      testSelectableSelection(select, [ "lb3_item1" ], "addChildToSelection: ");
+      select.addItemToSelection(0);
+      testSelectableSelection(select, [ "lb3_item1" ], "addItemToSelection: ");
 
-      select.removeChildFromSelection(0);
-      testSelectableSelection(select, [ ], "removeChildFromSelection: ");
+      select.removeItemFromSelection(0);
+      testSelectableSelection(select, [ ], "removeItemFromSelection: ");
 
-      is(select.selectAllSelection(), true,
+      is(select.selectAll(), true,
          "All items in listbox '" + id + "' should be selected");
       testSelectableSelection(select, [ "lb3_item1", "lb3_item2"],
-                              "selectAllSelection: ");
+                              "selectAll: ");
 
-      select.clearSelection();
-      testSelectableSelection(select, [ ], "clearSelection: ");
+      select.unselectAll();
+      testSelectableSelection(select, [ ], "unselectAll: ");
 
       //////////////////////////////////////////////////////////////////////////
       // select@size="4" multiselect with optgroups
 
       var id = "listbox4";
       ok(isAccessible(id, [nsIAccessibleSelectable]),
          "No selectable accessible for " + id);
 
       select = getAccessible(id, [nsIAccessibleSelectable]);
       testSelectableSelection(select, [ ]);
 
-      select.addChildToSelection(0);
+      select.addItemToSelection(0);
       testSelectableSelection(select, [ "lb4_item1" ]);
 
-      select.removeChildFromSelection(0);
+      select.removeItemFromSelection(0);
       testSelectableSelection(select, [ ]);
 
-      is(select.selectAllSelection(), true,
+      is(select.selectAll(), true,
          "All items in listbox '" + id + "' should be selected");
       testSelectableSelection(select, [ "lb4_item1", "lb4_item2"]);
 
-      select.clearSelection();
+      select.unselectAll();
       testSelectableSelection(select, [ ]);
 
       SimpleTest.finish();
     }
 
     SimpleTest.waitForExplicitFinish();
     addA11yLoadEvent(doTest);
   </script>
--- a/accessible/tests/mochitest/selectable/test_tree.xul
+++ b/accessible/tests/mochitest/selectable/test_tree.xul
@@ -48,58 +48,58 @@
       {
         var tree = getAccessible(this.DOMNode);
 
         var isTreeMultiSelectable = false;
         var seltype = this.DOMNode.getAttribute("seltype");
         if (seltype != "single" && seltype != "cell" && seltype != "text")
           isTreeMultiSelectable = true;
 
-        // selectAllSelection
+        // selectAll
         var accSelectable = getAccessible(this.DOMNode,
                                           [nsIAccessibleSelectable]);
         ok(accSelectable, "tree is not selectable!");
         if (accSelectable) {
-          is(accSelectable.selectAllSelection(), isTreeMultiSelectable,
-             "SelectAllSelection is not correct for seltype: " + seltype);
+          is(accSelectable.selectAll(), isTreeMultiSelectable,
+             "SelectAll is not correct for seltype: " + seltype);
         }
 
         var selectedChildren = [];
         if (isTreeMultiSelectable) {
           var rows = tree.children;
           for (var i = 0; i < rows.length; i++) {
           var row = rows.queryElementAt(i, nsIAccessible);
             if (getRole(row) == ROLE_OUTLINEITEM || getRole(row) == ROLE_ROW)
               selectedChildren.push(row);
           }
         }
         testSelectableSelection(accSelectable, selectedChildren,
-                                "selectAllSelection test. ");
+                                "selectAll test. ");
 
-        // clearSelection
-        accSelectable.clearSelection();
-        testSelectableSelection(accSelectable, [], "clearSelection test. ");
+        // unselectAll
+        accSelectable.unselectAll();
+        testSelectableSelection(accSelectable, [], "unselectAll test. ");
 
-        // addChildToSelection
-        accSelectable.addChildToSelection(1);
-        accSelectable.addChildToSelection(3);
+        // addItemToSelection
+        accSelectable.addItemToSelection(1);
+        accSelectable.addItemToSelection(3);
 
         selectedChildren = isTreeMultiSelectable ?
           [ accSelectable.getChildAt(2), accSelectable.getChildAt(4) ] :
           [ accSelectable.getChildAt(2) ];
         testSelectableSelection(accSelectable, selectedChildren,
-                                "addChildToSelection test. ");
+                                "addItemToSelection test. ");
 
-        // removeChildFromSelection
-        accSelectable.removeChildFromSelection(1);
+        // removeItemFromSelection
+        accSelectable.removeItemFromSelection(1);
 
         selectedChildren = isTreeMultiSelectable ?
           [ accSelectable.getChildAt(4) ] : [ ];
         testSelectableSelection(accSelectable, selectedChildren,
-                                "removeChildFromSelection test. ");
+                                "removeItemFromSelection test. ");
       }
 
       this.getID = function getID()
       {
         "tree processor for " + prettyName(aTreeID);
       }
     }