# HG changeset patch
# Parent e01187ca17026e95dfc8ac05ef1462981fab91ba
Bug 931891 - Backed out bug 887515 and the followups (bug 896291, 909662, 896896).
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
@@ -6211,43 +6211,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;
+ var 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.
@@ -7060,23 +7043,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
@@ -99,18 +99,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
@@ -1666,36 +1666,23 @@
throw new Error("Required argument missing: aTab");
tabsToClose = this.getTabsToTheEndFrom(aTab).length;
break;
default:
throw new Error("Invalid argument: " + aCloseTabs);
}
- let maxUndo =
- Services.prefs.getIntPref("browser.sessionstore.max_tabs_undo");
- let warnOnCloseOtherTabs =
- Services.prefs.getBoolPref("browser.tabs.warnOnCloseOtherTabs");
- let warnOnCloseWindow =
- Services.prefs.getBoolPref("browser.tabs.warnOnClose");
- let isWindowClosing = aCloseTabs == this.closingTabsEnum.ALL;
-
- let skipWarning =
- // 1) If there is only one tab to close, we'll never warn the user.
- tabsToClose <= 1 ||
- // 2) If the whole window is going to be closed, don't warn the
- // user if the user has browser.tabs.warnOnClose set to false.
- (isWindowClosing && !warnOnCloseWindow) ||
- // 3) If the number of tabs are less than the undo threshold
- // or if the user has specifically opted-in to ignoring
- // this warning via the warnOnCloseOtherTabs pref.
- (!isWindowClosing && (!warnOnCloseOtherTabs ||
- tabsToClose <= maxUndo));
- if (skipWarning)
+ 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;
@@ -1709,26 +1696,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) {
- let pref = isWindowClosing ? "browser.tabs.warnOnClose" :
- "browser.tabs.warnOnCloseOtherTabs";
+ if (aCloseTabs == this.closingTabsEnum.ALL && reallyClose && !warnOnClose.value)
Services.prefs.setBoolPref(pref, false);
- }
return reallyClose;
]]>