Bug 1263975 - XUL scrollbox (e.g. the tab bar) should respond to pixel scrolls by pixel scrolling. r=Enn
authorMarkus Stange <mstange@themasta.com>
Tue, 05 Jan 2016 18:35:23 +0100
changeset 333597 f46b258468565665bddb428f1d7993c2104d3af8
parent 333596 ec382036764ccd8050a40ccd121f408ec6637962
child 333598 6963c6f6caacf104ac52b99dc68a0e9b89eaacba
push id1146
push userCallek@gmail.com
push dateMon, 25 Jul 2016 16:35:44 +0000
treeherdermozilla-release@a55778f9cd5a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn
bugs1263975
milestone48.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1263975 - XUL scrollbox (e.g. the tab bar) should respond to pixel scrolls by pixel scrolling. r=Enn MozReview-Commit-ID: FWSBkg9wM7r
toolkit/content/widgets/scrollbox.xml
--- a/toolkit/content/widgets/scrollbox.xml
+++ b/toolkit/content/widgets/scrollbox.xml
@@ -492,51 +492,52 @@
             this.setAttribute("scrolledtostart", "true");
           else
             this.removeAttribute("scrolledtostart");
         ]]></body>
       </method>
     </implementation>
 
     <handlers>
-      <handler event="DOMMouseScroll"><![CDATA[
+      <handler event="wheel"><![CDATA[
         if (this.orient == "vertical") {
-          // prevent horizontal scrolling from scrolling a vertical scrollbox
-          if (event.axis == event.HORIZONTAL_AXIS)
-            return;
-          this.scrollByIndex(event.detail);
+          if (event.deltaMode == event.DOM_DELTA_PIXEL)
+            this.scrollByPixels(event.deltaY);
+          else
+            this.scrollByIndex(event.deltaY);
         }
         // 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.
         // We do this by scrolling only when the last two scroll events were
         // on the same axis as the current scroll event.
+        // For diagonal scroll events we only respect the dominant axis.
         else {
-          let isVertical = event.axis == event.VERTICAL_AXIS;
+          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))
-            this.scrollByIndex(isVertical && this._isRTLScrollbox ? -event.detail :
-                                                                    event.detail);
+          if (this._prevMouseScrolls.every(prev => prev == isVertical)) {
+            if (event.deltaMode == event.DOM_DELTA_PIXEL)
+              this.scrollByPixels(scrollByDelta);
+            else
+              this.scrollByIndex(scrollByDelta);
+          }
 
           if (this._prevMouseScrolls.length > 1)
             this._prevMouseScrolls.shift();
           this._prevMouseScrolls.push(isVertical);
         }
 
         event.stopPropagation();
         event.preventDefault();
       ]]></handler>
 
-      <handler event="MozMousePixelScroll"><![CDATA[
-        event.stopPropagation();
-        event.preventDefault();
-      ]]></handler>
-
       <handler event="underflow" phase="capturing"><![CDATA[
         // filter underflow events which were dispatched on nested scrollboxes
         if (event.target != this)
           return;
 
         // Ignore events that doesn't match our orientation.
         // Scrollport event orientation:
         //   0: vertical