Ensure the tree selection exists before trying to do things to it
b=397788 r=jag
--- a/xpfe/components/autocomplete/resources/content/autocomplete.xml
+++ b/xpfe/components/autocomplete/resources/content/autocomplete.xml
@@ -1436,16 +1436,21 @@
<field name="treebody">
document.getAnonymousElementByAttribute(this, "anonid", "treebody");
</field>
<field name="view">
null
</field>
+ <!-- Setting tree.view doesn't always immediately create a selection,
+ so we ensure the selection by asking the tree for the view. Note:
+ this.view.selection is quicker if we know the selection exists. -->
+ <property name="selection" onget="return this.tree.view.selection;"/>
+
<property name="pageCount"
onget="return this.tree.treeBoxObject.getPageLength();"/>
<field name="mLastRows">0</field>
<method name="initialize">
<body><![CDATA[
this.showCommentColumn = this.textbox.showCommentColumn;
@@ -1476,17 +1481,17 @@
this.tree.removeAttribute("collapsed");
this.tree.setAttribute("height", height);
}
]]></body>
</method>
<method name="clearSelection">
<body>
- this.view.selection.clearSelection();
+ this.selection.clearSelection();
</body>
</method>
<method name="selectBy">
<parameter name="aReverse"/>
<parameter name="aPage"/>
<body><![CDATA[
try {
@@ -1533,25 +1538,25 @@
<!-- This property is meant to be overriden by bindings extending
this one. When the user selects an item from the list by
hitting enter or clicking, this method can set the value
of the textbox to a different value if it wants to. -->
<property name="overrideValue" readonly="true" onget="return null;"/>
<property name="selectedIndex">
<getter>
- if (!this.view || !this.view.selection.count)
+ if (!this.view || !this.selection.count)
return -1;
var start = {}, end = {};
this.view.selection.getRangeAt(0, start, end);
return start.value;
</getter>
<setter>
if (this.view) {
- this.view.selection.select(val);
+ this.selection.select(val);
if (val >= 0) {
this.view.selection.currentIndex = -1;
this.tree.treeBoxObject.ensureRowIsVisible(val);
}
}
return val;
</setter>
</property>