2007-03-22 10:30:00 -07:00
|
|
|
<?xml version="1.0"?>
|
|
|
|
|
2012-05-21 04:12:37 -07:00
|
|
|
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<!DOCTYPE bindings [
|
|
|
|
<!ENTITY % findBarDTD SYSTEM "chrome://global/locale/findbar.dtd" >
|
|
|
|
%findBarDTD;
|
|
|
|
]>
|
|
|
|
|
|
|
|
<bindings id="findbarBindings"
|
|
|
|
xmlns="http://www.mozilla.org/xbl"
|
|
|
|
xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
|
|
xmlns:xbl="http://www.mozilla.org/xbl">
|
|
|
|
|
|
|
|
<!-- Private binding -->
|
|
|
|
<binding id="findbar-textbox"
|
|
|
|
extends="chrome://global/content/bindings/textbox.xml#textbox">
|
|
|
|
<implementation>
|
|
|
|
|
|
|
|
<field name="_findbar">null</field>
|
|
|
|
<property name="findbar" readonly="true">
|
|
|
|
<getter>
|
|
|
|
return this._findbar ?
|
|
|
|
this._findbar : this._findbar = document.getBindingParent(this);
|
|
|
|
</getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<method name="_handleEnter">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this.findbar._findMode == this.findbar.FIND_NORMAL) {
|
2013-09-13 07:41:23 -07:00
|
|
|
let findString = this.findbar._findField;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!findString.value)
|
|
|
|
return;
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
if (aEvent.metaKey) {
|
|
|
|
#else
|
|
|
|
if (aEvent.ctrlKey) {
|
|
|
|
#endif
|
|
|
|
this.findbar.getElement("highlight").click();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.findbar.onFindAgainCommand(aEvent.shiftKey);
|
2013-09-26 08:21:02 -07:00
|
|
|
} else {
|
2013-09-13 07:41:23 -07:00
|
|
|
this.findbar._finishFAYT(aEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_handleTab">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let shouldHandle = !aEvent.altKey && !aEvent.ctrlKey &&
|
2007-03-22 10:30:00 -07:00
|
|
|
!aEvent.metaKey;
|
|
|
|
if (shouldHandle &&
|
2013-09-13 07:41:23 -07:00
|
|
|
this.findbar._findMode != this.findbar.FIND_NORMAL) {
|
|
|
|
|
|
|
|
this.findbar._finishFAYT(aEvent);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
|
|
|
<handler event="input"><![CDATA[
|
2012-01-12 22:19:22 -08:00
|
|
|
// We should do nothing during composition. E.g., composing string
|
|
|
|
// before converting may matches a forward word of expected word.
|
|
|
|
// After that, even if user converts the composition string to the
|
|
|
|
// expected word, it may find second or later searching word in the
|
|
|
|
// document.
|
|
|
|
if (this.findbar._isIMEComposing) {
|
|
|
|
return;
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
this.findbar._find(this.value);
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
<handler event="keypress"><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let shouldHandle = !event.altKey && !event.ctrlKey &&
|
2009-03-22 01:59:56 -07:00
|
|
|
!event.metaKey && !event.shiftKey;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
switch (event.keyCode) {
|
|
|
|
case KeyEvent.DOM_VK_RETURN:
|
|
|
|
this._handleEnter(event);
|
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_TAB:
|
|
|
|
this._handleTab(event);
|
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_PAGE_UP:
|
|
|
|
case KeyEvent.DOM_VK_PAGE_DOWN:
|
2009-03-22 01:59:56 -07:00
|
|
|
if (shouldHandle) {
|
2013-09-13 07:41:23 -07:00
|
|
|
this.findbar.browser.finder.keyPress(event);
|
2009-03-22 01:59:56 -07:00
|
|
|
event.preventDefault();
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
case KeyEvent.DOM_VK_UP:
|
|
|
|
case KeyEvent.DOM_VK_DOWN:
|
2013-09-13 07:41:23 -07:00
|
|
|
this.findbar.browser.finder.keyPress(event);
|
2007-03-22 10:30:00 -07:00
|
|
|
event.preventDefault();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
<handler event="blur"><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let findbar = this.findbar;
|
2013-10-29 12:28:51 -07:00
|
|
|
// Note: This code used to remove the selection
|
|
|
|
// if it matched an editable.
|
|
|
|
findbar.browser.finder.enableSelection();
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></handler>
|
|
|
|
|
2014-02-28 07:07:32 -08:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
<handler event="focus"><![CDATA[
|
|
|
|
let findbar = this.findbar;
|
|
|
|
findbar._onFindFieldFocus();
|
|
|
|
]]></handler>
|
|
|
|
#endif
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<handler event="compositionstart"><![CDATA[
|
|
|
|
// Don't close the find toolbar while IME is composing.
|
2013-09-13 07:41:23 -07:00
|
|
|
let findbar = this.findbar;
|
2007-03-22 10:30:00 -07:00
|
|
|
findbar._isIMEComposing = true;
|
|
|
|
if (findbar._quickFindTimeout) {
|
|
|
|
clearTimeout(findbar._quickFindTimeout);
|
|
|
|
findbar._quickFindTimeout = null;
|
|
|
|
}
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
<handler event="compositionend"><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let findbar = this.findbar;
|
2007-03-22 10:30:00 -07:00
|
|
|
findbar._isIMEComposing = false;
|
2014-02-17 06:42:59 -08:00
|
|
|
if (findbar._findMode != findbar.FIND_NORMAL)
|
2007-03-22 10:30:00 -07:00
|
|
|
findbar._setFindCloseTimeout();
|
|
|
|
]]></handler>
|
|
|
|
|
2010-05-13 06:42:57 -07:00
|
|
|
<handler event="dragover"><![CDATA[
|
|
|
|
if (event.dataTransfer.types.contains("text/plain"))
|
|
|
|
event.preventDefault();
|
|
|
|
]]></handler>
|
|
|
|
|
|
|
|
<handler event="drop"><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let value = event.dataTransfer.getData("text/plain");
|
2009-06-20 17:04:07 -07:00
|
|
|
this.value = value;
|
|
|
|
this.findbar._find(value);
|
|
|
|
event.stopPropagation();
|
2010-05-13 06:42:57 -07:00
|
|
|
event.preventDefault();
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></handler>
|
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
|
|
|
|
<binding id="findbar"
|
|
|
|
extends="chrome://global/content/bindings/toolbar.xml#toolbar">
|
|
|
|
<resources>
|
|
|
|
<stylesheet src="chrome://global/skin/findBar.css"/>
|
|
|
|
</resources>
|
|
|
|
|
2008-04-09 15:03:09 -07:00
|
|
|
<content hidden="true">
|
2008-04-09 16:55:10 -07:00
|
|
|
<xul:hbox anonid="findbar-container" class="findbar-container" flex="1" align="center">
|
2013-07-08 11:48:12 -07:00
|
|
|
<xul:hbox anonid="findbar-textbox-wrapper" align="stretch">
|
|
|
|
<xul:textbox anonid="findbar-textbox"
|
|
|
|
class="findbar-textbox findbar-find-fast"
|
|
|
|
xbl:inherits="flash"/>
|
|
|
|
<xul:toolbarbutton anonid="find-previous"
|
|
|
|
class="findbar-find-previous tabbable"
|
|
|
|
tooltiptext="&previous.tooltip;"
|
|
|
|
oncommand="onFindAgainCommand(true);"
|
|
|
|
disabled="true"
|
|
|
|
xbl:inherits="accesskey=findpreviousaccesskey"/>
|
|
|
|
<xul:toolbarbutton anonid="find-next"
|
|
|
|
class="findbar-find-next tabbable"
|
|
|
|
tooltiptext="&next.tooltip;"
|
|
|
|
oncommand="onFindAgainCommand(false);"
|
|
|
|
disabled="true"
|
|
|
|
xbl:inherits="accesskey=findnextaccesskey"/>
|
|
|
|
</xul:hbox>
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:toolbarbutton anonid="highlight"
|
2014-09-03 13:37:53 -07:00
|
|
|
class="findbar-highlight tabbable"
|
2013-07-08 11:48:12 -07:00
|
|
|
label="&highlightAll.label;"
|
|
|
|
accesskey="&highlightAll.accesskey;"
|
|
|
|
tooltiptext="&highlightAll.tooltiptext;"
|
2007-11-12 07:23:13 -08:00
|
|
|
oncommand="toggleHighlight(this.checked);"
|
2007-03-22 10:30:00 -07:00
|
|
|
type="checkbox"
|
|
|
|
xbl:inherits="accesskey=highlightaccesskey"/>
|
2013-07-08 11:48:12 -07:00
|
|
|
<xul:toolbarbutton anonid="find-case-sensitive"
|
2014-09-03 13:37:53 -07:00
|
|
|
class="findbar-case-sensitive tabbable"
|
2013-07-08 11:48:12 -07:00
|
|
|
label="&caseSensitive.label;"
|
|
|
|
accesskey="&caseSensitive.accesskey;"
|
|
|
|
tooltiptext="&caseSensitive.tooltiptext;"
|
2014-09-04 03:29:00 -07:00
|
|
|
oncommand="_setCaseSensitivity(this.checked ? 1 : 0);"
|
2013-07-08 11:48:12 -07:00
|
|
|
type="checkbox"
|
|
|
|
xbl:inherits="accesskey=matchcaseaccesskey"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<xul:label anonid="match-case-status" class="findbar-find-fast"/>
|
2014-05-01 04:01:14 -07:00
|
|
|
<xul:label anonid="found-matches" class="findbar-find-fast found-matches" hidden="true"/>
|
2014-04-15 13:41:00 -07:00
|
|
|
<xul:image anonid="find-status-icon" class="findbar-find-fast find-status-icon"/>
|
|
|
|
<xul:description anonid="find-status"
|
|
|
|
control="findbar-textbox"
|
|
|
|
class="findbar-find-fast findbar-find-status">
|
|
|
|
<!-- Do not use value, first child is used because it provides a11y with text change events -->
|
|
|
|
</xul:description>
|
2008-04-09 15:03:09 -07:00
|
|
|
</xul:hbox>
|
2013-11-08 06:23:55 -08:00
|
|
|
<xul:toolbarbutton anonid="find-closebutton"
|
2013-11-09 17:46:29 -08:00
|
|
|
class="findbar-closebutton close-icon"
|
2013-11-08 06:23:55 -08:00
|
|
|
tooltiptext="&findCloseButton.tooltip;"
|
|
|
|
oncommand="close();"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
</content>
|
|
|
|
|
2009-05-19 16:51:22 -07:00
|
|
|
<implementation implements="nsIDOMEventListener, nsIEditActionListener">
|
2007-03-22 10:30:00 -07:00
|
|
|
<field name="FIND_NORMAL">0</field>
|
|
|
|
<field name="FIND_TYPEAHEAD">1</field>
|
|
|
|
<field name="FIND_LINKS">2</field>
|
|
|
|
|
|
|
|
<field name="_findMode">0</field>
|
|
|
|
|
|
|
|
<field name="_flashFindBar">0</field>
|
|
|
|
<field name="_initialFlashFindBarCount">6</field>
|
|
|
|
|
|
|
|
<property name="prefillWithSelection"
|
|
|
|
onget="return this.getAttribute('prefillwithselection') != 'false'"
|
|
|
|
onset="this.setAttribute('prefillwithselection', val); return val;"/>
|
|
|
|
<field name="_selectionMaxLen">150</field>
|
|
|
|
|
|
|
|
<method name="getElement">
|
|
|
|
<parameter name="aAnonymousID"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
return document.getAnonymousElementByAttribute(this,
|
|
|
|
"anonid",
|
|
|
|
aAnonymousID)
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<property name="findMode"
|
|
|
|
readonly="true"
|
|
|
|
onget="return this._findMode;"/>
|
|
|
|
|
2012-10-22 04:42:53 -07:00
|
|
|
<property name="canClear" readonly="true">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (this._findField.value)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
// Watch out for lazy editor init
|
|
|
|
if (this._findField.editor) {
|
|
|
|
let tm = this._findField.editor.transactionManager;
|
|
|
|
return !!(tm.numberOfUndoItems || tm.numberOfRedoItems);
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<field name="_browser">null</field>
|
|
|
|
<property name="browser">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (!this._browser) {
|
|
|
|
this._browser =
|
|
|
|
document.getElementById(this.getAttribute("browserid"));
|
|
|
|
}
|
|
|
|
return this._browser;
|
|
|
|
]]></getter>
|
|
|
|
<setter><![CDATA[
|
2014-10-16 00:38:58 -07:00
|
|
|
// A shortcut for the service.
|
|
|
|
let els = Components.classes["@mozilla.org/eventlistenerservice;1"].
|
|
|
|
getService(Components.interfaces.nsIEventListenerService);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (this._browser) {
|
2014-10-16 00:38:58 -07:00
|
|
|
els.removeSystemEventListener(this._browser, "keypress", this,
|
|
|
|
false);
|
|
|
|
els.removeSystemEventListener(this._browser, "mouseup", this,
|
|
|
|
false);
|
2013-09-13 07:41:23 -07:00
|
|
|
let finder = this._browser.finder;
|
|
|
|
if (finder)
|
|
|
|
finder.removeResultListener(this);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
this._browser = val;
|
|
|
|
if (this._browser) {
|
2014-10-16 00:38:58 -07:00
|
|
|
els.addSystemEventListener(this._browser, "keypress", this, false);
|
|
|
|
els.addSystemEventListener(this._browser, "mouseup", this, false);
|
2013-09-13 07:41:23 -07:00
|
|
|
this._browser.finder.addResultListener(this);
|
|
|
|
|
|
|
|
this._findField.value = this._browser._lastSearchString;
|
|
|
|
this.toggleHighlight(this.browser._lastSearchHighlight);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return val;
|
|
|
|
]]></setter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<field name="_observer"><![CDATA[({
|
|
|
|
_self: this,
|
|
|
|
|
|
|
|
QueryInterface: function(aIID) {
|
|
|
|
if (aIID.equals(Components.interfaces.nsIObserver) ||
|
|
|
|
aIID.equals(Components.interfaces.nsISupportsWeakReference) ||
|
|
|
|
aIID.equals(Components.interfaces.nsISupports))
|
|
|
|
return this;
|
|
|
|
|
|
|
|
throw Components.results.NS_ERROR_NO_INTERFACE;
|
|
|
|
},
|
|
|
|
|
|
|
|
observe: function(aSubject, aTopic, aPrefName) {
|
|
|
|
if (aTopic != "nsPref:changed")
|
|
|
|
return;
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
let prefsvc =
|
2012-01-16 17:18:29 -08:00
|
|
|
aSubject.QueryInterface(Components.interfaces.nsIPrefBranch);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
switch (aPrefName) {
|
|
|
|
case "accessibility.typeaheadfind":
|
|
|
|
this._self._useTypeAheadFind = prefsvc.getBoolPref(aPrefName);
|
|
|
|
break;
|
|
|
|
case "accessibility.typeaheadfind.linksonly":
|
|
|
|
this._self._typeAheadLinksOnly = prefsvc.getBoolPref(aPrefName);
|
|
|
|
break;
|
|
|
|
case "accessibility.typeaheadfind.casesensitive":
|
2014-09-04 03:29:00 -07:00
|
|
|
this._self._setCaseSensitivity(prefsvc.getIntPref(aPrefName));
|
2007-03-22 10:30:00 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})]]></field>
|
|
|
|
|
2009-07-13 04:34:22 -07:00
|
|
|
<field name="_destroyed">false</field>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<constructor><![CDATA[
|
|
|
|
// These elements are accessed frequently and are therefore cached
|
|
|
|
this._findField = this.getElement("findbar-textbox");
|
2014-05-01 04:01:14 -07:00
|
|
|
this._foundMatches = this.getElement("found-matches");
|
2007-03-22 10:30:00 -07:00
|
|
|
this._findStatusIcon = this.getElement("find-status-icon");
|
2007-09-17 13:49:21 -07:00
|
|
|
this._findStatusDesc = this.getElement("find-status");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
this._foundURL = null;
|
2012-05-05 08:09:50 -07:00
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
let prefsvc =
|
2007-03-22 10:30:00 -07:00
|
|
|
Components.classes["@mozilla.org/preferences-service;1"]
|
2012-01-16 17:18:29 -08:00
|
|
|
.getService(Components.interfaces.nsIPrefBranch);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
this._quickFindTimeoutLength =
|
|
|
|
prefsvc.getIntPref("accessibility.typeaheadfind.timeout");
|
|
|
|
this._flashFindBar =
|
|
|
|
prefsvc.getIntPref("accessibility.typeaheadfind.flashBar");
|
2014-05-01 04:01:14 -07:00
|
|
|
this._matchesCountTimeoutLength =
|
|
|
|
prefsvc.getIntPref("accessibility.typeaheadfind.matchesCountTimeout");
|
|
|
|
this._matchesCountLimit =
|
|
|
|
prefsvc.getIntPref("accessibility.typeaheadfind.matchesCountLimit");
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
prefsvc.addObserver("accessibility.typeaheadfind",
|
|
|
|
this._observer, false);
|
|
|
|
prefsvc.addObserver("accessibility.typeaheadfind.linksonly",
|
|
|
|
this._observer, false);
|
|
|
|
prefsvc.addObserver("accessibility.typeaheadfind.casesensitive",
|
|
|
|
this._observer, false);
|
|
|
|
|
|
|
|
this._useTypeAheadFind =
|
|
|
|
prefsvc.getBoolPref("accessibility.typeaheadfind");
|
|
|
|
this._typeAheadLinksOnly =
|
|
|
|
prefsvc.getBoolPref("accessibility.typeaheadfind.linksonly");
|
|
|
|
this._typeAheadCaseSensitive =
|
|
|
|
prefsvc.getIntPref("accessibility.typeaheadfind.casesensitive");
|
|
|
|
|
|
|
|
// Convenience
|
|
|
|
this.nsITypeAheadFind = Components.interfaces.nsITypeAheadFind;
|
|
|
|
this.nsISelectionController = Components.interfaces.nsISelectionController;
|
2009-04-06 09:02:32 -07:00
|
|
|
this._findSelection = this.nsISelectionController.SELECTION_FIND;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-01 22:52:05 -07:00
|
|
|
this._findResetTimeout = -1;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Make sure the FAYT keypress listener is attached by initializing the
|
|
|
|
// browser property
|
2011-02-15 04:47:32 -08:00
|
|
|
if (this.getAttribute("browserid"))
|
|
|
|
setTimeout(function(aSelf) { aSelf.browser = aSelf.browser; }, 0, this);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></constructor>
|
|
|
|
|
|
|
|
<destructor><![CDATA[
|
2009-07-13 04:34:22 -07:00
|
|
|
this.destroy();
|
|
|
|
]]></destructor>
|
2009-04-06 09:02:32 -07:00
|
|
|
|
2009-07-13 04:34:22 -07:00
|
|
|
<!-- This is necessary because the destructor isn't called when
|
|
|
|
we are removed from a document that is not destroyed. This
|
|
|
|
needs to be explicitly called in this case -->
|
|
|
|
<method name="destroy">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._destroyed)
|
|
|
|
return;
|
|
|
|
this._destroyed = true;
|
|
|
|
|
|
|
|
this.browser = null;
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
let prefsvc =
|
2009-07-13 04:34:22 -07:00
|
|
|
Components.classes["@mozilla.org/preferences-service;1"]
|
2012-01-16 17:18:29 -08:00
|
|
|
.getService(Components.interfaces.nsIPrefBranch);
|
2009-07-13 04:34:22 -07:00
|
|
|
prefsvc.removeObserver("accessibility.typeaheadfind",
|
|
|
|
this._observer);
|
|
|
|
prefsvc.removeObserver("accessibility.typeaheadfind.linksonly",
|
|
|
|
this._observer);
|
|
|
|
prefsvc.removeObserver("accessibility.typeaheadfind.casesensitive",
|
|
|
|
this._observer);
|
2013-08-29 06:44:36 -07:00
|
|
|
|
|
|
|
// Clear all timers that might still be running.
|
|
|
|
this._cancelTimers();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_cancelTimers">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._flashFindBarTimeout) {
|
|
|
|
clearInterval(this._flashFindBarTimeout);
|
|
|
|
this._flashFindBarTimeout = null;
|
|
|
|
}
|
|
|
|
if (this._quickFindTimeout) {
|
|
|
|
clearTimeout(this._quickFindTimeout);
|
|
|
|
this._quickFindTimeout = null;
|
|
|
|
}
|
|
|
|
if (this._highlightTimeout) {
|
|
|
|
clearTimeout(this._highlightTimeout);
|
|
|
|
this._highlightTimeout = null;
|
|
|
|
}
|
|
|
|
if (this._findResetTimeout) {
|
|
|
|
clearTimeout(this._findResetTimeout);
|
|
|
|
this._findResetTimeout = null;
|
|
|
|
}
|
2014-05-01 04:01:14 -07:00
|
|
|
if (this._updateMatchesCountTimeout) {
|
|
|
|
clearTimeout(this._updateMatchesCountTimeout);
|
|
|
|
this._updateMatchesCountTimeout = null;
|
|
|
|
}
|
2009-07-13 04:34:22 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
<method name="_setFindCloseTimeout">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._quickFindTimeout)
|
|
|
|
clearTimeout(this._quickFindTimeout);
|
|
|
|
|
2014-02-17 06:42:59 -08:00
|
|
|
// Don't close the find toolbar while IME is composing OR when the
|
|
|
|
// findbar is already hidden.
|
|
|
|
if (this._isIMEComposing || this.hidden) {
|
2007-03-22 10:30:00 -07:00
|
|
|
this._quickFindTimeout = null;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-02-17 06:42:59 -08:00
|
|
|
this._quickFindTimeout = setTimeout(() => {
|
|
|
|
if (this._findMode != this.FIND_NORMAL)
|
|
|
|
this.close();
|
|
|
|
this._quickFindTimeout = null;
|
|
|
|
}, this._quickFindTimeoutLength);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2014-05-01 04:01:14 -07:00
|
|
|
<field name="_pluralForm">null</field>
|
|
|
|
<property name="pluralForm">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (!this._pluralForm) {
|
|
|
|
this._pluralForm = Components.utils.import(
|
|
|
|
"resource://gre/modules/PluralForm.jsm", {}).PluralForm;
|
|
|
|
}
|
|
|
|
return this._pluralForm;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
- Updates the search match count after each find operation on a new string.
|
|
|
|
- @param aRes
|
|
|
|
- the result of the find operation
|
|
|
|
-->
|
|
|
|
<method name="_updateMatchesCount">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._matchesCountLimit == 0 || !this._dispatchFindEvent("matchescount"))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this._updateMatchesCountTimeout) {
|
|
|
|
window.clearTimeout(this._updateMatchesCountTimeout);
|
|
|
|
}
|
|
|
|
this._updateMatchesCountTimeout =
|
2014-09-18 01:23:00 -07:00
|
|
|
window.setTimeout(() => {
|
|
|
|
this.browser.finder.requestMatchesCount(this._findField.value, this._matchesCountLimit,
|
|
|
|
this._findMode == this.FIND_LINKS);
|
|
|
|
}, this._matchesCountTimeoutLength);
|
2014-05-01 04:01:14 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<!--
|
|
|
|
- Turns highlight on or off.
|
|
|
|
- @param aHighlight (boolean)
|
2008-07-30 13:48:56 -07:00
|
|
|
- Whether to turn the highlight on or off
|
2007-03-22 10:30:00 -07:00
|
|
|
-->
|
|
|
|
<method name="toggleHighlight">
|
|
|
|
<parameter name="aHighlight"/>
|
|
|
|
<body><![CDATA[
|
2012-10-04 16:53:49 -07:00
|
|
|
if (!this._dispatchFindEvent("highlightallchange"))
|
|
|
|
return;
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
let word = this._findField.value;
|
2009-04-06 09:02:32 -07:00
|
|
|
// Bug 429723. Don't attempt to highlight ""
|
|
|
|
if (aHighlight && !word)
|
2008-09-25 09:27:52 -07:00
|
|
|
return;
|
2009-04-06 09:02:32 -07:00
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
this.browser._lastSearchHighlight = aHighlight;
|
|
|
|
this.browser.finder.highlight(aHighlight, word);
|
2014-05-01 04:01:14 -07:00
|
|
|
|
|
|
|
// Update the matches count
|
|
|
|
this._updateMatchesCount(this.nsITypeAheadFind.FIND_FOUND);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
- Updates the case-sensitivity mode of the findbar and its UI.
|
|
|
|
- @param [optional] aString
|
|
|
|
- The string for which case sensitivity might be turned on.
|
|
|
|
- This only used when case-sensitivity is in auto mode,
|
|
|
|
- @see _shouldBeCaseSensitive. The default value for this
|
|
|
|
- parameter is the find-field value.
|
|
|
|
-->
|
|
|
|
<method name="_updateCaseSensitivity">
|
|
|
|
<parameter name="aString"/>
|
|
|
|
<body><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let val = aString || this._findField.value;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
let caseSensitive = this._shouldBeCaseSensitive(val);
|
|
|
|
let checkbox = this.getElement("find-case-sensitive");
|
|
|
|
let statusLabel = this.getElement("match-case-status");
|
2007-03-22 10:30:00 -07:00
|
|
|
checkbox.checked = caseSensitive;
|
|
|
|
|
|
|
|
statusLabel.value = caseSensitive ? this._caseSensitiveStr : "";
|
|
|
|
|
|
|
|
// Show the checkbox on the full Find bar in non-auto mode.
|
|
|
|
// Show the label in all other cases.
|
2013-09-13 07:41:23 -07:00
|
|
|
let hideCheckbox = this._findMode != this.FIND_NORMAL ||
|
2007-03-22 10:30:00 -07:00
|
|
|
(this._typeAheadCaseSensitive != 0 &&
|
|
|
|
this._typeAheadCaseSensitive != 1);
|
|
|
|
checkbox.hidden = hideCheckbox;
|
|
|
|
statusLabel.hidden = !hideCheckbox;
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
this.browser.finder.caseSensitive = caseSensitive;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
- Sets the findbar case-sensitivity mode
|
2014-09-04 03:29:00 -07:00
|
|
|
- @param aCaseSensitivity (int)
|
|
|
|
- 0 - case insensitive
|
|
|
|
- 1 - case sensitive
|
|
|
|
- 2 - auto = case sensitive iff match string contains upper case letters
|
|
|
|
- @see _shouldBeCaseSensitive
|
2007-03-22 10:30:00 -07:00
|
|
|
-->
|
|
|
|
<method name="_setCaseSensitivity">
|
2014-09-04 03:29:00 -07:00
|
|
|
<parameter name="aCaseSensitivity"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<body><![CDATA[
|
2014-09-04 03:29:00 -07:00
|
|
|
this._typeAheadCaseSensitive = aCaseSensitivity;
|
|
|
|
this._updateCaseSensitivity();
|
2014-10-02 08:23:00 -07:00
|
|
|
this._findFailedString = null;
|
|
|
|
this._find();
|
2014-09-04 03:29:00 -07:00
|
|
|
if (this.getElement("highlight").checked)
|
|
|
|
this._setHighlightTimeout();
|
2012-10-04 16:53:49 -07:00
|
|
|
|
|
|
|
this._dispatchFindEvent("casesensitivitychange");
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2014-05-01 04:01:14 -07:00
|
|
|
<field name="_strBundle">null</field>
|
|
|
|
<property name="strBundle">
|
|
|
|
<getter><![CDATA[
|
|
|
|
if (!this._strBundle) {
|
|
|
|
this._strBundle =
|
|
|
|
Components.classes["@mozilla.org/intl/stringbundle;1"]
|
|
|
|
.getService(Components.interfaces.nsIStringBundleService)
|
|
|
|
.createBundle("chrome://global/locale/findbar.properties");
|
|
|
|
}
|
|
|
|
return this._strBundle;
|
|
|
|
]]></getter>
|
|
|
|
</property>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<!--
|
|
|
|
- Opens and displays the find bar.
|
|
|
|
-
|
|
|
|
- @param aMode
|
|
|
|
- the find mode to be used, which is either FIND_NORMAL,
|
|
|
|
- FIND_TYPEAHEAD or FIND_LINKS. If not passed, the last
|
|
|
|
- find mode if any or FIND_NORMAL.
|
|
|
|
- @returns true if the find bar wasn't previously open, false otherwise.
|
|
|
|
-->
|
|
|
|
<method name="open">
|
|
|
|
<parameter name="aMode"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aMode != undefined)
|
|
|
|
this._findMode = aMode;
|
|
|
|
|
|
|
|
if (!this._notFoundStr) {
|
2014-05-01 04:01:14 -07:00
|
|
|
var stringsBundle = this.strBundle;
|
2007-03-22 10:30:00 -07:00
|
|
|
this._notFoundStr = stringsBundle.GetStringFromName("NotFound");
|
|
|
|
this._wrappedToTopStr =
|
|
|
|
stringsBundle.GetStringFromName("WrappedToTop");
|
|
|
|
this._wrappedToBottomStr =
|
|
|
|
stringsBundle.GetStringFromName("WrappedToBottom");
|
|
|
|
this._normalFindStr =
|
2013-07-08 11:48:12 -07:00
|
|
|
stringsBundle.GetStringFromName("NormalFind");
|
2007-03-22 10:30:00 -07:00
|
|
|
this._fastFindStr =
|
2013-07-08 11:48:12 -07:00
|
|
|
stringsBundle.GetStringFromName("FastFind");
|
2007-03-22 10:30:00 -07:00
|
|
|
this._fastFindLinksStr =
|
2013-07-08 11:48:12 -07:00
|
|
|
stringsBundle.GetStringFromName("FastFindLinks");
|
2007-03-22 10:30:00 -07:00
|
|
|
this._caseSensitiveStr =
|
|
|
|
stringsBundle.GetStringFromName("CaseSensitive");
|
|
|
|
}
|
|
|
|
|
2009-09-01 22:52:05 -07:00
|
|
|
this._findFailedString = null;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
this._updateFindUI();
|
|
|
|
if (this.hidden) {
|
|
|
|
this.hidden = false;
|
|
|
|
|
|
|
|
this._updateStatusUI(this.nsITypeAheadFind.FIND_FOUND);
|
2011-03-02 16:48:58 -08:00
|
|
|
|
|
|
|
let event = document.createEvent("Events");
|
|
|
|
event.initEvent("findbaropen", true, false);
|
|
|
|
this.dispatchEvent(event);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
- Closes the findbar.
|
|
|
|
-->
|
|
|
|
<method name="close">
|
|
|
|
<body><![CDATA[
|
2011-02-11 16:11:24 -08:00
|
|
|
if (this.hidden)
|
|
|
|
return;
|
|
|
|
|
2013-09-13 08:41:47 -07:00
|
|
|
this.hidden = true;
|
2013-09-13 07:41:23 -07:00
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
this.browser.finder.focusContent();
|
2013-10-15 17:02:23 -07:00
|
|
|
this.browser.finder.enableSelection();
|
2013-09-13 07:41:23 -07:00
|
|
|
this._findField.blur();
|
|
|
|
|
2013-08-29 06:44:36 -07:00
|
|
|
this._cancelTimers();
|
2009-09-26 08:51:21 -07:00
|
|
|
|
|
|
|
this._findFailedString = null;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2012-10-22 04:42:53 -07:00
|
|
|
<method name="clear">
|
|
|
|
<body><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
this.browser.finder.removeSelection();
|
2012-10-22 04:42:53 -07:00
|
|
|
this._findField.reset();
|
|
|
|
this.toggleHighlight(false);
|
|
|
|
this._updateStatusUI();
|
|
|
|
this._enableFindButtons(false);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<method name="_dispatchKeypressEvent">
|
|
|
|
<parameter name="aTarget"/>
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (!aTarget)
|
|
|
|
return;
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
let event = document.createEvent("KeyEvents");
|
2007-03-22 10:30:00 -07:00
|
|
|
event.initKeyEvent(aEvent.type, aEvent.bubbles, aEvent.cancelable,
|
|
|
|
aEvent.view, aEvent.ctrlKey, aEvent.altKey,
|
|
|
|
aEvent.shiftKey, aEvent.metaKey, aEvent.keyCode,
|
|
|
|
aEvent.charCode);
|
|
|
|
aTarget.dispatchEvent(event);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<field name="_xulBrowserWindow">null</field>
|
|
|
|
<method name="_updateStatusUIBar">
|
2013-09-13 07:41:23 -07:00
|
|
|
<parameter name="aFoundURL"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
<body><![CDATA[
|
|
|
|
if (!this._xulBrowserWindow) {
|
|
|
|
try {
|
|
|
|
this._xulBrowserWindow =
|
|
|
|
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Components.interfaces.nsIWebNavigation)
|
|
|
|
.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
|
|
|
|
.treeOwner
|
|
|
|
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Components.interfaces.nsIXULWindow)
|
|
|
|
.XULBrowserWindow;
|
|
|
|
}
|
|
|
|
catch(ex) { }
|
|
|
|
if (!this._xulBrowserWindow)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
// Call this has the same effect like hovering over link,
|
|
|
|
// the browser shows the URL as a tooltip.
|
|
|
|
this._xulBrowserWindow.setOverLink(aFoundURL || "", null);
|
2007-03-22 10:30:00 -07:00
|
|
|
return true;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_finishFAYT">
|
|
|
|
<parameter name="aKeypressEvent"/>
|
|
|
|
<body><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
this.browser.finder.focusContent();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (aKeypressEvent)
|
|
|
|
aKeypressEvent.preventDefault();
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
this.browser.finder.keyPress(aKeypressEvent);
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
this.close();
|
|
|
|
return true;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-08-25 21:17:32 -07:00
|
|
|
<!--
|
|
|
|
- Returns true if |aMimeType| is text-based, or false otherwise.
|
|
|
|
-
|
|
|
|
- @param aMimeType
|
|
|
|
- The MIME type to check.
|
2008-03-06 12:12:09 -08:00
|
|
|
-
|
|
|
|
- if adding types to this function, please see the similar function
|
|
|
|
- in browser/base/content/browser.js
|
2007-08-25 21:17:32 -07:00
|
|
|
-->
|
|
|
|
<method name="_mimeTypeIsTextBased">
|
|
|
|
<parameter name="aMimeType"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
return /^text\/|\+xml$/.test(aMimeType) ||
|
|
|
|
aMimeType == "application/x-javascript" ||
|
2008-03-06 12:12:09 -08:00
|
|
|
aMimeType == "application/javascript" ||
|
2013-06-13 18:28:23 -07:00
|
|
|
aMimeType == "application/json" ||
|
2007-08-25 21:17:32 -07:00
|
|
|
aMimeType == "application/xml";
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<!--
|
|
|
|
- Returns whether FAYT can be used for the given event in
|
|
|
|
- the current content state.
|
|
|
|
-->
|
|
|
|
<method name="_shouldFastFind">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aEvent.ctrlKey || aEvent.altKey || aEvent.metaKey ||
|
2011-12-08 01:21:32 -08:00
|
|
|
aEvent.defaultPrevented)
|
2007-03-22 10:30:00 -07:00
|
|
|
return false;
|
|
|
|
|
2014-03-14 11:47:46 -07:00
|
|
|
let {BrowserUtils} = Components.utils.import("resource://gre/modules/BrowserUtils.jsm", {});
|
|
|
|
let [elt, win] = BrowserUtils.getFocusSync(document);
|
2013-09-19 09:37:37 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (elt) {
|
2010-08-04 19:40:18 -07:00
|
|
|
if (elt instanceof HTMLInputElement && elt.mozIsTextField(false))
|
2010-06-15 14:42:36 -07:00
|
|
|
return false;
|
|
|
|
|
2014-04-07 02:02:31 -07:00
|
|
|
if (elt.isContentEditable)
|
|
|
|
return false;
|
|
|
|
|
2010-06-15 14:42:36 -07:00
|
|
|
if (elt instanceof HTMLTextAreaElement ||
|
|
|
|
elt instanceof HTMLSelectElement ||
|
|
|
|
elt instanceof HTMLObjectElement ||
|
|
|
|
elt instanceof HTMLEmbedElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-06-15 14:42:36 -07:00
|
|
|
if (win && !this._mimeTypeIsTextBased(win.document.contentType))
|
|
|
|
return false;
|
|
|
|
|
2011-01-11 13:33:51 -08:00
|
|
|
// disable FAYT in about:blank to prevent FAYT opening unexpectedly.
|
2013-09-13 07:41:23 -07:00
|
|
|
let url = this.browser.currentURI;
|
2011-01-11 13:33:51 -08:00
|
|
|
if (url.spec == "about:blank")
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// disable FAYT in documents that ask for it to be disabled.
|
|
|
|
if ((url.schemeIs("about") || url.schemeIs("chrome")) &&
|
|
|
|
(win.document.documentElement &&
|
|
|
|
win.document.documentElement.getAttribute("disablefastfind") == "true"))
|
2007-03-22 10:30:00 -07:00
|
|
|
return false;
|
|
|
|
|
|
|
|
if (win) {
|
|
|
|
try {
|
2013-09-13 07:41:23 -07:00
|
|
|
let editingSession = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
2007-03-22 10:30:00 -07:00
|
|
|
.getInterface(Components.interfaces.nsIWebNavigation)
|
|
|
|
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
|
|
|
.getInterface(Components.interfaces.nsIEditingSession);
|
|
|
|
if (editingSession.windowIsEditable(win))
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
catch (e) {
|
|
|
|
// If someone built with composer disabled, we can't get an editing session.
|
|
|
|
}
|
2009-10-01 04:03:22 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
return true;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_shouldBeCaseSensitive">
|
|
|
|
<parameter name="aString"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._typeAheadCaseSensitive == 0)
|
|
|
|
return false;
|
|
|
|
if (this._typeAheadCaseSensitive == 1)
|
|
|
|
return true;
|
|
|
|
|
|
|
|
return aString != aString.toLowerCase();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_onBrowserKeypress">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
const TAF_LINKS_KEY = "'";
|
|
|
|
const TAF_TEXT_KEY = "/";
|
|
|
|
|
|
|
|
if (!this._shouldFastFind(aEvent))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (this._findMode != this.FIND_NORMAL && this._quickFindTimeout) {
|
|
|
|
if (!aEvent.charCode)
|
|
|
|
return;
|
|
|
|
|
|
|
|
this._findField.select();
|
|
|
|
this._findField.focus();
|
|
|
|
this._dispatchKeypressEvent(this._findField.inputField, aEvent);
|
|
|
|
aEvent.preventDefault();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
let key = aEvent.charCode ? String.fromCharCode(aEvent.charCode) : null;
|
|
|
|
let manualstartFAYT = (key == TAF_LINKS_KEY || key == TAF_TEXT_KEY);
|
|
|
|
let autostartFAYT = !manualstartFAYT && this._useTypeAheadFind &&
|
2007-03-22 10:30:00 -07:00
|
|
|
key && key != " ";
|
|
|
|
if (manualstartFAYT || autostartFAYT) {
|
2013-09-13 07:41:23 -07:00
|
|
|
let mode = (key == TAF_LINKS_KEY ||
|
2007-03-22 10:30:00 -07:00
|
|
|
(autostartFAYT && this._typeAheadLinksOnly)) ?
|
|
|
|
this.FIND_LINKS : this.FIND_TYPEAHEAD;
|
|
|
|
|
|
|
|
// Clear bar first, so that when openFindBar() calls setCaseSensitivity()
|
|
|
|
// it doesn't get confused by a lingering value
|
|
|
|
this._findField.value = "";
|
|
|
|
|
|
|
|
this.open(mode);
|
|
|
|
this._setFindCloseTimeout();
|
|
|
|
this._findField.select();
|
|
|
|
this._findField.focus();
|
|
|
|
|
|
|
|
if (autostartFAYT)
|
|
|
|
this._dispatchKeypressEvent(this._findField.inputField, aEvent);
|
|
|
|
else
|
|
|
|
this._updateStatusUI(this.nsITypeAheadFind.FIND_FOUND);
|
|
|
|
|
|
|
|
aEvent.preventDefault();
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!-- See nsIDOMEventListener -->
|
|
|
|
<method name="handleEvent">
|
|
|
|
<parameter name="aEvent"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
switch (aEvent.type) {
|
|
|
|
case "mouseup":
|
|
|
|
if (!this.hidden && this._findMode != this.FIND_NORMAL)
|
|
|
|
this.close();
|
|
|
|
|
|
|
|
break;
|
|
|
|
case "keypress":
|
|
|
|
this._onBrowserKeypress(aEvent);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_enableFindButtons">
|
|
|
|
<parameter name="aEnable"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
this.getElement("find-next").disabled =
|
2013-07-08 11:48:12 -07:00
|
|
|
this.getElement("find-previous").disabled = !aEnable;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
- Determines whether minimalist or general-purpose search UI is to be
|
|
|
|
- displayed when the find bar is activated.
|
|
|
|
-->
|
|
|
|
<method name="_updateFindUI">
|
|
|
|
<body><![CDATA[
|
2013-07-08 11:48:12 -07:00
|
|
|
let showMinimalUI = this._findMode != this.FIND_NORMAL;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-08 11:48:12 -07:00
|
|
|
let nodes = this.getElement("findbar-container").childNodes;
|
|
|
|
let wrapper = this.getElement("findbar-textbox-wrapper");
|
|
|
|
for (let node of nodes) {
|
|
|
|
if (node == wrapper)
|
2007-03-22 10:30:00 -07:00
|
|
|
continue;
|
2013-07-08 11:48:12 -07:00
|
|
|
node.hidden = showMinimalUI;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-07-08 11:48:12 -07:00
|
|
|
this.getElement("find-next").hidden =
|
|
|
|
this.getElement("find-previous").hidden = showMinimalUI;
|
2007-05-12 23:27:11 -07:00
|
|
|
this._updateCaseSensitivity();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-07-08 11:48:12 -07:00
|
|
|
if (showMinimalUI)
|
|
|
|
this._findField.classList.add("minimal");
|
|
|
|
else
|
|
|
|
this._findField.classList.remove("minimal");
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
if (this._findMode == this.FIND_TYPEAHEAD)
|
2013-07-08 11:48:12 -07:00
|
|
|
this._findField.placeholder = this._fastFindStr;
|
2007-03-22 10:30:00 -07:00
|
|
|
else if (this._findMode == this.FIND_LINKS)
|
2013-07-08 11:48:12 -07:00
|
|
|
this._findField.placeholder = this._fastFindLinksStr;
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
2013-07-08 11:48:12 -07:00
|
|
|
this._findField.placeholder = this._normalFindStr;
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_find">
|
|
|
|
<parameter name="aValue"/>
|
|
|
|
<body><![CDATA[
|
2012-10-04 16:53:49 -07:00
|
|
|
if (!this._dispatchFindEvent(""))
|
2013-09-13 07:41:23 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
let val = aValue || this._findField.value;
|
2012-10-04 16:53:49 -07:00
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
// We have to carry around an explicit version of this,
|
|
|
|
// because finder.searchString doesn't update on failed
|
|
|
|
// searches.
|
|
|
|
this.browser._lastSearchString = val;
|
2009-09-01 22:52:05 -07:00
|
|
|
|
|
|
|
// Only search on input if we don't have a last-failed string,
|
|
|
|
// or if the current search string doesn't start with it.
|
2013-11-08 09:35:28 -08:00
|
|
|
if (!this._findFailedString ||
|
2013-09-13 07:41:23 -07:00
|
|
|
!val.startsWith(this._findFailedString))
|
2009-09-01 22:52:05 -07:00
|
|
|
{
|
|
|
|
this._enableFindButtons(val);
|
|
|
|
if (this.getElement("highlight").checked)
|
|
|
|
this._setHighlightTimeout();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2009-09-01 22:52:05 -07:00
|
|
|
this._updateCaseSensitivity(val);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-09-26 08:21:02 -07:00
|
|
|
this.browser.finder.fastFind(val, this._findMode == this.FIND_LINKS,
|
|
|
|
this._findMode != this.FIND_NORMAL);
|
2009-09-01 22:52:05 -07:00
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (this._findMode != this.FIND_NORMAL)
|
|
|
|
this._setFindCloseTimeout();
|
|
|
|
|
2009-09-01 22:52:05 -07:00
|
|
|
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
|
2013-09-13 07:41:23 -07:00
|
|
|
this._findResetTimeout = setTimeout(() => {
|
|
|
|
this._findFailedString = null;
|
|
|
|
this._findResetTimeout = -1;
|
|
|
|
}, 1000);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_flash">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._flashFindBarCount === undefined)
|
|
|
|
this._flashFindBarCount = this._initialFlashFindBarCount;
|
|
|
|
|
|
|
|
if (this._flashFindBarCount-- == 0) {
|
|
|
|
clearInterval(this._flashFindBarTimeout);
|
|
|
|
this.removeAttribute("flash");
|
|
|
|
this._flashFindBarCount = 6;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setAttribute("flash",
|
|
|
|
(this._flashFindBarCount % 2 == 0) ?
|
|
|
|
"false" : "true");
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_setHighlightTimeout">
|
|
|
|
<body><![CDATA[
|
|
|
|
if (this._highlightTimeout)
|
|
|
|
clearTimeout(this._highlightTimeout);
|
|
|
|
this._highlightTimeout =
|
|
|
|
setTimeout(function(aSelf) {
|
|
|
|
aSelf.toggleHighlight(false);
|
|
|
|
aSelf.toggleHighlight(true);
|
|
|
|
}, 500, this);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_findAgain">
|
|
|
|
<parameter name="aFindPrevious"/>
|
|
|
|
<body><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
this.browser.finder.findAgain(aFindPrevious,
|
2013-09-26 08:21:02 -07:00
|
|
|
this._findMode == this.FIND_LINKS,
|
|
|
|
this._findMode != this.FIND_NORMAL);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_updateStatusUI">
|
|
|
|
<parameter name="res"/>
|
|
|
|
<parameter name="aFindPrevious"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
switch (res) {
|
|
|
|
case this.nsITypeAheadFind.FIND_WRAPPED:
|
|
|
|
this._findStatusIcon.setAttribute("status", "wrapped");
|
2007-09-17 13:49:21 -07:00
|
|
|
this._findStatusDesc.textContent =
|
2007-03-22 10:30:00 -07:00
|
|
|
aFindPrevious ? this._wrappedToBottomStr : this._wrappedToTopStr;
|
|
|
|
this._findField.removeAttribute("status");
|
|
|
|
break;
|
|
|
|
case this.nsITypeAheadFind.FIND_NOTFOUND:
|
|
|
|
this._findStatusIcon.setAttribute("status", "notfound");
|
2007-09-17 13:49:21 -07:00
|
|
|
this._findStatusDesc.textContent = this._notFoundStr;
|
2007-03-22 10:30:00 -07:00
|
|
|
this._findField.setAttribute("status", "notfound");
|
|
|
|
break;
|
2012-10-04 16:53:49 -07:00
|
|
|
case this.nsITypeAheadFind.FIND_PENDING:
|
|
|
|
this._findStatusIcon.setAttribute("status", "pending");
|
|
|
|
this._findStatusDesc.textContent = "";
|
|
|
|
this._findField.removeAttribute("status");
|
|
|
|
break;
|
2007-03-22 10:30:00 -07:00
|
|
|
case this.nsITypeAheadFind.FIND_FOUND:
|
|
|
|
default:
|
|
|
|
this._findStatusIcon.removeAttribute("status");
|
2007-09-17 13:49:21 -07:00
|
|
|
this._findStatusDesc.textContent = "";
|
2007-03-22 10:30:00 -07:00
|
|
|
this._findField.removeAttribute("status");
|
|
|
|
break;
|
|
|
|
}
|
2014-05-01 04:01:14 -07:00
|
|
|
this._updateMatchesCount(res);
|
2007-03-22 10:30:00 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2012-10-04 16:53:49 -07:00
|
|
|
<method name="updateControlState">
|
|
|
|
<parameter name="aResult"/>
|
|
|
|
<parameter name="aFindPrevious"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
this._updateStatusUI(aResult, aFindPrevious);
|
|
|
|
this._enableFindButtons(aResult !== this.nsITypeAheadFind.FIND_NOTFOUND);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<method name="_getInitialSelection">
|
|
|
|
<body><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let focusedElement = document.commandDispatcher.focusedElement;
|
|
|
|
let selText;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
if (focusedElement instanceof Components.interfaces.nsIDOMNSEditableElement &&
|
2008-07-08 08:26:54 -07:00
|
|
|
focusedElement.editor &&
|
|
|
|
focusedElement.ownerDocument.defaultView.top == this._browser.contentWindow)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
// The user may have a selection in an input or textarea
|
|
|
|
selText = focusedElement.editor.selectionController
|
|
|
|
.getSelection(Components.interfaces.nsISelectionController.SELECTION_NORMAL)
|
|
|
|
.toString();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
// Look for any selected text on the actual page
|
2013-09-13 07:41:23 -07:00
|
|
|
let focusedWindow = document.commandDispatcher.focusedWindow;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (focusedWindow.top == this._browser.contentWindow)
|
|
|
|
selText = focusedWindow.getSelection().toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!selText)
|
|
|
|
return "";
|
|
|
|
|
|
|
|
// Process our text to get rid of unwanted characters
|
|
|
|
if (selText.length > this._selectionMaxLen) {
|
2013-09-13 07:41:23 -07:00
|
|
|
let pattern = new RegExp("^(?:\\s*.){0," + this._selectionMaxLen + "}");
|
2007-03-22 10:30:00 -07:00
|
|
|
pattern.test(selText);
|
|
|
|
selText = RegExp.lastMatch;
|
|
|
|
}
|
|
|
|
return selText.replace(/^\s+/, "")
|
|
|
|
.replace(/\s+$/, "")
|
|
|
|
.replace(/\s+/g, " ")
|
|
|
|
.substr(0, this._selectionMaxLen);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2012-10-04 16:53:49 -07:00
|
|
|
<method name="_dispatchFindEvent">
|
|
|
|
<parameter name="aType"/>
|
|
|
|
<parameter name="aFindPrevious"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
let event = document.createEvent("CustomEvent");
|
|
|
|
event.initCustomEvent("find" + aType, true, true, {
|
|
|
|
query: this._findField.value,
|
|
|
|
caseSensitive: !!this._typeAheadCaseSensitive,
|
|
|
|
highlightAll: this.getElement("highlight").checked,
|
|
|
|
findPrevious: aFindPrevious
|
|
|
|
});
|
|
|
|
return this.dispatchEvent(event);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
<!--
|
|
|
|
- Opens the findbar, focuses the findfield and selects its contents.
|
|
|
|
- Also flashes the findbar the first time it's used.
|
|
|
|
- @param aMode
|
|
|
|
- the find mode to be used, which is either FIND_NORMAL,
|
|
|
|
- FIND_TYPEAHEAD or FIND_LINKS. If not passed, the last
|
|
|
|
- find mode if any or FIND_NORMAL.
|
|
|
|
-->
|
|
|
|
<method name="startFind">
|
|
|
|
<parameter name="aMode"/>
|
|
|
|
<body><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let prefsvc =
|
2007-03-22 10:30:00 -07:00
|
|
|
Components.classes["@mozilla.org/preferences-service;1"]
|
2012-01-16 17:18:29 -08:00
|
|
|
.getService(Components.interfaces.nsIPrefBranch);
|
2013-09-13 07:41:23 -07:00
|
|
|
let userWantsPrefill = true;
|
2007-03-22 10:30:00 -07:00
|
|
|
this.open(aMode);
|
|
|
|
|
|
|
|
if (this._flashFindBar) {
|
2013-09-13 07:41:23 -07:00
|
|
|
this._flashFindBarTimeout = setInterval(() => this._flash(), 500);
|
2007-03-22 10:30:00 -07:00
|
|
|
prefsvc.setIntPref("accessibility.typeaheadfind.flashBar",
|
|
|
|
--this._flashFindBar);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (this.prefillWithSelection)
|
2009-10-01 04:03:22 -07:00
|
|
|
userWantsPrefill =
|
2007-03-22 10:30:00 -07:00
|
|
|
prefsvc.getBoolPref("accessibility.typeaheadfind.prefillwithselection");
|
|
|
|
|
2014-02-28 07:07:32 -08:00
|
|
|
let initialString = null;
|
|
|
|
if (this.prefillWithSelection && userWantsPrefill)
|
|
|
|
initialString = this._getInitialSelection();
|
|
|
|
#ifdef XP_MACOSX
|
|
|
|
if (!initialString) {
|
|
|
|
let clipboardSearchString = this.browser.finder.clipboardSearchString;
|
|
|
|
if (clipboardSearchString)
|
|
|
|
initialString = clipboardSearchString;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2013-07-08 23:19:42 -07:00
|
|
|
if (initialString)
|
2007-03-22 10:30:00 -07:00
|
|
|
this._findField.value = initialString;
|
2013-07-08 23:19:42 -07:00
|
|
|
|
|
|
|
this._enableFindButtons(!!this._findField.value);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
this._findField.select();
|
|
|
|
this._findField.focus();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
- Convenient alias to startFind(gFindBar.FIND_NORMAL);
|
|
|
|
-
|
|
|
|
- You should generally map the window's find command to this method.
|
|
|
|
- e.g. <command name="cmd_find" oncommand="gFindBar.onFindCommand();"/>
|
|
|
|
-->
|
|
|
|
<method name="onFindCommand">
|
|
|
|
<body><![CDATA[
|
|
|
|
this.startFind(this.FIND_NORMAL);
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<!--
|
|
|
|
- Stub for find-next and find-previous commands
|
|
|
|
- @param aFindPrevious
|
|
|
|
- true for find-previous, false otherwise.
|
|
|
|
-->
|
|
|
|
<method name="onFindAgainCommand">
|
|
|
|
<parameter name="aFindPrevious"/>
|
|
|
|
<body><![CDATA[
|
2013-09-13 07:41:23 -07:00
|
|
|
let findString = this._browser.finder.searchString || this._findField.value;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (!findString) {
|
|
|
|
this.startFind();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-10-04 16:53:49 -07:00
|
|
|
// We dispatch the findAgain event here instead of in _findAgain since
|
|
|
|
// if there is a find event handler that prevents the default then
|
2013-09-13 07:41:23 -07:00
|
|
|
// finder.searchString will never get updated which in turn means
|
2012-10-04 16:53:49 -07:00
|
|
|
// there would never be findAgain events because of the logic below.
|
|
|
|
if (!this._dispatchFindEvent("again", aFindPrevious))
|
|
|
|
return;
|
|
|
|
|
2009-09-01 22:52:05 -07:00
|
|
|
// user explicitly requested another search, so do it even if we think it'll fail
|
|
|
|
this._findFailedString = null;
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// Ensure the stored SearchString is in sync with what we want to find
|
2013-09-13 07:41:23 -07:00
|
|
|
if (this._findField.value != this._browser.finder.searchString)
|
|
|
|
this._find(this._findField.value);
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
2013-09-13 07:41:23 -07:00
|
|
|
this._findAgain(aFindPrevious);
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
]]></body>
|
|
|
|
</method>
|
2013-09-13 07:41:23 -07:00
|
|
|
|
2014-02-28 07:07:32 -08:00
|
|
|
#ifdef XP_MACOSX
|
|
|
|
<!--
|
|
|
|
- Fetches the currently selected text and sets that as the text to search
|
|
|
|
- next. This is a MacOS specific feature.
|
|
|
|
-->
|
|
|
|
<method name="onFindSelectionCommand">
|
|
|
|
<body><![CDATA[
|
|
|
|
let searchString = this.browser.finder.setSearchStringToSelection();
|
|
|
|
if (searchString)
|
|
|
|
this._findField.value = searchString;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
|
|
|
<method name="_onFindFieldFocus">
|
|
|
|
<body><![CDATA[
|
2014-05-06 09:21:16 -07:00
|
|
|
let prefsvc =
|
|
|
|
Components.classes["@mozilla.org/preferences-service;1"]
|
|
|
|
.getService(Components.interfaces.nsIPrefBranch);
|
|
|
|
const kPref = "accessibility.typeaheadfind.prefillwithselection";
|
|
|
|
if (this.prefillWithSelection && prefsvc.getBoolPref(kPref))
|
|
|
|
return;
|
|
|
|
|
2014-02-28 07:07:32 -08:00
|
|
|
let clipboardSearchString = this._browser.finder.clipboardSearchString;
|
|
|
|
if (clipboardSearchString && this._findField.value != clipboardSearchString) {
|
|
|
|
this._findField.value = clipboardSearchString;
|
|
|
|
// Changing the search string makes the previous status invalid, so
|
|
|
|
// we better clear it here.
|
|
|
|
this._updateStatusUI();
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
#endif
|
|
|
|
|
2013-09-13 07:41:23 -07:00
|
|
|
<!--
|
|
|
|
- This handles all the result changes for both
|
|
|
|
- type-ahead-find and highlighting.
|
|
|
|
- @param aResult
|
|
|
|
- One of the nsITypeAheadFind.FIND_* constants
|
|
|
|
- indicating the result of a search operation.
|
|
|
|
- @param aFindBackwards
|
|
|
|
- If the search was done from the bottom to
|
|
|
|
- the top. This is used for right error messages
|
|
|
|
- when reaching "the end of the page".
|
|
|
|
- @param aLinkURL
|
|
|
|
- When a link matched then its URK. Always null
|
|
|
|
- when not in FIND_LINKS mode.
|
|
|
|
-->
|
|
|
|
<method name="onFindResult">
|
2014-01-13 17:58:33 -08:00
|
|
|
<parameter name="aData"/>
|
2013-09-13 07:41:23 -07:00
|
|
|
<body><![CDATA[
|
2014-01-13 17:58:33 -08:00
|
|
|
this._updateStatusUI(aData.result, aData.findBackwards);
|
|
|
|
this._updateStatusUIBar(aData.linkURL);
|
2013-09-13 07:41:23 -07:00
|
|
|
|
2014-01-13 17:58:33 -08:00
|
|
|
if (aData.result == this.nsITypeAheadFind.FIND_NOTFOUND)
|
|
|
|
this._findFailedString = aData.searchString;
|
2013-09-13 07:41:23 -07:00
|
|
|
else
|
|
|
|
this._findFailedString = null;
|
|
|
|
|
2014-02-17 06:42:59 -08:00
|
|
|
if (this._findMode != this.FIND_NORMAL)
|
2013-09-13 07:41:23 -07:00
|
|
|
this._setFindCloseTimeout();
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2014-05-01 04:01:14 -07:00
|
|
|
<!--
|
|
|
|
- This handles all the result changes for matches counts.
|
|
|
|
- @param aResult
|
|
|
|
- Result Object, containing the total amount of matches and a vector
|
|
|
|
- of the current result.
|
|
|
|
-->
|
|
|
|
<method name="onMatchesCountResult">
|
|
|
|
<parameter name="aResult"/>
|
|
|
|
<body><![CDATA[
|
|
|
|
if (aResult.total !== 0) {
|
|
|
|
if (aResult.total == -1) {
|
|
|
|
this._foundMatches.value = this.pluralForm.get(
|
|
|
|
this._matchesCountLimit,
|
2014-05-02 02:11:08 -07:00
|
|
|
this.strBundle.GetStringFromName("FoundMatchesCountLimit")
|
2014-05-01 04:01:14 -07:00
|
|
|
).replace("#1", this._matchesCountLimit);
|
|
|
|
} else {
|
|
|
|
this._foundMatches.value = this.pluralForm.get(
|
|
|
|
aResult.total,
|
|
|
|
this.strBundle.GetStringFromName("FoundMatches")
|
|
|
|
).replace("#1", aResult.current)
|
|
|
|
.replace("#2", aResult.total);
|
|
|
|
}
|
|
|
|
this._foundMatches.hidden = false;
|
|
|
|
} else {
|
|
|
|
this._foundMatches.hidden = true;
|
|
|
|
this._foundMatches.value = "";
|
|
|
|
}
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2013-10-16 08:04:49 -07:00
|
|
|
<!--
|
|
|
|
- This handler may cancel a request to focus content by returning |false|
|
|
|
|
- explicitly.
|
|
|
|
-->
|
|
|
|
<method name="shouldFocusContent">
|
|
|
|
<body><![CDATA[
|
|
|
|
const fm = Components.classes["@mozilla.org/focus-manager;1"]
|
|
|
|
.getService(Components.interfaces.nsIFocusManager);
|
|
|
|
if (fm.focusedWindow != window)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
let focusedElement = fm.focusedElement;
|
|
|
|
if (!focusedElement)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
let bindingParent = document.getBindingParent(focusedElement);
|
|
|
|
if (bindingParent != this && bindingParent != this._findField)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
|
|
|
]]></body>
|
|
|
|
</method>
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
</implementation>
|
|
|
|
|
|
|
|
<handlers>
|
2014-01-09 02:59:58 -08:00
|
|
|
<!--
|
|
|
|
- We have to guard against `this.close` being |null| due to an unknown
|
|
|
|
- issue, which is tracked in bug 957999.
|
|
|
|
-->
|
|
|
|
<handler event="keypress" keycode="VK_ESCAPE" phase="capturing"
|
|
|
|
action="if (this.close) this.close();" preventdefault="true"/>
|
2007-03-22 10:30:00 -07:00
|
|
|
</handlers>
|
|
|
|
</binding>
|
|
|
|
</bindings>
|