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
--- 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);
}