Add failsafe for unexpectedly stored tab attribute "tabbrowser-id"

This commit is contained in:
Piro / YUKI Hiroshi 2012-09-23 17:19:09 +09:00
parent 6f157657bc
commit 7ffe6709d2
2 changed files with 6 additions and 1 deletions

View File

@ -866,6 +866,7 @@ TreeStyleTabBrowser.prototype = {
if (!aTab.hasAttribute(this.kID)) { if (!aTab.hasAttribute(this.kID)) {
let id = this.getTabValue(aTab, this.kID) || this.makeNewId(); let id = this.getTabValue(aTab, this.kID) || this.makeNewId();
aTab.setAttribute(this.kID, id); aTab.setAttribute(this.kID, id);
aTab.setAttribute(this.kID_NEW, id);
aTab.setAttribute(this.kSUBTREE_COLLAPSED, true); aTab.setAttribute(this.kSUBTREE_COLLAPSED, true);
aTab.setAttribute(this.kALLOW_COLLAPSE, true); aTab.setAttribute(this.kALLOW_COLLAPSE, true);
let self = this; let self = this;
@ -877,6 +878,7 @@ TreeStyleTabBrowser.prototype = {
if (aTab.getAttribute(self.kID) != id) if (aTab.getAttribute(self.kID) != id)
return; return;
aTab.removeAttribute(this.kID_NEW);
if (!self.getTabValue(aTab, self.kID)) { if (!self.getTabValue(aTab, self.kID)) {
self.setTabValue(aTab, self.kID, id); self.setTabValue(aTab, self.kID, id);
if (!(id in self.tabsHash)) if (!(id in self.tabsHash))
@ -3608,7 +3610,9 @@ TreeStyleTabBrowser.prototype = {
_restoreTabId : function TSTBrowser_restoreTabId(aTab) _restoreTabId : function TSTBrowser_restoreTabId(aTab)
{ {
var currentId = aTab.getAttribute(this.kID); // kID can be overridden by nsSessionStore. kID_NEW is for failsafe.
var currentId = aTab.getAttribute(this.kID_NEW) || aTab.getAttribute(this.kID);
aTab.removeAttribute(this.kID_NEW);
var restoredId = this.getTabValue(aTab, this.kID); var restoredId = this.getTabValue(aTab, this.kID);
var mayBeDuplicated = false; var mayBeDuplicated = false;

View File

@ -96,6 +96,7 @@ var TreeStyleTabUtils = {
kINSERT_AFTER : 'treestyletab-insert-after', kINSERT_AFTER : 'treestyletab-insert-after',
kCLOSED_SET_ID : 'treestyletab-closed-set-id', kCLOSED_SET_ID : 'treestyletab-closed-set-id',
kID_NEW : 'treestyletab-id-new',
kID_RESTORING : 'treestyletab-id-restoring', kID_RESTORING : 'treestyletab-id-restoring',
kCHILDREN_RESTORING : 'treestyletab-children-restoring', kCHILDREN_RESTORING : 'treestyletab-children-restoring',