[Pkg-mozext-commits] [tabmixplus] 21/48: Follow up bug 1356705 - Use CSS smooth scroll when smooth scrolling a XUL scrollbox

David Prévot taffit at moszumanska.debian.org
Sun Aug 20 03:14:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit 1f3534e16d6306a126ac9789b1f47c53b44b4031
Author: onemen <tabmix.onemen at gmail.com>
Date:   Sat Aug 5 11:23:43 2017 +0300

    Follow up bug 1356705 - Use CSS smooth scroll when smooth scrolling a XUL scrollbox
---
 chrome/content/tab/scrollbox.xml    | 72 +++++++++++++++++++------------------
 chrome/content/tab/tabbrowser_4.xml |  5 +--
 chrome/content/tabmix.js            |  2 +-
 3 files changed, 41 insertions(+), 38 deletions(-)

diff --git a/chrome/content/tab/scrollbox.xml b/chrome/content/tab/scrollbox.xml
index b5cefe3..b3610ea 100644
--- a/chrome/content/tab/scrollbox.xml
+++ b/chrome/content/tab/scrollbox.xml
@@ -177,45 +177,47 @@
           this.offsetAmountToScroll = Tabmix.prefs.getBoolPref("offsetAmountToScroll");
           this.offsetRatio = Tabmix.tabsUtils.closeButtonsEnabled ? 0.70 : 0.50;
           this.minOffset = TabmixSvc.australis ? 25 : 50;
-          Tabmix.changeCode(this, "scrollbox.ensureElementIsVisible")._replace(
-            'var amountToScroll',
-            '$&, offset = true'
-          )._replace(
-            'STOP_DISTANCE = 15;',
-            'STOP_DISTANCE = this.isMultiRow ? 3 : 15;'
-          )._replace(
-            'amountToScroll = this._isScrolling * STOP_DISTANCE;',
-            '{$& \
-             offset = false;}'
-          )._replace(
-            'this._stopSmoothScroll();',
-            '$& \
-             if (offset) {\
-               amountToScroll += this.getOffsetAmountToScroll(element, amountToScroll);}'
-          ).toCode();
+          if (!Tabmix.isVersion(570)) {
+            Tabmix.changeCode(this, "scrollbox.ensureElementIsVisible")._replace(
+              'var amountToScroll',
+              '$&, offset = true'
+            )._replace(
+              'STOP_DISTANCE = 15;',
+              'STOP_DISTANCE = this.isMultiRow ? 3 : 15;'
+            )._replace(
+              'amountToScroll = this._isScrolling * STOP_DISTANCE;',
+              '{$& \
+               offset = false;}'
+            )._replace(
+              'this._stopSmoothScroll();',
+              '$& \
+               if (offset) {\
+                 amountToScroll += this.getOffsetAmountToScroll(element, amountToScroll);}'
+            ).toCode();
 
-          Tabmix.changeCode(this, "scrollbox._distanceScroll")._replace(
-            '{',
-            '{ if (aEvent.button && aEvent.button == 2) return;'
-          ).toCode();
+            Tabmix.changeCode(this, "scrollbox._smoothScrollByPixels")._replace(
+              '{',
+              '$& \
+               amountToScroll = this._distanceToRow(amountToScroll);'
+            ).toCode();
 
-          Tabmix.changeCode(this, "scrollbox._smoothScrollByPixels")._replace(
-            '{',
-            '$& \
-             amountToScroll = this._distanceToRow(amountToScroll);'
-          ).toCode();
+            // we divide scrollDelta by the ratio between tab width and tab height
+            Tabmix.changeCode(this._arrowScrollAnim, "scrollbox._arrowScrollAnim.sample")._replace(
+              '0.5 * timePassed * scrollIndex',
+              'this.scrollbox.isMultiRow ? $& / this.scrollbox._verticalAnimation : $&'
+            ).toCode();
 
-          // we divide scrollDelta by the ratio between tab width and tab height
-          Tabmix.changeCode(this._arrowScrollAnim, "scrollbox._arrowScrollAnim.sample")._replace(
-            '0.5 * timePassed * scrollIndex',
-            'this.scrollbox.isMultiRow ? $& / this.scrollbox._verticalAnimation : $&'
-          ).toCode();
+            // the ratio between tab width and tab height is approximately 6
+            // we multiply here the distance to get same animation effect.
+            Tabmix.changeCode(this._scrollAnim, "scrollbox._scrollAnim.start")._replace(
+              'Math.abs(distance)',
+              'Math.abs(distance * (this.scrollbox.isMultiRow ? this.scrollbox._verticalAnimation : 1))'
+            ).toCode();
+          }
 
-          // the ratio between tab width and tab height is approximately 6
-          // we multiply here the distance to get same animation effect.
-          Tabmix.changeCode(this._scrollAnim, "scrollbox._scrollAnim.start")._replace(
-            'Math.abs(distance)',
-            'Math.abs(distance * (this.scrollbox.isMultiRow ? this.scrollbox._verticalAnimation : 1))'
+          Tabmix.changeCode(this, "scrollbox._distanceScroll")._replace(
+            '{',
+            '{ if (aEvent.button && aEvent.button == 2) return;'
           ).toCode();
 
           if (Tabmix.isVersion(560)) {
diff --git a/chrome/content/tab/tabbrowser_4.xml b/chrome/content/tab/tabbrowser_4.xml
index 7e02b0b..989eed2 100644
--- a/chrome/content/tab/tabbrowser_4.xml
+++ b/chrome/content/tab/tabbrowser_4.xml
@@ -415,10 +415,11 @@
               return;
             }
 
+            const scrollByPixels = Tabmix.isVersion(570) ? "scrollByPixels" : "_smoothScrollByPixels";
             if (TabmixTabbar.isMultiRow)
-              this.mTabstrip._smoothScrollByPixels(selected.top - scrollRect.top);
+              this.mTabstrip[scrollByPixels](selected.top - scrollRect.top);
             else
-              this.mTabstrip._smoothScrollByPixels(this.mTabstrip._isRTLScrollbox ?
+              this.mTabstrip[scrollByPixels](this.mTabstrip._isRTLScrollbox ?
                 selected.right - scrollRect.right : selected.left - scrollRect.left);
           }
 
diff --git a/chrome/content/tabmix.js b/chrome/content/tabmix.js
index 3e44bfd..759f557 100644
--- a/chrome/content/tabmix.js
+++ b/chrome/content/tabmix.js
@@ -1073,7 +1073,7 @@ var TMP_eventListener = {
         }
 
         if (scrollByPixels) {
-          let useSmoothScroll = Tabmix.isVersion(530) &&
+          let useSmoothScroll = Tabmix.isVersion(530) && !Tabmix.isVersion(570) &&
             aEvent.deltaMode != aEvent.DOM_DELTA_PIXEL && tabStrip.smoothScroll;
           if (useSmoothScroll) {
             tabStrip._smoothScrollByPixels(scrollAmount);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list