Continuation of synchronisation of xpfe autocomplete with toolkit interfaces b=304309 r=ajschult sr=jag

This commit is contained in:
neil@parkwaycc.co.uk 2007-06-05 01:08:18 -07:00
Родитель bd9ea0ed3e
Коммит 34897043bc
1 изменённых файлов: 34 добавлений и 47 удалений

Просмотреть файл

@ -848,8 +848,7 @@
var val = this.resultsPopup.getOverrideValue(); var val = this.resultsPopup.getOverrideValue();
if (val) if (val)
this.setTextValue(val); this.setTextValue(val);
else if (this.resultsPopup.selectedIndex != null && else if (this.resultsPopup.selectedIndex != -1 && !this.noMatch) {
!this.noMatch) {
if (this.getSessionStatusAt(this.resultsPopup.selectedIndex) == if (this.getSessionStatusAt(this.resultsPopup.selectedIndex) ==
Components.interfaces.nsIAutoCompleteStatus.failureItems) { Components.interfaces.nsIAutoCompleteStatus.failureItems) {
this.setTextValue(this.currentSearchString); this.setTextValue(this.currentSearchString);
@ -932,7 +931,7 @@
this.mNeedToComplete = true; this.mNeedToComplete = true;
var str = this.value; var str = this.value;
this.currentSearchString = str; this.currentSearchString = str;
this.resultsPopup.selectedIndex = null; this.resultsPopup.selectedIndex = -1;
this.removeAttribute("noMatchesFound"); this.removeAttribute("noMatchesFound");
this.mAutoCompleteTimer = setTimeout(this.callListener, this.timeout, this, "startLookup"); this.mAutoCompleteTimer = setTimeout(this.callListener, this.timeout, this, "startLookup");
@ -963,7 +962,7 @@
// if this is a failure item, save it for fireErrorCommand // if this is a failure item, save it for fireErrorCommand
var errItem = null; var errItem = null;
if (this.resultsPopup.selectedIndex != null && if (this.resultsPopup.selectedIndex != -1 &&
this.getSessionStatusAt(this.resultsPopup.selectedIndex) == this.getSessionStatusAt(this.resultsPopup.selectedIndex) ==
Components.interfaces.nsIAutoCompleteStatus.failureItems) { Components.interfaces.nsIAutoCompleteStatus.failureItems) {
errItem = this.getResultAt(this.resultsPopup.selectedIndex); errItem = this.getResultAt(this.resultsPopup.selectedIndex);
@ -1071,7 +1070,7 @@
// determine which value to place in the textbox // determine which value to place in the textbox
this.ignoreInputEvent = true; this.ignoreInputEvent = true;
if (selected != null) { if (selected != -1) {
if (this.getSessionStatusAt(selected) == if (this.getSessionStatusAt(selected) ==
Components.interfaces.nsIAutoCompleteStatus.failureItems) { Components.interfaces.nsIAutoCompleteStatus.failureItems) {
if (this.currentSearchString) if (this.currentSearchString)
@ -1285,10 +1284,10 @@
({ ({
mTextbox: this, mTextbox: this,
mTree: null, mTree: null,
mBoxObject: null, mSelection: null,
mResults: [], mResults: [],
mRowCount: 0, mRowCount: 0,
mSelectedIndex: null, mSelectedIndex: -1,
get treeBoxObject() get treeBoxObject()
{ {
@ -1297,24 +1296,15 @@
set selectedIndex(aRow) set selectedIndex(aRow)
{ {
if (!this.mBoxObject) if (this.mSelection) {
return; this.mSelectedIndex = aRow;
this.mSelection.select(aRow);
if (this.mSelectedIndex != null) if (aRow >= 0) {
this.mBoxObject.invalidateRow(this.mSelectedIndex); this.mSelection.currentIndex = -1;
this.mTree.ensureRowIsVisible(aRow);
this.mSelectedIndex = aRow; }
if (aRow != null) {
this.mBoxObject.invalidateRow(aRow);
this.mBoxObject.ensureRowIsVisible(aRow);
// Fire select event on xul:tree so that accessibility API
// support layer can fire appropriate accessibility events.
var event = document.createEvent('Events');
event.initEvent("select", true, true);
this.mTree.element.dispatchEvent(event);
} }
return aRow;
}, },
get selectedIndex() get selectedIndex()
@ -1328,10 +1318,10 @@
this.mRowCount = 0; this.mRowCount = 0;
this.mResults = []; this.mResults = [];
if (this.mTree) if (this.mTree) {
this.mTree.rowCountChanged(0, -oldCount); this.mTree.rowCountChanged(0, -oldCount);
if (this.mBoxObject) this.mTree.scrollToRow(0);
this.mBoxObject.scrollToRow(0); }
}, },
addResults: function(aResults) addResults: function(aResults)
@ -1361,17 +1351,19 @@
return this.mRowCount; return this.mRowCount;
}, },
// implementing these results in a crash get selection() {
// get selection() {}, return this.mSelection;
// set selection(aVal) { }, },
set selection(aVal) {
return this.mSelection = aVal;
},
setTree: function(aTree) setTree: function(aTree)
{ {
this.mTree = aTree; this.mTree = aTree;
if (aTree) { if (aTree) {
this.mBoxObject = this.mTextbox.resultsPopup.tree.treeBoxObject;
// cache atoms for pseudoelement properties // cache atoms for pseudoelement properties
this.mAtomSelected = this.createAtom("menuactive") this.mAtomSelected = this.createAtom("menuactive")
} }
@ -1514,7 +1506,7 @@
this.tree.__AUTOCOMPLETE_BOX__ = this.textbox; this.tree.__AUTOCOMPLETE_BOX__ = this.textbox;
this.treebody.__AUTOCOMPLETE_BOX__ = this.textbox; this.treebody.__AUTOCOMPLETE_BOX__ = this.textbox;
this._selectedIndex = null; this._selectedIndex = -1;
this.initColumns(); this.initColumns();
this.view = this.textbox.view; this.view = this.textbox.view;
@ -1584,7 +1576,7 @@
// do nothing - occasionally timer-related js errors happen here // do nothing - occasionally timer-related js errors happen here
// e.g. "this.selectedIndex has no properties", when you type fast and hit a // e.g. "this.selectedIndex has no properties", when you type fast and hit a
// navigation key before this popup has opened // navigation key before this popup has opened
return null; return -1;
} }
]]></body> ]]></body>
</method> </method>
@ -1596,12 +1588,12 @@
<parameter name="aMaxRow"/> <parameter name="aMaxRow"/>
<body><![CDATA[ <body><![CDATA[
if (aMaxRow < 0) if (aMaxRow < 0)
return null; return -1;
if (aIndex == null) if (aIndex == -1)
return aReverse ? aMaxRow : 0; return aReverse ? aMaxRow : 0;
if (aIndex == (aReverse ? 0 : aMaxRow)) if (aIndex == (aReverse ? 0 : aMaxRow))
return null; return -1;
var amount = aPage ? this.pageCount - 1 : 1; var amount = aPage ? this.pageCount - 1 : 1;
aIndex = aReverse ? aIndex - amount : aIndex + amount; aIndex = aReverse ? aIndex - amount : aIndex + amount;
@ -1631,7 +1623,7 @@
<handler event="popuphiding"> <handler event="popuphiding">
this.textbox.mMenuOpen = false; this.textbox.mMenuOpen = false;
this.selectedIndex = null; this.selectedIndex = -1;
</handler> </handler>
<handler event="mousedown" phase="capturing" preventdefault="true"/> <handler event="mousedown" phase="capturing" preventdefault="true"/>
@ -1642,8 +1634,6 @@
<implementation> <implementation>
<property name="textbox" <property name="textbox"
onget="return this.__AUTOCOMPLETE_BOX__;"/> onget="return this.__AUTOCOMPLETE_BOX__;"/>
<property name="currentIndex" onget="return this.textbox.view.selectedIndex;"
onset="this.textbox.view.selectedIndex = val; return val;"/>
</implementation> </implementation>
</binding> </binding>
@ -1661,19 +1651,16 @@
// popup! // popup!
var x = aEvent.screenX - document.documentElement.boxObject.screenX; var x = aEvent.screenX - document.documentElement.boxObject.screenX;
var y = aEvent.screenY - document.documentElement.boxObject.screenY; var y = aEvent.screenY - document.documentElement.boxObject.screenY;
var row = this.textbox.view.treeBoxObject.getRowAt(x, y); return this.textbox.view.treeBoxObject.getRowAt(x, y);
if (row >= 0)
return row;
return null;
]]></body> ]]></body>
</method> </method>
</implementation> </implementation>
<handlers> <handlers>
<handler event="mouseout" action="this.textbox.view.selectedIndex = null;"/> <handler event="mouseout" action="this.textbox.view.selectedIndex = -1;"/>
<handler event="mouseup"><![CDATA[ <handler event="mouseup"><![CDATA[
var rc = this.getHoverRow(event); var rc = this.getHoverRow(event);
if (rc != null) { if (rc != -1) {
this.textbox.view.selectedIndex = rc; this.textbox.view.selectedIndex = rc;
this.textbox.onResultClick(); this.textbox.onResultClick();
} }
@ -1682,7 +1669,7 @@
<handler event="mousemove"><![CDATA[ <handler event="mousemove"><![CDATA[
if (Date.now() - this.mLastMoveTime > 30) { if (Date.now() - this.mLastMoveTime > 30) {
var rc = this.getHoverRow(event); var rc = this.getHoverRow(event);
if (rc != null && rc != this.textbox.view.selectedIndex) if (rc != -1 && rc != this.textbox.view.selectedIndex)
this.textbox.view.selectedIndex = rc; this.textbox.view.selectedIndex = rc;
this.mLastMoveTime = Date.now(); this.mLastMoveTime = Date.now();
} }