Update insertion position info of old previous/next tabs after rearrangement

This commit is contained in:
YUKI Hiroshi 2015-10-05 19:57:17 +09:00
parent 7c592fce12
commit b248f68fad

View File

@ -3482,37 +3482,29 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
this.moveTabSubtreeTo(tab, tab._tPos); this.moveTabSubtreeTo(tab, tab._tPos);
} }
var parentTab = this.getParentTab(tab);
if (parentTab && !this.subTreeChildrenMovingCount) {
this.updateChildrenArray(parentTab);
}
this.updateTabsCount(tab, true); this.updateTabsCount(tab, true);
this.updateInsertionPositionInfo(tab); var tabsToBeUpdated = [tab];
var old = aEvent.detail; var parentTab = this.getParentTab(tab);
if (old > tab._tPos) if (parentTab) {
old--; let children = this.getChildTabs(parentTab);
var tabs = this.getAllTabs(b); let oldChildIndex = children.indexOf(tab);
old = tabs[old]; if (oldChildIndex > -1) {
if (oldChildIndex > 0) {
var prev = this.getPreviousSiblingTab(old); let oldPrevTab = children[oldChildIndex - 1];
var next = this.getNextSiblingTab(old); tabsToBeUpdated.push(oldPrevTab);
}
if (prev) { if (oldChildIndex < children.lenght - 1) {
this.setTabValue(prev, this.kINSERT_BEFORE, old.getAttribute(this.kID)); let oldNextTab = children[oldChildIndex + 1];
this.setTabValue(old, this.kINSERT_AFTER, prev.getAttribute(this.kID)); tabsToBeUpdated.push(oldNextTab);
}
}
if (!this.subTreeChildrenMovingCount)
this.updateChildrenArray(parentTab);
} }
else
this.deleteTabValue(old, this.kINSERT_AFTER);
if (next) { tabsToBeUpdated.forEach(this.updateInsertionPositionInfo, this);
this.setTabValue(next, this.kINSERT_AFTER, old.getAttribute(this.kID));
this.setTabValue(old, this.kINSERT_BEFORE, next.getAttribute(this.kID));
}
else
this.deleteTabValue(old, this.kINSERT_BEFORE);
this.positionPinnedTabsWithDelay(); this.positionPinnedTabsWithDelay();