# HG changeset patch
# Parent dba809d7ee668b4fc7778965b2000245503013c8
Bug 931891 - Backout bug 887515 and its followups from Firefox 26.
diff --git a/browser/base/content/browser-places.js b/browser/base/content/browser-places.js
--- a/browser/base/content/browser-places.js
+++ b/browser/base/content/browser-places.js
@@ -563,17 +563,17 @@ HistoryMenu.prototype = {
// "Restore All Tabs"
var strings = gNavigatorBundle;
undoPopup.appendChild(document.createElement("menuseparator"));
m = undoPopup.appendChild(document.createElement("menuitem"));
m.id = "menu_restoreAllTabs";
m.setAttribute("label", strings.getString("menuRestoreAllTabs.label"));
m.addEventListener("command", function() {
for (var i = 0; i < undoItems.length; i++)
- undoCloseTab(0);
+ undoCloseTab();
}, false);
},
toggleRecentlyClosedWindows: function PHM_toggleRecentlyClosedWindows() {
// enable/disable the Recently Closed Windows sub menu
var undoMenu = this._rootElt.getElementsByClassName("recentlyClosedWindowsMenu")[0];
// no restorable windows, so disable menu
diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -6302,43 +6302,26 @@ function convertFromUnicode(charset, str
* @returns a reference to the reopened tab.
*/
function undoCloseTab(aIndex) {
// wallpaper patch to prevent an unnecessary blank tab (bug 343895)
var blankTabToRemove = null;
if (gBrowser.tabs.length == 1 && isTabEmpty(gBrowser.selectedTab))
blankTabToRemove = gBrowser.selectedTab;
- let numberOfTabsToUndoClose = 0;
- let index = Number(aIndex);
-
-
- if (isNaN(index)) {
- index = 0;
- numberOfTabsToUndoClose = SessionStore.getNumberOfTabsClosedLast(window);
- } else {
- if (0 > index || index >= SessionStore.getClosedTabCount(window))
- return null;
- numberOfTabsToUndoClose = 1;
+ let tab = null;
+ if (SessionStore.getClosedTabCount(window) > (aIndex || 0)) {
+ TabView.prepareUndoCloseTab(blankTabToRemove);
+ tab = SessionStore.undoCloseTab(window, aIndex || 0);
+ TabView.afterUndoCloseTab();
+
+ if (blankTabToRemove)
+ gBrowser.removeTab(blankTabToRemove);
}
- let tab = null;
- while (numberOfTabsToUndoClose > 0 &&
- numberOfTabsToUndoClose--) {
- TabView.prepareUndoCloseTab(blankTabToRemove);
- tab = SessionStore.undoCloseTab(window, index);
- TabView.afterUndoCloseTab();
- if (blankTabToRemove) {
- gBrowser.removeTab(blankTabToRemove);
- blankTabToRemove = null;
- }
- }
-
- // Reset the number of tabs closed last time to the default.
- SessionStore.setNumberOfTabsClosedLast(window, 1);
return tab;
}
/**
* Re-open a closed window.
* @param aIndex
* The index of the window (via SessionStore.getClosedWindowData)
* @returns a reference to the reopened window.
@@ -7128,23 +7111,18 @@ var TabContextMenu = {
menuItem.disabled = disabled;
disabled = gBrowser.visibleTabs.length == 1;
menuItems = aPopupMenu.getElementsByAttribute("tbattr", "tabbrowser-multiple-visible");
for (let menuItem of menuItems)
menuItem.disabled = disabled;
// Session store
- let undoCloseTabElement = document.getElementById("context_undoCloseTab");
- let closedTabCount = SessionStore.getNumberOfTabsClosedLast(window);
- undoCloseTabElement.disabled = closedTabCount == 0;
- // Change the label of "Undo Close Tab" to specify if it will undo a batch-close
- // or a single close.
- let visibleLabel = closedTabCount <= 1 ? "singletablabel" : "multipletablabel";
- undoCloseTabElement.setAttribute("label", undoCloseTabElement.getAttribute(visibleLabel));
+ document.getElementById("context_undoCloseTab").disabled =
+ SessionStore.getClosedTabCount(window) == 0;
// Only one of pin/unpin should be visible
document.getElementById("context_pinTab").hidden = this.contextTab.pinned;
document.getElementById("context_unpinTab").hidden = !this.contextTab.pinned;
// Disable "Close Tabs to the Right" if there are no tabs
// following it and hide it when the user rightclicked on a pinned
// tab.
diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul
--- a/browser/base/content/browser.xul
+++ b/browser/base/content/browser.xul
@@ -98,18 +98,17 @@
accesskey="&bookmarkAllTabs.accesskey;"
command="Browser:BookmarkAllTabs"/>
diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml
--- a/browser/base/content/tabbrowser.xml
+++ b/browser/base/content/tabbrowser.xml
@@ -1661,19 +1661,23 @@
throw new Error("Required argument missing: aTab");
tabsToClose = this.getTabsToTheEndFrom(aTab).length;
break;
default:
throw new Error("Invalid argument: " + aCloseTabs);
}
- if (tabsToClose <= 1 ||
- aCloseTabs != this.closingTabsEnum.ALL ||
- !Services.prefs.getBoolPref("browser.tabs.warnOnClose"))
+ if (tabsToClose <= 1)
+ return true;
+
+ const pref = aCloseTabs == this.closingTabsEnum.ALL ?
+ "browser.tabs.warnOnClose" : "browser.tabs.warnOnCloseOtherTabs";
+ var shouldPrompt = Services.prefs.getBoolPref(pref);
+ if (!shouldPrompt)
return true;
var ps = Services.prompt;
// default to true: if it were false, we wouldn't get this far
var warnOnClose = { value: true };
var bundle = this.mStringBundle;
@@ -1687,23 +1691,24 @@
ps.confirmEx(window,
bundle.getString("tabs.closeWarningTitle"),
bundle.getFormattedString("tabs.closeWarningMultipleTabs",
[tabsToClose]),
(ps.BUTTON_TITLE_IS_STRING * ps.BUTTON_POS_0)
+ (ps.BUTTON_TITLE_CANCEL * ps.BUTTON_POS_1),
bundle.getString("tabs.closeButtonMultiple"),
null, null,
- bundle.getString("tabs.closeWarningPromptMe"),
+ aCloseTabs == this.closingTabsEnum.ALL ?
+ bundle.getString("tabs.closeWarningPromptMe") : null,
warnOnClose);
var reallyClose = (buttonPressed == 0);
// don't set the pref unless they press OK and it's false
- if (reallyClose && !warnOnClose.value)
- Services.prefs.setBoolPref("browser.tabs.warnOnClose", false);
+ if (aCloseTabs == this.closingTabsEnum.ALL && reallyClose && !warnOnClose.value)
+ Services.prefs.setBoolPref(pref, false);
return reallyClose;
]]>