diff --git a/toolkit/content/tests/widgets/Makefile.in b/toolkit/content/tests/widgets/Makefile.in
index c9ef667e254..e4833270881 100644
--- a/toolkit/content/tests/widgets/Makefile.in
+++ b/toolkit/content/tests/widgets/Makefile.in
@@ -68,6 +68,8 @@ _TEST_FILES = test_bug360220.xul \
test_datepicker.xul \
test_timepicker.xul \
xul_selectcontrol.js \
+ test_hiddenitems.xul \
+ test_hiddenpaging.xul \
$(NULL)
ifeq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
diff --git a/toolkit/content/tests/widgets/test_hiddenitems.xul b/toolkit/content/tests/widgets/test_hiddenitems.xul
new file mode 100644
index 00000000000..126b1b2ecb9
--- /dev/null
+++ b/toolkit/content/tests/widgets/test_hiddenitems.xul
@@ -0,0 +1,89 @@
+
+
+
+
+
+
+
+
+
+
+
+ Mozilla Bug 317422
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/toolkit/content/tests/widgets/test_hiddenpaging.xul b/toolkit/content/tests/widgets/test_hiddenpaging.xul
new file mode 100644
index 00000000000..3c106a8c664
--- /dev/null
+++ b/toolkit/content/tests/widgets/test_hiddenpaging.xul
@@ -0,0 +1,128 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Mozilla Bug 317422
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/toolkit/content/widgets/listbox.xml b/toolkit/content/widgets/listbox.xml
index 199252f2635..36b26aaf400 100644
--- a/toolkit/content/widgets/listbox.xml
+++ b/toolkit/content/widgets/listbox.xml
@@ -99,8 +99,9 @@
insertItemAt(aIndex, aLabel, aValue)
/** Scroll up/down one page
- * @param aDirection - specifies scrolling direction, should be either -1
- or 1 */
+ * @param aDirection - specifies scrolling direction, should be either -1 or 1
+ * @return the number of elements the selection scrolled
+ */
scrollOnePage(aDirection)
/** Fire "select" event */
@@ -334,12 +335,15 @@
// Don't use clearSelection() because it causes a lot of noise
// with respect to selection removed notifications used by the
// accessibility API support.
+ var userSelecting = this._userSelecting;
+ this._userSelecting = false; // that's US automatically unselecting
for (; currentItem; currentItem = this.getNextItem(currentItem, 1))
this.removeItemFromSelection(currentItem);
for (currentItem = this.getItemAtIndex(0); currentItem != aStartItem;
currentItem = this.getNextItem(currentItem, 1))
this.removeItemFromSelection(currentItem);
+ this._userSelecting = userSelecting;
this._suppressOnSelect = suppressSelect;
@@ -478,8 +482,13 @@
newIndex = numItems - 1;
var newItem = this.getItemAtIndex(newIndex);
+ // make sure that the item is actually visible/selectable
+ if (this._userSelecting && newItem && !this._canUserSelect(newItem))
+ newItem =
+ aOffset > 0 ? this.getNextItem(newItem, 1) || this.getPreviousItem(newItem, 1) :
+ this.getPreviousItem(newItem, 1) || this.getNextItem(newItem, 1);
if (newItem) {
- this.ensureIndexIsVisible(newIndex);
+ this.ensureIndexIsVisible(this.getIndexOfItem(newItem));
if (aIsSelectingRange)
this.selectItemRange(null, newItem);
else if (aIsSelecting)
@@ -500,7 +509,8 @@
while (aStartItem) {
aStartItem = aStartItem.nextSibling;
if (aStartItem && aStartItem instanceof
- Components.interfaces.nsIDOMXULSelectControlItemElement) {
+ Components.interfaces.nsIDOMXULSelectControlItemElement &&
+ (!this._userSelecting || this._canUserSelect(aStartItem))) {
--aDelta;
if (aDelta == 0)
return aStartItem;
@@ -518,7 +528,8 @@
while (aStartItem) {
aStartItem = aStartItem.previousSibling;
if (aStartItem && aStartItem instanceof
- Components.interfaces.nsIDOMXULSelectControlItemElement) {
+ Components.interfaces.nsIDOMXULSelectControlItemElement &&
+ (!this._userSelecting || this._canUserSelect(aStartItem))) {
--aDelta;
if (aDelta == 0)
return aStartItem;
@@ -529,6 +540,28 @@