diff --git a/testing/mochitest/tests/SimpleTest/EventUtils.js b/testing/mochitest/tests/SimpleTest/EventUtils.js index de8405d15f9f..24b981dcbf4c 100644 --- a/testing/mochitest/tests/SimpleTest/EventUtils.js +++ b/testing/mochitest/tests/SimpleTest/EventUtils.js @@ -3921,6 +3921,14 @@ async function synthesizePlainDragAndDrop(aParams) { dragEvent ); srcSession.setDragEndPointForTests(event.screenX, event.screenY); + if (logFunc) { + logFunc( + `dragend event client (X,Y) = (${event.clientX}, ${event.clientY})` + ); + logFunc( + `dragend event screen (X,Y) = (${event.screenX}, ${event.screenY})` + ); + } } finally { await new Promise(r => setTimeout(r, 0)); diff --git a/widget/nsBaseDragService.cpp b/widget/nsBaseDragService.cpp index b9566a94dc2a..5dc79af985dc 100644 --- a/widget/nsBaseDragService.cpp +++ b/widget/nsBaseDragService.cpp @@ -285,8 +285,8 @@ uint32_t nsBaseDragSession::GetEffectAllowedForTests() { return mEffectAllowedForTests; } -NS_IMETHODIMP nsBaseDragSession::SetDragEndPointForTests(int32_t aScreenX, - int32_t aScreenY) { +NS_IMETHODIMP nsBaseDragSession::SetDragEndPointForTests(float aScreenX, + float aScreenY) { MOZ_ASSERT(mDoingDrag); MOZ_ASSERT(mSourceDocument); MOZ_ASSERT(mSessionIsSynthesizedForTests); @@ -298,7 +298,7 @@ NS_IMETHODIMP nsBaseDragSession::SetDragEndPointForTests(int32_t aScreenX, if (NS_WARN_IF(!pc)) { return NS_ERROR_FAILURE; } - auto p = LayoutDeviceIntPoint::Round(CSSIntPoint(aScreenX, aScreenY) * + auto p = LayoutDeviceIntPoint::Round(CSSPoint(aScreenX, aScreenY) * pc->CSSToDevPixelScale()); // p is screen-relative, and we want them to be top-level-widget-relative. if (nsCOMPtr widget = pc->GetRootWidget()) { @@ -1230,6 +1230,14 @@ nsBaseDragService::SetNeverAllowSessionIsSynthesizedForTests(bool aNeverAllow) { return NS_OK; } +void nsBaseDragSession::SetDragEndPoint( + mozilla::LayoutDeviceIntPoint aEndDragPoint) { + mEndDragPoint = aEndDragPoint; + MOZ_DRAGSERVICE_LOG("SetDragEndPoint (x,y)=(%d,%d)", + static_cast(mEndDragPoint.x), + static_cast(mEndDragPoint.y)); +} + NS_IMETHODIMP nsBaseDragSession::SetDragEndPoint(int32_t aScreenX, int32_t aScreenY) { SetDragEndPoint(LayoutDeviceIntPoint(aScreenX, aScreenY)); diff --git a/widget/nsBaseDragService.h b/widget/nsBaseDragService.h index a735c64430f8..db4b9917bbfe 100644 --- a/widget/nsBaseDragService.h +++ b/widget/nsBaseDragService.h @@ -64,12 +64,10 @@ class nsBaseDragSession : public nsIDragSession { int32_t TakeChildProcessDragAction(); void SetDragEndPoint(nsIntPoint aEndDragPoint) { - mEndDragPoint = - mozilla::LayoutDeviceIntPoint::FromUnknownPoint(aEndDragPoint); - } - void SetDragEndPoint(mozilla::LayoutDeviceIntPoint aEndDragPoint) { - mEndDragPoint = aEndDragPoint; + SetDragEndPoint( + mozilla::LayoutDeviceIntPoint::FromUnknownPoint(aEndDragPoint)); } + void SetDragEndPoint(mozilla::LayoutDeviceIntPoint aEndDragPoint); uint16_t GetInputSource() { return mInputSource; } diff --git a/widget/nsIDragSession.idl b/widget/nsIDragSession.idl index d02c6e180b9b..e8a82ef4df37 100644 --- a/widget/nsIDragSession.idl +++ b/widget/nsIDragSession.idl @@ -170,9 +170,9 @@ interface nsIDragSession : nsISupports /** * Sets drag end point of synthesized session when the test does not dispatch - * "drop" event. + * "drop" event. Position is relative to screen in CSS coordinates. */ - void setDragEndPointForTests(in long aScreenX, in long aScreenY); + void setDragEndPointForTests(in float aScreenX, in float aScreenY); /** * Returns true if the session is for dragging text in a text in text control