* APIによるタブの移動でのツリー再構築について、処理を簡略化

* TMPでタブの挿入位置を制御する設定のときにブックマーク等から新しいタブを開くとツリーがおかしくなる問題を修正したつもり

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5030 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-09-01 10:30:21 +00:00
parent c9603addd0
commit 9294210897
2 changed files with 5 additions and 31 deletions

View File

@ -473,16 +473,6 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() {
)
);
eval('gBrowser.TMmoveTabTo = '+
gBrowser.TMmoveTabTo.toSource().replace(
/(aTab.dispatchEvent)/,
'this.treeStyleTab.internallyTabMoving = true; $1'
).replace(
/(return aTab;\})(\)?)$/,
'this.treeStyleTab.internallyTabMoving = false; $1$2'
)
);
window.BrowserHome = window.TM_BrowserHome;
window.BrowserOpenTab = window.TMP_BrowserOpenTab;

View File

@ -1687,30 +1687,15 @@ TreeStyleTabBrowser.prototype = {
)
return;
this.attachTabFromPosition(tab, aEvent.detail);
this.attachTabFromPosition(tab);
this.showTabbarForFeedback();
},
attachTabFromPosition : function(aTab, aOldPosition)
attachTabFromPosition : function(aTab)
{
var parent = this.getParentTab(aTab);
if (aOldPosition === void(0)) aOldPosition = aTab._tPos;
var pos = this.getChildIndex(aTab, parent);
var oldPos = this.getChildIndex(this.getTabs(this.mTabBrowser).snapshotItem(aOldPosition), parent);
var delta;
if (pos == oldPos) { // no move?
return;
}
else if (pos < 0 || oldPos < 0) {
delta = 2;
}
else {
delta = Math.abs(pos - oldPos);
}
var prevTab = this.getPreviousTab(aTab);
var nextTab = this.getNextTab(aTab);
@ -1731,17 +1716,16 @@ TreeStyleTabBrowser.prototype = {
newParent = null;
}
else if (!nextTab) {
newParent = (delta > 1) ? prevParent : parent ;
newParent = prevParent || parent ;
}
else if (prevParent == nextParent) {
newParent = prevParent;
}
else if (prevLevel > nextLevel) {
var realDelta = Math.abs(aTab._tPos - aOldPosition);
newParent = realDelta < 2 ? prevParent : parent ;
newParent = prevParent || parent || nextParent;
}
else if (prevLevel < nextLevel) {
newParent = this.getParentTab(aTab) || this.getParentTab(nextTab);
newParent = parent || nextParent;
}
if (newParent != parent) {