diff --git a/browser/app/profile/firefox.js b/browser/app/profile/firefox.js index a03b6ce1806..c7f9e69305f 100644 --- a/browser/app/profile/firefox.js +++ b/browser/app/profile/firefox.js @@ -309,7 +309,8 @@ pref("browser.link.open_newwindow", 3); pref("browser.link.open_newwindow.restriction", 2); // Tabbed browser -pref("browser.tabs.autoHide", false); +pref("browser.tabs.autoHide", true); +pref("browser.tabs.forceHide", false); pref("browser.tabs.warnOnClose", true); pref("browser.tabs.warnOnOpen", true); pref("browser.tabs.maxOpenBeforeWarn", 15); diff --git a/browser/base/content/browser.js b/browser/base/content/browser.js index 19649710fdc..e84fb05ed11 100644 --- a/browser/base/content/browser.js +++ b/browser/base/content/browser.js @@ -1313,6 +1313,7 @@ AutoHideTabbarPrefListener.prototype = catch (e) { } gBrowser.setStripVisibilityTo(aVisible); + gPrefService.setBoolPref("browser.tabs.forceHide", false); } } } @@ -1635,7 +1636,8 @@ function BrowserOpenFileWindow() } } -function BrowserCloseTabOrWindow() { +function BrowserCloseTabOrWindow() +{ #ifdef XP_MACOSX // If we're not a browser window, just close the window if (window.location.href != getBrowserURL()) { @@ -1644,8 +1646,23 @@ function BrowserCloseTabOrWindow() { } #endif - // If the current tab is the last one, this will close the window. - gBrowser.removeCurrentTab(); + if (gBrowser.tabContainer.childNodes.length > 1) { + gBrowser.removeCurrentTab(); + return; + } + +#ifndef XP_MACOSX + if (gBrowser.localName == "tabbrowser" && window.toolbar.visible && + !gPrefService.getBoolPref("browser.tabs.autoHide")) { + // Replace the remaining tab with a blank one and focus the address bar + gBrowser.removeCurrentTab(); + if (gURLBar) + setTimeout(function() { gURLBar.focus(); }, 0); + return; + } +#endif + + closeWindow(true); } function BrowserTryToCloseWindow() diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index f6efd1c1f54..640adbdace3 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1217,6 +1217,8 @@ if (this.mStrip.collapsed) this.setStripVisibilityTo(true); + this.mPrefs.setBoolPref("browser.tabs.forceHide", false); + // wire up a progress listener for the new browser object. var position = this.mTabContainer.childNodes.length-1; var tabListener = this.mTabProgressListener(t, b, blank); @@ -1402,31 +1404,40 @@ if (aTab.localName != "tab") aTab = this.mCurrentTab; - if (aFireBeforeUnload) { - let ds = this.getBrowserForTab(aTab).docShell; - if (ds.contentViewer && !ds.contentViewer.permitUnload()) - return null; + var l = this.mTabContainer.childNodes.length; + if (l == 1 && this.mPrefs.getBoolPref("browser.tabs.autoHide")) { + // hide the tab bar + this.mPrefs.setBoolPref("browser.tabs.forceHide", true); + this.setStripVisibilityTo(false); + return; } - var l = this.mTabContainer.childNodes.length; - if (l == 1) { - closeWindow(true); - return null; + if (aFireBeforeUnload) { + var ds = this.getBrowserForTab(aTab).docShell; + if (ds.contentViewer && !ds.contentViewer.permitUnload()) + return; } - if (l == 2) { + + // see notes in addTab + var _delayedUpdate = function(aTabContainer) { + aTabContainer.adjustTabstrip(); + aTabContainer.mTabstrip._updateScrollButtonsDisabledState(); + } + setTimeout(_delayedUpdate, 0, this.mTabContainer); + + if (l == 1) { + // add a new blank tab to replace the one we're about to close + // (this ensures that the remaining tab is as good as new) + this.addTab("about:blank"); + l++; + } + else if (l == 2) { var autohide = this.mPrefs.getBoolPref("browser.tabs.autoHide"); var tabStripHide = !window.toolbar.visible; if (autohide || tabStripHide) this.setStripVisibilityTo(false); } - // see notes in addTab - var _delayedUpdate = function (aTabContainer) { - aTabContainer.adjustTabstrip(); - aTabContainer.mTabstrip._updateScrollButtonsDisabledState(); - }; - setTimeout(_delayedUpdate, 0, this.mTabContainer); - // We're committed to closing the tab now. // Dispatch a notification. // We dispatch it before any teardown so that event listeners can @@ -1468,9 +1479,6 @@