bug 348031 - make Cmd+W always close the window on the last tab
authormconnor@steelgryphon.com
Thu, 28 Feb 2008 22:06:06 -0800
changeset 12430 20ec2de552026646615411506268fb21f65a5b8f
parent 12429 5a23828ebfc65bb188cf67cc456733287f204c06
child 12431 a26f3266540ad8967f004379764c1545b0daa1a3
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs348031
milestone1.9b4pre
bug 348031 - make Cmd+W always close the window on the last tab
browser/base/content/browser.js
--- a/browser/base/content/browser.js
+++ b/browser/base/content/browser.js
@@ -1609,25 +1609,31 @@ function BrowserCloseTabOrWindow()
 #ifdef XP_MACOSX
   // If we're not a browser window, just close the window
   if (window.location.href != getBrowserURL()) {
     closeWindow(true);
     return;
   }
 #endif
 
-  if (gBrowser.tabContainer.childNodes.length > 1 ||
-      window.toolbar.visible && !gPrefService.getBoolPref("browser.tabs.autoHide")) {
-    // Just close the tab (and focus the address bar if it was the last one).
-    var isLastTab = gBrowser.tabContainer.childNodes.length == 1;
+  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 (isLastTab && gURLBar)
+    if (gURLBar)
       setTimeout(function() { gURLBar.focus(); }, 0);
     return;
   }
+#endif
 
   closeWindow(true);
 }
 
 function BrowserTryToCloseWindow()
 {
   if (WindowIsClosing())
     window.close();     // WindowIsClosing does all the necessary checks