Bug 1301673, use the correct coordinates when drag feedback is disabled or fails; this allows the drag feedback on Mac to appear as a grey rectangle, r=tn
This commit is contained in:
@@ -307,13 +307,15 @@ nsDragService::InvokeDragSessionImpl(nsIArray* aTransferableArray,
|
|||||||
if (NS_FAILED(SetUpDragClipboard(aTransferableArray)))
|
if (NS_FAILED(SetUpDragClipboard(aTransferableArray)))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
|
|
||||||
|
CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(gLastDragView);
|
||||||
|
|
||||||
LayoutDeviceIntRect dragRect(0, 0, 20, 20);
|
LayoutDeviceIntRect dragRect(0, 0, 20, 20);
|
||||||
NSImage* image = ConstructDragImage(mSourceNode, &dragRect, aDragRgn);
|
NSImage* image = ConstructDragImage(mSourceNode, &dragRect, aDragRgn);
|
||||||
if (!image) {
|
if (!image) {
|
||||||
// if no image was returned, just draw a rectangle
|
// if no image was returned, just draw a rectangle
|
||||||
NSSize size;
|
NSSize size;
|
||||||
size.width = dragRect.width;
|
size.width = nsCocoaUtils::DevPixelsToCocoaPoints(dragRect.width, scaleFactor);
|
||||||
size.height = dragRect.height;
|
size.height = nsCocoaUtils::DevPixelsToCocoaPoints(dragRect.height, scaleFactor);
|
||||||
image = [[NSImage alloc] initWithSize:size];
|
image = [[NSImage alloc] initWithSize:size];
|
||||||
[image lockFocus];
|
[image lockFocus];
|
||||||
[[NSColor grayColor] set];
|
[[NSColor grayColor] set];
|
||||||
@@ -329,7 +331,6 @@ nsDragService::InvokeDragSessionImpl(nsIArray* aTransferableArray,
|
|||||||
}
|
}
|
||||||
|
|
||||||
LayoutDeviceIntPoint pt(dragRect.x, dragRect.YMost());
|
LayoutDeviceIntPoint pt(dragRect.x, dragRect.YMost());
|
||||||
CGFloat scaleFactor = nsCocoaUtils::GetBackingScaleFactor(gLastDragView);
|
|
||||||
NSPoint point = nsCocoaUtils::DevPixelsToCocoaPoints(pt, scaleFactor);
|
NSPoint point = nsCocoaUtils::DevPixelsToCocoaPoints(pt, scaleFactor);
|
||||||
point.y = nsCocoaUtils::FlippedScreenY(point.y);
|
point.y = nsCocoaUtils::FlippedScreenY(point.y);
|
||||||
|
|
||||||
|
|||||||
@@ -566,19 +566,14 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
|
|||||||
if (!enableDragImages || !mHasImage) {
|
if (!enableDragImages || !mHasImage) {
|
||||||
// if a region was specified, set the screen rectangle to the area that
|
// if a region was specified, set the screen rectangle to the area that
|
||||||
// the region occupies
|
// the region occupies
|
||||||
|
nsIntRect dragRect;
|
||||||
if (aRegion) {
|
if (aRegion) {
|
||||||
// the region's coordinates are relative to the root frame
|
// the region's coordinates are relative to the root frame
|
||||||
nsIFrame* rootFrame = presShell->GetRootFrame();
|
aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height);
|
||||||
if (rootFrame) {
|
|
||||||
nsIntRect dragRect;
|
|
||||||
aRegion->GetBoundingBox(&dragRect.x, &dragRect.y, &dragRect.width, &dragRect.height);
|
|
||||||
dragRect = ToAppUnits(dragRect, nsPresContext::AppUnitsPerCSSPixel()).
|
|
||||||
ToOutsidePixels((*aPresContext)->AppUnitsPerDevPixel());
|
|
||||||
|
|
||||||
nsIntRect screenRect = rootFrame->GetScreenRect();
|
nsIFrame* rootFrame = presShell->GetRootFrame();
|
||||||
aScreenDragRect->SetRect(screenRect.x + dragRect.x, screenRect.y + dragRect.y,
|
nsIntRect screenRect = rootFrame->GetScreenRect();
|
||||||
dragRect.width, dragRect.height);
|
dragRect.MoveBy(screenRect.TopLeft());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// otherwise, there was no region so just set the rectangle to
|
// otherwise, there was no region so just set the rectangle to
|
||||||
@@ -586,12 +581,13 @@ nsBaseDragService::DrawDrag(nsIDOMNode* aDOMNode,
|
|||||||
nsCOMPtr<nsIContent> content = do_QueryInterface(dragNode);
|
nsCOMPtr<nsIContent> content = do_QueryInterface(dragNode);
|
||||||
nsIFrame* frame = content->GetPrimaryFrame();
|
nsIFrame* frame = content->GetPrimaryFrame();
|
||||||
if (frame) {
|
if (frame) {
|
||||||
nsIntRect screenRect = frame->GetScreenRect();
|
dragRect = frame->GetScreenRect();
|
||||||
aScreenDragRect->SetRect(screenRect.x, screenRect.y,
|
|
||||||
screenRect.width, screenRect.height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dragRect = ToAppUnits(dragRect, nsPresContext::AppUnitsPerCSSPixel()).
|
||||||
|
ToOutsidePixels((*aPresContext)->AppUnitsPerDevPixel());
|
||||||
|
aScreenDragRect->SizeTo(dragRect.width, dragRect.height);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user