зеркало из https://github.com/mozilla/pjs.git
Bug 81712; new turbo-mode implementation, removes old stuff and replaces it with code that no longer holds a browser window open; r=syd, sr=blake, a=asa
This commit is contained in:
Родитель
48d2555120
Коммит
7e0c5a3de3
|
@ -278,6 +278,7 @@ function Startup()
|
|||
contentArea.addEventListener("load", loadEventHandlers, true);
|
||||
contentArea.addEventListener("focus", contentAreaFrameFocus, true);
|
||||
|
||||
var turboMode = false;
|
||||
// set default character set if provided
|
||||
if ("arguments" in window && window.arguments.length > 1 && window.arguments[1]) {
|
||||
if (window.arguments[1].indexOf("charset=") != -1) {
|
||||
|
@ -286,6 +287,8 @@ function Startup()
|
|||
//we should "inherit" the charset menu setting in a new window
|
||||
appCore.setDefaultCharacterSet(arrayArgComponents[1]); //XXXjag see bug 67442
|
||||
}
|
||||
} else if (window.arguments[1].indexOf("turbo=yes") != -1) {
|
||||
turboMode = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -314,7 +317,7 @@ function Startup()
|
|||
if (!isPageCycling) {
|
||||
var uriToLoad;
|
||||
|
||||
if (!appCore.cmdLineURLUsed) {
|
||||
if (!appCore.cmdLineURLUsed && !turboMode) {
|
||||
var cmdLineService = Components.classes["@mozilla.org/appshell/commandLineService;1"]
|
||||
.getService(Components.interfaces.nsICmdLineService);
|
||||
uriToLoad = cmdLineService.URLToLoad;
|
||||
|
@ -337,6 +340,17 @@ function Startup()
|
|||
loadURI(uriToLoad);
|
||||
}
|
||||
|
||||
// Close the window now, if it's for turbo mode startup.
|
||||
if ( turboMode ) {
|
||||
// Set "command line used" flag. If we don't do this, then when a cmd line url
|
||||
// for a "real* invocation comes in, we will override it with the "cmd line url"
|
||||
// from the turbo-mode process (i.e., the home page).
|
||||
appCore.cmdLineURLUsed = true;
|
||||
// For some reason, window.close() directly doesn't work, so do it in the future.
|
||||
window.setTimeout( "window.close()", 100 );
|
||||
return;
|
||||
}
|
||||
|
||||
// Focus the content area if the caller instructed us to.
|
||||
if ("arguments" in window && window.arguments.length >= 3 && window.arguments[2] == true)
|
||||
_content.focus();
|
||||
|
@ -364,42 +378,6 @@ function BrowserFlushBookmarksAndHistory() {
|
|||
}
|
||||
}
|
||||
|
||||
function BrowserCanClose() {
|
||||
// Check for "server mode."
|
||||
try {
|
||||
var appShellSvc = Components.classes["@mozilla.org/appshell/appShellService;1"]
|
||||
.getService(Components.interfaces.nsIAppShellService);
|
||||
var nativeSupport = appShellSvc.nativeAppSupport;
|
||||
if (nativeSupport && nativeSupport.isServerMode) {
|
||||
// Give native app a chance to cache this window.
|
||||
if (nativeSupport.cacheBrowserWindow(window)) {
|
||||
// Window is "cached" so don't close it.
|
||||
|
||||
// But flush bookmarks and history, as if we did close it.
|
||||
BrowserFlushBookmarksAndHistory();
|
||||
|
||||
// Reset session history.
|
||||
var webNav = getWebNavigation();
|
||||
if (webNav) {
|
||||
try {
|
||||
webNav.sessionHistory.PurgeHistory( webNav.sessionHistory.count );
|
||||
} catch(ex) {
|
||||
}
|
||||
}
|
||||
|
||||
// Go to blank page.
|
||||
loadURI( "about:blank" );
|
||||
|
||||
// This stops the close.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} catch (ex) {
|
||||
}
|
||||
// Ok to close window.
|
||||
return true;
|
||||
}
|
||||
|
||||
function Shutdown()
|
||||
{
|
||||
var browser = getBrowser();
|
||||
|
|
|
@ -45,7 +45,7 @@ Contributor(s): ______________________________________. -->
|
|||
<window id="main-window" xmlns:html="http://www.w3.org/1999/xhtml"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
||||
onload="Startup()" onunload="Shutdown()" onclose="return BrowserCanClose()"
|
||||
onload="Startup()" onunload="Shutdown()"
|
||||
contenttitlesetting="true"
|
||||
title="&mainWindow.title;"
|
||||
titlemodifier="&mainWindow.titlemodifier;"
|
||||
|
|
|
@ -111,7 +111,7 @@
|
|||
<command id="Browser:Open" oncommand="BrowserOpenWindow();"/>
|
||||
<command id="Browser:Print" oncommand="BrowserPrint();"/>
|
||||
<command id="cmd_quit"/>
|
||||
<command id="cmd_close" oncommand="if(BrowserCanClose()){BrowserClose();}"/>
|
||||
<command id="cmd_close" oncommand="BrowserClose()"/>
|
||||
|
||||
<!-- Edit Menu -->
|
||||
<command id="cmd_undo"/>
|
||||
|
|
Загрузка…
Ссылка в новой задаче