failed to scroll to the expanded tree when a collapsed tree was selected

This commit is contained in:
Piro / SHIMODA Hiroshi 2012-01-29 06:22:04 +09:00
parent 71cfcd3601
commit 7511b03b8e

View File

@ -3807,7 +3807,7 @@ TreeStyleTabBrowser.prototype = {
{ {
this.collapseExpandSubtree(parentTab, false); this.collapseExpandSubtree(parentTab, false);
} }
this.collapseExpandTreesIntelligentlyWithDelayFor(tab); this.collapseExpandTreesIntelligentlyForNewActiveTab(tab);
} }
else { else {
b.selectedTab = this.getRootTab(tab); b.selectedTab = this.getRootTab(tab);
@ -3836,16 +3836,16 @@ TreeStyleTabBrowser.prototype = {
if (delay > 0) { if (delay > 0) {
this._autoExpandOnTabSelectTimer = this.window.setTimeout(function(aSelf) { this._autoExpandOnTabSelectTimer = this.window.setTimeout(function(aSelf) {
if (tab && tab.parentNode) if (tab && tab.parentNode)
aSelf.collapseExpandTreesIntelligentlyWithDelayFor(tab); aSelf.collapseExpandTreesIntelligentlyForNewActiveTab(tab);
}, delay, this); }, delay, this);
} }
else { else {
this.collapseExpandTreesIntelligentlyWithDelayFor(tab); this.collapseExpandTreesIntelligentlyForNewActiveTab(tab);
} }
} }
} }
else { else {
this.collapseExpandTreesIntelligentlyWithDelayFor(tab); this.collapseExpandTreesIntelligentlyForNewActiveTab(tab);
} }
} }
} }
@ -5244,14 +5244,21 @@ TreeStyleTabBrowser.prototype = {
this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, aCollapse); this.setTabValue(aTab, this.kSUBTREE_COLLAPSED, aCollapse);
this.getChildTabs(aTab).forEach(function(aTab) { var expandedTabs = this.getChildTabs(aTab);
var lastExpandedTabIndex = expandedTabs.length - 1;
expandedTabs.forEach(function(aTab, aIndex) {
if (!aCollapse && !aJustNow && aIndex == lastExpandedTabIndex) {
let self = this;
this.collapseExpandTab(aTab, aCollapse, aJustNow, function() {
self.scrollToTabSubtree(aTab);
});
}
else
this.collapseExpandTab(aTab, aCollapse, aJustNow); this.collapseExpandTab(aTab, aCollapse, aJustNow);
}, this); }, this);
if (aCollapse) if (aCollapse)
this.deleteTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY); this.deleteTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY);
else
this.scrollToTabSubtree(aTab);
this.doingCollapseExpand = false; this.doingCollapseExpand = false;
}, },
@ -5262,12 +5269,12 @@ TreeStyleTabBrowser.prototype = {
this.setTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY, true); this.setTabValue(aTab, this.kSUBTREE_EXPANDED_MANUALLY, true);
}, },
collapseExpandTab : function TSTBrowser_collapseExpandTab(aTab, aCollapse, aJustNow) collapseExpandTab : function TSTBrowser_collapseExpandTab(aTab, aCollapse, aJustNow, aCallbackToRunOnStartAnimation)
{ {
if (!aTab || !this.getParentTab(aTab)) return; if (!aTab || !this.getParentTab(aTab)) return;
this.setTabValue(aTab, this.kCOLLAPSED, aCollapse); this.setTabValue(aTab, this.kCOLLAPSED, aCollapse);
this.updateTabCollapsed(aTab, aCollapse, aJustNow); this.updateTabCollapsed(aTab, aCollapse, aJustNow, aCallbackToRunOnStartAnimation);
var data = { var data = {
collapsed : aCollapse collapsed : aCollapse
@ -5394,6 +5401,7 @@ TreeStyleTabBrowser.prototype = {
var firstFrame = true; var firstFrame = true;
aTab.__treestyletab__updateTabCollapsedTask = function(aTime, aBeginning, aChange, aDuration) { aTab.__treestyletab__updateTabCollapsedTask = function(aTime, aBeginning, aChange, aDuration) {
if (firstFrame) { if (firstFrame) {
// The callback must be started before offsetAttr is changed!
if (aCallbackToRunOnStartAnimation) if (aCallbackToRunOnStartAnimation)
aCallbackToRunOnStartAnimation(); aCallbackToRunOnStartAnimation();
if (CSSTransitionEnabled) { if (CSSTransitionEnabled) {
@ -5515,18 +5523,22 @@ TreeStyleTabBrowser.prototype = {
this.collapseExpandSubtree(aTab, false, aJustNow); this.collapseExpandSubtree(aTab, false, aJustNow);
}, },
collapseExpandTreesIntelligentlyWithDelayFor : function TSTBrowser_collapseExpandTreesIntelligentlyWithDelayFor(aTab) collapseExpandTreesIntelligentlyForNewActiveTab : function TSTBrowser_collapseExpandTreesIntelligentlyForNewActiveTab(aTab)
{ {
if (this.doingCollapseExpand) return; if (this.doingCollapseExpand) return;
if (this._cETIWDFTimer) if (this._cETIFNATTimer)
this.window.clearTimeout(this._cETIWDFTimer); this.window.clearTimeout(this._cETIFNATTimer);
this._cETIWDFTimer = this.window.setTimeout(function(aSelf) { /**
aSelf.window.clearTimeout(aSelf._cETIWDFTimer); * First, we wait until all event listeners for the TabSelect
aSelf._cETIWDFTimer = null; * event were processed.
*/
this._cETIFNATTimer = this.window.setTimeout(function(aSelf) {
aSelf.window.clearTimeout(aSelf._cETIFNATTimer);
aSelf._cETIFNATTimer = null;
aSelf.collapseExpandTreesIntelligentlyFor(aTab); aSelf.collapseExpandTreesIntelligentlyFor(aTab);
}, 0, this); }, 0, this);
}, },
_cETIWDFTimer : null, _cETIFNATTimer : null,
collapseExpandAllSubtree : function TSTBrowser_collapseExpandAllSubtree(aCollapse, aJustNow) collapseExpandAllSubtree : function TSTBrowser_collapseExpandAllSubtree(aCollapse, aJustNow)
{ {