Bug 1446724 - Lets plugins still receive original delta values instead of horizontalized values if the default action for wheel scrolling is horizontalizing vertical wheel scrolling. r=masayuki
authorZhang Junzhi <zjz@zjz.name>
Mon, 19 Mar 2018 13:50:49 +0800
changeset 462281 38f424da56206f0946ddd01b3c9b1ce5bf195739
parent 462280 c8f111ec6150e7628ca1686cdf1293f8a6c9322e
child 462299 4f1014eb5039bdfdd7a39fb7785d102df1994a6f
child 462302 7b801fbf9bc4f4d6c3c1928d88d58ea4322e27bc
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmasayuki
bugs1446724
milestone61.0a1
first release with
nightly linux32
38f424da5620 / 61.0a1 / 20180319100039 / files
nightly linux64
38f424da5620 / 61.0a1 / 20180319100039 / files
nightly mac
38f424da5620 / 61.0a1 / 20180319100039 / files
nightly win32
38f424da5620 / 61.0a1 / 20180319100039 / files
nightly win64
38f424da5620 / 61.0a1 / 20180319100039 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1446724 - Lets plugins still receive original delta values instead of horizontalized values if the default action for wheel scrolling is horizontalizing vertical wheel scrolling. r=masayuki Unlike a DOM wheel event listeners which receive original delta values, plugins receive horizontalized ones. It's not reasonable to not send original values to plugins. Plugin developers can do any delta adjustment, and they are also capable of DIRECTLY getting what inputs the user is manipulating, that is to say, developers can horizontalize scrolling for [Shift+Vertical Wheel] or other other inputs if they want, it's just their matter; conversely, they aren't capable of getting what delta adjustment their upstream has already encapsulated for them. So it's not reasonable to send adjusted delta values to plugins. This patch restores horizontalized delta values to the original for plugins. MozReview-Commit-ID: IX8XJn0lbKq
dom/events/EventStateManager.cpp
dom/events/WheelHandlingHelper.cpp
dom/events/WheelHandlingHelper.h
--- a/dom/events/EventStateManager.cpp
+++ b/dom/events/EventStateManager.cpp
@@ -3374,16 +3374,18 @@ EventStateManager::PostHandleEvent(nsPre
       // because if the scroll target is a plugin, the default action should be
       // chosen by the plugin rather than by our prefs.
       nsIFrame* frameToScroll =
         ComputeScrollTarget(mCurrentTarget, wheelEvent,
                             COMPUTE_DEFAULT_ACTION_TARGET);
       nsPluginFrame* pluginFrame = do_QueryFrame(frameToScroll);
       if (pluginFrame) {
         MOZ_ASSERT(pluginFrame->WantsToHandleWheelEventAsDefaultAction());
+        // Plugins should receive original values instead of adjusted values.
+        adjuster.CancelAdjustment();
         action = WheelPrefs::ACTION_SEND_TO_PLUGIN;
       }
 
       switch (action) {
         case WheelPrefs::ACTION_SCROLL:
         case WheelPrefs::ACTION_HORIZONTAL_SCROLL: {
           // For scrolling of default action, we should honor the mouse wheel
           // transaction.
--- a/dom/events/WheelHandlingHelper.cpp
+++ b/dom/events/WheelHandlingHelper.cpp
@@ -605,24 +605,30 @@ AutoWheelDeltaAdjuster::AutoWheelDeltaAd
     mWheelEvent.mOverflowDeltaY = 0.0;
     mWheelEvent.mLineOrPageDeltaX = mWheelEvent.mLineOrPageDeltaY;
     mWheelEvent.mLineOrPageDeltaY = 0;
     mWheelEvent.mDeltaValuesAdjustedForDefaultHandler = true;
     mTreatedVerticalWheelAsHorizontalScroll = true;
   }
 }
 
-AutoWheelDeltaAdjuster::~AutoWheelDeltaAdjuster()
+void AutoWheelDeltaAdjuster::CancelAdjustment()
 {
   if (mTreatedVerticalWheelAsHorizontalScroll &&
       mWheelEvent.mDeltaValuesAdjustedForDefaultHandler) {
     mWheelEvent.mDeltaY = mWheelEvent.mDeltaX;
     mWheelEvent.mDeltaX = mOldDeltaX;
     mWheelEvent.mDeltaZ = mOldDeltaZ;
     mWheelEvent.mOverflowDeltaY = mWheelEvent.mOverflowDeltaX;
     mWheelEvent.mOverflowDeltaX = mOldOverflowDeltaX;
     mWheelEvent.mLineOrPageDeltaY = mWheelEvent.mLineOrPageDeltaX;
     mWheelEvent.mLineOrPageDeltaX = mOldLineOrPageDeltaX;
     mWheelEvent.mDeltaValuesAdjustedForDefaultHandler = false;
+    mTreatedVerticalWheelAsHorizontalScroll = false;
   }
 }
 
+AutoWheelDeltaAdjuster::~AutoWheelDeltaAdjuster()
+{
+  CancelAdjustment();
+}
+
 } // namespace mozilla
--- a/dom/events/WheelHandlingHelper.h
+++ b/dom/events/WheelHandlingHelper.h
@@ -224,16 +224,17 @@ public:
    *                           modified for default handler.
    *                           Its mDeltaValuesAdjustedForDefaultHandler
    *                           must not be true because if it's true,
    *                           the event has already been adjusted the
    *                           delta values for default handler.
    */
   explicit AutoWheelDeltaAdjuster(WidgetWheelEvent& aWheelEvent);
   ~AutoWheelDeltaAdjuster();
+  void CancelAdjustment();
 
 private:
   WidgetWheelEvent& mWheelEvent;
   double mOldDeltaX;
   double mOldDeltaZ;
   double mOldOverflowDeltaX;
   int32_t mOldLineOrPageDeltaX;
   bool mTreatedVerticalWheelAsHorizontalScroll;