From a8871654b22eefa49b4193993eac47b53a9029aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A3o=20Gottwald?= Date: Mon, 22 Mar 2010 16:43:20 +0100 Subject: [PATCH] Bug 501714 - Last tab should show close button when browser.tabs.closeWindowWithLastTab=false. r=gavin --HG-- extra : rebase_source : 95100a017a51ff81e850f1ce8bd9fbfba1219eab --- browser/base/content/tabbrowser.css | 7 ++----- browser/base/content/tabbrowser.xml | 24 ++++++++++++++++-------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/browser/base/content/tabbrowser.css b/browser/base/content/tabbrowser.css index 069971a5eaa3..6eb6315cab8d 100644 --- a/browser/base/content/tabbrowser.css +++ b/browser/base/content/tabbrowser.css @@ -19,11 +19,8 @@ display: none; } -.tabbrowser-tabs:not([closebuttons="noclose"]):not([closebuttons="closeatend"]) > .tabbrowser-tab[selected="true"]:not(:only-child) > .tab-close-button { - display: -moz-box; -} - -.tabbrowser-tabs[closebuttons="alltabs"] > .tabbrowser-tab:not(:only-child) > .tab-close-button { +.tabbrowser-tabs:not([closebuttons="noclose"]):not([closebuttons="closeatend"]) > .tabbrowser-tab[selected="true"] > .tab-close-button, +.tabbrowser-tabs[closebuttons="alltabs"] > .tabbrowser-tab > .tab-close-button { display: -moz-box; } diff --git a/browser/base/content/tabbrowser.xml b/browser/base/content/tabbrowser.xml index a9e65b9703c4..bded26285181 100644 --- a/browser/base/content/tabbrowser.xml +++ b/browser/base/content/tabbrowser.xml @@ -1379,7 +1379,7 @@ if (this.tabs.length - this._removingTabs.length == 1) { closeWindow = aCloseWindowWithLastTab != null ? aCloseWindowWithLastTab : !window.toolbar.visible || - Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab"); + this.tabContainer._closeWindowWithLastTab; // Closing the tab and replacing it with a blank one is notably slower // than closing the window right away. If the caller opts in, take @@ -2449,6 +2449,7 @@ this.mTabMaxWidth = Services.prefs.getIntPref("browser.tabs.tabMaxWidth"); this.mTabClipWidth = Services.prefs.getIntPref("browser.tabs.tabClipWidth"); this.mCloseButtons = Services.prefs.getIntPref("browser.tabs.closeButtons"); + this._closeWindowWithLastTab = Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab"); var tab = this.firstChild; tab.setAttribute("label", @@ -2464,6 +2465,7 @@ Services.prefs.addObserver("browser.tabs.closeButtons", this._prefObserver, false); Services.prefs.addObserver("browser.tabs.autoHide", this._prefObserver, false); + Services.prefs.addObserver("browser.tabs.closeWindowWithLastTab", this._prefObserver, false); window.addEventListener("resize", this, false); ]]> @@ -2473,6 +2475,7 @@ @@ -2506,13 +2509,13 @@ case "browser.tabs.autoHide": this.tabContainer.updateVisibility(); break; + case "browser.tabs.closeWindowWithLastTab": + this.tabContainer._closeWindowWithLastTab = Services.prefs.getBoolPref(data); + this.tabContainer.adjustTabstrip(); + break; } } });]]> - 100 - 250 - 140 - 1 false @@ -2565,10 +2568,15 @@ // 3 - closeatend = close button at the end of the tabstrip switch (this.mCloseButtons) { case 0: - this.setAttribute("closebuttons", "activetab"); + if (this.childNodes.length == 1 && this._closeWindowWithLastTab) + this.setAttribute("closebuttons", "noclose"); + else + this.setAttribute("closebuttons", "activetab"); break; case 1: - if (this.firstChild.getBoundingClientRect().width > this.mTabClipWidth) + if (this.childNodes.length == 1 && this._closeWindowWithLastTab) + this.setAttribute("closebuttons", "noclose"); + else if (this.firstChild.getBoundingClientRect().width > this.mTabClipWidth) this.setAttribute("closebuttons", "alltabs"); else this.setAttribute("closebuttons", "activetab"); @@ -2786,7 +2794,7 @@ return; if (this.childNodes.length > 1 || - !Services.prefs.getBoolPref("browser.tabs.closeWindowWithLastTab")) + !this._closeWindowWithLastTab) this.tabbrowser.removeTab(event.target); event.stopPropagation();