Bug 1446724 - Lets plugins still receive original delta values instead of horizontalized values if the default action for wheel scrolling is to horizontalize vertical wheel scrolling. ?masayuki
Unlike a DOM wheel event listeners which receive original delta values, plugins
receive horizontalized ones. However, the result for the plugin isn't quite
reasonable.
Plugin developers can do any delta adjustment if they want, because they are
capable of DIRECTLY getting what IO the user is manipulating; conversely, they
aren't capable of getting what delta adjustment their upstream has already
encapsulated for them.
So we need to restore adjusted delta values to the original for plugins.
MozReview-Commit-ID: 8YQq1bTaRFx
--- 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;