suppress unexpected jumping on the tab bar after new child tabs are opened
This commit is contained in:
parent
d45ec4a947
commit
585ab07c48
@ -612,7 +612,9 @@ var TreeStyleTabWindowHelper = {
|
||||
'{',
|
||||
<![CDATA[{
|
||||
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
|
||||
if (treeStyleTab.scrollToNewTabMode == 0) return;
|
||||
if (treeStyleTab.scrollToNewTabMode == 0 ||
|
||||
treeStyleTab.shouldCancelEnsureElementIsVisible())
|
||||
return;
|
||||
]]>.toString()
|
||||
).replace(
|
||||
/\.screenX/g, '[treeStyleTab.screenPositionProp]'
|
||||
@ -663,6 +665,8 @@ var TreeStyleTabWindowHelper = {
|
||||
'{',
|
||||
<![CDATA[{
|
||||
var treeStyleTab = TreeStyleTabService.getTabBrowserFromChild(this).treeStyleTab;
|
||||
if (treeStyleTab && treeStyleTab.shouldCancelEnsureElementIsVisible())
|
||||
return;
|
||||
if (
|
||||
treeStyleTab &&
|
||||
(arguments.length == 1 || arguments[1])
|
||||
|
@ -2502,8 +2502,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
clearLastScrollPosition : function TSTBrowser_clearLastScrollPosition()
|
||||
{
|
||||
this.lastScrollX = -1;
|
||||
this.lastScrollY = -1;
|
||||
this.lastScrollX = this.lastScrollY = -1;
|
||||
},
|
||||
|
||||
updateLastScrollPosition : function TSTBrowser_updateLastScrollPosition()
|
||||
@ -2517,6 +2516,31 @@ TreeStyleTabBrowser.prototype = {
|
||||
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)
|
||||
{
|
||||
var tab = aTab || aEvent.originalTarget;
|
||||
@ -4095,8 +4119,8 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
onMouseDown : function TSTBrowser_onMouseDown(aEvent)
|
||||
{
|
||||
if (this.smoothScrollTask && this.isEventFiredOnScrollbar(aEvent))
|
||||
this.animationManager.removeTask(this.smoothScrollTask);
|
||||
if (this.isEventFiredOnScrollbar(aEvent))
|
||||
this.cancelPerformingAutoScroll();
|
||||
|
||||
if (
|
||||
aEvent.button == 0 &&
|
||||
@ -4114,8 +4138,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
onDOMMouseScroll : function TSTBrowser_onDOMMouseScroll(aEvent)
|
||||
{
|
||||
if (this.smoothScrollTask)
|
||||
this.animationManager.removeTask(this.smoothScrollTask);
|
||||
this.cancelPerformingAutoScroll();
|
||||
},
|
||||
|
||||
onScroll : function TSTBrowser_onScroll(aEvent)
|
||||
@ -4145,7 +4168,8 @@ TreeStyleTabBrowser.prototype = {
|
||||
{
|
||||
if (
|
||||
!aEvent.originalTarget ||
|
||||
!(aEvent.originalTarget instanceof Ci.nsIDOMWindow)
|
||||
!(aEvent.originalTarget instanceof Ci.nsIDOMWindow) ||
|
||||
aEvent.originalTarget.top != this.mTabBrowser.contentWindow
|
||||
)
|
||||
return;
|
||||
|
||||
@ -5572,16 +5596,14 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
scrollTo : function TSTBrowser_scrollTo(aEndX, aEndY)
|
||||
{
|
||||
// Prevent to restore scroll position for "TabClose".
|
||||
// We override it.
|
||||
this.lastScrollX = -1;
|
||||
this.lastScrollY = -1;
|
||||
if (this.cancelingPerformingAutoScroll) return;
|
||||
|
||||
if (this.animationEnabled || this.smoothScrollEnabled) {
|
||||
this.smoothScrollTo(aEndX, aEndY);
|
||||
}
|
||||
else {
|
||||
try {
|
||||
this.cancelPerformingAutoScroll();
|
||||
this.scrollBoxObject.scrollTo(aEndX, aEndY);
|
||||
}
|
||||
catch(e) {
|
||||
@ -5591,9 +5613,9 @@ TreeStyleTabBrowser.prototype = {
|
||||
|
||||
smoothScrollTo : function TSTBrowser_smoothScrollTo(aEndX, aEndY, aDuration)
|
||||
{
|
||||
var b = this.mTabBrowser;
|
||||
this.animationManager.removeTask(this.smoothScrollTask);
|
||||
this.cancelPerformingAutoScroll();
|
||||
|
||||
var b = this.mTabBrowser;
|
||||
var scrollBoxObject = this.scrollBoxObject;
|
||||
var x = {}, y = {};
|
||||
scrollBoxObject.getPosition(x, y);
|
||||
@ -5616,7 +5638,8 @@ TreeStyleTabBrowser.prototype = {
|
||||
var self = this;
|
||||
this.smoothScrollTask = function(aTime, aBeginning, aChange, aDuration) {
|
||||
var scrollBoxObject = self.scrollBoxObject;
|
||||
if (aTime >= aDuration) {
|
||||
if (aTime >= aDuration || this.cancelingPerformingAutoScroll) {
|
||||
if (!this.cancelingPerformingAutoScroll) {
|
||||
scrollBoxObject.scrollTo(aEndX, aEndY);
|
||||
|
||||
/**
|
||||
@ -5642,6 +5665,7 @@ TreeStyleTabBrowser.prototype = {
|
||||
self = null;
|
||||
scrollBoxObject = null;
|
||||
});
|
||||
}
|
||||
|
||||
b = null;
|
||||
x = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user