Bug 1263975 - XUL scrollbox (e.g. the tab bar) should respond to pixel scrolls by pixel scrolling. r=enndeakin+6102
☠☠ backed out by b0628853f899 ☠ ☠
authorMarkus Stange <mstange@themasta.com>
Tue, 05 Jan 2016 18:35:23 +0100
changeset 293300 954189d579d5db542624d10c11108db60af13816
parent 293299 7f765725b3b4575a01171f31e399e8723047c9d7
child 293301 410d733097ac4378441053cb5f4d19eb792f1b05
push id18749
push usercbook@mozilla.com
push dateFri, 15 Apr 2016 12:01:19 +0000
treeherderfx-team@8f7045b63b07 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs1263975
milestone48.0a1
Bug 1263975 - XUL scrollbox (e.g. the tab bar) should respond to pixel scrolls by pixel scrolling. r=enndeakin+6102 MozReview-Commit-ID: 8XgagEVbiQg
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