折りたたみ可能かどうかの判定がおかしくなっていた

git-svn-id: http://www.cozmixng.org/repos/piro/treestyletab/trunk@5266 599a83e7-65a4-db11-8015-0010dcdd6dc2
This commit is contained in:
piro 2009-10-26 02:47:38 +00:00
parent ec8cf69153
commit 2a65b99cab
2 changed files with 27 additions and 34 deletions

View File

@ -821,8 +821,7 @@ var TreeStyleTabService = {
{ {
if (!aTab) return null; if (!aTab) return null;
var b = this.getTabBrowserFromChild(aTab) || this.browser; if (!this.canCollapseSubtree(aTab))
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
return this.getNextTab(aTab); return this.getNextTab(aTab);
return this.evaluateXPath( return this.evaluateXPath(
@ -836,8 +835,7 @@ var TreeStyleTabService = {
{ {
if (!aTab) return null; if (!aTab) return null;
var b = this.getTabBrowserFromChild(aTab) || this.browser; if (!this.canCollapseSubtree(aTab))
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
return this.getPreviousTab(aTab); return this.getPreviousTab(aTab);
return this.evaluateXPath( return this.evaluateXPath(
@ -851,8 +849,7 @@ var TreeStyleTabService = {
{ {
if (!aTab) return null; if (!aTab) return null;
var b = this.getTabBrowserFromChild(aTab) || this.browser; if (!this.canCollapseSubtree(aTab))
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
return this.getLastTab(aTab); return this.getLastTab(aTab);
return this.evaluateXPath( return this.evaluateXPath(
@ -864,8 +861,7 @@ var TreeStyleTabService = {
getVisibleTabs : function(aTab) getVisibleTabs : function(aTab)
{ {
var b = this.getTabBrowserFromChild(aTab) || this.browser; if (!this.canCollapseSubtree(aTab))
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
return this.getTabs(b); return this.getTabs(b);
var xpathResult = this.evaluateXPath( var xpathResult = this.evaluateXPath(
@ -879,8 +875,7 @@ var TreeStyleTabService = {
{ {
if (!aTab) return -1; if (!aTab) return -1;
var b = this.getTabBrowserFromChild(aTab) || this.browser; if (!this.canCollapseSubtree(aTab))
if (b.getAttribute(this.kALLOW_COLLAPSE) != 'true')
return this.getTabIndex(aTab); return this.getTabIndex(aTab);
return aTab.getAttribute(this.kCOLLAPSED) == 'true' ? return aTab.getAttribute(this.kCOLLAPSED) == 'true' ?
@ -904,12 +899,15 @@ var TreeStyleTabService = {
); );
}, },
canCollapseSubtree : function(aTabBrowser) /* PUBLIC API */
{
var b = this.getTabBrowserFromChild(aTabBrowser) || this.browser;
return b.getAttribute(this.kALLOW_COLLAPSE) == 'true';
},
isCollapsed : function(aTab) /* PUBLIC API */ isCollapsed : function(aTab) /* PUBLIC API */
{ {
if (!aTab) return false; if (!aTab || !this.canCollapseSubtree(aTab))
var b = this.getTabBrowserFromChild(aTab) || this.browser;
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true')
return false; return false;
return aTab.getAttribute(this.kCOLLAPSED) == 'true'; return aTab.getAttribute(this.kCOLLAPSED) == 'true';
@ -917,10 +915,7 @@ var TreeStyleTabService = {
isSubtreeCollapsed : function(aTab) /* PUBLIC API */ isSubtreeCollapsed : function(aTab) /* PUBLIC API */
{ {
if (!aTab) return false; if (!aTab || !this.canCollapseSubtree(aTab))
var b = this.getTabBrowserFromChild(aTab) || this.browser;
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true')
return false; return false;
return aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true'; return aTab.getAttribute(this.kSUBTREE_COLLAPSED) == 'true';
@ -1122,10 +1117,9 @@ var TreeStyleTabService = {
getXOffsetOfTab : function(aTab) getXOffsetOfTab : function(aTab)
{ {
var extraCondition = ''; var extraCondition = this.canCollapseSubtree(aTab) ?
var b = this.getTabBrowserFromChild(aTab) || this.browser; '[not(@'+this.kCOLLAPSED+'="true")]' :
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') '' ;
extraCondition = '[not(@'+this.kCOLLAPSED+'="true")]';
return this.evaluateXPath( return this.evaluateXPath(
'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kX_OFFSET+')', 'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kX_OFFSET+')',
@ -1135,10 +1129,9 @@ var TreeStyleTabService = {
}, },
getYOffsetOfTab : function(aTab) getYOffsetOfTab : function(aTab)
{ {
var extraCondition = ''; var extraCondition = this.canCollapseSubtree(aTab) ?
var b = this.getTabBrowserFromChild(aTab) || this.browser; '[not(@'+this.kCOLLAPSED+'="true")]' :
if (b.getAttribute(this.kALLOW_COLLAPSE) == 'true') '';
extraCondition = '[not(@'+this.kCOLLAPSED+'="true")]';
return this.evaluateXPath( return this.evaluateXPath(
'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kY_OFFSET+')', 'sum((self::* | preceding-sibling::xul:tab'+extraCondition+')/attribute::'+this.kY_OFFSET+')',

View File

@ -223,7 +223,7 @@ 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.browser.getAttribute(treeStyleTab.kALLOW_COLLAPSE) == 'true' && if (treeStyleTab.canCollapseSubtree() &&
treeStyleTab.getTreePref('focusMode') == treeStyleTab.kFOCUS_VISIBLE) { 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) ;
@ -2071,8 +2071,7 @@ TreeStyleTabBrowser.prototype = {
if (this.isEventFiredOnTwisty(aEvent)) { if (this.isEventFiredOnTwisty(aEvent)) {
var tab = this.getTabFromEvent(aEvent); var tab = this.getTabFromEvent(aEvent);
if (this.hasChildTabs(tab) && if (this.hasChildTabs(tab) && this.canCollapseSubtree()) {
this.mTabBrowser.getAttribute(this.kALLOW_COLLAPSE) == 'true') {
this.collapseExpandSubtree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true'); this.collapseExpandSubtree(tab, tab.getAttribute(this.kSUBTREE_COLLAPSED) != 'true');
aEvent.preventDefault(); aEvent.preventDefault();
aEvent.stopPropagation(); aEvent.stopPropagation();
@ -2218,7 +2217,7 @@ 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 (b.getAttribute(this.kALLOW_COLLAPSE) == 'true' && if (this.canCollapseSubtree(b) &&
this.evaluateXPath( this.evaluateXPath(
'child::xul:tab[@'+this.kCHILDREN+']', 'child::xul:tab[@'+this.kCHILDREN+']',
b.mTabContainer b.mTabContainer
@ -3285,7 +3284,7 @@ TreeStyleTabBrowser.prototype = {
aJustNow || aJustNow ||
this.collapseDuration < 1 || this.collapseDuration < 1 ||
// !this.isVertical || // !this.isVertical ||
this.mTabBrowser.getAttribute(this.kALLOW_COLLAPSE) != 'true' !this.canCollapseSubtree()
) { ) {
aTab.setAttribute( aTab.setAttribute(
'style', 'style',
@ -3421,11 +3420,12 @@ TreeStyleTabBrowser.prototype = {
collapseExpandTreesIntelligentlyFor : function(aTab, aJustNow) collapseExpandTreesIntelligentlyFor : function(aTab, aJustNow)
{ {
if (!aTab || this.doingCollapseExpand) return; if (!aTab ||
this.doingCollapseExpand ||
!this.canCollapseSubtree())
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)