Bug 1386777 - Interpret autoscroll anchor coordinates correctly when there is a device scale. r=kats draft
authorBotond Ballo <botond@mozilla.com>
Wed, 02 Aug 2017 20:11:07 -0400
changeset 620082 4052dd05a4c05cc8fc4effe0f7911179aa8005d0
parent 620030 792d0a2e04d7bc337c77f4777848337ac6ba6dd6
child 640572 2f3b48a00ddf757e3e599d402c5a729ad5295938
push id71901
push userbballo@mozilla.com
push dateThu, 03 Aug 2017 00:11:37 +0000
reviewerskats
bugs1386777
milestone57.0a1
Bug 1386777 - Interpret autoscroll anchor coordinates correctly when there is a device scale. r=kats MozReview-Commit-ID: 6caXxWjuqxm
dom/interfaces/base/nsITabParent.idl
dom/ipc/TabParent.cpp
--- a/dom/interfaces/base/nsITabParent.idl
+++ b/dom/interfaces/base/nsITabParent.idl
@@ -76,17 +76,17 @@ interface nsITabParent : nsISupports
    * True if any of the frames loaded in the TabChild have registered
    * an onbeforeunload event handler.
    */
   readonly attribute boolean hasBeforeUnload;
 
   /**
    * Notify APZ to start autoscrolling.
    * (aAnchorX, aAnchorY) are the coordinates of the autoscroll anchor,
-   * in LayoutDevice coordinates relative to the screen. aScrollId and 
+   * in CSS coordinates relative to the screen. aScrollId and 
    * aPresShellId identify the scroll frame that content chose to scroll.
    */
   void startApzAutoscroll(in float aAnchorX, in float aAnchorY,
                           in nsViewID aScrollId, in uint32_t aPresShellId);
 
   /**
    * Notify APZ to stop autoscrolling.
    * aScrollId and aPresShellId identify the scroll frame that is being
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -3274,17 +3274,18 @@ TabParent::StartApzAutoscroll(float aAnc
   if (RenderFrameParent* renderFrame = GetRenderFrame()) {
     uint64_t layersId = renderFrame->GetLayersId();
     if (nsCOMPtr<nsIWidget> widget = GetWidget()) {
       ScrollableLayerGuid guid{layersId, aPresShellId, aScrollId};
 
       // The anchor coordinates that are passed in are relative to the origin
       // of the screen, but we are sending them to APZ which only knows about
       // coordinates relative to the widget, so convert them accordingly.
-      LayoutDeviceIntPoint anchor = RoundedToInt(LayoutDevicePoint{aAnchorX, aAnchorY});
+      CSSPoint anchorCss{aAnchorX, aAnchorY};
+      LayoutDeviceIntPoint anchor = RoundedToInt(anchorCss * widget->GetDefaultScale());
       anchor -= widget->WidgetToScreenOffset();
 
       widget->StartAsyncAutoscroll(
           ViewAs<ScreenPixel>(anchor, PixelCastJustification::LayoutDeviceIsScreenForBounds),
           guid);
     }
   }
   return NS_OK;