Reduce usecases of evaluateXPath()
This commit is contained in:
parent
f106546809
commit
a6792a2b4b
@ -205,7 +205,7 @@ TreeStyleTabWindowHelper.overrideExtensionsPreInit = function TSTWH_overrideExte
|
|||||||
'var tabcount = ',
|
'var tabcount = ',
|
||||||
<![CDATA[
|
<![CDATA[
|
||||||
gBrowser.treeStyleTab.collapseExpandAllSubtree(false, true);
|
gBrowser.treeStyleTab.collapseExpandAllSubtree(false, true);
|
||||||
let (tabs = gBrowser.treeStyleTab.getTabsArray(gBrowser).slice(1).reverse()) {
|
let (tabs = gBrowser.treeStyleTab.getTabs(gBrowser).slice(1).reverse()) {
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let tab = tabs[i];
|
let tab = tabs[i];
|
||||||
|
@ -1094,7 +1094,7 @@ AutoHideBrowser.prototype = {
|
|||||||
this.cancelDelayedShowForShortcut();
|
this.cancelDelayedShowForShortcut();
|
||||||
|
|
||||||
if (
|
if (
|
||||||
sv.getTabsArray(b).length > 1 &&
|
sv.getTabs(b).length > 1 &&
|
||||||
!aEvent.altKey &&
|
!aEvent.altKey &&
|
||||||
w.TreeStyleTabService.accelKeyPressed
|
w.TreeStyleTabService.accelKeyPressed
|
||||||
) {
|
) {
|
||||||
|
@ -374,7 +374,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
getTabFromCoordinate : function TSTBrowser_getTabFromCoordinate(aCoordinate)
|
getTabFromCoordinate : function TSTBrowser_getTabFromCoordinate(aCoordinate)
|
||||||
{
|
{
|
||||||
var tab = null;
|
var tab = null;
|
||||||
this.getTabsArray(this.mTabBrowser).some(function(aTab) {
|
this.getTabs(this.mTabBrowser).some(function(aTab) {
|
||||||
var box = aTab.boxObject;
|
var box = aTab.boxObject;
|
||||||
if (box[this.screenPositionProp] > aCoordinate ||
|
if (box[this.screenPositionProp] > aCoordinate ||
|
||||||
box[this.screenPositionProp] + box[this.sizeProp] < aCoordinate) {
|
box[this.screenPositionProp] + box[this.sizeProp] < aCoordinate) {
|
||||||
@ -558,7 +558,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
updateTabsZIndex : function TSTBrowser_updateTabsZIndex(aStacked)
|
updateTabsZIndex : function TSTBrowser_updateTabsZIndex(aStacked)
|
||||||
{
|
{
|
||||||
var tabs = this.getTabsArray(this.mTabBrowser);
|
var tabs = this.getTabs(this.mTabBrowser);
|
||||||
var count = tabs.length;
|
var count = tabs.length;
|
||||||
for (let i = 0; i < count; i++)
|
for (let i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
@ -678,7 +678,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this._initTabbrowserContextMenu();
|
this._initTabbrowserContextMenu();
|
||||||
w.TreeStyleTabWindowHelper.updateTabDNDObserver(b);
|
w.TreeStyleTabWindowHelper.updateTabDNDObserver(b);
|
||||||
|
|
||||||
this.getAllTabsArray(b).forEach(this.initTab, this);
|
this.getAllTabs(b).forEach(this.initTab, this);
|
||||||
|
|
||||||
this.onPrefChange('extensions.treestyletab.maxTreeLevel');
|
this.onPrefChange('extensions.treestyletab.maxTreeLevel');
|
||||||
this.onPrefChange('extensions.treestyletab.tabbar.style');
|
this.onPrefChange('extensions.treestyletab.tabbar.style');
|
||||||
@ -1159,7 +1159,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
[aTarget] :
|
[aTarget] :
|
||||||
(typeof aTarget == 'object' && 'length' in aTarget) ?
|
(typeof aTarget == 'object' && 'length' in aTarget) ?
|
||||||
Array.slice(aTarget) :
|
Array.slice(aTarget) :
|
||||||
self.getAllTabsArray(b);
|
self.getAllTabs(b);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
self.initTabContentsOrder(tabs[i]);
|
self.initTabContentsOrder(tabs[i]);
|
||||||
@ -1401,7 +1401,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var tabs = this.getAllTabsArray(b);
|
var tabs = this.getAllTabs(b);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let tab = tabs[i];
|
let tab = tabs[i];
|
||||||
@ -1745,7 +1745,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (splitter.collapsed || splitter.getAttribute('state') != 'collapsed') {
|
if (splitter.collapsed || splitter.getAttribute('state') != 'collapsed') {
|
||||||
this._tabStripPlaceHolder.collapsed =
|
this._tabStripPlaceHolder.collapsed =
|
||||||
splitter.collapsed =
|
splitter.collapsed =
|
||||||
(this.getPref('browser.tabs.autoHide') && this.getTabsArray(this.mTabBrowser).length == 1);
|
(this.getPref('browser.tabs.autoHide') && this.getTabs(this.mTabBrowser).length == 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
var strip = this.tabStrip;
|
var strip = this.tabStrip;
|
||||||
@ -1943,7 +1943,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
reinitAllTabs : function TSTBrowser_reinitAllTabs(aSouldUpdateCount)
|
reinitAllTabs : function TSTBrowser_reinitAllTabs(aSouldUpdateCount)
|
||||||
{
|
{
|
||||||
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
var tabs = this.getAllTabs(this.mTabBrowser);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let tab = tabs[i];
|
let tab = tabs[i];
|
||||||
@ -1984,7 +1984,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
delete b.tabContainer.treeStyleTab;
|
delete b.tabContainer.treeStyleTab;
|
||||||
|
|
||||||
var tabs = this.getAllTabsArray(b);
|
var tabs = this.getAllTabs(b);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let tab = tabs[i];
|
let tab = tabs[i];
|
||||||
@ -2294,7 +2294,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
var value = this.getPref(aPrefName);
|
var value = this.getPref(aPrefName);
|
||||||
var tabContainer = b.mTabContainer;
|
var tabContainer = b.mTabContainer;
|
||||||
var tabs = this.getAllTabsArray(b);
|
var tabs = this.getAllTabs(b);
|
||||||
switch (aPrefName)
|
switch (aPrefName)
|
||||||
{
|
{
|
||||||
case 'extensions.treestyletab.tabbar.position':
|
case 'extensions.treestyletab.tabbar.position':
|
||||||
@ -2413,7 +2413,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
return this.updateInvertedTabContentsOrder(true);
|
return this.updateInvertedTabContentsOrder(true);
|
||||||
|
|
||||||
case 'browser.tabs.autoHide':
|
case 'browser.tabs.autoHide':
|
||||||
if (this.getTabsArray(this.mTabBrowser).length == 1)
|
if (this.getTabs(this.mTabBrowser).length == 1)
|
||||||
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR);
|
this.updateFloatingTabbar(this.kTABBAR_UPDATE_BY_SHOWHIDE_TABBAR);
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -2824,7 +2824,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
// if there is only one tab and new another tab is opened,
|
// if there is only one tab and new another tab is opened,
|
||||||
// closebox appearance is possibly changed.
|
// closebox appearance is possibly changed.
|
||||||
var tabs = this.getTabsArray(b);
|
var tabs = this.getTabs(b);
|
||||||
if (tabs.length == 2)
|
if (tabs.length == 2)
|
||||||
this.updateInvertedTabContentsOrder(tabs);
|
this.updateInvertedTabContentsOrder(tabs);
|
||||||
|
|
||||||
@ -3150,7 +3150,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
var old = aEvent.detail;
|
var old = aEvent.detail;
|
||||||
if (old > tab._tPos) old--;
|
if (old > tab._tPos) old--;
|
||||||
var tabs = this.getAllTabsArray(b);
|
var tabs = this.getAllTabs(b);
|
||||||
old = tabs[old];
|
old = tabs[old];
|
||||||
|
|
||||||
prev = this.getPreviousSiblingTab(old);
|
prev = this.getPreviousSiblingTab(old);
|
||||||
@ -3195,7 +3195,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (aOldPosition === void(0)) aOldPosition = aTab._tPos;
|
if (aOldPosition === void(0)) aOldPosition = aTab._tPos;
|
||||||
|
|
||||||
var pos = this.getChildIndex(aTab, parent);
|
var pos = this.getChildIndex(aTab, parent);
|
||||||
var oldPos = this.getChildIndex(this.getAllTabsArray(this.mTabBrowser)[aOldPosition], parent);
|
var oldPos = this.getChildIndex(this.getAllTabs(this.mTabBrowser)[aOldPosition], parent);
|
||||||
var delta;
|
var delta;
|
||||||
if (pos == oldPos) { // no move?
|
if (pos == oldPos) { // no move?
|
||||||
return;
|
return;
|
||||||
@ -3374,7 +3374,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
{
|
{
|
||||||
this.internallyTabMovingCount++;
|
this.internallyTabMovingCount++;
|
||||||
|
|
||||||
var allTabs = this.getAllTabsArray(this.mTabBrowser);
|
var allTabs = this.getAllTabs(this.mTabBrowser);
|
||||||
var normalTabs = allTabs.filter(function(aTab) {
|
var normalTabs = allTabs.filter(function(aTab) {
|
||||||
return !aTab.hasAttribute('pinned');
|
return !aTab.hasAttribute('pinned');
|
||||||
});
|
});
|
||||||
@ -3453,7 +3453,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.internallyTabMovingCount++;
|
this.internallyTabMovingCount++;
|
||||||
var w = this.window;
|
var w = this.window;
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
var lastCount = this.getAllTabs(b).snapshotLength - 1;
|
var lastCount = this.getAllTabs(b).length - 1;
|
||||||
|
|
||||||
this.detachTab(aParent);
|
this.detachTab(aParent);
|
||||||
b.moveTabTo(aParent, lastCount);
|
b.moveTabTo(aParent, lastCount);
|
||||||
@ -4693,7 +4693,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
resetAllTabs : function TSTBrowser_resetAllTabs(aDetachAllChildren)
|
resetAllTabs : function TSTBrowser_resetAllTabs(aDetachAllChildren)
|
||||||
{
|
{
|
||||||
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
var tabs = this.getAllTabs(this.mTabBrowser);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
this.resetTab(tabs[i], aDetachAllChildren);
|
this.resetTab(tabs[i], aDetachAllChildren);
|
||||||
@ -4731,7 +4731,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.allowSubtreeCollapseExpand = true;
|
this.allowSubtreeCollapseExpand = true;
|
||||||
delete this._lastAllowSubtreeCollapseExpand;
|
delete this._lastAllowSubtreeCollapseExpand;
|
||||||
|
|
||||||
let tabs = this.getAllTabsArray(this.browser);
|
let tabs = this.getAllTabs(this.browser);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let tab = tabs[i];
|
let tab = tabs[i];
|
||||||
@ -4746,7 +4746,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.updateTabsIndent(this.rootTabs, undefined, true);
|
this.updateTabsIndent(this.rootTabs, undefined, true);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
let tabs = this.getAllTabsArray(this.browser);
|
let tabs = this.getAllTabs(this.browser);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let tab = tabs[i];
|
let tab = tabs[i];
|
||||||
@ -5002,7 +5002,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
this.isGroupTab(aTab) &&
|
this.isGroupTab(aTab) &&
|
||||||
this.getTabsArray(b).filter(function(aTab) {
|
this.getTabs(b).filter(function(aTab) {
|
||||||
return !b._removingTabs || b._removingTabs.indexOf(aTab) < 0;
|
return !b._removingTabs || b._removingTabs.indexOf(aTab) < 0;
|
||||||
}).length == children.length
|
}).length == children.length
|
||||||
) {
|
) {
|
||||||
@ -5390,7 +5390,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (this.maxTreeLevel < 0 || !this.maxTreeLevelPhisical)
|
if (this.maxTreeLevel < 0 || !this.maxTreeLevelPhisical)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var tabs = aParent ? this.getDescendantTabs(aParent) : this.getAllTabsArray(this.mTabBrowser) ;
|
var tabs = aParent ? this.getDescendantTabs(aParent) : this.getAllTabs(this.mTabBrowser) ;
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let level = parseInt(tab.getAttribute(this.kNEST) || 0);
|
let level = parseInt(tab.getAttribute(this.kNEST) || 0);
|
||||||
@ -5513,7 +5513,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
var shouldClose = (
|
var shouldClose = (
|
||||||
!aOptions.duplicate &&
|
!aOptions.duplicate &&
|
||||||
sourceService.getAllTabsArray(sourceBrowser).length == aTabs.length
|
sourceService.getAllTabs(sourceBrowser).length == aTabs.length
|
||||||
);
|
);
|
||||||
var newTabs = [];
|
var newTabs = [];
|
||||||
var treeStructure = sourceService.getTreeStructureFromTabs(aTabs);
|
var treeStructure = sourceService.getTreeStructureFromTabs(aTabs);
|
||||||
@ -5529,7 +5529,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
(sourceService != this || aOptions.duplicate)
|
(sourceService != this || aOptions.duplicate)
|
||||||
);
|
);
|
||||||
|
|
||||||
var tabs = this.getTabsArray(targetBrowser);
|
var tabs = this.getTabs(targetBrowser);
|
||||||
var lastTabIndex = tabs[tabs.length -1]._tPos;
|
var lastTabIndex = tabs[tabs.length -1]._tPos;
|
||||||
for (let i in aTabs)
|
for (let i in aTabs)
|
||||||
{
|
{
|
||||||
@ -6239,7 +6239,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var onlyVisible = level <= this.kRESTORE_TREE_ONLY_VISIBLE;
|
var onlyVisible = level <= this.kRESTORE_TREE_ONLY_VISIBLE;
|
||||||
var tabs = this.getAllTabsArray(this.mTabBrowser);
|
var tabs = this.getAllTabs(this.mTabBrowser);
|
||||||
tabs = tabs.filter(function(aTab) {
|
tabs = tabs.filter(function(aTab) {
|
||||||
return (
|
return (
|
||||||
aTab.linkedBrowser.__SS_restoreState &&
|
aTab.linkedBrowser.__SS_restoreState &&
|
||||||
|
@ -250,7 +250,7 @@ catch(e) {
|
|||||||
var d = this.document;
|
var d = this.document;
|
||||||
|
|
||||||
var tab = sv.getTabFromEvent(aEvent) || sv.getTabFromTabbarEvent(aEvent) || aEvent.target;
|
var tab = sv.getTabFromEvent(aEvent) || sv.getTabFromTabbarEvent(aEvent) || aEvent.target;
|
||||||
var tabs = sv.getTabsArray(b);
|
var tabs = sv.getTabs(b);
|
||||||
var firstTab = sv.getFirstNormalTab(b) || tabs[0];
|
var firstTab = sv.getFirstNormalTab(b) || tabs[0];
|
||||||
var lastTabIndex = tabs.length - 1;
|
var lastTabIndex = tabs.length - 1;
|
||||||
var isInverted = sv.isVertical ? false : b.ownerDocument.defaultView.getComputedStyle(b.parentNode, null).direction == 'rtl';
|
var isInverted = sv.isVertical ? false : b.ownerDocument.defaultView.getComputedStyle(b.parentNode, null).direction == 'rtl';
|
||||||
@ -433,7 +433,7 @@ catch(e) {
|
|||||||
|
|
||||||
|
|
||||||
var targetBrowser = b;
|
var targetBrowser = b;
|
||||||
var tabs = sv.getTabsArray(targetBrowser);
|
var tabs = sv.getTabs(targetBrowser);
|
||||||
|
|
||||||
var draggedWholeTree = [].concat(draggedRoots);
|
var draggedWholeTree = [].concat(draggedRoots);
|
||||||
for (let i = 0, maxi = draggedRoots.length; i < maxi; i++)
|
for (let i = 0, maxi = draggedRoots.length; i < maxi; i++)
|
||||||
@ -597,12 +597,12 @@ catch(e) {
|
|||||||
action : sv.kACTIONS_FOR_DESTINATION | sv.kACTION_IMPORT
|
action : sv.kACTIONS_FOR_DESTINATION | sv.kACTION_IMPORT
|
||||||
};
|
};
|
||||||
var tabsInfo = this.getDraggedTabsInfoFromOneTab(actionInfo, aTab);
|
var tabsInfo = this.getDraggedTabsInfoFromOneTab(actionInfo, aTab);
|
||||||
return tabsInfo.draggedTabs.length == (aTabs || sv.getAllTabsArray(b)).length;
|
return tabsInfo.draggedTabs.length == (aTabs || sv.getAllTabs(b)).length;
|
||||||
},
|
},
|
||||||
|
|
||||||
isDraggingAllCurrentTabs : function TabbarDND_isDraggingAllCurrentTabs(aTab)
|
isDraggingAllCurrentTabs : function TabbarDND_isDraggingAllCurrentTabs(aTab)
|
||||||
{
|
{
|
||||||
return this.isDraggingAllTabs(aTab, this.treeStyleTab.getTabsArray(this.treeStyleTab.browser));
|
return this.isDraggingAllTabs(aTab, this.treeStyleTab.getTabs(this.treeStyleTab.browser));
|
||||||
},
|
},
|
||||||
|
|
||||||
handleEvent : function TabbarDND_handleEvent(aEvent)
|
handleEvent : function TabbarDND_handleEvent(aEvent)
|
||||||
|
@ -1428,7 +1428,7 @@ var TreeStyleTabUtils = {
|
|||||||
{
|
{
|
||||||
var b = aTabBrowser || this.browser;
|
var b = aTabBrowser || this.browser;
|
||||||
var top = aFrame.top;
|
var top = aFrame.top;
|
||||||
var tabs = this.getAllTabsArray(b);
|
var tabs = this.getAllTabs(b);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let tab = tabs[i];
|
let tab = tabs[i];
|
||||||
@ -1606,11 +1606,7 @@ var TreeStyleTabUtils = {
|
|||||||
if (this.tabsHash) // XPath-less implementation
|
if (this.tabsHash) // XPath-less implementation
|
||||||
return this.tabsHash[aId] || null;
|
return this.tabsHash[aId] || null;
|
||||||
|
|
||||||
return this.evaluateXPath(
|
return b.mTabContainer.querySelector('tab['+this.kID+'="'+aId+'"]');
|
||||||
'descendant::xul:tab[@'+this.kID+' = "'+aId+'"]',
|
|
||||||
b.mTabContainer,
|
|
||||||
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
||||||
).singleNodeValue;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
isTabDuplicated : function TSTUtils_isTabDuplicated(aTab)
|
isTabDuplicated : function TSTUtils_isTabDuplicated(aTab)
|
||||||
@ -1625,54 +1621,36 @@ var TreeStyleTabUtils = {
|
|||||||
).booleanValue;
|
).booleanValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all tabs in the current group as a XPathResult.
|
|
||||||
* It includes tabs hidden by Tab Panorama.
|
|
||||||
*/
|
|
||||||
getAllTabs : function TSTUtils_getTabs(aTabBrowserChild) /* OBSOLETE */
|
|
||||||
{
|
|
||||||
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
|
||||||
this.assertBeforeDestruction(b && b.mTabContainer);
|
|
||||||
return this.evaluateXPath(
|
|
||||||
'descendant::xul:tab',
|
|
||||||
b.mTabContainer
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all tabs in the current group as a XPathResult.
|
|
||||||
* It excludes tabs hidden by Tab Panorama.
|
|
||||||
*/
|
|
||||||
getTabs : function TSTUtils_getTabs(aTabBrowserChild) /* OBSOLETE */
|
|
||||||
{
|
|
||||||
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
|
||||||
this.assertBeforeDestruction(b && b.mTabContainer);
|
|
||||||
return this.evaluateXPath(
|
|
||||||
'descendant::xul:tab[not(@hidden="true")]',
|
|
||||||
b.mTabContainer
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all tabs in the current group as an array.
|
* Returns all tabs in the current group as an array.
|
||||||
* It includes tabs hidden by Tab Panorama.
|
* It includes tabs hidden by Tab Panorama.
|
||||||
*/
|
*/
|
||||||
getAllTabsArray : function TSTUtils_getAllTabsArray(aTabBrowserChild)
|
getAllTabs : function TSTUtils_getTabs(aTabBrowserChild)
|
||||||
{
|
{
|
||||||
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
||||||
this.assertBeforeDestruction(b && b.mTabContainer);
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
||||||
return Array.slice(b.mTabContainer.childNodes) ;
|
return Array.slice(b.mTabContainer.querySelectorAll('tab'));
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns all tabs in the current group as an array.
|
* Returns all tabs in the current group as an array.
|
||||||
* It excludes tabs hidden by Tab Panorama.
|
* It excludes tabs hidden by Tab Panorama.
|
||||||
*/
|
*/
|
||||||
getTabsArray : function TSTUtils_getTabsArray(aTabBrowserChild)
|
getTabs : function TSTUtils_getTabs(aTabBrowserChild)
|
||||||
{
|
{
|
||||||
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
||||||
this.assertBeforeDestruction(b && b.mTabContainer);
|
this.assertBeforeDestruction(b && b.mTabContainer);
|
||||||
return b.visibleTabs || Array.slice(b.mTabContainer.childNodes) ;
|
return Array.slice(b.mTabContainer.querySelectorAll('tab:not([hidden="true"])'));
|
||||||
|
},
|
||||||
|
|
||||||
|
getAllTabsArray : function TSTUtils_getAllTabsArray(aTabBrowserChild) /* for backward compatibility */
|
||||||
|
{
|
||||||
|
return this.getAllTabs(aTabBrowserChild);
|
||||||
|
},
|
||||||
|
|
||||||
|
getTabsArray : function TSTUtils_getTabsArray(aTabBrowserChild) /* for backward compatibility */
|
||||||
|
{
|
||||||
|
return this.getTabs(aTabBrowserChild);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1696,7 +1674,6 @@ var TreeStyleTabUtils = {
|
|||||||
return this.evaluateXPath(
|
return this.evaluateXPath(
|
||||||
'descendant::xul:tab[not(@pinned="true") and not(@hidden="true")]',
|
'descendant::xul:tab[not(@pinned="true") and not(@hidden="true")]',
|
||||||
b.mTabContainer,
|
b.mTabContainer,
|
||||||
|
|
||||||
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
||||||
).singleNodeValue;
|
).singleNodeValue;
|
||||||
},
|
},
|
||||||
@ -1755,7 +1732,7 @@ var TreeStyleTabUtils = {
|
|||||||
{
|
{
|
||||||
if (!aTab) return -1;
|
if (!aTab) return -1;
|
||||||
var b = this.getTabBrowserFromChild(aTab);
|
var b = this.getTabBrowserFromChild(aTab);
|
||||||
return this.getTabsArray(b).indexOf(aTab);
|
return this.getTabs(b).indexOf(aTab);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1769,7 +1746,7 @@ var TreeStyleTabUtils = {
|
|||||||
if (!this.canCollapseSubtree(b))
|
if (!this.canCollapseSubtree(b))
|
||||||
return this.getNextTab(aTab);
|
return this.getNextTab(aTab);
|
||||||
|
|
||||||
var tabs = this.getVisibleTabsArray(b);
|
var tabs = this.getVisibleTabs(b);
|
||||||
if (tabs.indexOf(aTab) < 0) tabs.push(aTab);
|
if (tabs.indexOf(aTab) < 0) tabs.push(aTab);
|
||||||
tabs.sort(this.sortTabsByOrder);
|
tabs.sort(this.sortTabsByOrder);
|
||||||
|
|
||||||
@ -1788,7 +1765,7 @@ var TreeStyleTabUtils = {
|
|||||||
if (!this.canCollapseSubtree(b))
|
if (!this.canCollapseSubtree(b))
|
||||||
return this.getPreviousTab(aTab);
|
return this.getPreviousTab(aTab);
|
||||||
|
|
||||||
var tabs = this.getVisibleTabsArray(b);
|
var tabs = this.getVisibleTabs(b);
|
||||||
if (tabs.indexOf(aTab) < 0) tabs.push(aTab);
|
if (tabs.indexOf(aTab) < 0) tabs.push(aTab);
|
||||||
tabs.sort(this.sortTabsByOrder);
|
tabs.sort(this.sortTabsByOrder);
|
||||||
|
|
||||||
@ -1803,7 +1780,7 @@ var TreeStyleTabUtils = {
|
|||||||
{
|
{
|
||||||
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
||||||
if (!b) return null;
|
if (!b) return null;
|
||||||
var tabs = this.getVisibleTabsArray(b);
|
var tabs = this.getVisibleTabs(b);
|
||||||
return tabs.length ? tabs[tabs.length-1] : null ;
|
return tabs.length ? tabs[tabs.length-1] : null ;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1815,26 +1792,12 @@ var TreeStyleTabUtils = {
|
|||||||
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
||||||
if (!this.canCollapseSubtree(b))
|
if (!this.canCollapseSubtree(b))
|
||||||
return this.getTabs(b);
|
return this.getTabs(b);
|
||||||
|
return Array.slice(b.mTabContainer.querySelectorAll('tab:not(['+this.kCOLLAPSED+'="true"]):not([hidden="true"])'));
|
||||||
var XPathResult = this.evaluateXPath(
|
|
||||||
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true") and not(@hidden="true")]',
|
|
||||||
b.mTabContainer
|
|
||||||
);
|
|
||||||
return XPathResult;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
getVisibleTabsArray : function TSTUtils_getVisibleTabsArray(aTabBrowserChild) /* for backward compatibility */
|
||||||
* Returns an array of not collapsed tabs in the current group.
|
|
||||||
*/
|
|
||||||
getVisibleTabsArray : function TSTUtils_getVisibleTabsArray(aTabBrowserChild)
|
|
||||||
{
|
{
|
||||||
var b = this.getTabBrowserFromChild(aTabBrowserChild || this.browser);
|
return this.getVisibleTabs(aTabBrowserChild);
|
||||||
var tabs = this.getTabsArray(b);
|
|
||||||
return this.canCollapseSubtree(b) ?
|
|
||||||
tabs.filter(function(aTab) {
|
|
||||||
return aTab.getAttribute(this.kCOLLAPSED) != 'true';
|
|
||||||
}, this) :
|
|
||||||
tabs ;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1845,7 +1808,7 @@ var TreeStyleTabUtils = {
|
|||||||
{
|
{
|
||||||
if (!aTab) return -1;
|
if (!aTab) return -1;
|
||||||
var b = this.getTabBrowserFromChild(aTab);
|
var b = this.getTabBrowserFromChild(aTab);
|
||||||
return this.getVisibleTabsArray(b).indexOf(aTab);
|
return this.getVisibleTabs(b).indexOf(aTab);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1863,7 +1826,7 @@ var TreeStyleTabUtils = {
|
|||||||
*/
|
*/
|
||||||
getNewTabsFromPreviousTabsInfo : function TSTUtils_getNewTabsFromPreviousTabsInfo(aTabBrowser, aTabsInfo)
|
getNewTabsFromPreviousTabsInfo : function TSTUtils_getNewTabsFromPreviousTabsInfo(aTabBrowser, aTabsInfo)
|
||||||
{
|
{
|
||||||
var tabs = this.getTabsArray(aTabBrowser);
|
var tabs = this.getTabs(aTabBrowser);
|
||||||
var currentTabsInfo = this.getTabsInfo(aTabBrowser);
|
var currentTabsInfo = this.getTabsInfo(aTabBrowser);
|
||||||
return tabs.filter(function(aTab, aIndex) {
|
return tabs.filter(function(aTab, aIndex) {
|
||||||
return aTabsInfo.indexOf(currentTabsInfo[aIndex]) < 0;
|
return aTabsInfo.indexOf(currentTabsInfo[aIndex]) < 0;
|
||||||
@ -1871,7 +1834,7 @@ var TreeStyleTabUtils = {
|
|||||||
},
|
},
|
||||||
getTabsInfo : function TSTUtils_getTabsInfo(aTabBrowser)
|
getTabsInfo : function TSTUtils_getTabsInfo(aTabBrowser)
|
||||||
{
|
{
|
||||||
var tabs = this.getTabsArray(aTabBrowser);
|
var tabs = this.getTabs(aTabBrowser);
|
||||||
return tabs.map(function(aTab) {
|
return tabs.map(function(aTab) {
|
||||||
return aTab.getAttribute(this.kID)+'\n'+
|
return aTab.getAttribute(this.kID)+'\n'+
|
||||||
aTab.getAttribute('busy')+'\n'+
|
aTab.getAttribute('busy')+'\n'+
|
||||||
@ -2129,7 +2092,7 @@ var TreeStyleTabUtils = {
|
|||||||
return (
|
return (
|
||||||
b &&
|
b &&
|
||||||
this.shouldCloseTabSubtreeOf(aTab) &&
|
this.shouldCloseTabSubtreeOf(aTab) &&
|
||||||
this.getDescendantTabs(aTab).length + 1 == this.getAllTabsArray(b).length
|
this.getDescendantTabs(aTab).length + 1 == this.getAllTabs(b).length
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
shouldCloseLastTabSubTreeOf : function() { return this.shouldCloseLastTabSubtreeOf.apply(this, arguments); }, // obsolete, for backward compatibility
|
shouldCloseLastTabSubTreeOf : function() { return this.shouldCloseLastTabSubtreeOf.apply(this, arguments); }, // obsolete, for backward compatibility
|
||||||
@ -2622,12 +2585,12 @@ var TreeStyleTabUtils = {
|
|||||||
|
|
||||||
getTreeStructureFromTabBrowser : function TSTUtils_getTreeStructureFromTabBrowser(aTabBrowser)
|
getTreeStructureFromTabBrowser : function TSTUtils_getTreeStructureFromTabBrowser(aTabBrowser)
|
||||||
{
|
{
|
||||||
return this.getTreeStructureFromTabs(this.getAllTabsArray(aTabBrowser));
|
return this.getTreeStructureFromTabs(this.getAllTabs(aTabBrowser));
|
||||||
},
|
},
|
||||||
|
|
||||||
applyTreeStructureToTabBrowser : function TSTUtils_applyTreeStructureToTabBrowser(aTabBrowser, aTreeStructure, aExpandAllTree)
|
applyTreeStructureToTabBrowser : function TSTUtils_applyTreeStructureToTabBrowser(aTabBrowser, aTreeStructure, aExpandAllTree)
|
||||||
{
|
{
|
||||||
var tabs = this.getAllTabsArray(aTabBrowser);
|
var tabs = this.getAllTabs(aTabBrowser);
|
||||||
return this.applyTreeStructureToTabs(tabs, aTreeStructure, aExpandAllTree);
|
return this.applyTreeStructureToTabs(tabs, aTreeStructure, aExpandAllTree);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -483,7 +483,7 @@ TreeStyleTabWindow.prototype = {
|
|||||||
items = items.slice(firstItemIndex);
|
items = items.slice(firstItemIndex);
|
||||||
|
|
||||||
var b = this.getTabBrowserFromChild(aEvent.originalTarget) || this.browser;
|
var b = this.getTabBrowserFromChild(aEvent.originalTarget) || this.browser;
|
||||||
var tabs = this.getTabsArray(b);
|
var tabs = this.getTabs(b);
|
||||||
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
for (let i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
items[i].style.marginLeft = tabs[i].getAttribute(this.kNEST)+'em';
|
items[i].style.marginLeft = tabs[i].getAttribute(this.kNEST)+'em';
|
||||||
@ -1548,8 +1548,7 @@ TreeStyleTabWindow.prototype = {
|
|||||||
{
|
{
|
||||||
var keepTabs = [aTab].concat(this.getDescendantTabs(aTab));
|
var keepTabs = [aTab].concat(this.getDescendantTabs(aTab));
|
||||||
var b = this.getTabBrowserFromChild(aTab);
|
var b = this.getTabBrowserFromChild(aTab);
|
||||||
var closeTabs = this.getTabsArray(b)
|
var closeTabs = this.getTabs(b).filter(function(aTab) {
|
||||||
.filter(function(aTab) {
|
|
||||||
return keepTabs.indexOf(aTab) < 0 && !aTab.hasAttribute('pinned');
|
return keepTabs.indexOf(aTab) < 0 && !aTab.hasAttribute('pinned');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -120,19 +120,16 @@ function test_tabID()
|
|||||||
function test_getTabs()
|
function test_getTabs()
|
||||||
{
|
{
|
||||||
var result = sv.getTabs(gBrowser);
|
var result = sv.getTabs(gBrowser);
|
||||||
assert.isTrue(result instanceof XPathResult);
|
assert.equals(4, result.length);
|
||||||
assert.equals(4, result.snapshotLength);
|
|
||||||
|
|
||||||
var gotTabs = [];
|
var gotTabs = [];
|
||||||
for (var i = 0, maxi = result.snapshotLength; i < maxi; i++)
|
for (var i = 0, maxi = result.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
gotTabs.push(result.snapshotItem(i));
|
gotTabs.push(result[i]);
|
||||||
}
|
}
|
||||||
assert.equals(4, gotTabs.length);
|
assert.equals(4, gotTabs.length);
|
||||||
assert.equals(tabs, gotTabs);
|
assert.equals(tabs, gotTabs);
|
||||||
|
|
||||||
assert.equals(gotTabs, sv.getTabsArray(gBrowser));
|
|
||||||
|
|
||||||
assert.equals(tabs[0], sv.getFirstTab(gBrowser));
|
assert.equals(tabs[0], sv.getFirstTab(gBrowser));
|
||||||
assert.equals(tabs[3], sv.getLastTab(gBrowser));
|
assert.equals(tabs[3], sv.getLastTab(gBrowser));
|
||||||
assert.equals(tabs[1], sv.getNextTab(tabs[0]));
|
assert.equals(tabs[1], sv.getNextTab(tabs[0]));
|
||||||
@ -235,13 +232,12 @@ function test_getVisibleTabs()
|
|||||||
gBrowser.setAttribute(sv.kALLOW_COLLAPSE, true);
|
gBrowser.setAttribute(sv.kALLOW_COLLAPSE, true);
|
||||||
|
|
||||||
var visibleResult = sv.getVisibleTabs(tabs[0]);
|
var visibleResult = sv.getVisibleTabs(tabs[0]);
|
||||||
assert.implementsInterface(Ci.nsIDOMXPathResult, visibleResult);
|
assert.equals(2, visibleResult.length);
|
||||||
assert.equals(2, visibleResult.snapshotLength);
|
|
||||||
|
|
||||||
var visibleTabs = [];
|
var visibleTabs = [];
|
||||||
for (let i = 0, maxi = visibleResult.snapshotLength; i < maxi; i++)
|
for (let i = 0, maxi = visibleResult.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
visibleTabs.push(visibleResult.snapshotItem(i));
|
visibleTabs.push(visibleResult[i]);
|
||||||
}
|
}
|
||||||
assert.equals(2, visibleTabs.length);
|
assert.equals(2, visibleTabs.length);
|
||||||
assert.equals([tabs[0], tabs[2]], visibleTabs);
|
assert.equals([tabs[0], tabs[2]], visibleTabs);
|
||||||
@ -249,8 +245,7 @@ function test_getVisibleTabs()
|
|||||||
gBrowser.removeAttribute(sv.kALLOW_COLLAPSE);
|
gBrowser.removeAttribute(sv.kALLOW_COLLAPSE);
|
||||||
|
|
||||||
visibleResult = sv.getVisibleTabs(tabs[0]);
|
visibleResult = sv.getVisibleTabs(tabs[0]);
|
||||||
assert.implementsInterface(Ci.nsIDOMXPathResult, visibleResult);
|
assert.equals(4, visibleResult.length);
|
||||||
assert.equals(4, visibleResult.snapshotLength);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function test_getVisibleTabsArray()
|
function test_getVisibleTabsArray()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user