実際の状態と保存されたセッション情報との間に不整合が発生する場合があった(セッション復元時にツリー構造が壊れることがあった)のを修正

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5142 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-09-29 06:36:11 +00:00
parent d55a778206
commit c5d0a23157
3 changed files with 18 additions and 3 deletions

View File

@ -727,8 +727,7 @@ var TreeStyleTabService = {
getTabById : function(aId, aTabBrowserChildren)
{
if (!aId) return null;
var b = aTabBrowserChildren ? this.getTabBrowserFromChild(aTabBrowserChildren) : null ;
if (!b) b = this.browser;
var b = this.getTabBrowserFromChild(aTabBrowserChildren) || this.browser;
return this.evaluateXPath(
'descendant::xul:tab[@'+this.kID+' = "'+aId+'"]',
b.mTabContainer,
@ -736,6 +735,18 @@ var TreeStyleTabService = {
).singleNodeValue;
},
isTabDuplicated : function(aTab)
{
if (!aTab) return false;
var id = this.getTabValue(aTab, this.kID);
var b = this.getTabBrowserFromChild(aTab) || this.browser;
return this.evaluateXPath(
'count(descendant::xul:tab[@'+this.kID+' = "'+id+'" or @'+this.kID+'-temp = "'+id+'"]) > 1',
b.mTabContainer,
XPathResult.BOOLEAN_TYPE
).booleanValue;
},
getTabs : function(aTabBrowser)
{
return this.evaluateXPath(
@ -1113,6 +1124,7 @@ var TreeStyleTabService = {
{
aTab.removeAttribute(aKey);
try {
this.SessionStore.setTabValue(aTab, '');
this.SessionStore.deleteTabValue(aTab, aKey);
}
catch(e) {

View File

@ -1744,10 +1744,12 @@ TreeStyleTabBrowser.prototype = {
var id = this.getTabValue(tab, this.kID);
if (this.getTabById(id)) { // this is a duplicated tab!
tab.setAttribute(this.kID+'-temp', id);
if (this.isTabDuplicated(tab)) { // this is a duplicated tab!
maybeDuplicated = true;
id = this.redirectId(id);
}
tab.removeAttribute(this.kID+'-temp');
if (!maybeDuplicated) {
/* If it has a parent, it is wrongly attacched by tab moving

View File

@ -196,6 +196,7 @@ test_setAndGetTabValue.setUp = function() {
test_setAndGetTabValue.tearDown = function() {
tabs.forEach(function(aTab) {
try {
SessionStore.setTabValue(aTab, randomKey, '');
SessionStore.deleteTabValue(aTab, randomKey);
}
catch(e) {