From 895b038fe7b3303e09cbc17df6d2e0a5a195b598 Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Mon, 6 May 2013 04:52:55 +0900 Subject: [PATCH] Flatten codes --- modules/browser.js | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index 28442fe7..0dadae96 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -2929,18 +2929,14 @@ TreeStyleTabBrowser.prototype = { this.isSubtreeCollapsed(tab)) this._closeChildTabs(tab); + this._saveAndUpdateReferenceTabsInfo(tab); + var toBeClosedSibling = this._reserveCloseNeedlessGroupTabSibling(tab); var nextFocusedTab = null; - this._saveAndUpdateReferenceTabsInfo(tab); - var firstChild = this.getFirstChildTab(tab); if (firstChild) { let children = this.getChildTabs(tab); - this.detachAllChildren(tab, { - behavior : closeParentBehavior, - dontUpdateIndent : true - }); if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD) this.updateTabsIndentWithDelay(children.slice(0, 1)); @@ -2952,6 +2948,11 @@ TreeStyleTabBrowser.prototype = { nextFocusedTab = firstChild; } + this.detachAllChildren(tab, { + behavior : closeParentBehavior, + dontUpdateIndent : true + }); + var parentTab = this.getParentTab(tab); if (parentTab) { if (!nextFocusedTab && tab == this.getLastChildTab(parentTab)) { @@ -2964,8 +2965,6 @@ TreeStyleTabBrowser.prototype = { let toBeClosedParent = this._reserveCloseNeedlessGroupTabParent(parentTab); if (toBeClosedParent && nextFocusedTab == toBeClosedParent) nextFocusedTab = this.getNextFocusedTab(parentTab); - - this.detachTab(tab, { dontUpdateIndent : true }); } else if (!nextFocusedTab) { nextFocusedTab = this.getNextFocusedTab(tab); @@ -2974,6 +2973,8 @@ TreeStyleTabBrowser.prototype = { if (toBeClosedSibling && nextFocusedTab == toBeClosedSibling) nextFocusedTab = this.getFirstChildTab(nextFocusedTab); + this.detachTab(tab, { dontUpdateIndent : true }); + this.checkTabsIndentOverflow(); this._restoreTabAttributes(tab, backupAttributes); @@ -5035,7 +5036,12 @@ TreeStyleTabBrowser.prototype = { detachAllChildren : function TSTBrowser_detachAllChildren(aTab, aInfo) { - if (!aTab.parentNode) return; // do nothing for closed tab! + if (!aTab.parentNode) // do nothing for closed tab! + return; + + var children = this.getChildTabs(aTab); + if (!children.length) + return; aInfo = aInfo || {}; if (!('behavior' in aInfo)) @@ -5045,7 +5051,6 @@ TreeStyleTabBrowser.prototype = { var b = this.mTabBrowser; var parentTab = this.getParentTab(aTab); - var children = this.getChildTabs(aTab); if ( this.isGroupTab(aTab) &&