mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-19 15:51:33 +00:00
Bug 1247677 - Add support for the general.smoothScroll.{pages,pixels} prefs in APZ. r=dvander
MozReview-Commit-ID: HCOqbRZV5ui
This commit is contained in:
parent
6de82d82fb
commit
d805fe7934
@ -1051,9 +1051,11 @@ APZCTreeManager::ProcessWheelEvent(WidgetWheelEvent& aEvent,
|
||||
uint64_t* aOutInputBlockId)
|
||||
{
|
||||
ScrollWheelInput::ScrollMode scrollMode = ScrollWheelInput::SCROLLMODE_INSTANT;
|
||||
if ((aEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE ||
|
||||
aEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_PAGE) &&
|
||||
gfxPrefs::SmoothScrollEnabled() && gfxPrefs::WheelSmoothScrollEnabled())
|
||||
if (gfxPrefs::SmoothScrollEnabled() &&
|
||||
((aEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_LINE &&
|
||||
gfxPrefs::WheelSmoothScrollEnabled()) ||
|
||||
(aEvent.deltaMode == nsIDOMWheelEvent::DOM_DELTA_PAGE &&
|
||||
gfxPrefs::PageSmoothScrollEnabled())))
|
||||
{
|
||||
scrollMode = ScrollWheelInput::SCROLLMODE_SMOOTH;
|
||||
}
|
||||
|
@ -1792,8 +1792,7 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(const ScrollWheelInput& aEve
|
||||
|
||||
nsPoint initialPosition = CSSPoint::ToAppUnits(mFrameMetrics.GetScrollOffset());
|
||||
StartAnimation(new WheelScrollAnimation(
|
||||
*this,
|
||||
initialPosition));
|
||||
*this, initialPosition, aEvent.mDeltaType));
|
||||
}
|
||||
|
||||
nsPoint deltaInAppUnits =
|
||||
|
@ -13,10 +13,13 @@
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
WheelScrollAnimation::WheelScrollAnimation(AsyncPanZoomController& aApzc, const nsPoint& aInitialPosition)
|
||||
WheelScrollAnimation::WheelScrollAnimation(AsyncPanZoomController& aApzc,
|
||||
const nsPoint& aInitialPosition,
|
||||
ScrollWheelInput::ScrollDeltaType aDeltaType)
|
||||
: AsyncScrollBase(aInitialPosition)
|
||||
, mApzc(aApzc)
|
||||
, mFinalDestination(aInitialPosition)
|
||||
, mDeltaType(aDeltaType)
|
||||
{
|
||||
}
|
||||
|
||||
@ -86,8 +89,21 @@ WheelScrollAnimation::InitPreferences(TimeStamp aTime)
|
||||
return;
|
||||
}
|
||||
|
||||
mOriginMaxMS = clamped(gfxPrefs::WheelSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::WheelSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
switch (mDeltaType) {
|
||||
case ScrollWheelInput::SCROLLDELTA_PAGE:
|
||||
mOriginMaxMS = clamped(gfxPrefs::PageSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::PageSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
break;
|
||||
case ScrollWheelInput::SCROLLDELTA_PIXEL:
|
||||
mOriginMaxMS = clamped(gfxPrefs::PixelSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::PixelSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
break;
|
||||
case ScrollWheelInput::SCROLLDELTA_LINE:
|
||||
default:
|
||||
mOriginMaxMS = clamped(gfxPrefs::WheelSmoothScrollMaxDurationMs(), 0, 10000);
|
||||
mOriginMinMS = clamped(gfxPrefs::WheelSmoothScrollMinDurationMs(), 0, mOriginMaxMS);
|
||||
break;
|
||||
}
|
||||
|
||||
// The pref is 100-based int percentage, while mIntervalRatio is 1-based ratio
|
||||
mIntervalRatio = ((double)gfxPrefs::SmoothScrollDurationToIntervalRatio()) / 100.0;
|
||||
|
@ -9,6 +9,7 @@
|
||||
|
||||
#include "AsyncPanZoomAnimation.h"
|
||||
#include "AsyncScrollBase.h"
|
||||
#include "InputData.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
@ -20,7 +21,9 @@ class WheelScrollAnimation
|
||||
public AsyncScrollBase
|
||||
{
|
||||
public:
|
||||
WheelScrollAnimation(AsyncPanZoomController& aApzc, const nsPoint& aInitialPosition);
|
||||
WheelScrollAnimation(AsyncPanZoomController& aApzc,
|
||||
const nsPoint& aInitialPosition,
|
||||
ScrollWheelInput::ScrollDeltaType aDeltaType);
|
||||
|
||||
bool DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta) override;
|
||||
void Update(TimeStamp aTime, nsPoint aDelta, const nsSize& aCurrentVelocity);
|
||||
@ -35,6 +38,7 @@ private:
|
||||
private:
|
||||
AsyncPanZoomController& mApzc;
|
||||
nsPoint mFinalDestination;
|
||||
ScrollWheelInput::ScrollDeltaType mDeltaType;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
|
@ -212,6 +212,16 @@ private:
|
||||
WheelSmoothScrollMaxDurationMs, int32_t, 400);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.mouseWheel.durationMinMS",
|
||||
WheelSmoothScrollMinDurationMs, int32_t, 200);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.pages", PageSmoothScrollEnabled, bool, true);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.pages.durationMaxMS",
|
||||
PageSmoothScrollMaxDurationMs, int32_t, 150);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.pages.durationMinMS",
|
||||
PageSmoothScrollMinDurationMs, int32_t, 150);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.pixels", PixelSmoothScrollEnabled, bool, true);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.pixels.durationMaxMS",
|
||||
PixelSmoothScrollMaxDurationMs, int32_t, 150);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.pixels.durationMinMS",
|
||||
PixelSmoothScrollMinDurationMs, int32_t, 150);
|
||||
DECL_GFX_PREF(Live, "general.smoothScroll.stopDecelerationWeighting",
|
||||
SmoothScrollStopDecelerationWeighting, float, 0.4f);
|
||||
|
||||
|
@ -537,7 +537,7 @@ public:
|
||||
enum ScrollDeltaType
|
||||
{
|
||||
// There are three kinds of scroll delta modes in Gecko: "page", "line" and
|
||||
// "pixel". For apz, we currently only support the "line" and "pixel" modes.
|
||||
// "pixel".
|
||||
SCROLLDELTA_LINE,
|
||||
SCROLLDELTA_PAGE,
|
||||
SCROLLDELTA_PIXEL
|
||||
|
Loading…
x
Reference in New Issue
Block a user