Bug 1554022 - Use the current position in CSS pixels for the start point of ScrollBy. r=botond,mstange

Otherwise clamped positions in layer pixels might cause 1-pixel difference
in CSS pixels on Android.

Note that there is a fundamental issue on the interaction between
the layer-pixel alignment and scrolling APIs (bug 1556685), once we fix the bug
properly, we should use the scrolled position, which was given by the scrolling
APIs, for the current position.

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2019-06-11 22:43:34 +00:00
Родитель 19f96d0e2a
Коммит 56cfdf6c52
1 изменённых файлов: 11 добавлений и 1 удалений

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

@ -4289,7 +4289,17 @@ void ScrollFrameHelper::ScrollByCSSPixels(
const CSSIntPoint& aDelta, ScrollMode aMode, nsAtom* aOrigin,
nsIScrollbarMediator::ScrollSnapMode aSnap) {
nsPoint current = GetScrollPosition();
nsPoint pt = current + CSSPoint::ToAppUnits(aDelta);
// `current` value above might be a value which was aligned to in
// layer-pixels, so starting from such points will make the difference between
// the given position in script (e.g. scrollTo) and the aligned position
// larger, in the worst case the difference can be observed in CSS pixels.
// To avoid it, we use the current position in CSS pixels as the start
// position. Hopefully it exactly matches the position where it was given by
// the previous scrolling operation, but there may be some edge cases where
// the current position in CSS pixels differs from the given position, the
// cases should be fixed in bug 1556685.
CSSIntPoint currentCSSPixels = GetScrollPositionCSSPixels();
nsPoint pt = CSSPoint::ToAppUnits(currentCSSPixels + aDelta);
if (aSnap == nsIScrollableFrame::DEFAULT) {
aSnap = DefaultSnapMode();