From 327771a2b6b67f3bed9cb26662a0d0995be9c401 Mon Sep 17 00:00:00 2001 From: Piro / SHIMODA Hiroshi Date: Sat, 30 Jul 2011 03:07:37 +0900 Subject: [PATCH] * Needless group tab is not closed correctly when it is "to-be-reloaded". * Group tab wrongly closed even if the last sibling has any child. --- modules/browser.js | 28 +++++++++++++++------------- modules/utils.js | 10 ++++++++++ 2 files changed, 25 insertions(+), 13 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index 8171068f..7648632b 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -2606,8 +2606,6 @@ TreeStyleTabBrowser.prototype = { if (collapsed) this.stopRendering(); - this.closeNeedlessGroupTabSibling(tab); - var backupAttributes = {}; if (this.hasChildTabs(tab)) backupAttributes[this.kCHILDREN] = this.getTabValue(tab, this.kCHILDREN); @@ -2635,6 +2633,9 @@ TreeStyleTabBrowser.prototype = { } } + var toBeClosedSibling = !this.hasChildTabs(tab) ? + this._reserveCloseNeedlessGroupTabSibling(tab) : null ; + var firstChild = this.getFirstChildTab(tab); var parentTab = this.getParentTab(tab); var nextFocusedTab = null; @@ -2730,6 +2731,8 @@ TreeStyleTabBrowser.prototype = { } if (b.selectedTab == tab) { + if (nextFocusedTab && nextFocusedTab == toBeClosedSibling) + nextFocusedTab = this.getFirstChildTab(nextFocusedTab); if ( nextFocusedTab && !nextFocusedTab.hidden @@ -2766,31 +2769,30 @@ TreeStyleTabBrowser.prototype = { if (collapsed) this.startRendering(); }, - closeNeedlessGroupTabSibling : function TSTBrowser_closeNeedlessGroupTabSibling(aTab) + _reserveCloseNeedlessGroupTabSibling : function TSTBrowser_reserveCloseNeedlessGroupTabSibling(aTab) { if (!aTab) - return; + return null; 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); + var siblings = this.getSiblingTabs(aTab); + var groupTabs = siblings.filter(function(aTab) { + return this.isGroupTab(aTab); }, this); - var groupTab = ( groupTabs.length == 1 && siblings.length == 1 && this.hasChildTabs(groupTabs[0]) ) ? groupTabs[0] : null ; - if (groupTab) + if (groupTab) { this.window.setTimeout(function(aSelf, aGroupTab) { aSelf.getTabBrowserFromChild(aGroupTab).removeTab(aGroupTab, { animate : true }); }, 0, this, groupTab); + return groupTab; + } + + return null; }, getNextFocusedTab : function TSTBrowser_getNextFocusedTab(aTab) { diff --git a/modules/utils.js b/modules/utils.js index bdad475b..e2b94942 100644 --- a/modules/utils.js +++ b/modules/utils.js @@ -1978,6 +1978,16 @@ var TreeStyleTabUtils = { ).singleNodeValue; }, + getSiblingTabs : function TSTUtils_getSiblingTabs(aTab) /* PUBLIC API */ + { + var parent = this.getParentTab(aTab); + + var siblings = parent && parent.parentNode ? this.getChildTabs(parent) : this.visibleRootTabs ; + return siblings.filter(function(aSiblingTab) { + return aSiblingTab != aTab; + }); + }, + getChildTabs : function TSTUtils_getChildTabs(aTab, aAllTabsArray) /* PUBLIC API */ { var tabs = [];