Reduce usecases of evaluateXPath()
This commit is contained in:
parent
d2e9f51f8f
commit
3b692b4de4
@ -65,9 +65,7 @@
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.parentNode.hidePopup();
|
this.parentNode.hidePopup();
|
||||||
}"
|
}"
|
||||||
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
|
multipletab-insertafter="tabContextMenu.querySelector("*[id^='context_reloadTab']")"/>
|
||||||
"descendant::*[starts-with(@id, 'context_reloadTab')][1]"
|
|
||||||
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
|
|
||||||
<menuitem id="context-item-reloadDescendantTabs"
|
<menuitem id="context-item-reloadDescendantTabs"
|
||||||
label="&context.reloadDescendantTabs.label;"
|
label="&context.reloadDescendantTabs.label;"
|
||||||
accesskey="&context.reloadDescendantTabs.accesskey;"
|
accesskey="&context.reloadDescendantTabs.accesskey;"
|
||||||
@ -77,9 +75,7 @@
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.parentNode.hidePopup();
|
this.parentNode.hidePopup();
|
||||||
}"
|
}"
|
||||||
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
|
multipletab-insertafter="tabContextMenu.querySelector("*[id^='context-item-reloadTabSubtree']")"/>
|
||||||
"descendant::*[starts-with(@id, 'context-item-reloadTabSubtree')][1]"
|
|
||||||
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
|
|
||||||
|
|
||||||
<menuitem id="context-item-removeTabSubtree"
|
<menuitem id="context-item-removeTabSubtree"
|
||||||
label="&context.removeTabSubtree.label;"
|
label="&context.removeTabSubtree.label;"
|
||||||
@ -102,16 +98,12 @@
|
|||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
this.parentNode.hidePopup();
|
this.parentNode.hidePopup();
|
||||||
}"
|
}"
|
||||||
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
|
multipletab-insertafter="tabContextMenu.querySelector("*[id^='context-item-removeTabSubtree']")"/>
|
||||||
"descendant::*[starts-with(@id, 'context-item-removeTabSubtree')][1]"
|
|
||||||
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
|
|
||||||
<menuitem id="context-item-removeAllTabsButThisTree"
|
<menuitem id="context-item-removeAllTabsButThisTree"
|
||||||
label="&context.removeAllTabsBut.label;"
|
label="&context.removeAllTabsBut.label;"
|
||||||
accesskey="&context.removeAllTabsBut.accesskey;"
|
accesskey="&context.removeAllTabsBut.accesskey;"
|
||||||
oncommand="TreeStyleTabService.removeAllTabsBut(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"
|
oncommand="TreeStyleTabService.removeAllTabsBut(TreeStyleTabService.getTabBrowserFromChild(this).mContextTab);"
|
||||||
multipletab-insertafter="TreeStyleTabService.evaluateXPath(
|
multipletab-insertafter="tabContextMenu.querySelector("*[id^='context_closeOtherTabs']")"/>
|
||||||
"descendant::*[starts-with(@id, 'context_closeOtherTabs')][1]"
|
|
||||||
, tabContextMenu, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue"/>
|
|
||||||
|
|
||||||
<menuitem id="context-item-bookmarkTabSubtree"
|
<menuitem id="context-item-bookmarkTabSubtree"
|
||||||
label="&context.bookmarkTabSubtree.label;"
|
label="&context.bookmarkTabSubtree.label;"
|
||||||
|
@ -4280,13 +4280,8 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
var nextTab = (aDir < 0) ? this.getPreviousVisibleTab(tab) : this.getNextVisibleTab(tab) ;
|
var nextTab = (aDir < 0) ? this.getPreviousVisibleTab(tab) : this.getNextVisibleTab(tab) ;
|
||||||
if (!nextTab && aWrap) {
|
if (!nextTab && aWrap) {
|
||||||
nextTab = this.evaluateXPath(
|
let tabs = tabbar.querySelectorAll('tab:not(['+this.kCOLLAPSED+'="true"])');
|
||||||
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")]['+
|
nextTab = tabs[aDir < 0 ? tabs.length-1 : 0 ];
|
||||||
(aDir < 0 ? 'last()' : '1' )+
|
|
||||||
']',
|
|
||||||
tabbar,
|
|
||||||
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
||||||
).singleNodeValue;
|
|
||||||
}
|
}
|
||||||
if (nextTab && nextTab != tab)
|
if (nextTab && nextTab != tab)
|
||||||
tabbar._selectNewTab(nextTab, aDir, aWrap);
|
tabbar._selectNewTab(nextTab, aDir, aWrap);
|
||||||
@ -4473,11 +4468,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
for (let i = 0, maxi = ids.length; i < maxi; i++)
|
for (let i = 0, maxi = ids.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
let id = ids[i];
|
let id = ids[i];
|
||||||
let item = this.evaluateXPath(
|
let item = aEvent.currentTarget.querySelector('*[id^="'+id+'"]');
|
||||||
'descendant::xul:*[starts-with(@id, "'+id+'")]',
|
|
||||||
aEvent.currentTarget,
|
|
||||||
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
||||||
).singleNodeValue;
|
|
||||||
if (!item) continue;
|
if (!item) continue;
|
||||||
items[id] = item;
|
items[id] = item;
|
||||||
if (this.getTreePref('show.'+id))
|
if (this.getTreePref('show.'+id))
|
||||||
@ -4502,33 +4493,20 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// collapse/expand all
|
// collapse/expand all
|
||||||
sep = this.evaluateXPath(
|
sep = aEvent.currentTarget.querySelector('menuseparator[id^="'+this.kMENUITEM_COLLAPSEEXPAND_SEPARATOR+'"]');
|
||||||
'descendant::xul:menuseparator[starts-with(@id, "'+this.kMENUITEM_COLLAPSEEXPAND_SEPARATOR+'")]',
|
|
||||||
aEvent.currentTarget,
|
|
||||||
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
||||||
).singleNodeValue;
|
|
||||||
let collapseItem = items[this.kMENUITEM_COLLAPSE];
|
let collapseItem = items[this.kMENUITEM_COLLAPSE];
|
||||||
let expandItem = items[this.kMENUITEM_EXPAND];
|
let expandItem = items[this.kMENUITEM_EXPAND];
|
||||||
if (this.canCollapseSubtree(b) &&
|
if (this.canCollapseSubtree(b) &&
|
||||||
this.evaluateXPath(
|
b.mTabContainer.querySelector('tab['+this.kCHILDREN+']')) {
|
||||||
'child::xul:tab[@'+this.kCHILDREN+']',
|
|
||||||
b.mTabContainer
|
|
||||||
).snapshotLength) {
|
|
||||||
if (collapseItem) {
|
if (collapseItem) {
|
||||||
if (this.evaluateXPath(
|
if (b.mTabContainer.querySelector('tab['+this.kCHILDREN+']:not(['+this.kSUBTREE_COLLAPSED+'="true"])'))
|
||||||
'child::xul:tab[@'+this.kCHILDREN+' and not(@'+this.kSUBTREE_COLLAPSED+'="true")]',
|
|
||||||
b.mTabContainer
|
|
||||||
).snapshotLength)
|
|
||||||
collapseItem.removeAttribute('disabled');
|
collapseItem.removeAttribute('disabled');
|
||||||
else
|
else
|
||||||
collapseItem.setAttribute('disabled', true);
|
collapseItem.setAttribute('disabled', true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expandItem) {
|
if (expandItem) {
|
||||||
if (this.evaluateXPath(
|
if (b.mTabContainer.querySelector('tab['+this.kCHILDREN+']['+this.kSUBTREE_COLLAPSED+'="true"]'))
|
||||||
'child::xul:tab[@'+this.kCHILDREN+' and @'+this.kSUBTREE_COLLAPSED+'="true"]',
|
|
||||||
b.mTabContainer
|
|
||||||
).snapshotLength)
|
|
||||||
expandItem.removeAttribute('disabled');
|
expandItem.removeAttribute('disabled');
|
||||||
else
|
else
|
||||||
expandItem.setAttribute('disabled', true);
|
expandItem.setAttribute('disabled', true);
|
||||||
@ -4585,11 +4563,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
fixed.removeAttribute('checked');
|
fixed.removeAttribute('checked');
|
||||||
}
|
}
|
||||||
|
|
||||||
sep = this.evaluateXPath(
|
sep = aEvent.currentTarget.querySelector('menuseparator[id^="'+this.kMENUITEM_AUTOHIDE_SEPARATOR+'"]');
|
||||||
'descendant::xul:menuseparator[starts-with(@id, "'+this.kMENUITEM_AUTOHIDE_SEPARATOR+'")]',
|
|
||||||
aEvent.currentTarget,
|
|
||||||
Ci.nsIDOMXPathResult.FIRST_ORDERED_NODE_TYPE
|
|
||||||
).singleNodeValue;
|
|
||||||
if (sep) {
|
if (sep) {
|
||||||
if (
|
if (
|
||||||
(autohide && autohide.getAttribute('hidden') != 'true') ||
|
(autohide && autohide.getAttribute('hidden') != 'true') ||
|
||||||
@ -5289,13 +5263,12 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
var tabs = this.getArrayFromXPathResult(this.evaluateXPath(
|
var tabs = Array.slice(b.mTabContainer.querySelectorAll(
|
||||||
'child::xul:tab['+
|
'tab['+this.kNEST+']:not(['+this.kNEST+'="0"]):not(['+this.kNEST+'=""])'+
|
||||||
'@'+this.kNEST+' and not(@'+this.kNEST+'="0" or @'+this.kNEST+'="") and '+
|
':not(['+this.kCOLLAPSED+'="true"])'+
|
||||||
'not(@'+this.kCOLLAPSED+'="true") and '+
|
':not([hidden="true"])'+
|
||||||
'not(@hidden="true") and '+
|
':not([collapsed="true"])',
|
||||||
'not(@collapsed="true")]',
|
|
||||||
b.mTabContainer
|
|
||||||
));
|
));
|
||||||
if (!tabs.length) return;
|
if (!tabs.length) return;
|
||||||
|
|
||||||
@ -5968,19 +5941,17 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
collapseExpandAllSubtree : function TSTBrowser_collapseExpandAllSubtree(aCollapse, aJustNow)
|
collapseExpandAllSubtree : function TSTBrowser_collapseExpandAllSubtree(aCollapse, aJustNow)
|
||||||
{
|
{
|
||||||
var xpathResult = this.evaluateXPath(
|
var tabs = this.mTabBrowser.mTabContainer.querySelectorAll(
|
||||||
'child::xul:tab[@'+this.kID+' and @'+this.kCHILDREN+
|
'tab['+this.kID+']['+this.kCHILDREN+']'+
|
||||||
(
|
(
|
||||||
aCollapse ?
|
aCollapse ?
|
||||||
' and not(@'+this.kSUBTREE_COLLAPSED+'="true")' :
|
':not(['+this.kSUBTREE_COLLAPSED+'="true"])' :
|
||||||
' and @'+this.kSUBTREE_COLLAPSED+'="true"'
|
'['+this.kSUBTREE_COLLAPSED+'="true"]'
|
||||||
)+
|
),
|
||||||
']',
|
|
||||||
this.mTabBrowser.mTabContainer
|
|
||||||
);
|
);
|
||||||
for (var i = 0, maxi = xpathResult.snapshotLength; i < maxi; i++)
|
for (var i = 0, maxi = tabs.length; i < maxi; i++)
|
||||||
{
|
{
|
||||||
this.collapseExpandSubtree(xpathResult.snapshotItem(i), aCollapse, aJustNow);
|
this.collapseExpandSubtree(tabs[i], aCollapse, aJustNow);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -6049,11 +6020,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
oldSize[0] < newSize[0] || oldSize[1] < newSize[1] ||
|
oldSize[0] < newSize[0] || oldSize[1] < newSize[1] ||
|
||||||
// there are still animating tabs
|
// there are still animating tabs
|
||||||
self.getXOffsetOfTab(lastTab) || self.getYOffsetOfTab(lastTab) ||
|
self.getXOffsetOfTab(lastTab) || self.getYOffsetOfTab(lastTab) ||
|
||||||
self.evaluateXPath(
|
self.mTabBrowser.mTabContainer.querySelector('tab['+self.kCOLLAPSING_PHASE+'="'+self.kCOLLAPSING_PHASE_TO_BE_EXPANDED+'"]')
|
||||||
'child::xul:tab[@'+self.kCOLLAPSING_PHASE+'="'+self.kCOLLAPSING_PHASE_TO_BE_EXPANDED+'"]',
|
|
||||||
self.mTabBrowser.mTabContainer,
|
|
||||||
Ci.nsIDOMXPathResult.BOOLEAN_TYPE
|
|
||||||
).booleanValue
|
|
||||||
)
|
)
|
||||||
self.smoothScrollTo(aEndX, aEndY, parseInt(aDuration * 0.5));
|
self.smoothScrollTo(aEndX, aEndY, parseInt(aDuration * 0.5));
|
||||||
self = null;
|
self = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user