From c419a3f63b536e01603698fcf991ecaf6c618c61 Mon Sep 17 00:00:00 2001 From: SHIMODA Hiroshi Date: Fri, 29 Jul 2011 17:22:13 +0900 Subject: [PATCH] needless sibling group tab should be removed automatically --- modules/browser.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/browser.js b/modules/browser.js index 3c992a73..955329a0 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -2606,6 +2606,8 @@ TreeStyleTabBrowser.prototype = { if (collapsed) this.stopRendering(); + this.closeNeedlessGroupTabSibling(tab); + var backupAttributes = {}; if (this.hasChildTabs(tab)) backupAttributes[this.kCHILDREN] = this.getTabValue(tab, this.kCHILDREN); @@ -2764,6 +2766,28 @@ TreeStyleTabBrowser.prototype = { if (collapsed) this.startRendering(); }, + closeNeedlessGroupTabSibling : function TSTBrowser_closeNeedlessGroupTabSibling(aTab) + { + if (!aTab) + return; + + var parent = this.getParentTab(aTab); + + var siblings = parent && parent.parentNode ? this.getChildTabs(parent) : this.visibleRootTabs ; + siblings = siblings.filter(function(aSiblingTab) { + return aSiblingTab != aTab; + }); + var groupTabs = siblings.filter(function(aSiblingTab) { + return this.isGroupTab(aSiblingTab); + }, this); + + if ( + groupTabs.length == 1 && + siblings.length == 1 && + this.hasChildTabs(groupTabs[0]) + ) + this.getTabBrowserFromChild(groupTabs[0]).removeTab(groupTabs[0], { animate : true }); + }, getNextFocusedTab : function TSTBrowser_getNextFocusedTab(aTab) { return this.getNextSiblingTab(aTab) ||