Bug 1636273. Fix calculation of scroll position in AsyncPanZoomController::HandleDragEvent. r=kats,botond
authorTimothy Nikkel <tnikkel@gmail.com>
Thu, 21 May 2020 02:41:41 +0000
changeset 2913085 6191dcf6f130dd30fe25b93836231b0d122bc3e9
parent 2913084 b8c14a842909cc9b2a828a34f9f1fd5670775f48
child 2913086 0959979c79d636ea462372a16a4d6861cd896993
child 2913095 46fe0af8f03dadf116cb3cf8a86377d594b2a7ac
push id542231
push userbclary@mozilla.com
push dateSun, 24 May 2020 06:08:15 +0000
treeherdertry@5bd349510b42 [default view] [failures only]
reviewerskats, botond
bugs1636273
milestone78.0a1
Bug 1636273. Fix calculation of scroll position in AsyncPanZoomController::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
gfx/2d/BaseSize.h
gfx/layers/apz/src/AsyncPanZoomController.cpp
layout/base/Units.h
--- a/gfx/2d/BaseSize.h
+++ b/gfx/2d/BaseSize.h
@@ -37,16 +37,19 @@ struct BaseSize {
     width = aWidth;
     height = aHeight;
   }
 
   bool IsEmpty() const { return width <= 0 || height <= 0; }
 
   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
 
   bool operator==(const Sub& aSize) const {
     return width == aSize.width && height == aSize.height;
   }
   bool operator!=(const Sub& aSize) const {
     return width != aSize.width || height != aSize.height;
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -1083,20 +1083,18 @@ nsEventStatus AsyncPanZoomController::Ha
   float scrollPercent =
       maxThumbPos.value == 0.0f ? 0.0f : (float)(thumbPosition / maxThumbPos);
   APZC_LOG("%p scrollbar dragged to %f percent\n", this, scrollPercent);
 
   CSSCoord minScrollPosition =
       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));
 
   scrollPosition = std::max(scrollPosition, minScrollPosition);
   scrollPosition = std::min(scrollPosition, maxScrollPosition);
 
   CSSPoint scrollOffset = Metrics().GetScrollOffset();
--- a/layout/base/Units.h
+++ b/layout/base/Units.h
@@ -823,14 +823,19 @@ struct CoordOfImpl<gfx::RectTyped<Units>
   typedef gfx::CoordTyped<Units> Type;
 };
 
 template <typename Units>
 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;
 
 }  // namespace mozilla
 
 #endif