Bug 1316505 part.2 The "wheel" event of <scrollbox> should use |.scrollByPixels()| instead of |.scrollByPages()| for respecting high resolution delta value and making the scroll smoother r?enndeakin draft
authorMasayuki Nakano <masayuki@d-toybox.com>
Sun, 13 Nov 2016 18:04:08 +0900
changeset 438106 fd9e668c039aa3d0e9e2e97fca081218201e36ea
parent 438105 608cd1cd5dd8073b92b75a32d584cd228677bee2
child 536824 8310129c98f77565e6887d60e8cd8584694069af
push id35619
push usermasayuki@d-toybox.com
push dateSun, 13 Nov 2016 11:10:23 +0000
reviewersenndeakin
bugs1316505
milestone52.0a1
Bug 1316505 part.2 The "wheel" event of <scrollbox> should use |.scrollByPixels()| instead of |.scrollByPages()| for respecting high resolution delta value and making the scroll smoother r?enndeakin Similar to the previous patch, "wheel" event should use |.scrollByPixels()| instead of |.scrollByPages()| because |.scrollByPages()| doesn't support high resolution delta value. This patch makes the "wheel" event handler of <scrollbox> use |.scrollByPixels()| at handling "wheel" events whose deltaMode is DOM_DELTA_PAGE and multiplies the delta value and |.scrollClientSize|. MozReview-Commit-ID: 1nyD7niiq3W
toolkit/content/widgets/scrollbox.xml
--- a/toolkit/content/widgets/scrollbox.xml
+++ b/toolkit/content/widgets/scrollbox.xml
@@ -570,17 +570,17 @@
     </implementation>
 
     <handlers>
       <handler event="wheel"><![CDATA[
         if (this.orient == "vertical") {
           if (event.deltaMode == event.DOM_DELTA_PIXEL)
             this.scrollByPixels(event.deltaY);
           else if (event.deltaMode == event.DOM_DELTA_PAGE)
-            this.scrollByPage(event.deltaY);
+            this.scrollByPixels(event.deltaY * this.scrollClientSize);
           else
             this.scrollByPixels(event.deltaY * this.lineScrollAmount);
         }
         // We allow vertical scrolling to scroll a horizontal scrollbox
         // because many users have a vertical scroll wheel but no
         // horizontal support.
         // Because of this, we need to avoid scrolling chaos on trackpads
         // and mouse wheels that support simultaneous scrolling in both axes.
@@ -591,17 +591,17 @@
           let isVertical = Math.abs(event.deltaY) > Math.abs(event.deltaX);
           let delta = isVertical ? event.deltaY : event.deltaX;
           let scrollByDelta = isVertical && this._isRTLScrollbox ? -delta : delta;
 
           if (this._prevMouseScrolls.every(prev => prev == isVertical)) {
             if (event.deltaMode == event.DOM_DELTA_PIXEL)
               this.scrollByPixels(scrollByDelta);
             else if (event.deltaMode == event.DOM_DELTA_PAGE)
-              this.scrollByPage(scrollByDelta);
+              this.scrollByPixels(scrollByDelta * this.scrollClientSize);
             else
               this.scrollByPixels(scrollByDelta * this.lineScrollAmount);
           }
 
           if (this._prevMouseScrolls.length > 1)
             this._prevMouseScrolls.shift();
           this._prevMouseScrolls.push(isVertical);
         }