rearrange methods
This commit is contained in:
parent
f6fddbdadc
commit
a3af97ef98
@ -334,6 +334,36 @@ TreeStyleTabBrowser.prototype = {
|
||||
return close;
|
||||
},
|
||||
|
||||
getTabFromTabbarEvent : function TSTBrowser_getTabFromTabbarEvent(aEvent)
|
||||
{
|
||||
if (
|
||||
!this.shouldDetectClickOnIndentSpaces ||
|
||||
!this.getAncestorTabbarFromEvent(aEvent) ||
|
||||
this.isEventFiredOnClickable(aEvent) ||
|
||||
this.getSplitterFromEvent(aEvent)
|
||||
)
|
||||
return null;
|
||||
|
||||
var tab = null;
|
||||
var clickedPoint = aEvent[this.screenPositionProp];
|
||||
this.getTabsArray(this.mTabBrowser).some(function(aTab) {
|
||||
var box = aTab.boxObject;
|
||||
if (box[this.screenPositionProp] > clickedPoint ||
|
||||
box[this.screenPositionProp] + box[this.sizeProp] < clickedPoint) {
|
||||
return false;
|
||||
}
|
||||
tab = aTab;
|
||||
return true;
|
||||
}, this);
|
||||
return tab;
|
||||
},
|
||||
|
||||
getNextFocusedTab : function TSTBrowser_getNextFocusedTab(aTab)
|
||||
{
|
||||
return this.getNextSiblingTab(aTab) ||
|
||||
this.getPreviousVisibleTab(aTab);
|
||||
},
|
||||
|
||||
isTabInViewport : function TSTBrowser_isTabInViewport(aTab)
|
||||
{
|
||||
if (!this.windowService.preInitialized || !aTab)
|
||||
@ -834,10 +864,12 @@ TreeStyleTabBrowser.prototype = {
|
||||
if (!aTab.hasAttribute(this.kNEST))
|
||||
aTab.setAttribute(this.kNEST, 0);
|
||||
},
|
||||
|
||||
isTabInitialized : function TSTBrowser_isTabInitialized(aTab)
|
||||
{
|
||||
return aTab.getAttribute(this.kID);
|
||||
},
|
||||
|
||||
ensureTabInitialized : function TSTBrowser_ensureTabInitialized(aTab)
|
||||
{
|
||||
if (!aTab || this.isTabInitialized(aTab)) return;
|
||||
@ -2314,80 +2346,6 @@ TreeStyleTabBrowser.prototype = {
|
||||
this.restoreTree(true);
|
||||
},
|
||||
|
||||
restoreTree : function TSTBrowser_restoreTree(aForceRestore)
|
||||
{
|
||||
if (!this.needRestoreTree && !aForceRestore)
|
||||
return;
|
||||
|
||||
this.needRestoreTree = false;
|
||||
|
||||
if (!this.window.__SS_tabsToRestore || this.window.__SS_tabsToRestore <= 1)
|
||||
return;
|
||||
|
||||
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
||||
tabs = tabs.filter(function(aTab) {
|
||||
if (
|
||||
!aTab.linkedBrowser.__SS_restoreState ||
|
||||
!aTab.linkedBrowser.__treestyletab__toBeRestored
|
||||
)
|
||||
return false;
|
||||
|
||||
var currentId = aTab.getAttribute(this.kID);
|
||||
if (this.tabsHash[currentId] == aTab)
|
||||
delete this.tabsHash[currentId];
|
||||
|
||||
this.resetTabState(aTab);
|
||||
|
||||
var [id, duplicated] = this._restoreTabId(aTab);
|
||||
|
||||
this.setTabValue(aTab, this.kID, id);
|
||||
this.tabsHash[id] = aTab;
|
||||
|
||||
aTab.__treestyletab__structureRestored = true;
|
||||
aTab.__treestyletab__duplicated = duplicated;
|
||||
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
this.updateAllTabsIndent(true);
|
||||
|
||||
// restore tree from bottom safely
|
||||
tabs.reverse()
|
||||
.filter(this.restoreOneTab, this)
|
||||
.forEach(this.updateInsertionPositionInfo, this);
|
||||
},
|
||||
restoreOneTab : function TSTBrowser_restoreOneTab(aTab)
|
||||
{
|
||||
let duplicated = aTab.__treestyletab__duplicated;
|
||||
|
||||
let children = this.getTabValue(aTab, this.kCHILDREN);
|
||||
if (children) {
|
||||
this.deleteTabValue(aTab, this.kCHILDREN);
|
||||
let subTreeCollapsed = this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true';
|
||||
subTreeCollapsed = this._restoreSubtreeCollapsedState(aTab, subTreeCollapsed);
|
||||
let self = this;
|
||||
this._restoreChildTabsRelation(aTab, children, duplicated, function(aChild) {
|
||||
/**
|
||||
* When the child has the reference to the parent tab, attachTabTo()
|
||||
* does nothing. To ensure they are correctly related, we have to
|
||||
* clear the relation here.
|
||||
*/
|
||||
self.deleteTabValue(aChild, self.kPARENT);
|
||||
let refId = self.getTabValue(aChild, self.kINSERT_BEFORE);
|
||||
if (refId && duplicated) refId = self.redirectId(refId);
|
||||
return {
|
||||
forceExpand : true, // to prevent to collapse the selected tab
|
||||
dontAnimate : true,
|
||||
insertBefore : self.getTabById(refId)
|
||||
};
|
||||
});
|
||||
this.collapseExpandSubtree(aTab, subTreeCollapsed, true);
|
||||
}
|
||||
|
||||
delete aTab.__treestyletab__duplicated;
|
||||
return true
|
||||
},
|
||||
|
||||
/* DOM Event Handling */
|
||||
|
||||
handleEvent : function TSTBrowser_handleEvent(aEvent)
|
||||
@ -2541,11 +2499,13 @@ TreeStyleTabBrowser.prototype = {
|
||||
scrollBoxObject.scrollTo(lastX, lastY);
|
||||
}
|
||||
},
|
||||
|
||||
clearLastScrollPosition : function TSTBrowser_clearLastScrollPosition()
|
||||
{
|
||||
this.lastScrollX = -1;
|
||||
this.lastScrollY = -1;
|
||||
},
|
||||
|
||||
updateLastScrollPosition : function TSTBrowser_updateLastScrollPosition()
|
||||
{
|
||||
if (!this.isVertical) return;
|
||||
@ -2868,6 +2828,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
if (collapsed)
|
||||
this.startRendering();
|
||||
},
|
||||
|
||||
_reserveCloseNeedlessGroupTabSibling : function TSTBrowser_reserveCloseNeedlessGroupTabSibling(aTab)
|
||||
{
|
||||
if (!aTab)
|
||||
@ -2893,11 +2854,6 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
return null;
|
||||
},
|
||||
getNextFocusedTab : function TSTBrowser_getNextFocusedTab(aTab)
|
||||
{
|
||||
return this.getNextSiblingTab(aTab) ||
|
||||
this.getPreviousVisibleTab(aTab);
|
||||
},
|
||||
|
||||
onTabsClosing : function TSTBrowser_onTabsClosing(aEvent)
|
||||
{
|
||||
@ -3160,6 +3116,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
}, 0, this);
|
||||
},
|
||||
tabVisibilityChangedTimer : null,
|
||||
|
||||
updateTreeByTabVisibility : function TSTBrowser_updateTreeByTabVisibility(aChangedTabs)
|
||||
{
|
||||
this.internallyTabMovingCount++;
|
||||
@ -3231,7 +3188,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
}
|
||||
this.internallyTabMovingCount--;
|
||||
},
|
||||
tabViewTreeIsMoving : false,
|
||||
|
||||
subtreeFollowParentAcrossTabGroups : function TSTBrowser_subtreeFollowParentAcrossTabGroups(aParent)
|
||||
{
|
||||
if (this.tabViewTreeIsMoving) return;
|
||||
@ -3258,6 +3215,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
this.internallyTabMovingCount--;
|
||||
this.tabViewTreeIsMoving = false;
|
||||
},
|
||||
tabViewTreeIsMoving : false,
|
||||
|
||||
onTabRestoring : function TSTBrowser_onTabRestoring(aEvent)
|
||||
{
|
||||
@ -3400,6 +3358,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
if (mayBeDuplicated)
|
||||
this.clearRedirectionTable();
|
||||
},
|
||||
|
||||
_restoreTabId : function TSTBrowser_restoreTabId(aTab)
|
||||
{
|
||||
var id = this.getTabValue(aTab, this.kID);
|
||||
@ -3419,6 +3378,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
return [id, mayBeDuplicated];
|
||||
},
|
||||
|
||||
_getCloseSetId : function TSTBrowser_getCloseSetId(aTab, aMayBeDuplicated)
|
||||
{
|
||||
var closeSetId = null;
|
||||
@ -3442,6 +3402,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
this.deleteTabValue(aTab, this.kCLOSED_SET_ID);
|
||||
return closeSetId;
|
||||
},
|
||||
|
||||
_restoreSubtreeCollapsedState : function TSTBrowser_restoreSubtreeCollapsedState(aTab, aCollapsed)
|
||||
{
|
||||
var shouldCollapse = this.getTreePref('collapseExpandSubtree.sessionRestore');
|
||||
@ -3460,6 +3421,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, isSubtreeCollapsed);
|
||||
return isSubtreeCollapsed;
|
||||
},
|
||||
|
||||
_restoreChildTabsRelation : function TSTBrowser_restoreChildTabsRelation(aTab, aChildrenList, aMayBeDuplicated, aOptions)
|
||||
{
|
||||
var childTabs = [];
|
||||
@ -3491,6 +3453,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
return childTabs;
|
||||
},
|
||||
|
||||
_restoreTabPositionAndIndent : function TSTBrowser_restoreTabPositionAndIndent(aTab, aChildTabs, aMayBeDuplicated)
|
||||
{
|
||||
var restoringMultipleTabs = this.windowService.restoringTree;
|
||||
@ -3524,6 +3487,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
this._restoreTabPosition(aTab, position.next);
|
||||
}
|
||||
},
|
||||
|
||||
_prepareInsertionPosition : function TSTBrowser_prepareInsertionPosition(aTab, aMayBeDuplicated)
|
||||
{
|
||||
var next = this.getTabValue(aTab, this.kINSERT_BEFORE);
|
||||
@ -3567,6 +3531,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
next : next
|
||||
};
|
||||
},
|
||||
|
||||
_restoreTabPosition : function TSTBrowser_restoreTabPosition(aTab, aNextTab)
|
||||
{
|
||||
if (!aNextTab) aNextTab = this.getNextTab(aTab);
|
||||
@ -3695,6 +3660,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
this.doRestoreClosedSet(aRestoredTab, indexes);
|
||||
}
|
||||
},
|
||||
|
||||
doRestoreClosedSet : function TSTBrowser_doRestoreClosedSet(aRestoredTab, aIndexes)
|
||||
{
|
||||
if (!this.window.PlacesUIUtils._confirmOpenInTabs(aIndexes.length))
|
||||
@ -4033,29 +3999,6 @@ TreeStyleTabBrowser.prototype = {
|
||||
return;
|
||||
}
|
||||
},
|
||||
getTabFromTabbarEvent : function TSTBrowser_getTabFromTabbarEvent(aEvent)
|
||||
{
|
||||
if (
|
||||
!this.shouldDetectClickOnIndentSpaces ||
|
||||
!this.getAncestorTabbarFromEvent(aEvent) ||
|
||||
this.isEventFiredOnClickable(aEvent) ||
|
||||
this.getSplitterFromEvent(aEvent)
|
||||
)
|
||||
return null;
|
||||
|
||||
var tab = null;
|
||||
var clickedPoint = aEvent[this.screenPositionProp];
|
||||
this.getTabsArray(this.mTabBrowser).some(function(aTab) {
|
||||
var box = aTab.boxObject;
|
||||
if (box[this.screenPositionProp] > clickedPoint ||
|
||||
box[this.screenPositionProp] + box[this.sizeProp] < clickedPoint) {
|
||||
return false;
|
||||
}
|
||||
tab = aTab;
|
||||
return true;
|
||||
}, this);
|
||||
return tab;
|
||||
},
|
||||
|
||||
onClick : function TSTBrowser_onClick(aEvent)
|
||||
{
|
||||
@ -5748,6 +5691,80 @@ TreeStyleTabBrowser.prototype = {
|
||||
}
|
||||
},
|
||||
|
||||
restoreTree : function TSTBrowser_restoreTree(aForceRestore)
|
||||
{
|
||||
if (!this.needRestoreTree && !aForceRestore)
|
||||
return;
|
||||
|
||||
this.needRestoreTree = false;
|
||||
|
||||
if (!this.window.__SS_tabsToRestore || this.window.__SS_tabsToRestore <= 1)
|
||||
return;
|
||||
|
||||
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
||||
tabs = tabs.filter(function(aTab) {
|
||||
if (
|
||||
!aTab.linkedBrowser.__SS_restoreState ||
|
||||
!aTab.linkedBrowser.__treestyletab__toBeRestored
|
||||
)
|
||||
return false;
|
||||
|
||||
var currentId = aTab.getAttribute(this.kID);
|
||||
if (this.tabsHash[currentId] == aTab)
|
||||
delete this.tabsHash[currentId];
|
||||
|
||||
this.resetTabState(aTab);
|
||||
|
||||
var [id, duplicated] = this._restoreTabId(aTab);
|
||||
|
||||
this.setTabValue(aTab, this.kID, id);
|
||||
this.tabsHash[id] = aTab;
|
||||
|
||||
aTab.__treestyletab__structureRestored = true;
|
||||
aTab.__treestyletab__duplicated = duplicated;
|
||||
|
||||
return true;
|
||||
}, this);
|
||||
|
||||
this.updateAllTabsIndent(true);
|
||||
|
||||
// restore tree from bottom safely
|
||||
tabs.reverse()
|
||||
.filter(this.restoreOneTab, this)
|
||||
.forEach(this.updateInsertionPositionInfo, this);
|
||||
},
|
||||
restoreOneTab : function TSTBrowser_restoreOneTab(aTab)
|
||||
{
|
||||
let duplicated = aTab.__treestyletab__duplicated;
|
||||
|
||||
let children = this.getTabValue(aTab, this.kCHILDREN);
|
||||
if (children) {
|
||||
this.deleteTabValue(aTab, this.kCHILDREN);
|
||||
let subTreeCollapsed = this.getTabValue(aTab, this.kSUBTREE_COLLAPSED) == 'true';
|
||||
subTreeCollapsed = this._restoreSubtreeCollapsedState(aTab, subTreeCollapsed);
|
||||
let self = this;
|
||||
this._restoreChildTabsRelation(aTab, children, duplicated, function(aChild) {
|
||||
/**
|
||||
* When the child has the reference to the parent tab, attachTabTo()
|
||||
* does nothing. To ensure they are correctly related, we have to
|
||||
* clear the relation here.
|
||||
*/
|
||||
self.deleteTabValue(aChild, self.kPARENT);
|
||||
let refId = self.getTabValue(aChild, self.kINSERT_BEFORE);
|
||||
if (refId && duplicated) refId = self.redirectId(refId);
|
||||
return {
|
||||
forceExpand : true, // to prevent to collapse the selected tab
|
||||
dontAnimate : true,
|
||||
insertBefore : self.getTabById(refId)
|
||||
};
|
||||
});
|
||||
this.collapseExpandSubtree(aTab, subTreeCollapsed, true);
|
||||
}
|
||||
|
||||
delete aTab.__treestyletab__duplicated;
|
||||
return true
|
||||
},
|
||||
|
||||
/* sub modules */
|
||||
|
||||
get tabbarDNDObserver()
|
||||
|
Loading…
x
Reference in New Issue
Block a user