Split a large method onTabClose() to small methods
This commit is contained in:
parent
eda95c427a
commit
1f6333c22c
@ -2925,10 +2925,8 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
var backupAttributes = this._collectBackupAttributes(tab);
|
var backupAttributes = this._collectBackupAttributes(tab);
|
||||||
|
|
||||||
if (
|
if (closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
|
||||||
closeParentBehavior == this.kCLOSE_PARENT_BEHAVIOR_CLOSE_ALL_CHILDREN ||
|
this.isSubtreeCollapsed(tab))
|
||||||
this.isSubtreeCollapsed(tab)
|
|
||||||
)
|
|
||||||
this._closeChildTabs(tab);
|
this._closeChildTabs(tab);
|
||||||
|
|
||||||
var toBeClosedSibling = this._reserveCloseNeedlessGroupTabSibling(tab);
|
var toBeClosedSibling = this._reserveCloseNeedlessGroupTabSibling(tab);
|
||||||
@ -2956,52 +2954,32 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
var parentTab = this.getParentTab(tab);
|
var parentTab = this.getParentTab(tab);
|
||||||
if (parentTab) {
|
if (parentTab) {
|
||||||
let firstSibling = this.getFirstChildTab(parentTab);
|
if (!nextFocusedTab && tab == this.getLastChildTab(parentTab)) {
|
||||||
let lastSibling = this.getLastChildTab(parentTab);
|
if (tab == this.getFirstChildTab(parentTab)) // this is the really last child
|
||||||
if (tab == lastSibling && !nextFocusedTab) {
|
|
||||||
if (tab == firstSibling) { // there is only one child
|
|
||||||
nextFocusedTab = parentTab;
|
nextFocusedTab = parentTab;
|
||||||
}
|
else
|
||||||
else { // previous sibling tab
|
|
||||||
nextFocusedTab = this.getPreviousSiblingTab(tab);
|
nextFocusedTab = this.getPreviousSiblingTab(tab);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let shouldCloseParentTab = (
|
let toBeClosedParent = this._reserveCloseNeedlessGroupTabParent(parentTab);
|
||||||
this.isGroupTab(parentTab) &&
|
if (toBeClosedParent && nextFocusedTab == toBeClosedParent)
|
||||||
this.getDescendantTabs(parentTab).length == 1
|
|
||||||
);
|
|
||||||
if (shouldCloseParentTab && nextFocusedTab == parentTab)
|
|
||||||
nextFocusedTab = this.getNextFocusedTab(parentTab);
|
nextFocusedTab = this.getNextFocusedTab(parentTab);
|
||||||
|
|
||||||
this.detachTab(tab, { dontUpdateIndent : true });
|
this.detachTab(tab, { dontUpdateIndent : true });
|
||||||
|
|
||||||
if (shouldCloseParentTab) {
|
|
||||||
let key = 'onTabClose_'+parseInt(Math.random() * 65000);
|
|
||||||
let self = this;
|
|
||||||
(this.deferredTasks[key] = this.Deferred.next(function() {
|
|
||||||
if (parentTab.parentNode)
|
|
||||||
b.removeTab(parentTab, { animate : true });
|
|
||||||
parentTab = null;
|
|
||||||
b = null;
|
|
||||||
})).error(this.defaultDeferredErrorHandler).next(function() {
|
|
||||||
delete self.deferredTasks[key];
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (!nextFocusedTab) {
|
else if (!nextFocusedTab) {
|
||||||
nextFocusedTab = this.getNextFocusedTab(tab);
|
nextFocusedTab = this.getNextFocusedTab(tab);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toBeClosedSibling && nextFocusedTab == toBeClosedSibling)
|
||||||
|
nextFocusedTab = this.getFirstChildTab(nextFocusedTab);
|
||||||
|
|
||||||
this.checkTabsIndentOverflow();
|
this.checkTabsIndentOverflow();
|
||||||
|
|
||||||
this._restoreTabAttributes(tab, backupAttributes);
|
this._restoreTabAttributes(tab, backupAttributes);
|
||||||
|
|
||||||
if (b.selectedTab == tab) {
|
if (b.selectedTab == tab)
|
||||||
if (nextFocusedTab && nextFocusedTab == toBeClosedSibling)
|
|
||||||
nextFocusedTab = this.getFirstChildTab(nextFocusedTab);
|
|
||||||
this._tryMoveFocusFromClosingCurrentTab(nextFocusedTab);
|
this._tryMoveFocusFromClosingCurrentTab(nextFocusedTab);
|
||||||
}
|
|
||||||
|
|
||||||
this.updateLastScrollPosition();
|
this.updateLastScrollPosition();
|
||||||
|
|
||||||
@ -3091,6 +3069,32 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_reserveCloseNeedlessGroupTabParent : function TSTBrowser_reserveCloseNeedlessGroupTabParent(aParentTab)
|
||||||
|
{
|
||||||
|
var shouldCloseParentTab = (
|
||||||
|
this.isGroupTab(aParentTab) &&
|
||||||
|
this.getDescendantTabs(aParentTab).length == 1
|
||||||
|
);
|
||||||
|
if (shouldCloseParentTab) {
|
||||||
|
let key = 'onTabClose_'+parseInt(Math.random() * 65000);
|
||||||
|
let self = this;
|
||||||
|
(this.deferredTasks[key] = this.Deferred.next(function() {
|
||||||
|
if (aParentTab.parentNode)
|
||||||
|
self.mTabBrowser.removeTab(aParentTab, { animate : true });
|
||||||
|
aParentTab = null;
|
||||||
|
})).error(this.defaultDeferredErrorHandler).next(function() {
|
||||||
|
delete self.deferredTasks[key];
|
||||||
|
}).next(function() {
|
||||||
|
self = null;
|
||||||
|
key = null;
|
||||||
|
});
|
||||||
|
return parentTab;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_saveAndUpdateReferenceTabsInfo : function TSTBrowser_saveAndUpdateReferenceTabsInfo(aTab)
|
_saveAndUpdateReferenceTabsInfo : function TSTBrowser_saveAndUpdateReferenceTabsInfo(aTab)
|
||||||
{
|
{
|
||||||
var prev = this.getPreviousSiblingTab(aTab);
|
var prev = this.getPreviousSiblingTab(aTab);
|
||||||
|
Loading…
Reference in New Issue
Block a user