From 4ff458483384c2eb6659b2844b082e3522c9ea03 Mon Sep 17 00:00:00 2001 From: Piro / YUKI Hiroshi Date: Wed, 18 Mar 2015 02:52:02 +0900 Subject: [PATCH] Use Firefox's native smooth scrolling method if possible, to activate accelerations #856 --- modules/browser.js | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/modules/browser.js b/modules/browser.js index e2bd584e..3a196872 100644 --- a/modules/browser.js +++ b/modules/browser.js @@ -6540,13 +6540,13 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { /* scroll */ - scrollTo : function TSTBrowser_scrollTo(aEndX, aEndY) + scrollTo : function TSTBrowser_scrollTo(aEndX, aEndY, aTargetElement) { if (this.timers['cancelPerformingAutoScroll']) return; if (this.animationEnabled || this.smoothScrollEnabled) { - this.smoothScrollTo(aEndX, aEndY); + this.smoothScrollTo(aEndX, aEndY, null, aTargetElement); } else { try { @@ -6558,7 +6558,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { } }, - smoothScrollTo : function TSTBrowser_smoothScrollTo(aEndX, aEndY, aDuration) + smoothScrollTo : function TSTBrowser_smoothScrollTo(aEndX, aEndY, aDuration, aTargetElement) { this.cancelPerformingAutoScroll(true); @@ -6571,6 +6571,14 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { var deltaX = aEndX - startX; var deltaY = aEndY - startY; + // Use Firefox's native smooth scroll if possible + // because it can be accelerated. + if (typeof this.scrollBox._smoothScrollByPixels == 'function') { + let amountToScroll = this.isVertical ? deltaY : deltaX ; + return this.scrollBox._smoothScrollByPixels(amountToScroll, aTargetElement); + } + // Otherwise fallback to TST's custom one. + var arrowscrollbox = scrollBoxObject.element.parentNode; if ( arrowscrollbox && @@ -6654,13 +6662,20 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { isSmoothScrolling : function TSTBrowser_isSmoothScrolling() { return Boolean( - this.smoothScrollTask || - this.scrollBox._smoothScrollTimer + // Firefox's native scroll + this.scrollBox._smoothScrollTimer || + // TST's custom one + this.smoothScrollTask ); }, stopSmoothScroll : function TSTBrowser_stopSmoothScroll() { + // Firefox's native scroll + if (typeof this.scrollBox._stopSmoothScroll == 'function') + this.scrollBox._stopSmoothScroll(); + + // TST's custom one if (this.smoothScrollTask) { this.animationManager.removeTask(this.smoothScrollTask); this.smoothScrollTask = null; @@ -6673,8 +6688,6 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { return; this.cancelPerformingAutoScroll(true); - if (this.isTabInViewport(aTab)) - return; var b = this.mTabBrowser; @@ -6705,7 +6718,7 @@ TreeStyleTabBrowser.prototype = inherit(TreeStyleTabWindow.prototype, { return; } - this.scrollTo(targetX, targetY); + this.scrollTo(targetX, targetY, aTab); }, scrollToTabSubtree : function TSTBrowser_scrollToTabSubtree(aTab)