From 19179bc9fe36cf5c0b9fe8e4a473b7626bd07306 Mon Sep 17 00:00:00 2001 From: Masayuki Nakano Date: Sun, 12 Aug 2012 10:42:36 +0900 Subject: [PATCH] Bug 719320 part.8-11 Cancel applying delta multipliers from overflowDelta r=smaug --- content/events/src/nsEventStateManager.cpp | 15 +++++++++++++++ content/events/src/nsEventStateManager.h | 8 ++++++++ 2 files changed, 23 insertions(+) diff --git a/content/events/src/nsEventStateManager.cpp b/content/events/src/nsEventStateManager.cpp index 25a46e026421..2221d401c4c0 100644 --- a/content/events/src/nsEventStateManager.cpp +++ b/content/events/src/nsEventStateManager.cpp @@ -2814,6 +2814,7 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame, aEvent->overflowDeltaX = aEvent->deltaX; aEvent->overflowDeltaY = aEvent->deltaY; + WheelPrefs::GetInstance()->CancelApplyingUserPrefsFromOverflowDelta(aEvent); nsIFrame* scrollFrame = do_QueryFrame(aScrollableFrame); MOZ_ASSERT(scrollFrame); @@ -2938,6 +2939,7 @@ nsEventStateManager::DoScrollText(nsIScrollableFrame* aScrollableFrame, aEvent->overflowDeltaY = static_cast(overflow.y) / scrollAmountInDevPixels.height; } + WheelPrefs::GetInstance()->CancelApplyingUserPrefsFromOverflowDelta(aEvent); } void @@ -5357,6 +5359,19 @@ nsEventStateManager::WheelPrefs::ApplyUserPrefsToDelta( (mMultiplierZ[index] != 1.0)); } +void +nsEventStateManager::WheelPrefs::CancelApplyingUserPrefsFromOverflowDelta( + widget::WheelEvent* aEvent) +{ + Index index = GetIndexFor(aEvent); + Init(index); + + NS_ASSERTION(mMultiplierX[index] && mMultiplierY[index], + "The absolute values of both multipliers must be 1 or larger"); + aEvent->overflowDeltaX /= mMultiplierX[index]; + aEvent->overflowDeltaY /= mMultiplierY[index]; +} + nsEventStateManager::WheelPrefs::Action nsEventStateManager::WheelPrefs::ComputeActionFor(widget::WheelEvent* aEvent) { diff --git a/content/events/src/nsEventStateManager.h b/content/events/src/nsEventStateManager.h index 58a875bed5a9..e776e5ac251c 100644 --- a/content/events/src/nsEventStateManager.h +++ b/content/events/src/nsEventStateManager.h @@ -338,6 +338,14 @@ protected: */ void ApplyUserPrefsToDelta(mozilla::widget::WheelEvent* aEvent); + /** + * If ApplyUserPrefsToDelta() changed the delta values with customized + * prefs, the overflowDelta values would be inflated. + * CancelApplyingUserPrefsFromOverflowDelta() cancels the inflation. + */ + void CancelApplyingUserPrefsFromOverflowDelta( + mozilla::widget::WheelEvent* aEvent); + /** * Computes the default action for the aEvent with the prefs. */