Bug 1933228: Use float coordinates for test dragend position r=win-reviewers,gstoll

We need fractional coordinates here for device scale.

Differential Revision: https://phabricator.services.mozilla.com/D247190
This commit is contained in:
David Parks
2025-05-07 03:17:26 +00:00
committed by jmaher@mozilla.com
parent c30fd88fe5
commit 060bf8db67
4 changed files with 24 additions and 10 deletions

View File

@@ -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));

View File

@@ -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<nsIWidget> 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<int>(mEndDragPoint.x),
static_cast<int>(mEndDragPoint.y));
}
NS_IMETHODIMP
nsBaseDragSession::SetDragEndPoint(int32_t aScreenX, int32_t aScreenY) {
SetDragEndPoint(LayoutDeviceIntPoint(aScreenX, aScreenY));

View File

@@ -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; }

View File

@@ -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