Bug 1386777 - Interpret autoscroll anchor coordinates correctly when there is a device scale. r=kats
MozReview-Commit-ID: 6caXxWjuqxm
--- 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;