Bug 459567 - reuse the Session Restore page's window for restoring the session; r=dietrich

This commit is contained in:
Simon Bünzli 2008-10-30 12:46:43 +03:30
Родитель 8b0bd09a29
Коммит 6c7e81309e
1 изменённых файлов: 11 добавлений и 13 удалений

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

@ -115,21 +115,24 @@ function restoreSession() {
}
var stateString = gStateObject.toSource();
// restore the session into a new window and close the current tab
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
var top = getBrowserWindow();
var selfBrowser = top.gBrowser.getBrowserForDocument(document);
// if there's only this page open, reuse the window for restoring the session
if (top.gBrowser.tabContainer.childNodes.length == 1) {
ss.setWindowState(top, stateString, true);
return;
}
// restore the session into a new window and close the current tab
var newWindow = top.openDialog(top.location, "_blank", "chrome,dialog=no,all");
newWindow.addEventListener("load", function() {
newWindow.removeEventListener("load", arguments.callee, true);
var ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
ss.setWindowState(newWindow, stateString, true);
var tabbrowser = top.gBrowser;
if (tabbrowser.tabContainer.childNodes.length == 1)
top.close();
else
tabbrowser.removeTab(getTabForBrowser(selfBrowser));
var tabIndex = tabbrowser.getBrowserIndexForDocument(document);
tabbrowser.removeTab(tabbrowser.tabContainer.childNodes[tabIndex]);
}, true);
}
@ -185,11 +188,6 @@ function getBrowserWindow() {
.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindow);
}
function getTabForBrowser(aBrowser) {
return Array.filter(getBrowserWindow().gBrowser.tabContainer.childNodes,
function(aTab) aTab.linkedBrowser == aBrowser)[0];
}
function toggleRowChecked(aIx) {
var item = gTreeData[aIx];
item.checked = !item.checked;