フラグではなくカウント方式に

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5156 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-09-30 05:42:48 +00:00
parent fe3d2b4c0e
commit 052924cca3
3 changed files with 29 additions and 25 deletions

View File

@ -477,10 +477,10 @@ TreeStyleTabService.overrideExtensionsOnInitAfter = function() {
window.BrowserHome = window.TM_BrowserHome; window.BrowserHome = window.TM_BrowserHome;
window.BrowserOpenTab = window.TMP_BrowserOpenTab; window.BrowserOpenTab = window.TMP_BrowserOpenTab;
gBrowser.treeStyleTab.internallyTabMoving = false; gBrowser.treeStyleTab.internallyTabMovingCount--;
}, 0); }, 0);
gBrowser.treeStyleTab.internallyTabMoving = true; // until "TMmoveTabTo" method is overwritten gBrowser.treeStyleTab.internallyTabMovingCount++; // until "TMmoveTabTo" method is overwritten
} }

View File

@ -124,6 +124,10 @@ TreeStyleTabBrowser.prototype = {
{ {
var b = this.mTabBrowser; var b = this.mTabBrowser;
this.internallyTabMovingCount = 0;
this.subTreeMovingCount = 0;
this.subTreeChildrenMovingCount = 0;
let (splitter, toggler) { let (splitter, toggler) {
splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER); splitter = document.getAnonymousElementByAttribute(b, 'class', this.kSPLITTER);
if (!splitter) { if (!splitter) {
@ -335,7 +339,7 @@ TreeStyleTabBrowser.prototype = {
).replace( ).replace(
'this.moveTabToStart();', 'this.moveTabToStart();',
<![CDATA[ <![CDATA[
this.treeStyleTab.internallyTabMoving = true; this.treeStyleTab.internallyTabMovingCount++;
var parentTab = this.treeStyleTab.getParentTab(this.mCurrentTab); var parentTab = this.treeStyleTab.getParentTab(this.mCurrentTab);
if (parentTab) { if (parentTab) {
this.moveTabTo(this.mCurrentTab, this.treeStyleTab.getFirstChildTab(parentTab)._tPos); this.moveTabTo(this.mCurrentTab, this.treeStyleTab.getFirstChildTab(parentTab)._tPos);
@ -344,7 +348,7 @@ TreeStyleTabBrowser.prototype = {
else { else {
$& $&
} }
this.treeStyleTab.internallyTabMoving = false; this.treeStyleTab.internallyTabMovingCount--;
]]> ]]>
) )
); );
@ -360,7 +364,7 @@ TreeStyleTabBrowser.prototype = {
).replace( ).replace(
'this.moveTabToEnd();', 'this.moveTabToEnd();',
<![CDATA[ <![CDATA[
this.treeStyleTab.internallyTabMoving = true; this.treeStyleTab.internallyTabMovingCount++;
var parentTab = this.treeStyleTab.getParentTab(this.mCurrentTab); var parentTab = this.treeStyleTab.getParentTab(this.mCurrentTab);
if (parentTab) { if (parentTab) {
this.moveTabTo(this.mCurrentTab, this.treeStyleTab.getLastChildTab(parentTab)._tPos); this.moveTabTo(this.mCurrentTab, this.treeStyleTab.getLastChildTab(parentTab)._tPos);
@ -369,7 +373,7 @@ TreeStyleTabBrowser.prototype = {
else { else {
$& $&
} }
this.treeStyleTab.internallyTabMoving = false; this.treeStyleTab.internallyTabMovingCount--;
]]> ]]>
) )
); );
@ -1379,9 +1383,9 @@ TreeStyleTabBrowser.prototype = {
if (newIndex > -1) { if (newIndex > -1) {
if (newIndex > tab._tPos) newIndex--; if (newIndex > tab._tPos) newIndex--;
this.internallyTabMoving = true; this.internallyTabMovingCount++;
b.moveTabTo(tab, newIndex); b.moveTabTo(tab, newIndex);
this.internallyTabMoving = false; this.internallyTabMovingCount--;
} }
} }
@ -1612,12 +1616,12 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser; var b = this.mTabBrowser;
this.initTabContents(tab); // twisty vanished after the tab is moved!! this.initTabContents(tab); // twisty vanished after the tab is moved!!
if (this.hasChildTabs(tab) && !this.isSubTreeMoving) { if (this.hasChildTabs(tab) && !this.subTreeMovingCount) {
this.moveTabSubTreeTo(tab, tab._tPos); this.moveTabSubTreeTo(tab, tab._tPos);
} }
var parentTab = this.getParentTab(tab); var parentTab = this.getParentTab(tab);
if (parentTab && !this.isSubTreeChildrenMoving) { if (parentTab && !this.subTreeChildrenMovingCount) {
this.updateChildrenArray(parentTab); this.updateChildrenArray(parentTab);
} }
@ -1662,8 +1666,8 @@ TreeStyleTabBrowser.prototype = {
this.deleteTabValue(old, this.kINSERT_BEFORE); this.deleteTabValue(old, this.kINSERT_BEFORE);
if ( if (
this.isSubTreeMoving || this.subTreeMovingCount ||
this.internallyTabMoving this.internallyTabMovingCount
) )
return; return;
@ -2548,10 +2552,10 @@ TreeStyleTabBrowser.prototype = {
var newIndex = aInfo.insertBefore ? aInfo.insertBefore._tPos : lastTabIndex ; var newIndex = aInfo.insertBefore ? aInfo.insertBefore._tPos : lastTabIndex ;
if (aInfo.insertBefore && newIndex > tab._tPos) newIndex--; if (aInfo.insertBefore && newIndex > tab._tPos) newIndex--;
this.internallyTabMoving = true; this.internallyTabMovingCount++;
targetBrowser.moveTabTo(tab, newIndex); targetBrowser.moveTabTo(tab, newIndex);
this.collapseExpandTab(tab, false, true); this.collapseExpandTab(tab, false, true);
this.internallyTabMoving = false; this.internallyTabMovingCount--;
}, this); }, this);
@ -3096,21 +3100,21 @@ TreeStyleTabBrowser.prototype = {
if (!aTab) return; if (!aTab) return;
var b = this.mTabBrowser; var b = this.mTabBrowser;
this.isSubTreeMoving = true; this.subTreeMovingCount++;
this.internallyTabMoving = true; this.internallyTabMovingCount++;
b.moveTabTo(aTab, aIndex); b.moveTabTo(aTab, aIndex);
this.internallyTabMoving = false; this.internallyTabMovingCount--;
this.isSubTreeChildrenMoving = true; this.subTreeChildrenMovingCount++;
this.internallyTabMoving = true; this.internallyTabMovingCount++;
this.getDescendantTabs(aTab).forEach(function(aDescendantTab, aIndex) { this.getDescendantTabs(aTab).forEach(function(aDescendantTab, aIndex) {
b.moveTabTo(aDescendantTab, aTab._tPos + aIndex + (aTab._tPos < aDescendantTab._tPos ? 1 : 0 )); b.moveTabTo(aDescendantTab, aTab._tPos + aIndex + (aTab._tPos < aDescendantTab._tPos ? 1 : 0 ));
}, this); }, this);
this.internallyTabMoving = false; this.internallyTabMovingCount--;
this.isSubTreeChildrenMoving = false; this.subTreeChildrenMovingCount--;
this.isSubTreeMoving = false; this.subTreeMovingCount--;
}, },
moveTabLevel : function(aEvent) moveTabLevel : function(aEvent)
@ -3138,14 +3142,14 @@ TreeStyleTabBrowser.prototype = {
else { else {
var nextTab = this.getNextSiblingTab(parentTab); var nextTab = this.getNextSiblingTab(parentTab);
this.partTab(b.mCurrentTab); this.partTab(b.mCurrentTab);
this.internallyTabMoving = true; this.internallyTabMovingCount++;
if (nextTab) { if (nextTab) {
b.moveTabTo(b.mCurrentTab, nextTab._tPos - 1); b.moveTabTo(b.mCurrentTab, nextTab._tPos - 1);
} }
else { else {
b.moveTabTo(b.mCurrentTab, this.getLastTab(b)._tPos); b.moveTabTo(b.mCurrentTab, this.getLastTab(b)._tPos);
} }
this.internallyTabMoving = false; this.internallyTabMovingCount--;
b.mCurrentTab.focus(); b.mCurrentTab.focus();
return true; return true;
} }

View File

@ -844,7 +844,7 @@ TreeStyleTabBrowserAutoHide.prototype = {
return; return;
case 'TabMove': case 'TabMove':
if (!this.mOwner.isSubTreeMoving && !this.mOwner.internallyTabMoving) if (!this.mOwner.subTreeMovingCount && !this.mOwner.internallyTabMovingCount)
this.showForFeedback(); this.showForFeedback();
return; return;