Mac: Update drag&drop image creation.

git-svn-id: https://chromiumembedded.googlecode.com/svn/trunk@943 5089003a-bbd8-11dd-ad1f-f1f9622dbc98
This commit is contained in:
Marshall Greenblatt 2012-12-06 20:49:39 +00:00
parent 33fad449b6
commit 086f3cb47d
2 changed files with 10 additions and 13 deletions

View File

@ -22,6 +22,9 @@
#include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebPoint.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebPopupMenu.h"
#include "third_party/WebKit/Source/WebKit/chromium/public/WebView.h"
#include "ui/base/layout.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/image/image_skia_util_mac.h"
#include "webkit/glue/webcursor.h"
#include "webkit/glue/webdropdata.h"
#include "webkit/plugins/npapi/plugin_list.h"
@ -396,9 +399,11 @@ void BrowserWebViewDelegate::startDragging(
NSImage* ns_image = nil;
if (!image.isNull()) {
const SkBitmap& bitmap = image.getSkBitmap();
CGColorSpaceRef color_space = base::mac::GetSystemColorSpace();
ns_image = gfx::SkBitmapToNSImageWithColorSpace(bitmap, color_space);
ui::ScaleFactor scale_factor =
ui::GetScaleFactorForNativeView(host->view_handle());
gfx::ImageSkia image_skia(
gfx::ImageSkiaRep(image.getSkBitmap(), scale_factor));
ns_image = gfx::NSImageFromImageSkia(image_skia);
}
NSPoint offset = NSPointFromCGPoint(gfx::Point(image_offset).ToCGPoint());

View File

@ -88,7 +88,6 @@ void PromiseWriterHelper(const WebDropData& drop_data,
@interface WebDragSource(Private)
- (void)fillPasteboard;
- (NSImage*)dragImage;
@end // @interface WebDragSource(Private)
@ -238,9 +237,10 @@ void PromiseWriterHelper(const WebDropData& drop_data,
// Deal with Cocoa's flipped coordinate system.
position.y -= [dragImage_.get() size].height - imageOffset_.y;
}
// Per kwebster, offset arg is ignored, see -_web_DragImageForElement: in
// third_party/WebKit/Source/WebKit/mac/Misc/WebNSViewExtras.m.
[window dragImage:[self dragImage]
[window dragImage:dragImage_
at:position
offset:NSZeroSize
event:dragEvent
@ -423,12 +423,4 @@ void PromiseWriterHelper(const WebDropData& drop_data,
owner:view_];
}
- (NSImage*)dragImage {
if (dragImage_)
return dragImage_;
// Default to returning a generic image.
return gfx::GetCachedImageWithName(@"nav.pdf");
}
@end // @implementation WebDragSource (Private)