Collect strongly related codes
This commit is contained in:
parent
eedc895e22
commit
43e1813650
@ -2931,27 +2931,20 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
this._saveAndUpdateReferenceTabsInfo(tab);
|
this._saveAndUpdateReferenceTabsInfo(tab);
|
||||||
|
|
||||||
var toBeClosedSibling = this._reserveCloseNeedlessGroupTabSibling(tab);
|
|
||||||
var nextFocusedTab = null;
|
|
||||||
|
|
||||||
var firstChild = this.getFirstChildTab(tab);
|
var firstChild = this.getFirstChildTab(tab);
|
||||||
if (firstChild) {
|
|
||||||
let children = this.getChildTabs(tab);
|
|
||||||
if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD)
|
|
||||||
this.updateTabsIndentWithDelay(children.slice(0, 1));
|
|
||||||
else
|
|
||||||
this.updateTabsIndentWithDelay(children);
|
|
||||||
|
|
||||||
if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_ALL_CHILDREN ||
|
|
||||||
closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD)
|
|
||||||
nextFocusedTab = firstChild;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.detachAllChildren(tab, {
|
this.detachAllChildren(tab, {
|
||||||
behavior : closeParentBehavior,
|
behavior : closeParentBehavior
|
||||||
dontUpdateIndent : true
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var nextFocusedTab = null;
|
||||||
|
if (firstChild &&
|
||||||
|
(closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_ALL_CHILDREN ||
|
||||||
|
closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_PROMOTE_FIRST_CHILD))
|
||||||
|
nextFocusedTab = firstChild;
|
||||||
|
|
||||||
|
var toBeClosedTabs = this._collectNeedlessGroupTabs(tab);
|
||||||
|
|
||||||
var parentTab = this.getParentTab(tab);
|
var parentTab = this.getParentTab(tab);
|
||||||
if (parentTab) {
|
if (parentTab) {
|
||||||
if (!nextFocusedTab && tab == this.getLastChildTab(parentTab)) {
|
if (!nextFocusedTab && tab == this.getLastChildTab(parentTab)) {
|
||||||
@ -2961,21 +2954,20 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
nextFocusedTab = this.getPreviousSiblingTab(tab);
|
nextFocusedTab = this.getPreviousSiblingTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
let toBeClosedParent = this._reserveCloseNeedlessGroupTabParent(tab);
|
if (nextFocusedTab && toBeClosedTabs.indexOf(nextFocusedTab) > -1)
|
||||||
if (toBeClosedParent && nextFocusedTab == toBeClosedParent)
|
|
||||||
nextFocusedTab = this.getNextFocusedTab(parentTab);
|
nextFocusedTab = this.getNextFocusedTab(parentTab);
|
||||||
}
|
}
|
||||||
else if (!nextFocusedTab) {
|
else if (!nextFocusedTab) {
|
||||||
nextFocusedTab = this.getNextFocusedTab(tab);
|
nextFocusedTab = this.getNextFocusedTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (toBeClosedSibling && nextFocusedTab == toBeClosedSibling)
|
if (nextFocusedTab && toBeClosedTabs.indexOf(nextFocusedTab) > -1)
|
||||||
nextFocusedTab = this.getFirstChildTab(nextFocusedTab);
|
nextFocusedTab = this.getNextFocusedTab(nextFocusedTab);
|
||||||
|
|
||||||
|
this._reserveCloseRelatedTabs(toBeClosedTabs);
|
||||||
|
|
||||||
this.detachTab(tab, { dontUpdateIndent : true });
|
this.detachTab(tab, { dontUpdateIndent : true });
|
||||||
|
|
||||||
this.checkTabsIndentOverflow();
|
|
||||||
|
|
||||||
this._restoreTabAttributes(tab, backupAttributes);
|
this._restoreTabAttributes(tab, backupAttributes);
|
||||||
|
|
||||||
if (b.selectedTab == tab)
|
if (b.selectedTab == tab)
|
||||||
@ -3045,10 +3037,11 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.startRendering();
|
this.startRendering();
|
||||||
},
|
},
|
||||||
|
|
||||||
_reserveCloseNeedlessGroupTabSibling : function TSTBrowser_reserveCloseNeedlessGroupTabSibling(aTab)
|
_collectNeedlessGroupTabs : function TSTBrowser_collectNeedlessGroupTabs(aTab)
|
||||||
{
|
{
|
||||||
if (!aTab || !aTab.parentNode || !this.hasChildTabs(aTab))
|
var tabs = [];
|
||||||
return null;
|
if (!aTab || !aTab.parentNode)
|
||||||
|
return tabs;
|
||||||
|
|
||||||
var parent = this.getParentTab(aTab);
|
var parent = this.getParentTab(aTab);
|
||||||
var siblings = this.getSiblingTabs(aTab);
|
var siblings = this.getSiblingTabs(aTab);
|
||||||
@ -3058,49 +3051,39 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
siblings.length == 1 &&
|
siblings.length == 1 &&
|
||||||
this.hasChildTabs(groupTabs[0])
|
this.hasChildTabs(groupTabs[0])
|
||||||
) ? groupTabs[0] : null ;
|
) ? groupTabs[0] : null ;
|
||||||
|
if (groupTab)
|
||||||
if (groupTab) {
|
tabs.push(groupTab);
|
||||||
this.window.setTimeout(function(aSelf, aGroupTab) {
|
|
||||||
aSelf.getTabBrowserFromChild(aGroupTab).removeTab(aGroupTab, { animate : true });
|
|
||||||
}, 0, this, groupTab);
|
|
||||||
return groupTab;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
},
|
|
||||||
|
|
||||||
_reserveCloseNeedlessGroupTabParent : function TSTBrowser_reserveCloseNeedlessGroupTabParent(aTab)
|
|
||||||
{
|
|
||||||
if (!aTab)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var parentTab = this.getParentTab(aTab);
|
|
||||||
if (!parentTab)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
var shouldCloseParentTab = (
|
var shouldCloseParentTab = (
|
||||||
this.isGroupTab(parentTab) &&
|
parent &&
|
||||||
this.getDescendantTabs(parentTab).length == 1
|
this.isGroupTab(parent) &&
|
||||||
|
this.getDescendantTabs(parent).length == 1
|
||||||
);
|
);
|
||||||
if (shouldCloseParentTab) {
|
if (shouldCloseParentTab)
|
||||||
let key = 'onTabClose_'+parseInt(Math.random() * 65000);
|
tabs.push(parent);
|
||||||
let self = this;
|
|
||||||
|
return tabs;
|
||||||
|
},
|
||||||
|
|
||||||
|
_reserveCloseRelatedTabs : function TSTBrowser_reserveCloseRelatedTabs(aTabs)
|
||||||
|
{
|
||||||
|
if (!aTabs.length)
|
||||||
|
return;
|
||||||
|
|
||||||
|
var key = 'onTabClose_'+parseInt(Math.random() * 65000);
|
||||||
|
var self = this;
|
||||||
(this.deferredTasks[key] = this.Deferred.next(function() {
|
(this.deferredTasks[key] = this.Deferred.next(function() {
|
||||||
if (parentTab.parentNode)
|
aTabs.forEach(function(aTab) {
|
||||||
self.mTabBrowser.removeTab(parentTab, { animate : true });
|
if (aTab.parentNode)
|
||||||
|
self.mTabBrowser.removeTab(aTab, { animate : true });
|
||||||
|
});
|
||||||
})).error(this.defaultDeferredErrorHandler).next(function() {
|
})).error(this.defaultDeferredErrorHandler).next(function() {
|
||||||
delete self.deferredTasks[key];
|
delete self.deferredTasks[key];
|
||||||
}).next(function() {
|
}).next(function() {
|
||||||
parentTab = null;
|
aTabs = null;
|
||||||
aTab = null;
|
|
||||||
self = null;
|
self = null;
|
||||||
key = null;
|
key = null;
|
||||||
});
|
});
|
||||||
return parentTab;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_saveAndUpdateReferenceTabsInfo : function TSTBrowser_saveAndUpdateReferenceTabsInfo(aTab)
|
_saveAndUpdateReferenceTabsInfo : function TSTBrowser_saveAndUpdateReferenceTabsInfo(aTab)
|
||||||
|
Loading…
Reference in New Issue
Block a user