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:
committed by
jmaher@mozilla.com
parent
c30fd88fe5
commit
060bf8db67
@@ -3921,6 +3921,14 @@ async function synthesizePlainDragAndDrop(aParams) {
|
|||||||
dragEvent
|
dragEvent
|
||||||
);
|
);
|
||||||
srcSession.setDragEndPointForTests(event.screenX, event.screenY);
|
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 {
|
} finally {
|
||||||
await new Promise(r => setTimeout(r, 0));
|
await new Promise(r => setTimeout(r, 0));
|
||||||
|
|
||||||
|
|||||||
@@ -285,8 +285,8 @@ uint32_t nsBaseDragSession::GetEffectAllowedForTests() {
|
|||||||
return mEffectAllowedForTests;
|
return mEffectAllowedForTests;
|
||||||
}
|
}
|
||||||
|
|
||||||
NS_IMETHODIMP nsBaseDragSession::SetDragEndPointForTests(int32_t aScreenX,
|
NS_IMETHODIMP nsBaseDragSession::SetDragEndPointForTests(float aScreenX,
|
||||||
int32_t aScreenY) {
|
float aScreenY) {
|
||||||
MOZ_ASSERT(mDoingDrag);
|
MOZ_ASSERT(mDoingDrag);
|
||||||
MOZ_ASSERT(mSourceDocument);
|
MOZ_ASSERT(mSourceDocument);
|
||||||
MOZ_ASSERT(mSessionIsSynthesizedForTests);
|
MOZ_ASSERT(mSessionIsSynthesizedForTests);
|
||||||
@@ -298,7 +298,7 @@ NS_IMETHODIMP nsBaseDragSession::SetDragEndPointForTests(int32_t aScreenX,
|
|||||||
if (NS_WARN_IF(!pc)) {
|
if (NS_WARN_IF(!pc)) {
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
auto p = LayoutDeviceIntPoint::Round(CSSIntPoint(aScreenX, aScreenY) *
|
auto p = LayoutDeviceIntPoint::Round(CSSPoint(aScreenX, aScreenY) *
|
||||||
pc->CSSToDevPixelScale());
|
pc->CSSToDevPixelScale());
|
||||||
// p is screen-relative, and we want them to be top-level-widget-relative.
|
// p is screen-relative, and we want them to be top-level-widget-relative.
|
||||||
if (nsCOMPtr<nsIWidget> widget = pc->GetRootWidget()) {
|
if (nsCOMPtr<nsIWidget> widget = pc->GetRootWidget()) {
|
||||||
@@ -1230,6 +1230,14 @@ nsBaseDragService::SetNeverAllowSessionIsSynthesizedForTests(bool aNeverAllow) {
|
|||||||
return NS_OK;
|
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
|
NS_IMETHODIMP
|
||||||
nsBaseDragSession::SetDragEndPoint(int32_t aScreenX, int32_t aScreenY) {
|
nsBaseDragSession::SetDragEndPoint(int32_t aScreenX, int32_t aScreenY) {
|
||||||
SetDragEndPoint(LayoutDeviceIntPoint(aScreenX, aScreenY));
|
SetDragEndPoint(LayoutDeviceIntPoint(aScreenX, aScreenY));
|
||||||
|
|||||||
@@ -64,12 +64,10 @@ class nsBaseDragSession : public nsIDragSession {
|
|||||||
int32_t TakeChildProcessDragAction();
|
int32_t TakeChildProcessDragAction();
|
||||||
|
|
||||||
void SetDragEndPoint(nsIntPoint aEndDragPoint) {
|
void SetDragEndPoint(nsIntPoint aEndDragPoint) {
|
||||||
mEndDragPoint =
|
SetDragEndPoint(
|
||||||
mozilla::LayoutDeviceIntPoint::FromUnknownPoint(aEndDragPoint);
|
mozilla::LayoutDeviceIntPoint::FromUnknownPoint(aEndDragPoint));
|
||||||
}
|
|
||||||
void SetDragEndPoint(mozilla::LayoutDeviceIntPoint aEndDragPoint) {
|
|
||||||
mEndDragPoint = aEndDragPoint;
|
|
||||||
}
|
}
|
||||||
|
void SetDragEndPoint(mozilla::LayoutDeviceIntPoint aEndDragPoint);
|
||||||
|
|
||||||
uint16_t GetInputSource() { return mInputSource; }
|
uint16_t GetInputSource() { return mInputSource; }
|
||||||
|
|
||||||
|
|||||||
@@ -170,9 +170,9 @@ interface nsIDragSession : nsISupports
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets drag end point of synthesized session when the test does not dispatch
|
* 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
|
* Returns true if the session is for dragging text in a text in text control
|
||||||
|
|||||||
Reference in New Issue
Block a user