suppress unexpected jumping on the tab bar after new child tabs are opened

This commit is contained in:
SHIMODA Hiroshi 2012-01-13 12:16:35 +09:00
parent d45ec4a947
commit 585ab07c48
2 changed files with 67 additions and 39 deletions

View File

@ -612,7 +612,9 @@ var TreeStyleTabWindowHelper = {
'{', '{',
<![CDATA[{ <![CDATA[{
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab; var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
if (treeStyleTab.scrollToNewTabMode == 0) return; if (treeStyleTab.scrollToNewTabMode == 0 ||
treeStyleTab.shouldCancelEnsureElementIsVisible())
return;
]]>.toString() ]]>.toString()
).replace( ).replace(
/\.screenX/g, '[treeStyleTab.screenPositionProp]' /\.screenX/g, '[treeStyleTab.screenPositionProp]'
@ -663,6 +665,8 @@ var TreeStyleTabWindowHelper = {
'{', '{',
<![CDATA[{ <![CDATA[{
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab; var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
if (treeStyleTab && treeStyleTab.shouldCancelEnsureElementIsVisible())
return;
if ( if (
treeStyleTab && treeStyleTab &&
(arguments.length == 1 || arguments[1]) (arguments.length == 1 || arguments[1])

View File

@ -2502,8 +2502,7 @@ TreeStyleTabBrowser.prototype = {
clearLastScrollPosition : function TSTBrowser_clearLastScrollPosition() clearLastScrollPosition : function TSTBrowser_clearLastScrollPosition()
{ {
this.lastScrollX = -1; this.lastScrollX = this.lastScrollY = -1;
this.lastScrollY = -1;
}, },
updateLastScrollPosition : function TSTBrowser_updateLastScrollPosition() updateLastScrollPosition : function TSTBrowser_updateLastScrollPosition()
@ -2517,6 +2516,31 @@ TreeStyleTabBrowser.prototype = {
this.lastScrollY = y.value; this.lastScrollY = y.value;
}, },
cancelPerformingAutoScroll : function TSTBrowser_cancelPerformingAutoScroll()
{
if (this.smoothScrollTask) {
this.animationManager.removeTask(this.smoothScrollTask);
this.smoothScrollTask = null;
}
this.clearLastScrollPosition();
if (this.cancelingPerformingAutoScroll) return;
this.cancelingPerformingAutoScroll = true;
var self = this;
this.Deferred.wait(0.1).next(function() {
self.cancelingPerformingAutoScroll = false;
});
},
shouldCancelEnsureElementIsVisible : function TSTBRowser_shouldCancelEnsureElementIsVisible()
{
return (
this.cancelingPerformingAutoScroll &&
(new Error()).stack.indexOf('onxblDOMMouseScroll') < 0
);
},
onTabOpen : function TSTBrowser_onTabOpen(aEvent, aTab) onTabOpen : function TSTBrowser_onTabOpen(aEvent, aTab)
{ {
var tab = aTab || aEvent.originalTarget; var tab = aTab || aEvent.originalTarget;
@ -4095,8 +4119,8 @@ TreeStyleTabBrowser.prototype = {
onMouseDown : function TSTBrowser_onMouseDown(aEvent) onMouseDown : function TSTBrowser_onMouseDown(aEvent)
{ {
if (this.smoothScrollTask && this.isEventFiredOnScrollbar(aEvent)) if (this.isEventFiredOnScrollbar(aEvent))
this.animationManager.removeTask(this.smoothScrollTask); this.cancelPerformingAutoScroll();
if ( if (
aEvent.button == 0 && aEvent.button == 0 &&
@ -4114,8 +4138,7 @@ TreeStyleTabBrowser.prototype = {
onDOMMouseScroll : function TSTBrowser_onDOMMouseScroll(aEvent) onDOMMouseScroll : function TSTBrowser_onDOMMouseScroll(aEvent)
{ {
if (this.smoothScrollTask) this.cancelPerformingAutoScroll();
this.animationManager.removeTask(this.smoothScrollTask);
}, },
onScroll : function TSTBrowser_onScroll(aEvent) onScroll : function TSTBrowser_onScroll(aEvent)
@ -4145,7 +4168,8 @@ TreeStyleTabBrowser.prototype = {
{ {
if ( if (
!aEvent.originalTarget || !aEvent.originalTarget ||
!(aEvent.originalTarget instanceof Ci.nsIDOMWindow) !(aEvent.originalTarget instanceof Ci.nsIDOMWindow) ||
aEvent.originalTarget.top != this.mTabBrowser.contentWindow
) )
return; return;
@ -5572,16 +5596,14 @@ TreeStyleTabBrowser.prototype = {
scrollTo : function TSTBrowser_scrollTo(aEndX, aEndY) scrollTo : function TSTBrowser_scrollTo(aEndX, aEndY)
{ {
// Prevent to restore scroll position for "TabClose". if (this.cancelingPerformingAutoScroll) return;
// We override it.
this.lastScrollX = -1;
this.lastScrollY = -1;
if (this.animationEnabled || this.smoothScrollEnabled) { if (this.animationEnabled || this.smoothScrollEnabled) {
this.smoothScrollTo(aEndX, aEndY); this.smoothScrollTo(aEndX, aEndY);
} }
else { else {
try { try {
this.cancelPerformingAutoScroll();
this.scrollBoxObject.scrollTo(aEndX, aEndY); this.scrollBoxObject.scrollTo(aEndX, aEndY);
} }
catch(e) { catch(e) {
@ -5591,9 +5613,9 @@ TreeStyleTabBrowser.prototype = {
smoothScrollTo : function TSTBrowser_smoothScrollTo(aEndX, aEndY, aDuration) smoothScrollTo : function TSTBrowser_smoothScrollTo(aEndX, aEndY, aDuration)
{ {
var b = this.mTabBrowser; this.cancelPerformingAutoScroll();
this.animationManager.removeTask(this.smoothScrollTask);
var b = this.mTabBrowser;
var scrollBoxObject = this.scrollBoxObject; var scrollBoxObject = this.scrollBoxObject;
var x = {}, y = {}; var x = {}, y = {};
scrollBoxObject.getPosition(x, y); scrollBoxObject.getPosition(x, y);
@ -5616,7 +5638,8 @@ TreeStyleTabBrowser.prototype = {
var self = this; var self = this;
this.smoothScrollTask = function(aTime, aBeginning, aChange, aDuration) { this.smoothScrollTask = function(aTime, aBeginning, aChange, aDuration) {
var scrollBoxObject = self.scrollBoxObject; var scrollBoxObject = self.scrollBoxObject;
if (aTime >= aDuration) { if (aTime >= aDuration || this.cancelingPerformingAutoScroll) {
if (!this.cancelingPerformingAutoScroll) {
scrollBoxObject.scrollTo(aEndX, aEndY); scrollBoxObject.scrollTo(aEndX, aEndY);
/** /**
@ -5642,6 +5665,7 @@ TreeStyleTabBrowser.prototype = {
self = null; self = null;
scrollBoxObject = null; scrollBoxObject = null;
}); });
}
b = null; b = null;
x = null; x = null;