From 184555c3faab00dcf2fa2368d45177a5e9a9663f Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Mon, 30 Nov 2015 00:43:59 +0900 Subject: [PATCH] Update insertion position info for old previous/next sibling elements too #735 --- modules/browser.js | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index d8c33284..f405f117 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -3568,7 +3568,9 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { { var tab = aEvent.originalTarget; var b = this.mTabBrowser; - tab.__treestyletab__previousPosition = aEvent.detail; + + var prevPosition = aEvent.detail; + tab.__treestyletab__previousPosition = prevPosition; // When the tab was moved before TabOpen event is fired, we have to update manually. var newlyOpened = !this.isTabInitialized(tab) && this.onTabOpen(null, tab); @@ -3600,6 +3602,17 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { var tabsToBeUpdated = [tab]; + var allTabs = this.getAllTabs(this.mTabBrowser); + tabsToBeUpdated.push(allTabs[prevPosition]); + if (prevPosition > tab._tPos) { // from bottom to top + if (prevPosition < allTabs.length - 1) + tabsToBeUpdated.push(allTabs[prevPosition + 1]); + } + else { // from top to bottom + if (prevPosition > 0) + tabsToBeUpdated.push(allTabs[prevPosition - 1]); + } + var parentTab = this.getParentTab(tab); if (parentTab) { let children = this.getChildTabs(parentTab); @@ -3618,7 +3631,14 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { this.updateChildrenArray(parentTab); } - tabsToBeUpdated.forEach(this.updateInsertionPositionInfo, this); + var updatedTabs = new WeakMap(); + tabsToBeUpdated.forEach(function(aTab) { + if (updatedTabs.has(aTab)) + return; + updatedTabs.set(aTab, true); + this.updateInsertionPositionInfo(aTab); + }, this); + updatedTabs = undefined; this.positionPinnedTabsWithDelay();