Bug 1562048 - Draw the fallback drag image using a different API. r=spohl

This also fixes a leak - the return value is expected to be autoreleased.

Differential Revision: https://phabricator.services.mozilla.com/D36252

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Markus Stange 2019-06-28 13:44:15 +00:00
Родитель b6e7a0b743
Коммит 5f8ce768ac
1 изменённых файлов: 9 добавлений и 12 удалений

Просмотреть файл

@ -72,18 +72,15 @@ NSImage* nsDragService::ConstructDragImage(nsINode* aDOMNode, const Maybe<CSSInt
NSSize size;
size.width = nsCocoaUtils::DevPixelsToCocoaPoints(dragRect.width, scaleFactor);
size.height = nsCocoaUtils::DevPixelsToCocoaPoints(dragRect.height, scaleFactor);
image = [[NSImage alloc] initWithSize:size];
[image lockFocus];
[[NSColor grayColor] set];
NSBezierPath* path = [NSBezierPath bezierPath];
[path setLineWidth:2.0];
[path moveToPoint:NSMakePoint(0, 0)];
[path lineToPoint:NSMakePoint(0, size.height)];
[path lineToPoint:NSMakePoint(size.width, size.height)];
[path lineToPoint:NSMakePoint(size.width, 0)];
[path lineToPoint:NSMakePoint(0, 0)];
[path stroke];
[image unlockFocus];
image = [NSImage imageWithSize:size
flipped:YES
drawingHandler:^BOOL(NSRect dstRect) {
[[NSColor grayColor] set];
NSBezierPath* path = [NSBezierPath bezierPathWithRect:dstRect];
[path setLineWidth:2.0];
[path stroke];
return YES;
}];
}
LayoutDeviceIntPoint pt(dragRect.x, dragRect.YMost());