Bug 1658169 - Add a SmoothScrollAnimation that matches the main-thread smooth scroll physics. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D89666
This commit is contained in:
Kartikaya Gupta 2020-09-12 14:15:47 +00:00
parent 6ea98dfe88
commit 216859f173
4 changed files with 67 additions and 0 deletions

View File

@ -12,6 +12,7 @@
#include "mozilla/TimeStamp.h"
#include "nsISupportsImpl.h"
#include "nsTArray.h"
#include "nsThreadUtils.h"
namespace mozilla {
namespace layers {
@ -21,6 +22,7 @@ struct FrameMetrics;
class WheelScrollAnimation;
class KeyboardScrollAnimation;
class SmoothMsdScrollAnimation;
class SmoothScrollAnimation;
class AsyncPanZoomAnimation {
NS_INLINE_DECL_THREADSAFE_REFCOUNTING(AsyncPanZoomAnimation)
@ -75,6 +77,7 @@ class AsyncPanZoomAnimation {
virtual SmoothMsdScrollAnimation* AsSmoothMsdScrollAnimation() {
return nullptr;
}
virtual SmoothScrollAnimation* AsSmoothScrollAnimation() { return nullptr; }
virtual bool WantsRepaints() { return true; }

View File

@ -0,0 +1,29 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "SmoothScrollAnimation.h"
#include "ScrollAnimationBezierPhysics.h"
#include "mozilla/layers/APZPublicUtils.h"
namespace mozilla {
namespace layers {
SmoothScrollAnimation::SmoothScrollAnimation(AsyncPanZoomController& aApzc,
const nsPoint& aInitialPosition,
ScrollOrigin aOrigin)
: GenericScrollAnimation(
aApzc, aInitialPosition,
apz::ComputeBezierAnimationSettingsForOrigin(aOrigin)),
mOrigin(aOrigin) {}
SmoothScrollAnimation* SmoothScrollAnimation::AsSmoothScrollAnimation() {
return this;
}
ScrollOrigin SmoothScrollAnimation::GetScrollOrigin() const { return mOrigin; }
} // namespace layers
} // namespace mozilla

View File

@ -0,0 +1,34 @@
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef mozilla_layers_SmoothScrollAnimation_h_
#define mozilla_layers_SmoothScrollAnimation_h_
#include "GenericScrollAnimation.h"
#include "mozilla/ScrollOrigin.h"
namespace mozilla {
namespace layers {
class AsyncPanZoomController;
class SmoothScrollAnimation : public GenericScrollAnimation {
public:
SmoothScrollAnimation(AsyncPanZoomController& aApzc,
const nsPoint& aInitialPosition,
ScrollOrigin aScrollOrigin);
SmoothScrollAnimation* AsSmoothScrollAnimation() override;
ScrollOrigin GetScrollOrigin() const;
private:
ScrollOrigin mOrigin;
};
} // namespace layers
} // namespace mozilla
#endif // mozilla_layers_SmoothScrollAnimation_h_

View File

@ -382,6 +382,7 @@ UNIFIED_SOURCES += [
'apz/src/SampledAPZCState.cpp',
'apz/src/SimpleVelocityTracker.cpp',
'apz/src/SmoothMsdScrollAnimation.cpp',
'apz/src/SmoothScrollAnimation.cpp',
'apz/src/WheelScrollAnimation.cpp',
'apz/testutil/APZTestData.cpp',
'apz/util/ActiveElementManager.cpp',