* セッション復元時に現在のタブの位置がおかしくなる問題を修正(対処)

* 変数スコープのエラーを修正

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@4674 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-07-08 10:40:51 +00:00
parent 286a583752
commit 28a91a3a86
2 changed files with 61 additions and 55 deletions

View File

@ -776,6 +776,7 @@ var TreeStyleTabService = {
getNextTab : function(aTab)
{
if (!aTab) return null;
return this.evaluateXPath(
'following-sibling::xul:tab[1]',
aTab,
@ -785,6 +786,7 @@ var TreeStyleTabService = {
getPreviousTab : function(aTab)
{
if (!aTab) return null;
return this.evaluateXPath(
'preceding-sibling::xul:tab[1]',
aTab,
@ -794,6 +796,7 @@ var TreeStyleTabService = {
getNextVisibleTab : function(aTab)
{
if (!aTab) return null;
return this.evaluateXPath(
'following-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")][1]',
aTab,
@ -803,6 +806,7 @@ var TreeStyleTabService = {
getPreviousVisibleTab : function(aTab)
{
if (!aTab) return null;
return this.evaluateXPath(
'preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")][1]',
aTab,
@ -812,6 +816,7 @@ var TreeStyleTabService = {
getLastVisibleTab : function(aTab)
{
if (!aTab) return null;
return this.evaluateXPath(
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")][last()]',
aTab.parentNode,
@ -830,7 +835,7 @@ var TreeStyleTabService = {
getVisibleIndex : function(aTab)
{
if (aTab.getAttribute(this.kCOLLAPSED) == 'true') return -1;
if (!aTab || aTab.getAttribute(this.kCOLLAPSED) == 'true') return -1;
return this.evaluateXPath(
'count(preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")])',
aTab,

View File

@ -514,54 +514,49 @@ TreeStyleTabBrowser.prototype = {
aTabBrowser.treeStyleTab.onPrefChange('extensions.treestyletab.tabbar.autoHide.mode');
}, 0, b);
let (tabContextMenu) {
tabContextMenu = document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu');
tabContextMenu.addEventListener('popupshowing', this, false);
if (!('MultipleTabService' in window)) {
window.setTimeout(function(aSelf, aTabBrowser, aPopup) {
let suffix = '-tabbrowser-'+(aTabBrowser.id || 'instance-'+parseInt(Math.random() * 65000));
[
aSelf.kMENUITEM_RELOADSUBTREE,
aSelf.kMENUITEM_RELOADCHILDREN,
aSelf.kMENUITEM_REMOVESUBTREE,
aSelf.kMENUITEM_REMOVECHILDREN,
aSelf.kMENUITEM_COLLAPSEEXPAND_SEPARATOR,
aSelf.kMENUITEM_COLLAPSE,
aSelf.kMENUITEM_EXPAND,
aSelf.kMENUITEM_AUTOHIDE_SEPARATOR,
aSelf.kMENUITEM_AUTOHIDE,
aSelf.kMENUITEM_FIXED,
aSelf.kMENUITEM_POSITION,
aSelf.kMENUITEM_BOOKMARKSUBTREE
].forEach(function(aID) {
let item = document.getElementById(aID).cloneNode(true);
item.setAttribute('id', item.getAttribute('id')+suffix);
var tabContextMenu = document.getAnonymousElementByAttribute(b, 'anonid', 'tabContextMenu');
tabContextMenu.addEventListener('popupshowing', this, false);
if (!('MultipleTabService' in window)) {
window.setTimeout(function(aSelf, aTabBrowser, aPopup) {
let suffix = '-tabbrowser-'+(aTabBrowser.id || 'instance-'+parseInt(Math.random() * 65000));
[
aSelf.kMENUITEM_RELOADSUBTREE,
aSelf.kMENUITEM_RELOADCHILDREN,
aSelf.kMENUITEM_REMOVESUBTREE,
aSelf.kMENUITEM_REMOVECHILDREN,
aSelf.kMENUITEM_COLLAPSEEXPAND_SEPARATOR,
aSelf.kMENUITEM_COLLAPSE,
aSelf.kMENUITEM_EXPAND,
aSelf.kMENUITEM_AUTOHIDE_SEPARATOR,
aSelf.kMENUITEM_AUTOHIDE,
aSelf.kMENUITEM_FIXED,
aSelf.kMENUITEM_POSITION,
aSelf.kMENUITEM_BOOKMARKSUBTREE
].forEach(function(aID) {
let item = document.getElementById(aID).cloneNode(true);
item.setAttribute('id', item.getAttribute('id')+suffix);
let refNode = void(0);
let insertAfter = item.getAttribute('multipletab-insertafter');
if (insertAfter) {
try {
eval('refNode = ('+insertAfter+').nextSibling');
}
catch(e) {
}
let refNode = void(0);
let insertAfter = item.getAttribute('multipletab-insertafter');
if (insertAfter) {
try {
eval('refNode = ('+insertAfter+').nextSibling');
}
let insertBefore = item.getAttribute('multipletab-insertbefore');
if (refNode === void(0) && insertBefore) {
try {
eval('refNode = '+insertBefore);
}
catch(e) {
}
catch(e) {
}
aPopup.insertBefore(item, refNode || null);
});
tabContextMenu = null;
}, 0, this, b, tabContextMenu);
}
else {
}
let insertBefore = item.getAttribute('multipletab-insertbefore');
if (refNode === void(0) && insertBefore) {
try {
eval('refNode = '+insertBefore);
}
catch(e) {
}
}
aPopup.insertBefore(item, refNode || null);
});
tabContextMenu = null;
}
}, 0, this, b, tabContextMenu);
}
let (allTabPopup) {
@ -1008,11 +1003,15 @@ TreeStyleTabBrowser.prototype = {
var b = this.mTabBrowser;
var tabs = this.getTabs(b);
for (var i = 0, maxi = tabs.snapshotLength; i < maxi; i++)
{
this.destroyTab(tabs.snapshotItem(i));
}
var tabs = this.getTabsArray(b);
tabs.forEach(function(aTab) {
let next = this.getNextSiblingTab(aTab);
if (next)
this.setTabValue(aTab, this.kINSERT_BEFORE, next.getAttribute(this.kID));
}, this);
tabs.forEach(function(aTab) {
this.destroyTab(aTab);
}, this);
b.removeEventListener('TabOpen', this, true);
b.removeEventListener('TabClose', this, true);
@ -1760,9 +1759,8 @@ TreeStyleTabBrowser.prototype = {
}
var nextTab = this.getTabValue(tab, this.kINSERT_BEFORE);
if (nextTab && maybeDuplicated) {
nextTab = this.redirectId(nextTab);
}
if (nextTab && maybeDuplicated) nextTab = this.redirectId(nextTab);
nextTab = this.getTabById(nextTab);
var ancestors = (this.getTabValue(tab, this.kANCESTOR) || this.getTabValue(tab, this.kPARENT)).split('|');
var parent = null;
@ -1783,7 +1781,7 @@ TreeStyleTabBrowser.prototype = {
if (parent) {
this.attachTabTo(tab, parent, {
dontExpand : true,
insertBefore : (nextTab ? this.getTabById(nextTab) : null ),
insertBefore : nextTab,
dontUpdateIndent : true
});
this.updateTabsIndent([tab], undefined, undefined, aWithoutAnimation);
@ -1799,7 +1797,6 @@ TreeStyleTabBrowser.prototype = {
}
if (!parent) {
nextTab = this.getTabById(nextTab);
if (!nextTab) nextTab = this.getNextTab(tab);
var parentOfNext = this.getParentTab(nextTab);
var newPos = -1;
@ -2839,7 +2836,10 @@ TreeStyleTabBrowser.prototype = {
var insertBefore = aInfo.insertBefore;
var beforeTab = insertBefore ? insertBefore.getAttribute(this.kID) : null ;
var beforeIndex;
Application.console.log('insertBefore '+insertBefore);
Application.console.log('beforeTab '+beforeTab);
if (beforeTab && (beforeIndex = children.indexOf(beforeTab)) > -1) {
Application.console.log('beforeIndex '+beforeIndex);
children.splice(beforeIndex, 0, id);
newIndex = insertBefore._tPos;
}
@ -2858,6 +2858,7 @@ TreeStyleTabBrowser.prototype = {
this.inheritTabIndent(aChild, aParent);
if (newIndex > aChild._tPos) newIndex--;
Application.console.log('newIndex '+newIndex);
this.moveTabSubTreeTo(aChild, newIndex);
if (!aInfo.dontExpand) {