Skip to content

Commit

Permalink
needless sibling group tab should be removed automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
piroor committed Jul 29, 2011
1 parent 93c2f9f commit c419a3f
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions modules/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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) ||
Expand Down

0 comments on commit c419a3f

Please sign in to comment.