Skip to content

Commit

Permalink
Bug 1636273. Fix calculation of scroll position in AsyncPanZoomContro…
Browse files Browse the repository at this point in the history
…ller::HandleDragEvent. r=kats,botond

The scroll position and scrollable rect are inside the zoom boundary so we need to use the composisted size inside the zoom boundary as well.

Differential Revision: https://phabricator.services.mozilla.com/D76089
  • Loading branch information
tnikkel committed May 21, 2020
1 parent f99ed95 commit cfedff2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 3 additions & 0 deletions gfx/2d/BaseSize.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ struct BaseSize {

bool IsSquare() const { return width == height; }

MOZ_ALWAYS_INLINE T Width() const { return width; }
MOZ_ALWAYS_INLINE T Height() const { return height; }

// Note that '=' isn't defined so we'll get the
// compiler generated default assignment operator

Expand Down
6 changes: 2 additions & 4 deletions gfx/layers/apz/src/AsyncPanZoomController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1088,10 +1088,8 @@ nsEventStatus AsyncPanZoomController::HandleDragEvent(
GetAxisStart(direction, Metrics().GetScrollableRect().TopLeft());
CSSCoord maxScrollPosition =
GetAxisStart(direction, Metrics().GetScrollableRect().BottomRight()) -
GetAxisLength(
direction,
Metrics()
.CalculateCompositionBoundsInCssPixelsOfSurroundingContent());
GetAxisLength(direction,
Metrics().CalculateCompositedSizeInCssPixels());
CSSCoord scrollPosition =
minScrollPosition +
(scrollPercent * (maxScrollPosition - minScrollPosition));
Expand Down
5 changes: 5 additions & 0 deletions layout/base/Units.h
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,11 @@ struct CoordOfImpl<gfx::IntRectTyped<Units>> {
typedef gfx::IntCoordTyped<Units> Type;
};

template <typename Units>
struct CoordOfImpl<gfx::SizeTyped<Units>> {
typedef gfx::CoordTyped<Units> Type;
};

template <typename T>
using CoordOf = typename CoordOfImpl<T>::Type;

Expand Down

0 comments on commit cfedff2

Please sign in to comment.