diff --git a/accessible/public/nsIAccessibleSelectable.idl b/accessible/public/nsIAccessibleSelectable.idl index 0a43c4c15a54..461fb55d5c08 100644 --- a/accessible/public/nsIAccessibleSelectable.idl +++ b/accessible/public/nsIAccessibleSelectable.idl @@ -2,71 +2,63 @@ /* 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(); }; diff --git a/accessible/src/generic/Accessible.cpp b/accessible/src/generic/Accessible.cpp index 077685875114..d7c4f8660c81 100644 --- a/accessible/src/generic/Accessible.cpp +++ b/accessible/src/generic/Accessible.cpp @@ -1013,7 +1013,7 @@ Accessible::TakeSelection() Accessible* select = nsAccUtils::GetSelectableContainer(this, State()); if (select) { if (select->State() & states::MULTISELECTABLE) - select->ClearSelection(); + select->UnselectAll(); return SetSelected(true); } @@ -2332,118 +2332,6 @@ Accessible::ScrollToPoint(uint32_t aCoordinateType, int32_t aX, int32_t aY) 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 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 diff --git a/accessible/src/generic/Accessible.h b/accessible/src/generic/Accessible.h index c9540c66b54d..0d55cc76d439 100644 --- a/accessible/src/generic/Accessible.h +++ b/accessible/src/generic/Accessible.h @@ -13,9 +13,9 @@ #include "nsIAccessible.h" #include "nsIAccessibleHyperLink.h" -#include "nsIAccessibleSelectable.h" #include "nsIAccessibleValue.h" #include "nsIAccessibleStates.h" +#include "xpcAccessibleSelectable.h" #include "nsIContent.h" #include "nsString.h" @@ -104,7 +104,7 @@ typedef nsRefPtrHashtable, Accessible> class Accessible : public nsIAccessible, public nsIAccessibleHyperLink, - public nsIAccessibleSelectable, + public xpcAccessibleSelectable, public nsIAccessibleValue { public: @@ -116,7 +116,6 @@ public: NS_DECL_NSIACCESSIBLE NS_DECL_NSIACCESSIBLEHYPERLINK - NS_DECL_NSIACCESSIBLESELECTABLE NS_DECL_NSIACCESSIBLEVALUE NS_DECLARE_STATIC_IID_ACCESSOR(NS_ACCESSIBLE_IMPL_IID) diff --git a/accessible/src/xpcom/moz.build b/accessible/src/xpcom/moz.build index 148569fa4e0e..b9fb8e31f0c2 100644 --- a/accessible/src/xpcom/moz.build +++ b/accessible/src/xpcom/moz.build @@ -6,8 +6,13 @@ MODULE = 'accessibility' +EXPORTS += [ + 'xpcAccessibleSelectable.h', +] + SOURCES += [ 'nsAccessibleRelation.cpp', + 'xpcAccessibleSelectable.cpp', 'xpcAccessibleTable.cpp', 'xpcAccessibleTableCell.cpp', ] diff --git a/accessible/src/xpcom/xpcAccessibleSelectable.cpp b/accessible/src/xpcom/xpcAccessibleSelectable.cpp new file mode 100644 index 000000000000..e7e7a79145d6 --- /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(this); + if (acc->IsDefunct()) + return NS_ERROR_FAILURE; + NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!"); + + nsCOMPtr 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(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(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(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(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(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(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(this); + if (acc->IsDefunct()) + return NS_ERROR_FAILURE; + NS_PRECONDITION(acc->IsSelect(), "Called on non selectable widget!"); + + acc->UnselectAll(); + return NS_OK; +} diff --git a/accessible/src/xpcom/xpcAccessibleSelectable.h b/accessible/src/xpcom/xpcAccessibleSelectable.h new file mode 100644 index 000000000000..28fc482aa195 --- /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 diff --git a/accessible/src/xul/XULTreeGridAccessible.cpp b/accessible/src/xul/XULTreeGridAccessible.cpp index 911dc86470e6..47faa3c1b0b0 100644 --- a/accessible/src/xul/XULTreeGridAccessible.cpp +++ b/accessible/src/xul/XULTreeGridAccessible.cpp @@ -61,21 +61,14 @@ 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 @@ -164,12 +157,7 @@ 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 diff --git a/accessible/tests/mochitest/selectable.js b/accessible/tests/mochitest/selectable.js index 5ec4c47de195..87bf296f0fdb 100644 --- a/accessible/tests/mochitest/selectable.js +++ b/accessible/tests/mochitest/selectable.js @@ -14,7 +14,7 @@ function testSelectableSelection(aIdentifier, aSelectedChildren, 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)); @@ -28,28 +28,26 @@ function testSelectableSelection(aIdentifier, aSelectedChildren, aMsg) 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++) { @@ -65,9 +63,9 @@ function testIsChildSelected(aSelectAcc, aTraversedAcc, aIndexObj, aSelectedChil } } - // 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 @@ -77,6 +75,6 @@ function testIsChildSelected(aSelectAcc, aTraversedAcc, aIndexObj, aSelectedChil continue; } - testIsChildSelected(aSelectAcc, child, aIndexObj, aSelectedChildren); + testIsItemSelected(aSelectAcc, child, aIndexObj, aSelectedChildren); } } diff --git a/accessible/tests/mochitest/selectable/test_aria.html b/accessible/tests/mochitest/selectable/test_aria.html index 52d2f9eb248b..075871b66372 100644 --- a/accessible/tests/mochitest/selectable/test_aria.html +++ b/accessible/tests/mochitest/selectable/test_aria.html @@ -27,10 +27,10 @@ testSelectableSelection(acc, []); - acc.selectAllSelection(); + acc.selectAll(); testSelectableSelection(acc, aSelectableChildren); - acc.clearSelection(); + acc.unselectAll(); testSelectableSelection(acc, []); } @@ -64,13 +64,13 @@ 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, [ ]); ////////////////////////////////////////////////////////////////////////// diff --git a/accessible/tests/mochitest/selectable/test_listbox.xul b/accessible/tests/mochitest/selectable/test_listbox.xul index e949e3a6003d..990589257d46 100644 --- a/accessible/tests/mochitest/selectable/test_listbox.xul +++ b/accessible/tests/mochitest/selectable/test_listbox.xul @@ -41,20 +41,20 @@ 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 @@ -66,30 +66,30 @@ 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(); } diff --git a/accessible/tests/mochitest/selectable/test_menulist.xul b/accessible/tests/mochitest/selectable/test_menulist.xul index dc33a321b7c0..5bd7a26b26cf 100644 --- a/accessible/tests/mochitest/selectable/test_menulist.xul +++ b/accessible/tests/mochitest/selectable/test_menulist.xul @@ -43,20 +43,20 @@ 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(); } diff --git a/accessible/tests/mochitest/selectable/test_select.html b/accessible/tests/mochitest/selectable/test_select.html index 7c937c7b6ae5..9369fdfaf473 100644 --- a/accessible/tests/mochitest/selectable/test_select.html +++ b/accessible/tests/mochitest/selectable/test_select.html @@ -37,22 +37,22 @@ 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 @@ -66,17 +66,17 @@ 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" ]); ////////////////////////////////////////////////////////////////////////// @@ -90,22 +90,22 @@ 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 @@ -117,17 +117,17 @@ 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, [ ]); ////////////////////////////////////////////////////////////////////////// @@ -140,19 +140,19 @@ 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 @@ -164,17 +164,17 @@ 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(); diff --git a/accessible/tests/mochitest/selectable/test_tree.xul b/accessible/tests/mochitest/selectable/test_tree.xul index 55fc83497880..ad0e2a2a7dc4 100644 --- a/accessible/tests/mochitest/selectable/test_tree.xul +++ b/accessible/tests/mochitest/selectable/test_tree.xul @@ -53,13 +53,13 @@ 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 = []; @@ -72,29 +72,29 @@ } } 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()