needless sibling group tab should be removed automatically

This commit is contained in:
SHIMODA Hiroshi 2011-07-29 17:22:13 +09:00
parent 93c2f9f94f
commit c419a3f63b

View File

@ -2606,6 +2606,8 @@ TreeStyleTabBrowser.prototype = {
if (collapsed) if (collapsed)
this.stopRendering(); this.stopRendering();
this.closeNeedlessGroupTabSibling(tab);
var backupAttributes = {}; var backupAttributes = {};
if (this.hasChildTabs(tab)) if (this.hasChildTabs(tab))
backupAttributes[this.kCHILDREN] = this.getTabValue(tab, this.kCHILDREN); backupAttributes[this.kCHILDREN] = this.getTabValue(tab, this.kCHILDREN);
@ -2764,6 +2766,28 @@ TreeStyleTabBrowser.prototype = {
if (collapsed) if (collapsed)
this.startRendering(); 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) getNextFocusedTab : function TSTBrowser_getNextFocusedTab(aTab)
{ {
return this.getNextSiblingTab(aTab) || return this.getNextSiblingTab(aTab) ||