Suppress infinity loop from cyclic reference of tabs #309
This commit is contained in:
parent
7016e1eca1
commit
d100d26da3
@ -2939,14 +2939,12 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let ancestors = [],
|
let ancestors = this.getAncestorTabs(tab);
|
||||||
ancestor = parentTab;
|
ancestors = ancestors.map(function(aAncestor) {
|
||||||
do {
|
if (!next && (next = this.getNextSiblingTab(aAncestor)))
|
||||||
ancestors.push(ancestor.getAttribute(this.kID));
|
|
||||||
if (!next && (next = this.getNextSiblingTab(ancestor)))
|
|
||||||
backupAttributes[this.kINSERT_BEFORE] = next.getAttribute(this.kID);
|
backupAttributes[this.kINSERT_BEFORE] = next.getAttribute(this.kID);
|
||||||
}
|
return aAncestor.getAttribute(this.kID);
|
||||||
while (ancestor = this.getParentTab(ancestor));
|
}, this);
|
||||||
backupAttributes[this.kANCESTOR] = ancestors.join('|');
|
backupAttributes[this.kANCESTOR] = ancestors.join('|');
|
||||||
|
|
||||||
let shouldCloseParentTab = (
|
let shouldCloseParentTab = (
|
||||||
@ -3364,20 +3362,19 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
let parent = this.getParentTab(tab);
|
let parent = this.getParentTab(tab);
|
||||||
let attached = false;
|
let attached = false;
|
||||||
if (parent && (tab.hidden != parent.hidden)) {
|
if (parent && (tab.hidden != parent.hidden)) {
|
||||||
let ancestor = parent;
|
|
||||||
let lastNextTab = null;
|
let lastNextTab = null;
|
||||||
while (ancestor = this.getParentTab(ancestor))
|
this.getAncestorTabs(tab).some(function(aAncestor) {
|
||||||
{
|
if (aAncestor.hidden == tab.hidden) {
|
||||||
if (ancestor.hidden == tab.hidden) {
|
this.attachTabTo(tab, aAncestor, {
|
||||||
this.attachTabTo(tab, ancestor, {
|
|
||||||
dontMove : true,
|
dontMove : true,
|
||||||
insertBefore : lastNextTab
|
insertBefore : lastNextTab
|
||||||
});
|
});
|
||||||
attached = true;
|
attached = true;
|
||||||
break;
|
return true;
|
||||||
}
|
|
||||||
lastNextTab = this.getNextSiblingTab(ancestor);
|
|
||||||
}
|
}
|
||||||
|
lastNextTab = this.getNextSiblingTab(aAncestor);
|
||||||
|
return false;
|
||||||
|
}, this);
|
||||||
if (!attached) {
|
if (!attached) {
|
||||||
this.collapseExpandTab(tab, false, true);
|
this.collapseExpandTab(tab, false, true);
|
||||||
this.detachTab(tab);
|
this.detachTab(tab);
|
||||||
@ -4051,11 +4048,9 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
};
|
};
|
||||||
if (this.isCollapsed(tab)) {
|
if (this.isCollapsed(tab)) {
|
||||||
if (this.getTreePref('autoExpandSubtreeOnCollapsedChildFocused')) {
|
if (this.getTreePref('autoExpandSubtreeOnCollapsedChildFocused')) {
|
||||||
let parentTab = tab;
|
this.getAncestorTabs(tab).forEach(function(aAncestor) {
|
||||||
while (parentTab = this.getParentTab(parentTab))
|
this.collapseExpandSubtree(aAncestor, false);
|
||||||
{
|
}, this);
|
||||||
this.collapseExpandSubtree(parentTab, false);
|
|
||||||
}
|
|
||||||
this.handleNewActiveTab(tab, newActiveTabOptions);
|
this.handleNewActiveTab(tab, newActiveTabOptions);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -4730,13 +4725,18 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (!aChild.parentNode || (aParent && !aParent.parentNode)) return; // do nothing for closed tab!
|
if (!aChild.parentNode || (aParent && !aParent.parentNode)) return; // do nothing for closed tab!
|
||||||
|
|
||||||
aInfo = aInfo || {};
|
aInfo = aInfo || {};
|
||||||
|
var newAncestors = [];
|
||||||
|
|
||||||
if (aParent && this.maxTreeLevelPhisical && this.maxTreeLevel > -1) {
|
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(aParent.getAttribute(this.kNEST) || 0) + 1;
|
||||||
while (aParent && level > this.maxTreeLevel)
|
newAncestors.some(function(aAncestor) {
|
||||||
{
|
if (level <= this.maxTreeLevel)
|
||||||
|
return true;
|
||||||
level--;
|
level--;
|
||||||
aParent = this.getParentTab(aParent);
|
return false;
|
||||||
|
}, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -4837,21 +4837,17 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (this.getTreePref('autoCollapseExpandSubtreeOnSelect')) {
|
if (this.getTreePref('autoCollapseExpandSubtreeOnSelect')) {
|
||||||
if (this.shouldTabAutoExpanded(aParent))
|
if (this.shouldTabAutoExpanded(aParent))
|
||||||
this.collapseExpandTreesIntelligentlyFor(aParent);
|
this.collapseExpandTreesIntelligentlyFor(aParent);
|
||||||
let p = aParent;
|
newAncestors.forEach(function(aAncestor) {
|
||||||
do {
|
if (this.shouldTabAutoExpanded(aAncestor))
|
||||||
if (this.shouldTabAutoExpanded(p))
|
this.collapseExpandSubtree(aAncestor, false, aInfo.dontAnimate);
|
||||||
this.collapseExpandSubtree(p, false, aInfo.dontAnimate);
|
}, this);
|
||||||
}
|
|
||||||
while (p = this.getParentTab(p));
|
|
||||||
}
|
}
|
||||||
else if (this.shouldTabAutoExpanded(aParent)) {
|
else if (this.shouldTabAutoExpanded(aParent)) {
|
||||||
if (this.getTreePref('autoExpandSubtreeOnAppendChild')) {
|
if (this.getTreePref('autoExpandSubtreeOnAppendChild')) {
|
||||||
let p = aParent;
|
newAncestors.forEach(function(aAncestor) {
|
||||||
do {
|
if (this.shouldTabAutoExpanded(aAncestor))
|
||||||
if (this.shouldTabAutoExpanded(p))
|
this.collapseExpandSubtree(aAncestor, false, aInfo.dontAnimate);
|
||||||
this.collapseExpandSubtree(p, false, aInfo.dontAnimate);
|
}, this);
|
||||||
}
|
|
||||||
while (p = this.getParentTab(p));
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
this.collapseExpandTab(aChild, true, aInfo.dontAnimate);
|
this.collapseExpandTab(aChild, true, aInfo.dontAnimate);
|
||||||
@ -5639,12 +5635,12 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var parent;
|
var parent;
|
||||||
if (aCollapse && aTab == b.selectedTab && (parent = this.getParentTab(aTab))) {
|
if (aCollapse && aTab == b.selectedTab && (parent = this.getParentTab(aTab))) {
|
||||||
var newSelection = parent;
|
var newSelection = parent;
|
||||||
while (this.isCollapsed(parent))
|
this.getAncestorTabs(aTab).some(function(aAncestor) {
|
||||||
{
|
if (!this.isCollapsed(aAncestor))
|
||||||
parent = this.getParentTab(parent);
|
return true;
|
||||||
if (!parent) break;
|
newSelection = aAncestor;
|
||||||
newSelection = parent;
|
return false;
|
||||||
}
|
}, this);
|
||||||
b.selectedTab = newSelection;
|
b.selectedTab = newSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -5853,18 +5849,14 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
var sameParentTab = this.getParentTab(aTab);
|
var sameParentTab = this.getParentTab(aTab);
|
||||||
var expandedParentTabs = [
|
var expandedAncestors = [aTab].concat(this.getAncestorTabs(aTab))
|
||||||
aTab.getAttribute(this.kID)
|
.map(function(aAncestor) {
|
||||||
];
|
return aAncestor.getAttribute(this.kID);
|
||||||
var parentTab = aTab;
|
}, this)
|
||||||
while (parentTab = this.getParentTab(parentTab))
|
.join('|');
|
||||||
{
|
|
||||||
expandedParentTabs.push(parentTab.getAttribute(this.kID));
|
|
||||||
}
|
|
||||||
expandedParentTabs = expandedParentTabs.join('|');
|
|
||||||
|
|
||||||
var xpathResult = this.evaluateXPath(
|
var xpathResult = this.evaluateXPath(
|
||||||
'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kCOLLAPSED+'="true") and not(@'+this.kSUBTREE_COLLAPSED+'="true") and @'+this.kID+' and not(contains("'+expandedParentTabs+'", @'+this.kID+')) and not(@hidden="true")]',
|
'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kCOLLAPSED+'="true") and not(@'+this.kSUBTREE_COLLAPSED+'="true") and @'+this.kID+' and not(contains("'+expandedAncestors+'", @'+this.kID+')) and not(@hidden="true")]',
|
||||||
b.mTabContainer
|
b.mTabContainer
|
||||||
);
|
);
|
||||||
for (var i = 0, maxi = xpathResult.snapshotLength; i < maxi; i++)
|
for (var i = 0, maxi = xpathResult.snapshotLength; i < maxi; i++)
|
||||||
@ -5876,13 +5868,12 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (parentTab) {
|
if (parentTab) {
|
||||||
dontCollapse = true;
|
dontCollapse = true;
|
||||||
if (!this.isSubtreeCollapsed(parentTab)) {
|
if (!this.isSubtreeCollapsed(parentTab)) {
|
||||||
do {
|
this.getAncestorTabs(collapseTab).some(function(aAncestor) {
|
||||||
if (expandedParentTabs.indexOf(parentTab.getAttribute(this.kID)) < 0)
|
if (expandedAncestors.indexOf(aAncestor.getAttribute(this.kID)) < 0)
|
||||||
continue;
|
return false;
|
||||||
dontCollapse = false;
|
dontCollapse = false;
|
||||||
break;
|
return true;
|
||||||
}
|
}, this);
|
||||||
while (parentTab = this.getParentTab(parentTab));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user