Bug 97023 Default to Find toolbar instead of inline FAYT/Find dialog r+sr=Neil
This commit is contained in:
Родитель
7a00a508b9
Коммит
792f29037f
|
@ -107,6 +107,9 @@ pref("browser.download.progress.closeWhenDone", false);
|
|||
// feedback from their action.
|
||||
pref("browser.download.saveLinkAsFilenameTimeout", 1000);
|
||||
|
||||
// Use the findbar instead of the dialog box
|
||||
pref("browser.findbar.enabled", true);
|
||||
|
||||
// various default search settings
|
||||
pref("browser.search.defaulturl", "chrome://navigator-region/locale/region.properties");
|
||||
pref("browser.search.opensidebarsearchpanel", true);
|
||||
|
@ -319,6 +322,9 @@ pref("layout.spellcheckDefault", 1);
|
|||
pref("accessibility.blockautorefresh", false);
|
||||
|
||||
// special TypeAheadFind settings
|
||||
|
||||
// Use the findbar for type ahead find, instead of the XPFE implementation
|
||||
pref("accessibility.typeaheadfind.usefindbar", true);
|
||||
pref("accessibility.typeaheadfind.flashBar", 0);
|
||||
#ifndef XP_UNIX
|
||||
pref("accessibility.typeaheadfind.soundURL", "default");
|
||||
|
|
|
@ -85,6 +85,7 @@ function toggleAffectedChrome(aHide)
|
|||
// (*) tab browser ``strip''
|
||||
// (*) sidebar
|
||||
// (*) statusbar
|
||||
// (*) findbar
|
||||
|
||||
if (!gChromeState)
|
||||
gChromeState = new Object;
|
||||
|
@ -92,6 +93,7 @@ function toggleAffectedChrome(aHide)
|
|||
var statusbar = document.getElementById("status-bar");
|
||||
getNavToolbox().hidden = aHide;
|
||||
var notificationBox = gBrowser.getNotificationBox();
|
||||
var findbar = document.getElementById("FindToolbar")
|
||||
|
||||
// sidebar states map as follows:
|
||||
// was-hidden => hide/show nothing
|
||||
|
@ -123,6 +125,16 @@ function toggleAffectedChrome(aHide)
|
|||
// deal with the notification box
|
||||
gChromeState.notificationsWereHidden = notificationBox.notificationsHidden;
|
||||
notificationBox.notificationsHidden = true;
|
||||
|
||||
if (findbar)
|
||||
{
|
||||
gChromeState.findbarWasHidden = findbar.hidden;
|
||||
findbar.close();
|
||||
}
|
||||
else
|
||||
{
|
||||
gChromeState.findbarWasHidden = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -141,6 +153,9 @@ function toggleAffectedChrome(aHide)
|
|||
|
||||
// restore the notification box
|
||||
notificationBox.notificationsHidden = gChromeState.notificationsWereHidden;
|
||||
|
||||
if (!gChromeState.findbarWasHidden)
|
||||
findbar.open();
|
||||
}
|
||||
|
||||
// if we are unhiding and sidebar used to be there rebuild it
|
||||
|
|
|
@ -456,6 +456,7 @@
|
|||
taken care of by the builtin behavior inside the tabbrowser -->
|
||||
<vbox id="appcontent" flex="1"
|
||||
ondragdrop="nsDragAndDrop.drop(event, contentAreaDNDObserver);">
|
||||
<findbar id="FindToolbar" browserid="content"/>
|
||||
|
||||
<!-- this box is temporary, pending XBLified <browser> -->
|
||||
<hbox id="browser" flex="1">
|
||||
|
|
|
@ -2678,6 +2678,20 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<field name="_fastFind">null</field>
|
||||
<property name="fastFind" readonly="true">
|
||||
<getter>
|
||||
<![CDATA[
|
||||
if (!this._fastFind) {
|
||||
this._fastFind = Components.classes["@mozilla.org/typeaheadfind;1"]
|
||||
.createInstance(Components.interfaces.nsITypeAheadFind);
|
||||
this._fastFind.init(this.docShell);
|
||||
}
|
||||
return this._fastFind;
|
||||
]]>
|
||||
</getter>
|
||||
</property>
|
||||
|
||||
<constructor>
|
||||
<![CDATA[
|
||||
this.mCurrentBrowser = this.mPanelContainer.firstChild.firstChild;
|
||||
|
|
|
@ -0,0 +1,178 @@
|
|||
<?xml version="1.0"?>
|
||||
<!--
|
||||
SeaMonkey Flexible Findbar
|
||||
|
||||
The binding implemented here mostly works like its toolkit ancestor,
|
||||
except that it will not appear during a manually triggered type ahead find
|
||||
if accessibility.typeaheadfind.usefindbar is false, and the automatic
|
||||
typeahead find is controlled by the accessibility.typeaheadfind.autostart
|
||||
preference instead of the accessibility.typeaheadfind preference.
|
||||
|
||||
This allows the in status bar type ahead find to be used in place of the
|
||||
findbar implementation and allows the in status bar type ahead find
|
||||
to only need to cache the accessibility.typeaheadfind preference branch.
|
||||
-->
|
||||
|
||||
<!DOCTYPE bindings>
|
||||
|
||||
<bindings id="findbarBindings"
|
||||
xmlns="http://www.mozilla.org/xbl">
|
||||
|
||||
<binding id="findbar"
|
||||
extends="chrome://global/content/bindings/findbar.xml#findbar">
|
||||
<implementation>
|
||||
<constructor><![CDATA[
|
||||
var prefsvc =
|
||||
Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
|
||||
prefsvc.removeObserver("accessibility.typeaheadfind",
|
||||
this._observer);
|
||||
prefsvc.addObserver("accessibility.typeaheadfind.autostart",
|
||||
this._suiteObserver, false);
|
||||
prefsvc.addObserver("accessibility.typeaheadfind.usefindbar",
|
||||
this._suiteObserver, false);
|
||||
|
||||
this._useTypeAheadFind =
|
||||
prefsvc.getBoolPref("accessibility.typeaheadfind.autostart");
|
||||
this._useTypeAheadFindFindbar =
|
||||
prefsvc.getBoolPref("accessibility.typeaheadfind.usefindbar");
|
||||
]]></constructor>
|
||||
|
||||
<field name="_suiteObserver"><![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;
|
||||
|
||||
var prefsvc =
|
||||
aSubject.QueryInterface(Components.interfaces.nsIPrefBranch2);
|
||||
|
||||
switch (aPrefName) {
|
||||
case "accessibility.typeaheadfind.autostart":
|
||||
this._self._useTypeAheadFind = prefsvc.getBoolPref(aPrefName);
|
||||
break;
|
||||
case "accessibility.typeaheadfind.usefindbar":
|
||||
this._self._useTypeAheadFindFindbar = prefsvc.getBoolPref(aPrefName);
|
||||
break;
|
||||
}
|
||||
}
|
||||
})]]></field>
|
||||
|
||||
<!-- 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;
|
||||
|
||||
// It is possible that the findbar may be destroyed before any
|
||||
// documents it is listening to (see nsIEditActionListener code below).
|
||||
// Thus, to avoid leaking, if we are listening to any editors, unhook
|
||||
// ourselves now, and remove our cached copies
|
||||
if (this._editors) {
|
||||
for (var x = this._editors.length - 1; x >= 0; --x)
|
||||
this._unhookListenersAtIndex(x);
|
||||
}
|
||||
|
||||
this.browser = null;
|
||||
|
||||
var prefsvc =
|
||||
Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefBranch2);
|
||||
prefsvc.removeObserver("accessibility.typeaheadfind.linksonly",
|
||||
this._observer);
|
||||
prefsvc.removeObserver("accessibility.typeaheadfind.casesensitive",
|
||||
this._observer);
|
||||
prefsvc.removeObserver("accessibility.typeaheadfind.usefindbar",
|
||||
this._suiteObserver);
|
||||
prefsvc.removeObserver("accessibility.typeaheadfind.autostart",
|
||||
this._suiteObserver);
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<!--
|
||||
- Returns whether FAYT can be used for the given event in
|
||||
- the current content state.
|
||||
-->
|
||||
<method name="_shouldFastFind">
|
||||
<parameter name="aEvent"/>
|
||||
<body><![CDATA[
|
||||
if (!this._useTypeAheadFindFindbar || aEvent.ctrlKey ||
|
||||
aEvent.altKey || aEvent.metaKey || aEvent.getPreventDefault())
|
||||
return false;
|
||||
|
||||
var win = document.commandDispatcher.focusedWindow;
|
||||
if (win)
|
||||
if (!this._mimeTypeIsTextBased(win.document.contentType))
|
||||
return false;
|
||||
|
||||
var elt = document.commandDispatcher.focusedElement;
|
||||
if (elt) {
|
||||
if (elt instanceof NSHTMLInputElement && elt.mozIsTextField(false))
|
||||
return false;
|
||||
|
||||
if (elt instanceof HTMLTextAreaElement ||
|
||||
elt instanceof HTMLSelectElement ||
|
||||
elt instanceof HTMLIsIndexElement ||
|
||||
elt instanceof HTMLObjectElement ||
|
||||
elt instanceof HTMLEmbedElement)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (win) {
|
||||
try {
|
||||
var editingSession = win.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
|
||||
.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.
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
]]></body>
|
||||
</method>
|
||||
|
||||
<method name="startFastFind">
|
||||
<parameter name="aMode"/>
|
||||
<body><![CDATA[
|
||||
if (this._findMode == aMode && this._quickFindTimeout) {
|
||||
this._findField.select();
|
||||
this._findField.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear bar first, so that when openFindBar() calls setCaseSensitivity()
|
||||
// it doesn't get confused by a lingering value
|
||||
this._findField.value = "";
|
||||
|
||||
if (this._quickFindTimeout)
|
||||
clearTimeout(this._quickFindTimeout);
|
||||
this.open(aMode);
|
||||
this._setFindCloseTimeout();
|
||||
this._findField.select();
|
||||
this._findField.focus();
|
||||
|
||||
this._updateStatusUI(this.nsITypeAheadFind.FIND_FOUND);
|
||||
]]></body>
|
||||
</method>
|
||||
</implementation>
|
||||
</binding>
|
||||
</bindings>
|
|
@ -97,6 +97,10 @@ prefpane[xpfe="false"] {
|
|||
-moz-binding: url("chrome://global/content/bindings/preferences.xml#prefpane");
|
||||
}
|
||||
|
||||
findbar[xpfe="false"] {
|
||||
-moz-binding: url("chrome://global/content/bindings/findbar.xml#findbar");
|
||||
}
|
||||
|
||||
/******* SeaMonkey XPFE *******/
|
||||
/* These bindings reflect SeaMonkey XPFE, modulo new toolkit features. */
|
||||
toolbox {
|
||||
|
@ -131,6 +135,10 @@ prefpane {
|
|||
-moz-binding: url("chrome://communicator/content/bindings/general.xml#statusbarpanel-backgroundbox");
|
||||
}
|
||||
|
||||
findbar {
|
||||
-moz-binding: url("chrome://communicator/content/bindings/findbar.xml#findbar");
|
||||
}
|
||||
|
||||
/******* lightweight themes *******/
|
||||
window[lwtheme="true"] {
|
||||
background-repeat: no-repeat;
|
||||
|
|
|
@ -84,8 +84,10 @@ nsFindInstData.prototype =
|
|||
// currentSearchWindow is the frame to start searching (can be, and normally, rootSearchWindow)
|
||||
function findInPage(findInstData)
|
||||
{
|
||||
// is the dialog up already?
|
||||
if ("findDialog" in window && window.findDialog)
|
||||
var findbar = document.getElementById("FindToolbar");
|
||||
if (findbar && Services.prefs.getBoolPref("browser.findbar.enabled"))
|
||||
findbar.onFindCommand();
|
||||
else if ("findDialog" in window && window.findDialog) // is the find dialog up already?
|
||||
window.findDialog.focus();
|
||||
else
|
||||
{
|
||||
|
@ -96,46 +98,73 @@ function findInPage(findInstData)
|
|||
|
||||
function findAgainInPage(findInstData, reverse)
|
||||
{
|
||||
// get the find service, which stores global find state, and init the
|
||||
// nsIWebBrowser find with it. We don't assume that there was a previous
|
||||
// Find that set this up.
|
||||
var findService = Components.classes["@mozilla.org/find/find_service;1"]
|
||||
.getService(Components.interfaces.nsIFindService);
|
||||
var findbar = document.getElementById("FindToolbar");
|
||||
if (findbar && Services.prefs.getBoolPref("browser.findbar.enabled"))
|
||||
document.getElementById("FindToolbar").onFindAgainCommand(reverse);
|
||||
else
|
||||
{
|
||||
// get the find service, which stores global find state, and init the
|
||||
// nsIWebBrowser find with it. We don't assume that there was a previous
|
||||
// Find that set this up.
|
||||
var findService = Components.classes["@mozilla.org/find/find_service;1"]
|
||||
.getService(Components.interfaces.nsIFindService);
|
||||
|
||||
var searchString = findService.searchString;
|
||||
if (searchString.length == 0) {
|
||||
// no previous find text
|
||||
findInPage(findInstData);
|
||||
return;
|
||||
var searchString = findService.searchString;
|
||||
if (searchString.length == 0) {
|
||||
// no previous find text
|
||||
findInPage(findInstData);
|
||||
return;
|
||||
}
|
||||
|
||||
findInstData.init();
|
||||
var findInst = findInstData.webBrowserFind;
|
||||
findInst.searchString = searchString;
|
||||
findInst.matchCase = findService.matchCase;
|
||||
findInst.wrapFind = findService.wrapFind;
|
||||
findInst.entireWord = findService.entireWord;
|
||||
findInst.findBackwards = findService.findBackwards ^ reverse;
|
||||
|
||||
var found = findInst.findNext();
|
||||
if (!found) {
|
||||
if (!gPromptService)
|
||||
gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService()
|
||||
.QueryInterface(Components.interfaces.nsIPromptService);
|
||||
if (!gFindBundle)
|
||||
gFindBundle = document.getElementById("findBundle");
|
||||
|
||||
gPromptService.alert(window, gFindBundle.getString("notFoundTitle"), gFindBundle.getString("notFoundWarning"));
|
||||
}
|
||||
|
||||
// Reset to normal value, otherwise setting can get changed in find dialog
|
||||
findInst.findBackwards = findService.findBackwards;
|
||||
}
|
||||
|
||||
findInstData.init();
|
||||
var findInst = findInstData.webBrowserFind;
|
||||
findInst.searchString = searchString;
|
||||
findInst.matchCase = findService.matchCase;
|
||||
findInst.wrapFind = findService.wrapFind;
|
||||
findInst.entireWord = findService.entireWord;
|
||||
findInst.findBackwards = findService.findBackwards ^ reverse;
|
||||
|
||||
var found = findInst.findNext();
|
||||
if (!found) {
|
||||
if (!gPromptService)
|
||||
gPromptService = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService()
|
||||
.QueryInterface(Components.interfaces.nsIPromptService);
|
||||
if (!gFindBundle)
|
||||
gFindBundle = document.getElementById("findBundle");
|
||||
|
||||
gPromptService.alert(window, gFindBundle.getString("notFoundTitle"), gFindBundle.getString("notFoundWarning"));
|
||||
}
|
||||
|
||||
// Reset to normal value, otherwise setting can get changed in find dialog
|
||||
findInst.findBackwards = findService.findBackwards;
|
||||
}
|
||||
|
||||
function canFindAgainInPage()
|
||||
{
|
||||
var findService = Components.classes["@mozilla.org/find/find_service;1"]
|
||||
.getService(Components.interfaces.nsIFindService);
|
||||
return (findService.searchString.length > 0);
|
||||
if (isFindbarEnabled())
|
||||
// The findbar will just be brought up in an error state if you cannot find text again.
|
||||
return true;
|
||||
|
||||
var findService = Components.classes["@mozilla.org/find/find_service;1"]
|
||||
.getService(Components.interfaces.nsIFindService);
|
||||
return (findService.searchString.length > 0);
|
||||
}
|
||||
|
||||
function findLinksAsYouType()
|
||||
{
|
||||
var findbar = document.getElementById("FindToolbar");
|
||||
if (findbar && Services.prefs.getBoolPref("accessibility.typeaheadfind.usefindbar"))
|
||||
findbar.startFastFind(findbar.FIND_LINKS);
|
||||
else
|
||||
goDoCommand("cmd_findTypeLinks");
|
||||
}
|
||||
|
||||
function findTextAsYouType()
|
||||
{
|
||||
var findbar = document.getElementById("FindToolbar");
|
||||
if (findbar && Services.prefs.getBoolPref("accessibility.typeaheadfind.usefindbar"))
|
||||
findbar.startFastFind(findbar.FIND_TYPEAHEAD);
|
||||
else
|
||||
goDoCommand("cmd_findTypeText");
|
||||
}
|
||||
|
|
|
@ -106,6 +106,7 @@ comm.jar:
|
|||
#endif
|
||||
#endif
|
||||
content/communicator/bindings/general.xml (bindings/general.xml)
|
||||
content/communicator/bindings/findbar.xml (bindings/findbar.xml)
|
||||
content/communicator/bindings/notification.xml (bindings/notification.xml)
|
||||
content/communicator/bindings/toolbar.xml (bindings/toolbar.xml)
|
||||
* content/communicator/bindings/prefwindow.xml (bindings/prefwindow.xml)
|
||||
|
|
|
@ -63,6 +63,9 @@
|
|||
<preference id="accessibility.tabfocus"
|
||||
name="accessibility.tabfocus"
|
||||
type="int"/>
|
||||
<preference id="accessibility.typeaheadfind.usefindbar"
|
||||
name="accessibility.typeaheadfind.usefindbar"
|
||||
type="bool"/>
|
||||
</preferences>
|
||||
|
||||
<groupbox id="tabNavigationPrefs"
|
||||
|
@ -114,7 +117,12 @@
|
|||
label="&findAsYouTypeTimeout.label;"
|
||||
accesskey="&findAsYouTypeTimeout.accesskey;"
|
||||
preference="accessibility.typeaheadfind.enabletimeout"/>
|
||||
<checkbox id="findAsYouTypeFindbarEnable"
|
||||
label="&findAsYouTypeFindbarEnable.label;"
|
||||
accesskey="&findAsYouTypeFindbarEnable.accesskey;"
|
||||
preference="accessibility.typeaheadfind.usefindbar"/>
|
||||
</vbox>
|
||||
<description>&findAsYouTypeFindbarEnableTip.label;</description>
|
||||
</groupbox>
|
||||
|
||||
</prefpane>
|
||||
|
|
|
@ -317,9 +317,9 @@
|
|||
oncommand="goDoCommand('cmd_switchTextDirection');"
|
||||
disabled="true"/>
|
||||
<command id="cmd_findTypeText"
|
||||
oncommand="goDoCommand('cmd_findTypeText')"/>
|
||||
oncommand="findTextAsYouType();"/>
|
||||
<command id="cmd_findTypeLinks"
|
||||
oncommand="goDoCommand('cmd_findTypeLinks')"/>
|
||||
oncommand="findLinksAsYouType();"/>
|
||||
|
||||
<!-- Not needed yet, window will need this: -->
|
||||
<!-- broadcaster id="cmd_preferences"/ -->
|
||||
|
|
|
@ -19,3 +19,6 @@
|
|||
<!ENTITY findAsYouTypeAutoLinks.label "Links only">
|
||||
<!ENTITY findAsYouTypeAutoLinks.accesskey "o">
|
||||
|
||||
<!ENTITY findAsYouTypeFindbarEnable.label "Show the find toolbar during find as you type">
|
||||
<!ENTITY findAsYouTypeFindbarEnable.accesskey "S">
|
||||
<!ENTITY findAsYouTypeFindbarEnableTip.label "Note: Find as you type without showing the findbar does not allow international text entry.">
|
||||
|
|
Загрузка…
Ссылка в новой задаче