зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1739541 - Introduce WasTriggeedByScript() function in AsyncPanZoomAnimation class. r=botond
Differential Revision: https://phabricator.services.mozilla.com/D130420
This commit is contained in:
Родитель
33d1f8ef64
Коммит
d858a93e39
|
@ -81,6 +81,8 @@ class AsyncPanZoomAnimation {
|
||||||
|
|
||||||
virtual void Cancel(CancelAnimationFlags aFlags) {}
|
virtual void Cancel(CancelAnimationFlags aFlags) {}
|
||||||
|
|
||||||
|
virtual bool WasTriggeredByScript() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// Protected destructor, to discourage deletion outside of Release():
|
// Protected destructor, to discourage deletion outside of Release():
|
||||||
virtual ~AsyncPanZoomAnimation() = default;
|
virtual ~AsyncPanZoomAnimation() = default;
|
||||||
|
|
|
@ -1995,7 +1995,7 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
|
||||||
// existing smooth scroll animation if there is one.
|
// existing smooth scroll animation if there is one.
|
||||||
APZC_LOG("%p keyboard scrolling to snap point %s\n", this,
|
APZC_LOG("%p keyboard scrolling to snap point %s\n", this,
|
||||||
ToString(destination).c_str());
|
ToString(destination).c_str());
|
||||||
SmoothMsdScrollTo(destination);
|
SmoothMsdScrollTo(destination, ScrollTriggeredByScript::No);
|
||||||
return nsEventStatus_eConsumeDoDefault;
|
return nsEventStatus_eConsumeDoDefault;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2408,7 +2408,7 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(
|
||||||
// existing smooth scroll animation if there is one.
|
// existing smooth scroll animation if there is one.
|
||||||
APZC_LOG("%p wheel scrolling to snap point %s\n", this,
|
APZC_LOG("%p wheel scrolling to snap point %s\n", this,
|
||||||
ToString(startPosition).c_str());
|
ToString(startPosition).c_str());
|
||||||
SmoothMsdScrollTo(startPosition);
|
SmoothMsdScrollTo(startPosition, ScrollTriggeredByScript::No);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3719,12 +3719,13 @@ void AsyncPanZoomController::SmoothScrollTo(const CSSPoint& aDestination,
|
||||||
StartAnimation(animation.get());
|
StartAnimation(animation.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
void AsyncPanZoomController::SmoothMsdScrollTo(const CSSPoint& aDestination) {
|
void AsyncPanZoomController::SmoothMsdScrollTo(
|
||||||
|
const CSSPoint& aDestination, ScrollTriggeredByScript aTriggeredByScript) {
|
||||||
if (mState == SMOOTHMSD_SCROLL && mAnimation) {
|
if (mState == SMOOTHMSD_SCROLL && mAnimation) {
|
||||||
APZC_LOG("%p updating destination on existing animation\n", this);
|
APZC_LOG("%p updating destination on existing animation\n", this);
|
||||||
RefPtr<SmoothMsdScrollAnimation> animation(
|
RefPtr<SmoothMsdScrollAnimation> animation(
|
||||||
static_cast<SmoothMsdScrollAnimation*>(mAnimation.get()));
|
static_cast<SmoothMsdScrollAnimation*>(mAnimation.get()));
|
||||||
animation->SetDestination(aDestination);
|
animation->SetDestination(aDestination, aTriggeredByScript);
|
||||||
} else {
|
} else {
|
||||||
CancelAnimation();
|
CancelAnimation();
|
||||||
SetState(SMOOTHMSD_SCROLL);
|
SetState(SMOOTHMSD_SCROLL);
|
||||||
|
@ -3739,7 +3740,8 @@ void AsyncPanZoomController::SmoothMsdScrollTo(const CSSPoint& aDestination) {
|
||||||
StartAnimation(new SmoothMsdScrollAnimation(
|
StartAnimation(new SmoothMsdScrollAnimation(
|
||||||
*this, Metrics().GetVisualScrollOffset(), initialVelocity, aDestination,
|
*this, Metrics().GetVisualScrollOffset(), initialVelocity, aDestination,
|
||||||
StaticPrefs::layout_css_scroll_behavior_spring_constant(),
|
StaticPrefs::layout_css_scroll_behavior_spring_constant(),
|
||||||
StaticPrefs::layout_css_scroll_behavior_damping_ratio()));
|
StaticPrefs::layout_css_scroll_behavior_damping_ratio(),
|
||||||
|
aTriggeredByScript));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5123,9 +5125,11 @@ void AsyncPanZoomController::NotifyLayersUpdated(
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scrollUpdate.GetMode() == ScrollMode::SmoothMsd) {
|
if (scrollUpdate.GetMode() == ScrollMode::SmoothMsd) {
|
||||||
SmoothMsdScrollTo(destination);
|
SmoothMsdScrollTo(destination,
|
||||||
|
scrollUpdate.GetScrollTriggeredByScript());
|
||||||
} else {
|
} else {
|
||||||
MOZ_ASSERT(scrollUpdate.GetMode() == ScrollMode::Smooth);
|
MOZ_ASSERT(scrollUpdate.GetMode() == ScrollMode::Smooth);
|
||||||
|
MOZ_ASSERT(!scrollUpdate.WasTriggeredByScript());
|
||||||
SmoothScrollTo(destination, scrollUpdate.GetOrigin());
|
SmoothScrollTo(destination, scrollUpdate.GetOrigin());
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
@ -5907,7 +5911,7 @@ void AsyncPanZoomController::ScrollSnapNear(const CSSPoint& aDestination) {
|
||||||
if (*snapPoint != Metrics().GetVisualScrollOffset()) {
|
if (*snapPoint != Metrics().GetVisualScrollOffset()) {
|
||||||
APZC_LOG("%p smooth scrolling to snap point %s\n", this,
|
APZC_LOG("%p smooth scrolling to snap point %s\n", this,
|
||||||
ToString(*snapPoint).c_str());
|
ToString(*snapPoint).c_str());
|
||||||
SmoothMsdScrollTo(*snapPoint);
|
SmoothMsdScrollTo(*snapPoint, ScrollTriggeredByScript::No);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5953,7 +5957,7 @@ void AsyncPanZoomController::ScrollSnapToDestination() {
|
||||||
(float)Metrics().GetVisualScrollOffset().y, (float)startPosition.x,
|
(float)Metrics().GetVisualScrollOffset().y, (float)startPosition.x,
|
||||||
(float)startPosition.y);
|
(float)startPosition.y);
|
||||||
|
|
||||||
SmoothMsdScrollTo(startPosition);
|
SmoothMsdScrollTo(startPosition, ScrollTriggeredByScript::No);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1483,7 +1483,8 @@ class AsyncPanZoomController {
|
||||||
|
|
||||||
// Start a smooth-scrolling animation to the given destination, with MSD
|
// Start a smooth-scrolling animation to the given destination, with MSD
|
||||||
// physics that is suited for scroll-snapping.
|
// physics that is suited for scroll-snapping.
|
||||||
void SmoothMsdScrollTo(const CSSPoint& aDestination);
|
void SmoothMsdScrollTo(const CSSPoint& aDestination,
|
||||||
|
ScrollTriggeredByScript aTriggeredByScript);
|
||||||
|
|
||||||
// Returns whether overscroll is allowed during an event.
|
// Returns whether overscroll is allowed during an event.
|
||||||
bool AllowScrollHandoffInCurrentBlock() const;
|
bool AllowScrollHandoffInCurrentBlock() const;
|
||||||
|
|
|
@ -12,12 +12,14 @@ namespace layers {
|
||||||
SmoothMsdScrollAnimation::SmoothMsdScrollAnimation(
|
SmoothMsdScrollAnimation::SmoothMsdScrollAnimation(
|
||||||
AsyncPanZoomController& aApzc, const CSSPoint& aInitialPosition,
|
AsyncPanZoomController& aApzc, const CSSPoint& aInitialPosition,
|
||||||
const CSSPoint& aInitialVelocity, const CSSPoint& aDestination,
|
const CSSPoint& aInitialVelocity, const CSSPoint& aDestination,
|
||||||
double aSpringConstant, double aDampingRatio)
|
double aSpringConstant, double aDampingRatio,
|
||||||
|
ScrollTriggeredByScript aTriggeredByScript)
|
||||||
: mApzc(aApzc),
|
: mApzc(aApzc),
|
||||||
mXAxisModel(aInitialPosition.x, aDestination.x, aInitialVelocity.x,
|
mXAxisModel(aInitialPosition.x, aDestination.x, aInitialVelocity.x,
|
||||||
aSpringConstant, aDampingRatio),
|
aSpringConstant, aDampingRatio),
|
||||||
mYAxisModel(aInitialPosition.y, aDestination.y, aInitialVelocity.y,
|
mYAxisModel(aInitialPosition.y, aDestination.y, aInitialVelocity.y,
|
||||||
aSpringConstant, aDampingRatio) {}
|
aSpringConstant, aDampingRatio),
|
||||||
|
mTriggeredByScript(aTriggeredByScript) {}
|
||||||
|
|
||||||
bool SmoothMsdScrollAnimation::DoSample(FrameMetrics& aFrameMetrics,
|
bool SmoothMsdScrollAnimation::DoSample(FrameMetrics& aFrameMetrics,
|
||||||
const TimeDuration& aDelta) {
|
const TimeDuration& aDelta) {
|
||||||
|
@ -113,9 +115,12 @@ bool SmoothMsdScrollAnimation::DoSample(FrameMetrics& aFrameMetrics,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmoothMsdScrollAnimation::SetDestination(const CSSPoint& aNewDestination) {
|
void SmoothMsdScrollAnimation::SetDestination(
|
||||||
|
const CSSPoint& aNewDestination,
|
||||||
|
ScrollTriggeredByScript aTriggeredByScript) {
|
||||||
mXAxisModel.SetDestination(aNewDestination.x);
|
mXAxisModel.SetDestination(aNewDestination.x);
|
||||||
mYAxisModel.SetDestination(aNewDestination.y);
|
mYAxisModel.SetDestination(aNewDestination.y);
|
||||||
|
mTriggeredByScript = aTriggeredByScript;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSSPoint SmoothMsdScrollAnimation::GetDestination() const {
|
CSSPoint SmoothMsdScrollAnimation::GetDestination() const {
|
||||||
|
|
|
@ -9,19 +9,21 @@
|
||||||
|
|
||||||
#include "AsyncPanZoomAnimation.h"
|
#include "AsyncPanZoomAnimation.h"
|
||||||
#include "mozilla/layers/AxisPhysicsMSDModel.h"
|
#include "mozilla/layers/AxisPhysicsMSDModel.h"
|
||||||
|
#include "mozilla/ScrollPositionUpdate.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace layers {
|
namespace layers {
|
||||||
|
|
||||||
class AsyncPanZoomController;
|
class AsyncPanZoomController;
|
||||||
|
|
||||||
class SmoothMsdScrollAnimation : public AsyncPanZoomAnimation {
|
class SmoothMsdScrollAnimation final : public AsyncPanZoomAnimation {
|
||||||
public:
|
public:
|
||||||
SmoothMsdScrollAnimation(AsyncPanZoomController& aApzc,
|
SmoothMsdScrollAnimation(AsyncPanZoomController& aApzc,
|
||||||
const CSSPoint& aInitialPosition,
|
const CSSPoint& aInitialPosition,
|
||||||
const CSSPoint& aInitialVelocity,
|
const CSSPoint& aInitialVelocity,
|
||||||
const CSSPoint& aDestination, double aSpringConstant,
|
const CSSPoint& aDestination, double aSpringConstant,
|
||||||
double aDampingRatio);
|
double aDampingRatio,
|
||||||
|
ScrollTriggeredByScript aTriggeredByScript);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Advances a smooth scroll simulation based on the time passed in |aDelta|.
|
* Advances a smooth scroll simulation based on the time passed in |aDelta|.
|
||||||
|
@ -32,14 +34,20 @@ class SmoothMsdScrollAnimation : public AsyncPanZoomAnimation {
|
||||||
bool DoSample(FrameMetrics& aFrameMetrics,
|
bool DoSample(FrameMetrics& aFrameMetrics,
|
||||||
const TimeDuration& aDelta) override;
|
const TimeDuration& aDelta) override;
|
||||||
|
|
||||||
void SetDestination(const CSSPoint& aNewDestination);
|
void SetDestination(const CSSPoint& aNewDestination,
|
||||||
|
ScrollTriggeredByScript aTriggeredByScript);
|
||||||
CSSPoint GetDestination() const;
|
CSSPoint GetDestination() const;
|
||||||
SmoothMsdScrollAnimation* AsSmoothMsdScrollAnimation() override;
|
SmoothMsdScrollAnimation* AsSmoothMsdScrollAnimation() override;
|
||||||
|
|
||||||
|
bool WasTriggeredByScript() const override {
|
||||||
|
return mTriggeredByScript == ScrollTriggeredByScript::Yes;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AsyncPanZoomController& mApzc;
|
AsyncPanZoomController& mApzc;
|
||||||
AxisPhysicsMSDModel mXAxisModel;
|
AxisPhysicsMSDModel mXAxisModel;
|
||||||
AxisPhysicsMSDModel mYAxisModel;
|
AxisPhysicsMSDModel mYAxisModel;
|
||||||
|
ScrollTriggeredByScript mTriggeredByScript;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace layers
|
} // namespace layers
|
||||||
|
|
Загрузка…
Ссылка в новой задаче