Bug 1502614 - Continue autoscroll animation after any main-thread scroll update (absolute or relative). r=rhunt

This matches the main thread behaviour prior to implementing APZ autoscrolling.

Differential Revision: https://phabricator.services.mozilla.com/D10778

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Botond Ballo 2018-11-05 14:38:43 +00:00
Родитель aa95912b8b
Коммит a23912a91d
5 изменённых файлов: 25 добавлений и 17 удалений

Просмотреть файл

@ -33,14 +33,20 @@ public:
const TimeDuration& aDelta) = 0;
/**
* Attempt to apply a translation to the animation in response to content
* providing a relative scroll offset update.
* Attempt to handle a main-thread scroll offset update without cancelling
* the animation. This may or may not make sense depending on the type of
* the animation and whether the scroll update is relative or absolute.
*
* @param aShiftDelta the amount to translate the animation in app units
* @returns Whether the animation was able to translate. If false, the
* animation must be canceled.
* If the scroll update is relative, |aRelativeDelta| will contain the
* delta of the relative update. If the scroll update is absolute,
* |aRelativeDelta| will be Nothing() (the animation can check the APZC's
* FrameMetrics for the new absolute scroll offset if it wants to handle
* and absolute update).
*
* Returns whether the animation could handle the scroll update. If the
* return value is false, the animation will be cancelled.
*/
virtual bool ApplyContentShift(const CSSPoint& aShiftDelta)
virtual bool HandleScrollOffsetUpdate(const Maybe<CSSPoint>& aRelativeDelta)
{
return false;
}

Просмотреть файл

@ -4409,12 +4409,11 @@ void AsyncPanZoomController::NotifyLayersUpdated(const ScrollMetadata& aScrollMe
mCompositedScrollOffset = Metrics().GetScrollOffset();
mExpectedGeckoMetrics = aLayerMetrics;
// If we have applied a relative scroll update and a scroll animation is
// happening, attempt to apply a content shift and preserve the
// animation.
// If an animation is underway, tell it about the scroll offset update.
// Some animations can handle some scroll offset updates and continue
// running. Those that can't will return false, and we cancel them.
if (!mAnimation ||
relativeDelta.isNothing() ||
!mAnimation->ApplyContentShift(relativeDelta.value())) {
!mAnimation->HandleScrollOffsetUpdate(relativeDelta)) {
// Cancel the animation (which might also trigger a repaint request)
// after we update the scroll offset above. Otherwise we can be left
// in a state where things are out of sync.

Просмотреть файл

@ -22,10 +22,10 @@ public:
bool DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta) override;
bool ApplyContentShift(const CSSPoint& aShiftDelta) override
bool HandleScrollOffsetUpdate(const Maybe<CSSPoint>& aRelativeDelta) override
{
// Autoscroll works using screen space coordinates, so there's no work we
// need to do to handle a content shift
// need to do to handle either a relative or an absolute scroll update.
return true;
}

Просмотреть файл

@ -111,10 +111,13 @@ GenericScrollAnimation::DoSample(FrameMetrics& aFrameMetrics, const TimeDuration
}
bool
GenericScrollAnimation::ApplyContentShift(const CSSPoint& aShiftDelta)
GenericScrollAnimation::HandleScrollOffsetUpdate(const Maybe<CSSPoint>& aRelativeDelta)
{
mAnimationPhysics->ApplyContentShift(aShiftDelta);
return true;
if (aRelativeDelta) {
mAnimationPhysics->ApplyContentShift(*aRelativeDelta);
return true;
}
return false;
}
} // namespace layers

Просмотреть файл

@ -28,7 +28,7 @@ public:
bool DoSample(FrameMetrics& aFrameMetrics, const TimeDuration& aDelta) override;
bool ApplyContentShift(const CSSPoint& aShiftDelta) override;
bool HandleScrollOffsetUpdate(const Maybe<CSSPoint>& aRelativeDelta) override;
void UpdateDelta(TimeStamp aTime,
const nsPoint& aDelta,