Bug 1105109 - Introduce a FrameMetrics::ClampAndSetScrollOffset() helper. r=kats

MozReview-Commit-ID: 6LCPKrdGM6M

--HG--
extra : rebase_source : 65f51ce5c40d9f1ac64c1f94055aa87d44a72cae
This commit is contained in:
Botond Ballo 2017-07-28 14:57:54 -04:00
Родитель e3ca66d639
Коммит 9da4eab494
2 изменённых файлов: 10 добавлений и 7 удалений

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

@ -335,6 +335,12 @@ public:
mScrollOffset = aScrollOffset;
}
// Set scroll offset, first clamping to the scroll range.
void ClampAndSetScrollOffset(const CSSPoint& aScrollOffset)
{
SetScrollOffset(CalculateScrollRange().ClampPoint(aScrollOffset));
}
const CSSPoint& GetScrollOffset() const
{
return mScrollOffset;

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

@ -582,10 +582,9 @@ public:
// offset to end up being a bit off from the destination, we can get
// artefacts like "scroll to the next snap point in this direction"
// scrolling to the snap point we're already supposed to be at.
aFrameMetrics.SetScrollOffset(
aFrameMetrics.CalculateScrollRange().ClampPoint(
CSSPoint::FromAppUnits(nsPoint(mXAxisModel.GetDestination(),
mYAxisModel.GetDestination()))));
aFrameMetrics.ClampAndSetScrollOffset(
CSSPoint::FromAppUnits(nsPoint(mXAxisModel.GetDestination(),
mYAxisModel.GetDestination())));
return false;
}
@ -3789,9 +3788,7 @@ void AsyncPanZoomController::NotifyLayersUpdated(const ScrollMetadata& aScrollMe
// Even if we didn't accept a new scroll offset from content, the
// scrollable rect may have changed in a way that makes our local
// scroll offset out of bounds, so re-clamp it.
mFrameMetrics.SetScrollOffset(
mFrameMetrics.CalculateScrollRange().ClampPoint(
mFrameMetrics.GetScrollOffset()));
mFrameMetrics.ClampAndSetScrollOffset(mFrameMetrics.GetScrollOffset());
}
}