Bug 1321885 - Expose the current async scroll offset in CSS pixels. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Mon, 21 Nov 2016 19:26:07 -0500
changeset 447181 5b752200fec4c72e4c532aeba142d07bc6470a39
parent 447180 effeb33dca0ea5ed6c4e4fa2120383c3b4d28d0b
child 447191 379299935358a552f69a0c5f7632c67a2a708562
child 447198 23e6a2b51c4d50be839e54309c3e4bd86dc1e34a
push id38008
push userbballo@mozilla.com
push dateFri, 02 Dec 2016 22:13:11 +0000
reviewerskats
bugs1321885
milestone53.0a1
Bug 1321885 - Expose the current async scroll offset in CSS pixels. r=kats Some consumers want to use the async scroll offset in CSS pixels, and it's pointless to convert to ParentLayer pixels only to have the consumer convert it back. MozReview-Commit-ID: B8nq3LUPM6Q
gfx/layers/apz/src/AsyncPanZoomController.cpp
gfx/layers/apz/src/AsyncPanZoomController.h
--- a/gfx/layers/apz/src/AsyncPanZoomController.cpp
+++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp
@@ -3130,16 +3130,27 @@ AsyncPanZoomController::GetCurrentAsyncS
   if (aMode == RESPECT_FORCE_DISABLE && mScrollMetadata.IsApzForceDisabled()) {
     return mLastContentPaintMetrics.GetScrollOffset() * mLastContentPaintMetrics.GetZoom();
   }
 
   return (mFrameMetrics.GetScrollOffset() + mTestAsyncScrollOffset)
       * mFrameMetrics.GetZoom() * mTestAsyncZoom.scale;
 }
 
+CSSPoint
+AsyncPanZoomController::GetCurrentAsyncScrollOffsetInCssPixels(AsyncMode aMode) const {
+  ReentrantMonitorAutoEnter lock(mMonitor);
+
+  if (aMode == RESPECT_FORCE_DISABLE && mScrollMetadata.IsApzForceDisabled()) {
+    return mLastContentPaintMetrics.GetScrollOffset();
+  }
+
+  return mFrameMetrics.GetScrollOffset() + mTestAsyncScrollOffset;
+}
+
 AsyncTransform
 AsyncPanZoomController::GetCurrentAsyncTransform(AsyncMode aMode) const
 {
   ReentrantMonitorAutoEnter lock(mMonitor);
 
   if (aMode == RESPECT_FORCE_DISABLE && mScrollMetadata.IsApzForceDisabled()) {
     return AsyncTransform();
   }
--- a/gfx/layers/apz/src/AsyncPanZoomController.h
+++ b/gfx/layers/apz/src/AsyncPanZoomController.h
@@ -754,16 +754,23 @@ public:
   /**
    * Get the current scroll offset of the scrollable frame corresponding
    * to this APZC, including the effects of any asynchronous panning and
    * zooming, in ParentLayer pixels.
    */
   ParentLayerPoint GetCurrentAsyncScrollOffset(AsyncMode aMode) const;
 
   /**
+   * Get the current scroll offset of the scrollable frame corresponding
+   * to this APZC, including the effects of any asynchronous panning, in
+   * CSS pixels.
+   */
+  CSSPoint GetCurrentAsyncScrollOffsetInCssPixels(AsyncMode aMode) const;
+
+  /**
    * Return a visual effect that reflects this apzc's
    * overscrolled state, if any.
    */
   AsyncTransformComponentMatrix GetOverscrollTransform(AsyncMode aMode) const;
 
   /**
    * Returns the incremental transformation corresponding to the async pan/zoom
    * in progress. That is, when this transform is multiplied with the layer's