b=512643; FAYT should be smarter when there are no current matches; r=gavin

This commit is contained in:
Vladimir Vukicevic 2009-09-01 22:52:05 -07:00
parent 5a8056ddad
commit d927a322cd

View File

@ -394,6 +394,8 @@
this.nsISelectionController = Components.interfaces.nsISelectionController;
this._findSelection = this.nsISelectionController.SELECTION_FIND;
this._findResetTimeout = -1;
// Make sure the FAYT keypress listener is attached by initializing the
// browser property
setTimeout(function(aSelf) { aSelf.browser = aSelf.browser; }, 0, this);
@ -1130,6 +1132,8 @@
stringsBundle.GetStringFromName("CaseSensitive");
}
this._findFailedString = null;
this._updateFindUI();
if (this.hidden) {
this.hidden = false;
@ -1516,22 +1520,46 @@
<method name="_find">
<parameter name="aValue"/>
<body><![CDATA[
var val = aValue || this._findField.value
var val = aValue || this._findField.value;
var res = this.nsITypeAheadFind.FIND_NOTFOUND;
this._enableFindButtons(val);
if (this.getElement("highlight").checked)
this._setHighlightTimeout();
// Only search on input if we don't have a last-failed string,
// or if the current search string doesn't start with it.
if (this._findFailedString == null ||
val.indexOf(this._findFailedString) != 0)
{
this._enableFindButtons(val);
if (this.getElement("highlight").checked)
this._setHighlightTimeout();
this._updateCaseSensitivity(val);
this._updateCaseSensitivity(val);
var fastFind = this.browser.fastFind;
var res = fastFind.find(val, this._findMode == this.FIND_LINKS);
this._updateFoundLink(res);
this._updateStatusUI(res, false);
var fastFind = this.browser.fastFind;
res = fastFind.find(val, this._findMode == this.FIND_LINKS);
this._updateFoundLink(res);
this._updateStatusUI(res, false);
if (res == this.nsITypeAheadFind.FIND_NOTFOUND)
this._findFailedString = val;
else
this._findFailedString = null;
}
if (this._findMode != this.FIND_NORMAL)
this._setFindCloseTimeout();
if (this._findResetTimeout != -1)
clearTimeout(this._findResetTimeout);
// allow a search to happen on input again after a second has
// expired since the previous input, to allow for dynamic
// content and/or page loading
this._findResetTimeout = setTimeout(function(self) {
self._findFailedString = null;
self._findResetTimeout = -1; },
1000, this);
return res;
]]></body>
</method>
@ -1713,6 +1741,9 @@
return;
}
// user explicitly requested another search, so do it even if we think it'll fail
this._findFailedString = null;
var res;
// Ensure the stored SearchString is in sync with what we want to find
if (this._findField.value != this._browser.fastFind.searchString &&