サブツリーを折りたためない設定の時にまで、タブが内部的に折りたたまれた状態として扱われてしまっていたのを修正
git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5265 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
parent
7a1e02f50e
commit
ec8cf69153
@ -807,9 +807,24 @@ var TreeStyleTabService = {
|
|||||||
).singleNodeValue;
|
).singleNodeValue;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getTabIndex : function(aTab)
|
||||||
|
{
|
||||||
|
if (!aTab) return -1;
|
||||||
|
return this.evaluateXPath(
|
||||||
|
'count(preceding-sibling::xul:tab)',
|
||||||
|
aTab,
|
||||||
|
XPathResult.NUMBER_TYPE
|
||||||
|
).numberValue;
|
||||||
|
},
|
||||||
|
|
||||||
getNextVisibleTab : function(aTab)
|
getNextVisibleTab : function(aTab)
|
||||||
{
|
{
|
||||||
if (!aTab) return null;
|
if (!aTab) return null;
|
||||||
|
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
|
||||||
|
return this.getNextTab(aTab);
|
||||||
|
|
||||||
return this.evaluateXPath(
|
return this.evaluateXPath(
|
||||||
'following-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")][1]',
|
'following-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")][1]',
|
||||||
aTab,
|
aTab,
|
||||||
@ -820,6 +835,11 @@ var TreeStyleTabService = {
|
|||||||
getPreviousVisibleTab : function(aTab)
|
getPreviousVisibleTab : function(aTab)
|
||||||
{
|
{
|
||||||
if (!aTab) return null;
|
if (!aTab) return null;
|
||||||
|
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
|
||||||
|
return this.getPreviousTab(aTab);
|
||||||
|
|
||||||
return this.evaluateXPath(
|
return this.evaluateXPath(
|
||||||
'preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")][1]',
|
'preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")][1]',
|
||||||
aTab,
|
aTab,
|
||||||
@ -830,6 +850,11 @@ var TreeStyleTabService = {
|
|||||||
getLastVisibleTab : function(aTab)
|
getLastVisibleTab : function(aTab)
|
||||||
{
|
{
|
||||||
if (!aTab) return null;
|
if (!aTab) return null;
|
||||||
|
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
|
||||||
|
return this.getLastTab(aTab);
|
||||||
|
|
||||||
return this.evaluateXPath(
|
return this.evaluateXPath(
|
||||||
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")][last()]',
|
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")][last()]',
|
||||||
aTab.parentNode,
|
aTab.parentNode,
|
||||||
@ -839,6 +864,10 @@ var TreeStyleTabService = {
|
|||||||
|
|
||||||
getVisibleTabs : function(aTab)
|
getVisibleTabs : function(aTab)
|
||||||
{
|
{
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
|
||||||
|
return this.getTabs(b);
|
||||||
|
|
||||||
var xpathResult = this.evaluateXPath(
|
var xpathResult = this.evaluateXPath(
|
||||||
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")]',
|
'child::xul:tab[not(@'+this.kCOLLAPSED+'="true")]',
|
||||||
aTab.parentNode
|
aTab.parentNode
|
||||||
@ -848,8 +877,15 @@ var TreeStyleTabService = {
|
|||||||
|
|
||||||
getVisibleIndex : function(aTab)
|
getVisibleIndex : function(aTab)
|
||||||
{
|
{
|
||||||
if (!aTab || aTab.getAttribute(this.kCOLLAPSED) == 'true') return -1;
|
if (!aTab) return -1;
|
||||||
return this.evaluateXPath(
|
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
|
||||||
|
return this.getTabIndex(aTab);
|
||||||
|
|
||||||
|
return aTab.getAttribute(this.kCOLLAPSED) == 'true' ?
|
||||||
|
-1 :
|
||||||
|
this.evaluateXPath(
|
||||||
'count(preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")])',
|
'count(preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")])',
|
||||||
aTab,
|
aTab,
|
||||||
XPathResult.NUMBER_TYPE
|
XPathResult.NUMBER_TYPE
|
||||||
@ -868,6 +904,28 @@ var TreeStyleTabService = {
|
|||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
isCollapsed : function(aTab) /* PUBLIC API */
|
||||||
|
{
|
||||||
|
if (!aTab) return false;
|
||||||
|
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return aTab.getAttribute(this.kCOLLAPSED) == 'true';
|
||||||
|
},
|
||||||
|
|
||||||
|
isSubtreeCollapsed : function(aTab) /* PUBLIC API */
|
||||||
|
{
|
||||||
|
if (!aTab) return false;
|
||||||
|
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true';
|
||||||
|
},
|
||||||
|
|
||||||
getParentTab : function(aTab) /* PUBLIC API */
|
getParentTab : function(aTab) /* PUBLIC API */
|
||||||
{
|
{
|
||||||
if (!aTab) return null;
|
if (!aTab) return null;
|
||||||
@ -1064,16 +1122,26 @@ var TreeStyleTabService = {
|
|||||||
|
|
||||||
getXOffsetOfTab : function(aTab)
|
getXOffsetOfTab : function(aTab)
|
||||||
{
|
{
|
||||||
|
var extraCondition = '';
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true')
|
||||||
|
extraCondition = '[not(@'+this.kCOLLAPSED+'="true")]';
|
||||||
|
|
||||||
return this.evaluateXPath(
|
return this.evaluateXPath(
|
||||||
'sum((self::* | preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")])/attribute::'+this.kX_OFFSET+')',
|
'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kX_OFFSET+')',
|
||||||
aTab,
|
aTab,
|
||||||
XPathResult.NUMBER_TYPE
|
XPathResult.NUMBER_TYPE
|
||||||
).numberValue;
|
).numberValue;
|
||||||
},
|
},
|
||||||
getYOffsetOfTab : function(aTab)
|
getYOffsetOfTab : function(aTab)
|
||||||
{
|
{
|
||||||
|
var extraCondition = '';
|
||||||
|
var b = this.getTabBrowserFromChild(aTab) || this.browser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true')
|
||||||
|
extraCondition = '[not(@'+this.kCOLLAPSED+'="true")]';
|
||||||
|
|
||||||
return this.evaluateXPath(
|
return this.evaluateXPath(
|
||||||
'sum((self::* | preceding-sibling::xul:tab[not(@'+this.kCOLLAPSED+'="true")])/attribute::'+this.kY_OFFSET+')',
|
'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kY_OFFSET+')',
|
||||||
aTab,
|
aTab,
|
||||||
XPathResult.NUMBER_TYPE
|
XPathResult.NUMBER_TYPE
|
||||||
).numberValue;
|
).numberValue;
|
||||||
@ -1517,7 +1585,7 @@ try{
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
tab = TSTTabBrowser.treeStyleTab.getTabFromEvent(aEvent);
|
tab = TSTTabBrowser.treeStyleTab.getTabFromEvent(aEvent);
|
||||||
if (tab && tab.getAttribute(TreeStyleTabService.kCOLLAPSED) == 'true')
|
if (TreeStyleTabService.isCollapsed(tab))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var info = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
|
var info = TSTTabBrowser.treeStyleTab.getDropAction(aEvent, TST_DRAGSESSION);
|
||||||
@ -2208,7 +2276,7 @@ catch(e) {
|
|||||||
if (this._tabShouldBeExpandedAfterKeyReleased) {
|
if (this._tabShouldBeExpandedAfterKeyReleased) {
|
||||||
let tab = this._tabShouldBeExpandedAfterKeyReleased;
|
let tab = this._tabShouldBeExpandedAfterKeyReleased;
|
||||||
if (this.hasChildTabs(tab) &&
|
if (this.hasChildTabs(tab) &&
|
||||||
(tab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true')) {
|
this.isSubtreeCollapsed(tab)) {
|
||||||
this.getTabBrowserFromChild(tab)
|
this.getTabBrowserFromChild(tab)
|
||||||
.treeStyleTab
|
.treeStyleTab
|
||||||
.collapseExpandTreesIntelligentlyFor(tab);
|
.collapseExpandTreesIntelligentlyFor(tab);
|
||||||
@ -2310,7 +2378,7 @@ catch(e) {
|
|||||||
handleTooltip : function(aEvent, aTab)
|
handleTooltip : function(aEvent, aTab)
|
||||||
{
|
{
|
||||||
var label;
|
var label;
|
||||||
var collapsed = aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true';
|
var collapsed = this.isSubtreeCollapsed(aTab);
|
||||||
|
|
||||||
var base = parseInt(aTab.getAttribute(this.kNEST) || 0);
|
var base = parseInt(aTab.getAttribute(this.kNEST) || 0);
|
||||||
var descendant = this.getDescendantTabs(aTab);
|
var descendant = this.getDescendantTabs(aTab);
|
||||||
|
@ -223,7 +223,8 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
<![CDATA[$&
|
<![CDATA[$&
|
||||||
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
|
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
|
||||||
treeStyleTab._focusChangedByShortcut = TreeStyleTabService.accelKeyPressed;
|
treeStyleTab._focusChangedByShortcut = TreeStyleTabService.accelKeyPressed;
|
||||||
if (treeStyleTab.getTreePref('focusMode') == treeStyleTab.kFOCUS_VISIBLE) {
|
if (treeStyleTab.browser.getAttribute(treeStyleTab.kALLOW_COLLAPSE) == 'true' &&
|
||||||
|
treeStyleTab.getTreePref('focusMode') == treeStyleTab.kFOCUS_VISIBLE) {
|
||||||
(function(aDir, aWrap, aSelf) {
|
(function(aDir, aWrap, aSelf) {
|
||||||
var nextTab = (aDir < 0) ? treeStyleTab.getPreviousVisibleTab(aSelf.selectedItem) : treeStyleTab.getNextVisibleTab(aSelf.selectedItem) ;
|
var nextTab = (aDir < 0) ? treeStyleTab.getPreviousVisibleTab(aSelf.selectedItem) : treeStyleTab.getNextVisibleTab(aSelf.selectedItem) ;
|
||||||
if (!nextTab && aWrap) {
|
if (!nextTab && aWrap) {
|
||||||
@ -1440,7 +1441,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
closeParentBehavior == this.CLOSE_PARENT_BEHAVIOR_CLOSE ||
|
closeParentBehavior == this.CLOSE_PARENT_BEHAVIOR_CLOSE ||
|
||||||
tab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true'
|
this.isSubtreeCollapsed(tab)
|
||||||
) {
|
) {
|
||||||
this.getDescendantTabs(tab).reverse().forEach(function(aTab) {
|
this.getDescendantTabs(tab).reverse().forEach(function(aTab) {
|
||||||
b.removeTab(aTab);
|
b.removeTab(aTab);
|
||||||
@ -2023,7 +2024,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
var tab = b.selectedTab
|
var tab = b.selectedTab
|
||||||
|
|
||||||
if (tab.getAttribute(this.kCOLLAPSED) == 'true') {
|
if (this.isCollapsed(tab)) {
|
||||||
if (this.getTreePref('autoExpandSubTreeOnCollapsedChildFocused')) {
|
if (this.getTreePref('autoExpandSubTreeOnCollapsedChildFocused')) {
|
||||||
var parentTab = tab;
|
var parentTab = tab;
|
||||||
while (parentTab = this.getParentTab(parentTab))
|
while (parentTab = this.getParentTab(parentTab))
|
||||||
@ -2043,7 +2044,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.getTreePref('autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove')
|
this.getTreePref('autoCollapseExpandSubTreeOnSelect.onCurrentTabRemove')
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (!this.hasChildTabs(tab) || (tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true'))
|
if (!this.hasChildTabs(tab) || !this.isSubtreeCollapsed(tab))
|
||||||
tab = null;
|
tab = null;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@ -2217,7 +2218,8 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
).singleNodeValue;
|
).singleNodeValue;
|
||||||
let collapseItem = items[this.kMENUITEM_COLLAPSE];
|
let collapseItem = items[this.kMENUITEM_COLLAPSE];
|
||||||
let expanndItem = items[this.kMENUITEM_EXPAND];
|
let expanndItem = items[this.kMENUITEM_EXPAND];
|
||||||
if (this.evaluateXPath(
|
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true' &&
|
||||||
|
this.evaluateXPath(
|
||||||
'child::xul:tab[@'+this.kCHILDREN+']',
|
'child::xul:tab[@'+this.kCHILDREN+']',
|
||||||
b.mTabContainer
|
b.mTabContainer
|
||||||
).snapshotLength) {
|
).snapshotLength) {
|
||||||
@ -2859,11 +2861,11 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
this.collapseExpandTab(aChild, true, aInfo.dontAnimate);
|
this.collapseExpandTab(aChild, true, aInfo.dontAnimate);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aParent.getAttribute(this.kCOLLAPSED) == 'true')
|
if (this.isCollapsed(aParent))
|
||||||
this.collapseExpandTab(aChild, true, aInfo.dontAnimate);
|
this.collapseExpandTab(aChild, true, aInfo.dontAnimate);
|
||||||
}
|
}
|
||||||
else if (this.shouldTabAutoExpanded(aParent) ||
|
else if (this.shouldTabAutoExpanded(aParent) ||
|
||||||
aParent.getAttribute(this.kCOLLAPSED) == 'true') {
|
this.isCollapsed(aParent)) {
|
||||||
this.collapseExpandTab(aChild, true, aInfo.dontAnimate);
|
this.collapseExpandTab(aChild, true, aInfo.dontAnimate);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2882,7 +2884,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
shouldTabAutoExpanded : function(aTab)
|
shouldTabAutoExpanded : function(aTab)
|
||||||
{
|
{
|
||||||
return this.hasChildTabs(aTab) &&
|
return this.hasChildTabs(aTab) &&
|
||||||
aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true';
|
this.isSubtreeCollapsed(aTab);
|
||||||
},
|
},
|
||||||
|
|
||||||
partTab : function(aChild, aInfo) /* PUBLIC API */
|
partTab : function(aChild, aInfo) /* PUBLIC API */
|
||||||
@ -3017,7 +3019,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
aJustNow ||
|
aJustNow ||
|
||||||
this.indentDuration < 1 ||
|
this.indentDuration < 1 ||
|
||||||
!aProp ||
|
!aProp ||
|
||||||
(aTab.getAttribute(this.kCOLLAPSED) == 'true')
|
this.isCollapsed(aTab)
|
||||||
) {
|
) {
|
||||||
aTab.setAttribute(
|
aTab.setAttribute(
|
||||||
'style',
|
'style',
|
||||||
@ -3222,7 +3224,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
{
|
{
|
||||||
if (!aTab) return;
|
if (!aTab) return;
|
||||||
|
|
||||||
if ((aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true') == aCollapse) return;
|
if (this.isSubtreeCollapsed(aTab) == aCollapse) return;
|
||||||
|
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
this.doingCollapseExpand = true;
|
this.doingCollapseExpand = true;
|
||||||
@ -3256,7 +3258,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var parent;
|
var parent;
|
||||||
if (aCollapse && aTab == b.selectedTab && (parent = this.getParentTab(aTab))) {
|
if (aCollapse && aTab == b.selectedTab && (parent = this.getParentTab(aTab))) {
|
||||||
var newSelection = parent;
|
var newSelection = parent;
|
||||||
while (parent.getAttribute(this.kCOLLAPSED) == 'true')
|
while (this.isCollapsed(parent))
|
||||||
{
|
{
|
||||||
parent = this.getParentTab(parent);
|
parent = this.getParentTab(parent);
|
||||||
if (!parent) break;
|
if (!parent) break;
|
||||||
@ -3265,7 +3267,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
b.selectedTab = newSelection;
|
b.selectedTab = newSelection;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aTab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true') {
|
if (!this.isSubtreeCollapsed(aTab)) {
|
||||||
this.getChildTabs(aTab).forEach(function(aTab) {
|
this.getChildTabs(aTab).forEach(function(aTab) {
|
||||||
this.collapseExpandTab(aTab, aCollapse, aJustNow);
|
this.collapseExpandTab(aTab, aCollapse, aJustNow);
|
||||||
}, this);
|
}, this);
|
||||||
@ -3422,6 +3424,8 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
if (!aTab || this.doingCollapseExpand) return;
|
if (!aTab || this.doingCollapseExpand) return;
|
||||||
|
|
||||||
var b = this.mTabBrowser;
|
var b = this.mTabBrowser;
|
||||||
|
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true') return;
|
||||||
|
|
||||||
var sameParentTab = this.getParentTab(aTab);
|
var sameParentTab = this.getParentTab(aTab);
|
||||||
var expandedParentTabs = [
|
var expandedParentTabs = [
|
||||||
aTab.getAttribute(this.kID)
|
aTab.getAttribute(this.kID)
|
||||||
@ -3447,7 +3451,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
parentTab = this.getParentTab(collapseTab);
|
parentTab = this.getParentTab(collapseTab);
|
||||||
if (parentTab) {
|
if (parentTab) {
|
||||||
dontCollapse = true;
|
dontCollapse = true;
|
||||||
if (parentTab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true') {
|
if (!this.isSubtreeCollapsed(parentTab)) {
|
||||||
do {
|
do {
|
||||||
if (expandedParentTabs.indexOf(parentTab.getAttribute(this.kID)) < 0)
|
if (expandedParentTabs.indexOf(parentTab.getAttribute(this.kID)) < 0)
|
||||||
continue;
|
continue;
|
||||||
@ -3603,7 +3607,7 @@ TreeStyleTabBrowser.prototype = {
|
|||||||
var lastVisible = aTab;
|
var lastVisible = aTab;
|
||||||
for (var i = descendant.length-1; i > -1; i--)
|
for (var i = descendant.length-1; i > -1; i--)
|
||||||
{
|
{
|
||||||
if (descendant[i].getAttribute(this.kCOLLAPSED) == 'true') continue;
|
if (this.isCollapsed(descendant[i])) continue;
|
||||||
lastVisible = descendant[i];
|
lastVisible = descendant[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user