Read value of custom attributes of tabs via TSTBase.getTabAttribute() safely.

Tab's ID and other attributes saved via setTabValue is not available before the tab is completely restored.
As the result, TST sometimes fail to restore tab positions. (See: #676)
This issue doesn't happen on Firefox 24ESR, because recent Firefox (29 and later) uses message manager to restore tabs and it causes such "delay" of initializations about custom attributes.
This commit is contained in:
Piro / YUKI Hiroshi 2014-07-02 04:29:49 +09:00
parent b386b85bd3
commit f4fb6174d2
6 changed files with 113 additions and 99 deletions

View File

@ -870,8 +870,20 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
/* Session Store API */
getTabAttribute : function TSTBase_getTabAttribute(aTab, aAttribute)
{
if (aTab.__SS_extdata &&
aTab.__SS_extdata[aAttribute])
return aTab.__SS_extdata[aAttribute];
return aTab.getAttribute(aAttribute);
},
getTabValue : function TSTBase_getTabValue(aTab, aKey)
{
if (aTab.__SS_extdata &&
aTab.__SS_extdata[aKey])
return aTab.__SS_extdata[aKey];
var value = '';
try {
value = SessionStore.getTabValue(aTab, aKey);
@ -1532,7 +1544,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
{
var tabs = this.getTabs(aTabBrowser);
return tabs.map(function(aTab) {
return aTab.getAttribute(this.kID)+'\n'+
return this.getTabAttribute(aTab, this.kID)+'\n'+
aTab.getAttribute('busy')+'\n'+
aTab.linkedBrowser.currentURI.spec;
}, this);
@ -1556,12 +1568,12 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return false;
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
var parentId = parentTab.getAttribute(this.kID);
var parentId = this.getTabAttribute(parentTab, this.kID);
var refId = null;
if (aInsertBefore) {
ownerBrowser.treeStyleTab.ensureTabInitialized(parentTab);
refId = aInsertBefore.getAttribute(this.kID);
refId = this.getTabAttribute(aInsertBefore, this.kID);
}
ownerBrowser.treeStyleTab.readiedToAttachNewTab = true;
@ -1620,7 +1632,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return;
ownerBrowser.treeStyleTab.readiedToAttachNewTab = true;
ownerBrowser.treeStyleTab.parentTab = null;
ownerBrowser.treeStyleTab.insertBefore = nextTab.getAttribute(this.kID);
ownerBrowser.treeStyleTab.insertBefore = this.getTabAttribute(nextTab, this.kID);
return true;
}
},
@ -1799,7 +1811,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
!this.canCollapseSubtree(this.getRootTab(aTab)))
return false;
return aTab.getAttribute(this.kCOLLAPSED) == 'true';
return this.getTabAttribute(aTab, this.kCOLLAPSED) == 'true';
},
isSubtreeCollapsed : function TSTBase_isSubtreeCollapsed(aTab) /* PUBLIC API */
@ -1807,7 +1819,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
if (!aTab || !this.canCollapseSubtree(aTab) || !this.hasChildTabs(aTab))
return false;
return aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true';
return this.getTabAttribute(aTab, this.kSUBTREE_COLLAPSED) == 'true';
},
shouldCloseTabSubtreeOf : function TSTBase_shouldCloseTabSubtreeOf(aTab)
@ -1843,7 +1855,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return null;
var parent;
var id = aTab.getAttribute(this.kPARENT);
var id = this.getTabAttribute(aTab, this.kPARENT);
if (this.tabsHash) { // XPath-less implementation
parent = this.getTabById(id);
if (parent && !parent.parentNode && this.tabsHash) {
@ -1873,7 +1885,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
.reverse().map(function(aTab) {
return ' '+aTab._tPos+' : '+
aTab.label+'\n '+
aTab.getAttribute(this.kID);
this.getTabAttribute(aTab, this.kID);
}, this).join('\n');
dump(message+'\n');
break;
@ -1885,7 +1897,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
.reverse().map(function(aTab) {
return ' '+aTab._tPos+' : '+
aTab.label+'\n '+
aTab.getAttribute(this.kID);
this.getTabAttribute(aTab, this.kID);
}, this).join('\n');
dump(message+'\n');
}
@ -1932,9 +1944,9 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return next;
}
let children = parentTab.getAttribute(this.kCHILDREN);
let children = this.getTabAttribute(parentTab, this.kCHILDREN);
if (children) {
let list = ('|'+children).split('|'+aTab.getAttribute(this.kID));
let list = ('|'+children).split('|'+this.getTabAttribute(aTab, this.kID));
list = list.length > 1 ? list[1].split('|') : [] ;
for (let i = 0, maxi = list.length; i < maxi; i++)
{
@ -1946,7 +1958,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return null;
}
var parent = aTab.getAttribute(this.kPARENT);
var parent = this.getTabAttribute(aTab, this.kPARENT);
return this.evaluateXPath(
'following-sibling::xul:tab['+
(parent ? '@'+this.kPARENT+'="'+parent+'"' : 'not(@'+this.kPARENT+')' )+
@ -1975,9 +1987,9 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return prev;
}
let children = parentTab.getAttribute(this.kCHILDREN);
let children = this.getTabAttribute(parentTab, this.kCHILDREN);
if (children) {
let list = ('|'+children).split('|'+aTab.getAttribute(this.kID))[0].split('|');
let list = ('|'+children).split('|'+this.getTabAttribute(aTab, this.kID))[0].split('|');
for (let i = list.length-1; i > -1; i--)
{
let lastChild = this.getTabById(list[i], aTab);
@ -1988,7 +2000,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return null;
}
var parent = aTab.getAttribute(this.kPARENT);
var parent = this.getTabAttribute(aTab, this.kPARENT);
return this.evaluateXPath(
'preceding-sibling::xul:tab['+
(parent ? '@'+this.kPARENT+'="'+parent+'"' : 'not(@'+this.kPARENT+')' )+
@ -2014,7 +2026,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
if (!aTab)
return tabs;
var children = aTab.getAttribute(this.kCHILDREN);
var children = this.getTabAttribute(aTab, this.kCHILDREN);
if (!children)
return tabs;
@ -2032,7 +2044,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
tabs.map(function(aTab) {
return ' '+aTab._tPos+' : '+
aTab.label+'\n '+
aTab.getAttribute(this.kID);
this.getTabAttribute(aTab, this.kID);
}, this).join('\n');
dump(message+'\n');
continue;
@ -2065,7 +2077,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return null;
if (this.tabsHash) { // XPath-less implementation
let children = aTab.getAttribute(this.kCHILDREN);
let children = this.getTabAttribute(aTab, this.kCHILDREN);
let firstChild = null;
if (children) {
let list = children.split('|');
@ -2080,7 +2092,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
}
return this.evaluateXPath(
'following-sibling::xul:tab[@'+this.kPARENT+'="'+aTab.getAttribute(this.kID)+'"][1]',
'following-sibling::xul:tab[@'+this.kPARENT+'="'+this.getTabAttribute(aTab, this.kID)+'"][1]',
aTab,
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
@ -2092,7 +2104,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return null;
if (this.tabsHash) { // XPath-less implementation
let children = aTab.getAttribute(this.kCHILDREN);
let children = this.getTabAttribute(aTab, this.kCHILDREN);
let lastChild = null;
if (children) {
let list = children.split('|');
@ -2107,7 +2119,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
}
return this.evaluateXPath(
'following-sibling::xul:tab[@'+this.kPARENT+'="'+aTab.getAttribute(this.kID)+'"][last()]',
'following-sibling::xul:tab[@'+this.kPARENT+'="'+this.getTabAttribute(aTab, this.kID)+'"][last()]',
aTab,
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
@ -2123,11 +2135,11 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
return tabs.length ? tabs[tabs.length-1] : null ;
}
var parent = aTab.getAttribute(this.kPARENT);
var parent = this.getTabAttribute(aTab, this.kPARENT);
return this.evaluateXPath(
'following-sibling::xul:tab['+
(parent ? '@'+this.kPARENT+'="'+parent+'"' : 'not(@'+this.kPARENT+')' )+
'][1]/preceding-sibling::xul:tab[1][not(@'+this.kID+'="'+aTab.getAttribute(this.kID)+'")]',
'][1]/preceding-sibling::xul:tab[1][not(@'+this.kID+'="'+this.getTabAttribute(aTab, this.kID)+'")]',
aTab,
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
).singleNodeValue;
@ -2159,9 +2171,9 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
}
if (aParent) {
let children = aParent.getAttribute(this.kCHILDREN);
let children = this.getTabAttribute(aParent, this.kCHILDREN);
let list = children.split('|');
let id = aTab.getAttribute(this.kID);
let id = this.getTabAttribute(aTab, this.kID);
for (let i = 0, maxi = list.length; i < maxi; i++)
{
if (list[i] == id)
@ -2356,7 +2368,7 @@ var TreeStyleTabBase = inherit(TreeStyleTabConstants, {
let parentIndexInTree = aTreeStructure[i];
if (parentIndexInTree < 0) // there is no parent, so this is a new parent!
parentTab = tab.getAttribute(sv.kID);
parentTab = sv.getTabAttribute(tab, sv.kID);
let parent = sv.getTabById(parentTab);
if (parent) {

View File

@ -941,7 +941,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
this.deferredTasks[key].cancel();
(this.deferredTasks[key] = this.Deferred.next(function() {
// changed by someone!
if (aTab.getAttribute(self.kID) != id)
if (self.getTabAttribute(aTab, self.kID) != id)
return;
aTab.removeAttribute(this.kID_NEW);
@ -958,7 +958,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
}
else {
// if the tab is restored from session, it can be not-cached.
let id = aTab.getAttribute(this.kID);
let id = this.getTabAttribute(aTab, this.kID);
if (!(id in this.tabsHash))
this.tabsHash[id] = aTab;
}
@ -1493,7 +1493,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{
let tab = tabs[i];
this.updateTabCollapsed(tab, tab.getAttribute(this.kCOLLAPSED) == 'true', true);
this.updateTabCollapsed(tab, this.getTabAttribute(tab, this.kCOLLAPSED) == 'true', true);
}
// for updateTabbarOverflow(), we should reset the "overflow" now.
@ -2189,7 +2189,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
destroyTab : function TSTBrowser_destroyTab(aTab)
{
var id = aTab.getAttribute(this.kID);
var id = this.getTabAttribute(aTab, this.kID);
if (id in this.tabsHash &&
aTab == this.tabsHash[id])
delete this.tabsHash[id];
@ -2896,7 +2896,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (this.readiedToAttachNewTab) {
if (pareintIndexInTree < 0) { // there is no parent, so this is a new parent!
this.parentTab = tab.getAttribute(this.kID);
this.parentTab = this.getTabAttribute(tab, this.kID);
}
let parent = this.getTabById(this.parentTab);
@ -2928,7 +2928,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
元々最初の子だったタブとの間に挿入していく */
newIndex = parent._tPos + 1;
if (refTab = this.getFirstChildTab(parent))
this.insertBefore = refTab.getAttribute(this.kID);
this.insertBefore = this.getTabAttribute(refTab, this.kID);
}
if (newIndex > -1) {
@ -3019,14 +3019,14 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var prev = this.getPreviousSiblingTab(aTab);
if (prev) {
this.setTabValue(aTab, this.kINSERT_AFTER, prev.getAttribute(this.kID));
this.setTabValue(prev, this.kINSERT_BEFORE, aTab.getAttribute(this.kID));
this.setTabValue(aTab, this.kINSERT_AFTER, this.getTabAttribute(prev, this.kID));
this.setTabValue(prev, this.kINSERT_BEFORE, this.getTabAttribute(aTab, this.kID));
}
var next = this.getNextSiblingTab(aTab);
if (next) {
this.setTabValue(aTab, this.kINSERT_BEFORE, next.getAttribute(this.kID));
this.setTabValue(next, this.kINSERT_AFTER, aTab.getAttribute(this.kID));
this.setTabValue(aTab, this.kINSERT_BEFORE, this.getTabAttribute(next, this.kID));
this.setTabValue(next, this.kINSERT_AFTER, this.getTabAttribute(aTab, this.kID));
}
},
@ -3133,8 +3133,8 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
let next = this.getNextSiblingTab(aTab);
ancestors = ancestors.map(function(aAncestor) {
if (!next && (next = this.getNextSiblingTab(aAncestor)))
attributes[this.kINSERT_BEFORE] = next.getAttribute(this.kID);
return aAncestor.getAttribute(this.kID);
attributes[this.kINSERT_BEFORE] = this.getTabAttribute(next, this.kID);
return this.getTabAttribute(aAncestor, this.kID);
}, this);
attributes[this.kANCESTOR] = ancestors.join('|');
}
@ -3222,18 +3222,18 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var prev = this.getPreviousSiblingTab(aTab);
var next = this.getNextSiblingTab(aTab);
if (prev) {
this.setTabValue(aTab, this.kINSERT_AFTER, prev.getAttribute(this.kID));
this.setTabValue(aTab, this.kINSERT_AFTER, this.getTabAttribute(prev, this.kID));
if (next)
this.setTabValue(prev, this.kINSERT_BEFORE, next.getAttribute(this.kID));
this.setTabValue(prev, this.kINSERT_BEFORE, this.getTabAttribute(next, this.kID));
else
this.deleteTabValue(prev, this.kINSERT_BEFORE);
}
if (next) {
this.setTabValue(aTab, this.kINSERT_BEFORE, next.getAttribute(this.kID));
this.setTabValue(aTab, this.kINSERT_BEFORE, this.getTabAttribute(next, this.kID));
if (prev)
this.setTabValue(next, this.kINSERT_AFTER, prev.getAttribute(this.kID));
this.setTabValue(next, this.kINSERT_AFTER, this.getTabAttribute(prev, this.kID));
else
this.deleteTabValue(next, this.kINSERT_AFTER);
}
@ -3327,15 +3327,15 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var next = this.getNextSiblingTab(tab);
if (prev) {
this.setTabValue(prev, this.kINSERT_BEFORE, tab.getAttribute(this.kID));
this.setTabValue(tab, this.kINSERT_AFTER, prev.getAttribute(this.kID));
this.setTabValue(prev, this.kINSERT_BEFORE, this.getTabAttribute(tab, this.kID));
this.setTabValue(tab, this.kINSERT_AFTER, this.getTabAttribute(prev, this.kID));
}
else
this.deleteTabValue(tab, this.kINSERT_AFTER);
if (next) {
this.setTabValue(next, this.kINSERT_AFTER, tab.getAttribute(this.kID));
this.setTabValue(tab, this.kINSERT_BEFORE, next.getAttribute(this.kID));
this.setTabValue(next, this.kINSERT_AFTER, this.getTabAttribute(tab, this.kID));
this.setTabValue(tab, this.kINSERT_BEFORE, this.getTabAttribute(next, this.kID));
}
else
this.deleteTabValue(tab, this.kINSERT_BEFORE);
@ -3350,15 +3350,15 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
next = this.getNextSiblingTab(old);
if (prev) {
this.setTabValue(prev, this.kINSERT_BEFORE, old.getAttribute(this.kID));
this.setTabValue(old, this.kINSERT_AFTER, prev.getAttribute(this.kID));
this.setTabValue(prev, this.kINSERT_BEFORE, this.getTabAttribute(old, this.kID));
this.setTabValue(old, this.kINSERT_AFTER, this.getTabAttribute(prev, this.kID));
}
else
this.deleteTabValue(old, this.kINSERT_AFTER);
if (next) {
this.setTabValue(next, this.kINSERT_AFTER, old.getAttribute(this.kID));
this.setTabValue(old, this.kINSERT_BEFORE, next.getAttribute(this.kID));
this.setTabValue(next, this.kINSERT_AFTER, this.getTabAttribute(old, this.kID));
this.setTabValue(old, this.kINSERT_BEFORE, this.getTabAttribute(next, this.kID));
}
else
this.deleteTabValue(old, this.kINSERT_BEFORE);
@ -3412,8 +3412,8 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var prevParent = this.getParentTab(prevTab);
var nextParent = this.getParentTab(nextTab);
var prevLevel = prevTab ? Number(prevTab.getAttribute(this.kNEST)) : -1 ;
var nextLevel = nextTab ? Number(nextTab.getAttribute(this.kNEST)) : -1 ;
var prevLevel = prevTab ? Number(this.getTabAttribute(prevTab, this.kNEST)) : -1 ;
var nextLevel = nextTab ? Number(this.getTabAttribute(nextTab, this.kNEST)) : -1 ;
var newParent;
@ -3462,7 +3462,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
this.kCHILDREN,
children
.map(function(aItem) {
return aItem.getAttribute(this.kID);
return this.getTabAttribute(aItem, this.kID);
}, this)
.join('|')
);
@ -3549,11 +3549,11 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
let changed = aSelf.tabVisibilityChangedTabs[i];
let tab = changed.tab;
if (aSelf.getAncestorTabs(tab).some(function(aTab) {
return processedTabs[aTab.getAttribute(aSelf.kID)];
return processedTabs[aSelf.getTabAttribute(aTab, aSelf.kID)];
}))
continue;
aSelf.subtreeFollowParentAcrossTabGroups(tab);
processedTabs[tab.getAttribute(aSelf.kID)] = true;
processedTabs[aSelf.getTabAttribute(tab, aSelf.kID)] = true;
}
// now we can clear it!
aSelf.tabVisibilityChangedTabs = [];
@ -3760,7 +3760,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
!structureRestored &&
(
!mayBeDuplicated ||
aTab.getAttribute(this.kCHILDREN) != children
this.getTabAttribute(aTab, this.kCHILDREN) != children
)
) {
// failsafe
@ -3773,7 +3773,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var closeSetId = !structureRestored && this._getCloseSetId(aTab, mayBeDuplicated);
// remove temporary cache
var currentId = aTab.getAttribute(this.kID);
var currentId = this.getTabAttribute(aTab, this.kID);
if (id != currentId &&
currentId &&
currentId in this.tabsHash &&
@ -3817,7 +3817,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
_restoreTabId : function TSTBrowser_restoreTabId(aTab)
{
// kID can be overridden by nsSessionStore. kID_NEW is for failsafe.
var currentId = aTab.getAttribute(this.kID_NEW) || aTab.getAttribute(this.kID);
var currentId = this.getTabAttribute(aTab, this.kID_NEW) || this.getTabAttribute(aTab, this.kID);
aTab.removeAttribute(this.kID_NEW);
var restoredId = this.getTabValue(aTab, this.kID);
var mayBeDuplicated = false;
@ -3854,7 +3854,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
* tab, because the restoring session is got from the tab itself.
* ( like SS.setTabState(tab, SS.getTabState(tab)) )
*/
if (this.getTabValue(aTab, this.kID) != aTab.getAttribute(this.kID))
if (this.getTabValue(aTab, this.kID) != this.getTabAttribute(aTab, this.kID))
this.resetTab(aTab, false);
}
this.deleteTabValue(aTab, this.kCLOSED_SET_ID);
@ -3897,7 +3897,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
this.setTabValue(aTab, this.kCHILDREN, children.join('|'));
let subtreeCollapsed = this.getTabValue(aTab, this.kSUBTREE_COLLAPSED);
if (subtreeCollapsed != aTab.getAttribute(this.kSUBTREE_COLLAPSED))
if (subtreeCollapsed != this.getTabAttribute(aTab, this.kSUBTREE_COLLAPSED))
this.collapseExpandSubtree(aTab, subtreeCollapsed == 'true', true);
},
@ -3946,7 +3946,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
}
}
aChildrenList = aChildrenList.join('|');
if (aTab.getAttribute(this.kCHILDREN) == aChildrenList)
if (this.getTabAttribute(aTab, this.kCHILDREN) == aChildrenList)
aTab.removeAttribute(this.kCHILDREN_RESTORING);
else
aTab.setAttribute(this.kCHILDREN_RESTORING, aChildrenList);
@ -3974,7 +3974,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
this.updateTabsIndent([aTab], undefined, restoringMultipleTabs);
this.checkTabsIndentOverflow();
if (parent.getAttribute(this.kCHILDREN_RESTORING))
if (this.getTabAttribute(parent, this.kCHILDREN_RESTORING))
this.correctChildTabsOrderWithDelay(parent);
}
else {
@ -4028,7 +4028,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
* have been cleared.)
*/
if (!parent) {
parent = aTab.getAttribute(this.kPARENT);
parent = this.getTabAttribute(aTab, this.kPARENT);
if (DEBUG)
dump('handleRestoredTab: parent = ' + parent+'\n');
if (parent && !next)
@ -4075,10 +4075,10 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (!aTab.parentNode) // do nothing for closed tab!
return;
var restoringChildren = aTab.getAttribute(this.kCHILDREN_RESTORING);
var restoringChildren = this.getTabAttribute(aTab, this.kCHILDREN_RESTORING);
if (!restoringChildren) return;
var children = aTab.getAttribute(this.kCHILDREN);
var children = this.getTabAttribute(aTab, this.kCHILDREN);
if (restoringChildren != children) {
var restoringChildrenIDs = restoringChildren.split('|').reverse();
for (let i = 0, maxi = restoringChildrenIDs.length; i < maxi; i++)
@ -4102,7 +4102,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (newPos > -1)
this.moveTabSubtreeTo(child, newPos);
}
children = aTab.getAttribute(this.kCHILDREN);
children = this.getTabAttribute(aTab, this.kCHILDREN);
}
if (restoringChildren == children)
@ -4162,7 +4162,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (ancestors) {
ancestors = ancestors.split('|');
let actualAncestors = this.getAncestorTabs(aTab).map(function(aTab) {
return aTab.getAttribute(this.kID);
return this.getTabAttribute(aTab, this.kID);
}, this);
ancestors = ancestors.filter(function(aAncestor) {
if (actualAncestors.indexOf(aAncestor) < 0)
@ -4191,7 +4191,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
this.deleteTabValue(aTab, this.kCHILDREN);
}
var restoringChildren = aTab.getAttribute(this.kCHILDREN_RESTORING);
var restoringChildren = this.getTabAttribute(aTab, this.kCHILDREN_RESTORING);
if (restoringChildren) {
restoringChildren = restoringChildren.split('|');
restoringChildren = restoringChildren.filter(function(aChild) {
@ -4607,7 +4607,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (this.isEventFiredOnTwisty(aEvent)) {
if (this.hasChildTabs(aTab) && this.canCollapseSubtree(aTab)) {
this.manualCollapseExpandSubtree(aTab, aTab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
this.manualCollapseExpandSubtree(aTab, this.getTabAttribute(aTab, this.kSUBTREE_COLLAPSED) != 'true');
aEvent.preventDefault();
aEvent.stopPropagation();
}
@ -4650,7 +4650,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (tab &&
this.hasChildTabs(tab) &&
utils.getTreePref('collapseExpandSubtree.dblclick')) {
this.manualCollapseExpandSubtree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
this.manualCollapseExpandSubtree(tab, this.getTabAttribute(tab, this.kSUBTREE_COLLAPSED) != 'true');
aEvent.preventDefault();
aEvent.stopPropagation();
}
@ -5114,7 +5114,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (aParent) {
newAncestors = [aParent].concat(this.getAncestorTabs(aParent));
if (this.maxTreeLevelPhisical && this.maxTreeLevel > -1) {
let level = parseInt(aParent.getAttribute(this.kNEST) || 0) + 1;
let level = parseInt(this.getTabAttribute(aParent, this.kNEST) || 0) + 1;
newAncestors.some(function(aAncestor) {
if (level <= this.maxTreeLevel)
return true;
@ -5145,7 +5145,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
currentParent = ancestors[ancestors.length-1];
var shouldInheritIndent = (
!currentParent ||
(currentParent.getAttribute(this.kNEST) == aParent.getAttribute(this.kNEST))
(this.getTabAttribute(currentParent, this.kNEST) == this.getTabAttribute(aParent, this.kNEST))
);
this.ensureTabInitialized(aChild);
@ -5154,13 +5154,13 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (!aInfo)
aInfo = {};
var id = aChild.getAttribute(this.kID);
var id = this.getTabAttribute(aChild, this.kID);
this.detachTab(aChild, {
dontUpdateIndent : true
});
var children = aParent.getAttribute(this.kCHILDREN)
var children = this.getTabAttribute(aParent, this.kCHILDREN)
.split('|').filter(function(aId) {
return this.getTabById(aId);
}, this);
@ -5173,7 +5173,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var insertBefore = aInfo.insertBefore ||
(aInfo.dontMove ? this.getNextTab(aChild) : null );
var beforeTab = insertBefore ? insertBefore.getAttribute(this.kID) : null ;
var beforeTab = insertBefore ? this.getTabAttribute(insertBefore, this.kID) : null ;
var beforeIndex;
if (beforeTab && (beforeIndex = children.indexOf(beforeTab)) > -1) {
children.splice(beforeIndex, 0, id);
@ -5186,7 +5186,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
.map(this.getTabById, this)
.sort(this.sortTabsByOrder)
.map(function(aTab) {
return aTab.getAttribute(this.kID);
return this.getTabAttribute(aTab, this.kID);
}, this);
}
let refTab = aParent;
@ -5205,7 +5205,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
}
this.setTabValue(aParent, this.kCHILDREN, children.join('|'));
this.setTabValue(aChild, this.kPARENT, aParent.getAttribute(this.kID));
this.setTabValue(aChild, this.kPARENT, this.getTabAttribute(aParent, this.kID));
this.updateTabsCount(aParent);
if (shouldInheritIndent && !aInfo.dontUpdateIndent)
@ -5288,12 +5288,12 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
if (!parentTab)
return;
var id = aChild.getAttribute(this.kID);
var id = this.getTabAttribute(aChild, this.kID);
this.setTabValue(
parentTab,
this.kCHILDREN,
parentTab.getAttribute(this.kCHILDREN)
this.getTabAttribute(parentTab, this.kCHILDREN)
.split('|')
.filter(function(aId) {
return this.getTabById(aId) && aId != id;
@ -5658,8 +5658,10 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
return;
var self = this;
tabs.sort(function(aA, aB) { return Number(aA.getAttribute(self.kNEST)) - Number(aB.getAttribute(self.kNEST)); });
var nest = tabs[tabs.length-1].getAttribute(this.kNEST);
tabs.sort(function(aA, aB) {
return Number(self.getTabAttribute(aA, self.kNEST)) - Number(self.getTabAttribute(aB, self.kNEST));
});
var nest = this.getTabAttribute(tabs[tabs.length-1], this.kNEST);
if (this.maxTreeLevel > -1)
nest = Math.min(nest, this.maxTreeLevel);
if (!nest)
@ -5753,7 +5755,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var tabs = aParent ? this.getDescendantTabs(aParent) : this.getAllTabs(this.mTabBrowser) ;
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{
let level = parseInt(tab.getAttribute(this.kNEST) || 0);
let level = parseInt(this.getTabAttribute(tab, this.kNEST) || 0);
if (level <= this.maxTreeLevel)
continue;
@ -6332,7 +6334,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
var sameParentTab = this.getParentTab(aTab);
var expandedAncestors = [aTab].concat(this.getAncestorTabs(aTab))
.map(function(aAncestor) {
return aAncestor.getAttribute(this.kID);
return this.getTabAttribute(aAncestor, this.kID);
}, this)
.join('|');
@ -6350,7 +6352,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
dontCollapse = true;
if (!this.isSubtreeCollapsed(parentTab)) {
this.getAncestorTabs(collapseTab).some(function(aAncestor) {
if (expandedAncestors.indexOf(aAncestor.getAttribute(this.kID)) < 0)
if (expandedAncestors.indexOf(this.getTabAttribute(aAncestor, this.kID)) < 0)
return false;
dontCollapse = false;
return true;
@ -6665,7 +6667,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, {
for (let i = 0, maxi = tabs.length; i < maxi; i++)
{
let tab = tabs[i];
let currentId = tab.getAttribute(this.kID);
let currentId = this.getTabAttribute(tab, this.kID);
if (this.tabsHash[currentId] == tab)
delete this.tabsHash[currentId];

View File

@ -287,7 +287,7 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
var collapsed = this.isSubtreeCollapsed(tab);
var mode = utils.getTreePref('tooltip.mode');
var base = parseInt(tab.getAttribute(this.kNEST) || 0);
var base = parseInt(this.getTabAttribute(tab, this.kNEST) || 0);
var descendant = this.getDescendantTabs(tab);
var indentPart = ' ';
var tree = null;
@ -300,7 +300,7 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
.map(function(aTab) {
let label = aTab.getAttribute('label');
let indent = '';
let nest = parseInt(aTab.getAttribute(this.kNEST) || 0) - base;
let nest = parseInt(this.getTabAttribute(aTab, this.kNEST) || 0) - base;
for (let i = 0; i < nest; i++)
{
indent += indentPart;
@ -324,7 +324,7 @@ FullTooltipManager.prototype = inherit(TreeStyleTabBase, {
fullTooltipExtraLabel = utils.treeBundle.getFormattedString('tooltip.closeTree.labeled', ['%TREE%']).split(/\s*%TREE%\s*/);
}
}
else if (tab.getAttribute(this.kTWISTY_HOVER) == 'true') {
else if (this.getTabAttribute(tab, this.kTWISTY_HOVER) == 'true') {
let key = collapsed ?
'tooltip.expandSubtree' :
'tooltip.collapseSubtree' ;

View File

@ -398,7 +398,7 @@ GroupTab.prototype = inherit(TreeStyleTabBase, {
onTabAttached : function GT_onTabAttached(aEvent)
{
var tab = aEvent.detail.parentTab;
var id = tab.getAttribute(this.kID);
var id = this.getTabAttribute(tab, this.kID);
if (tab == this.getOwnerTab() ||
this.document.getElementsByAttribute('tab-id', id).length)
this.shouldUpdate = true;
@ -409,7 +409,7 @@ GroupTab.prototype = inherit(TreeStyleTabBase, {
onTabDetached : function GT_onTabDetached(aEvent)
{
var tab = aEvent.originalTarget;
var id = tab.getAttribute(this.kID);
var id = this.getTabAttribute(tab, this.kID);
if (this.document.getElementsByAttribute('tab-id', id).length)
this.shouldUpdate = true;
@ -420,7 +420,7 @@ GroupTab.prototype = inherit(TreeStyleTabBase, {
{
var tab = this.getOwnerTab(aEvent.target.defaultView.top);
if (tab) {
let id = tab.getAttribute(this.kID);
let id = this.getTabAttribute(tab, this.kID);
if (this.document.getElementsByAttribute('tab-id', id).length)
this.shouldUpdate = true;
}

View File

@ -419,8 +419,8 @@ catch(e) {
}
}
else {
var prevLevel = Number(prevTab.getAttribute(sv.kNEST));
var targetNest = Number(tab.getAttribute(sv.kNEST));
var prevLevel = Number(sv.getTabAttribute(prevTab, sv.kNEST));
var targetNest = Number(sv.getTabAttribute(tab, sv.kNEST));
info.parent = (prevLevel < targetNest) ? prevTab : sv.getParentTab(tab) ;
info.action = sv.kACTION_MOVE | (info.parent ? sv.kACTION_ATTACH : sv.kACTION_PART );
info.insertBefore = tab;
@ -452,8 +452,8 @@ catch(e) {
info.parent = sv.getParentTab(tab);
}
else {
var targetNest = Number(tab.getAttribute(sv.kNEST));
var nextLevel = Number(nextTab.getAttribute(sv.kNEST));
var targetNest = Number(sv.getTabAttribute(tab, sv.kNEST));
var nextLevel = Number(sv.getTabAttribute(nextTab, sv.kNEST));
info.parent = (targetNest < nextLevel) ? tab : sv.getParentTab(tab) ;
info.action = sv.kACTION_MOVE | (info.parent ? sv.kACTION_ATTACH : sv.kACTION_PART );
info.insertBefore = nextTab;
@ -785,7 +785,7 @@ catch(e) {
let tab = sv.getTabById(aTarget);
if (tab &&
sv.shouldTabAutoExpanded(tab) &&
tab.getAttribute(sv.kDROP_POSITION) == 'self') {
sv.getTabAttribute(tab, sv.kDROP_POSITION) == 'self') {
let draggedTab = aDragged && sv.getTabById(aDragged);
if (utils.getTreePref('autoExpand.intelligently')) {
sv.collapseExpandTreesIntelligentlyFor(tab);
@ -803,7 +803,7 @@ catch(e) {
},
utils.getTreePref('autoExpand.delay')
);
}, 0, this, tab.getAttribute(sv.kID), draggedTab && draggedTab.getAttribute(sv.kID));
}, 0, this, sv.getTabAttribute(tab, sv.kID), draggedTab && sv.getTabAttribute(draggedTab, sv.kID));
tab = null;
},
@ -998,7 +998,7 @@ try{
info.position == sv.kDROP_AFTER ? 'after' :
'self';
if (indicatorTab != draggedTab &&
indicatorTab.getAttribute(sv.kDROP_POSITION) != dropPosition) {
sv.getTabAttribute(indicatorTab, sv.kDROP_POSITION) != dropPosition) {
this.clearDropPosition();
indicatorTab.setAttribute(sv.kDROP_POSITION, dropPosition);
if (b.ownerDocument.defaultView['piro.sakura.ne.jp'].tabsDragUtils

View File

@ -448,7 +448,7 @@ TreeStyleTabWindow.prototype = inherit(TreeStyleTabBase, {
Array.forEach(aEvent.originalTarget.childNodes, function(aItem) {
if (aItem.classList.contains('alltabs-item') && 'tab' in aItem)
aItem.style.marginLeft = aItem.tab.getAttribute(this.kNEST) + 'em';
aItem.style.marginLeft = this.getTabAttribute(aItem.tab, this.kNEST) + 'em';
}, this);
},