Bug 1476611 - Part 1 - Remove unused listbox methods. r=bgrins
MozReview-Commit-ID: JDyuZFDPldV
--- a/toolkit/content/widgets/listbox.xml
+++ b/toolkit/content/widgets/listbox.xml
@@ -26,22 +26,16 @@
/** Return item at given index
* @param aIndex - index of item element */
getItemAtIndex(aIndex)
/** Return count of item elements */
getRowCount()
- /** Return count of visible item elements */
- getNumberOfVisibleRows()
-
- /** Return index of first visible item element */
- getIndexOfFirstVisibleRow()
-
/** Return true if item of given index is visible
* @param aIndex - index of item element
*
* @note XXX: this method should be removed after bug 364612 is fixed
*/
ensureIndexIsVisible(aIndex)
/** Return true if item element is visible
@@ -406,93 +400,17 @@
window.clearTimeout(this._selectTimeout);
this._selectTimeout =
window.setTimeout(this._selectTimeoutHandler, aTimeout, this);
}
]]>
</body>
</method>
- <method name="moveByOffset">
- <parameter name="aOffset"/>
- <parameter name="aIsSelecting"/>
- <parameter name="aIsSelectingRange"/>
- <body>
- <![CDATA[
- if ((aIsSelectingRange || !aIsSelecting) &&
- this.selType != "multiple")
- return;
-
- var newIndex = this.currentIndex + aOffset;
- if (newIndex < 0)
- newIndex = 0;
-
- var numItems = this.getRowCount();
- if (newIndex > numItems - 1)
- 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(this.getIndexOfItem(newItem));
- if (aIsSelectingRange)
- this.selectItemRange(null, newItem);
- else if (aIsSelecting)
- this.selectItem(newItem);
-
- this.currentItem = newItem;
- }
- ]]>
- </body>
- </method>
-
<!-- Private -->
- <method name="getNextItem">
- <parameter name="aStartItem"/>
- <parameter name="aDelta"/>
- <body>
- <![CDATA[
- while (aStartItem) {
- aStartItem = aStartItem.nextSibling;
- if (aStartItem && aStartItem instanceof
- Ci.nsIDOMXULSelectControlItemElement &&
- (!this._userSelecting || this._canUserSelect(aStartItem))) {
- --aDelta;
- if (aDelta == 0)
- return aStartItem;
- }
- }
- return null;
- ]]></body>
- </method>
-
- <method name="getPreviousItem">
- <parameter name="aStartItem"/>
- <parameter name="aDelta"/>
- <body>
- <![CDATA[
- while (aStartItem) {
- aStartItem = aStartItem.previousSibling;
- if (aStartItem && aStartItem instanceof
- Ci.nsIDOMXULSelectControlItemElement &&
- (!this._userSelecting || this._canUserSelect(aStartItem))) {
- --aDelta;
- if (aDelta == 0)
- return aStartItem;
- }
- }
- return null;
- ]]>
- </body>
- </method>
-
<method name="_moveByOffsetFromUserEvent">
<parameter name="aOffset"/>
<parameter name="aEvent"/>
<body>
<![CDATA[
if (!aEvent.defaultPrevented) {
this._userSelecting = true;
this._mayReverse = true;
@@ -653,18 +571,16 @@
return val;
]]></setter>
</property>
<!-- ///////////////// nsIDOMXULSelectControlItemElement ///////////////// -->
<property name="value" onget="return this.getAttribute('value');"
onset="this.setAttribute('value', val); return val;"/>
- <property name="label" onget="return this.getAttribute('label');"
- onset="this.setAttribute('label', val); return val;"/>
<property name="selected" onget="return this.getAttribute('selected') == 'true';">
<setter><![CDATA[
if (val)
this.setAttribute("selected", "true");
else
this.removeAttribute("selected");
--- a/toolkit/content/widgets/richlistbox.xml
+++ b/toolkit/content/widgets/richlistbox.xml
@@ -20,32 +20,20 @@
</content>
<implementation>
<field name="_scrollbox">
document.getAnonymousElementByAttribute(this, "anonid", "main-box");
</field>
<constructor>
<![CDATA[
- // add a template build listener
- if (this.builder)
- this.builder.addListener(this._builderListener);
- else
- this._refreshSelection();
+ this._refreshSelection();
]]>
</constructor>
- <destructor>
- <![CDATA[
- // remove the template build listener
- if (this.builder)
- this.builder.removeListener(this._builderListener);
- ]]>
- </destructor>
-
<!-- Overriding baselistbox -->
<method name="_fireOnSelect">
<body>
<![CDATA[
// make sure not to modify last-selected when suppressing select events
// (otherwise we'll lose the selection when a template gets rebuilt)
if (this._suppressOnSelect || this.suppressOnSelect)
return;
@@ -210,45 +198,16 @@
<![CDATA[
var item = this.getItemAtIndex(aIndex);
if (item)
this._scrollbox.scrollToElement(item);
]]>
</body>
</method>
- <method name="getNumberOfVisibleRows">
- <!-- returns the number of currently visible rows -->
- <!-- don't rely on this function, if the items' height can vary! -->
- <body>
- <![CDATA[
- var children = this.children;
-
- for (var top = 0; top < children.length && !this._isItemVisible(children[top]); top++);
- for (var ix = top; ix < children.length && this._isItemVisible(children[ix]); ix++);
-
- return ix - top;
- ]]>
- </body>
- </method>
-
- <method name="getIndexOfFirstVisibleRow">
- <body>
- <![CDATA[
- var children = this.children;
-
- for (var ix = 0; ix < children.length; ix++)
- if (this._isItemVisible(children[ix]))
- return ix;
-
- return -1;
- ]]>
- </body>
- </method>
-
<method name="getRowCount">
<body>
<![CDATA[
return this.children.length;
]]>
</body>
</method>
@@ -306,29 +265,16 @@
if (this.dir == "reverse" && this._mayReverse) {
children.reverse();
}
return children;
]]>
</getter>
</property>
- <field name="_builderListener" readonly="true">
- <![CDATA[
- ({
- mOuter: this,
- item: null,
- willRebuild(builder) { },
- didRebuild(builder) {
- this.mOuter._refreshSelection();
- }
- });
- ]]>
- </field>
-
<method name="_refreshSelection">
<body>
<![CDATA[
// when this method is called, we know that either the currentItem
// and selectedItems we have are null (ctor) or a reference to an
// element no longer in the DOM (template).
// first look for the last-selected attribute
@@ -426,59 +372,24 @@
(aItem.boxObject.y < y + this._scrollbox.boxObject.height);
]]>
</body>
</method>
<field name="_currentIndex">null</field>
<!-- For backwards-compatibility and for convenience.
- Use getIndexOfItem instead. -->
- <method name="getIndexOf">
- <parameter name="aElement"/>
- <body>
- <![CDATA[
- return this.getIndexOfItem(aElement);
- ]]>
- </body>
- </method>
-
- <!-- For backwards-compatibility and for convenience.
Use ensureElementIsVisible instead -->
<method name="ensureSelectedElementIsVisible">
<body>
<![CDATA[
return this.ensureElementIsVisible(this.selectedItem);
]]>
</body>
</method>
-
- <!-- For backwards-compatibility and for convenience.
- Use moveByOffset instead. -->
- <method name="goUp">
- <body>
- <![CDATA[
- var index = this.currentIndex;
- this.moveByOffset(-1, true, false);
- return index != this.currentIndex;
- ]]>
- </body>
- </method>
- <method name="goDown">
- <body>
- <![CDATA[
- var index = this.currentIndex;
- this.moveByOffset(1, true, false);
- return index != this.currentIndex;
- ]]>
- </body>
- </method>
-
- <!-- deprecated (is implied by currentItem and selectItem) -->
- <method name="fireActiveItemEvent"><body/></method>
</implementation>
<handlers>
<handler event="click">
<![CDATA[
// clicking into nothing should unselect
if (event.originalTarget == this._scrollbox) {
this.clearSelection();