Index: ui/base/clipboard/clipboard_mac.mm |
diff --git a/ui/base/clipboard/clipboard_mac.mm b/ui/base/clipboard/clipboard_mac.mm |
index fcc4a3a662f02b6d5318a069904751a680a81aa3..b0539a9eb6053edbf7bd108accab53a145f0b4a3 100644 |
--- a/ui/base/clipboard/clipboard_mac.mm |
+++ b/ui/base/clipboard/clipboard_mac.mm |
@@ -324,17 +324,23 @@ SkBitmap ClipboardMac::ReadImage(ClipboardType type, NSPasteboard* pb) const { |
} @catch (id exception) { |
} |
- if (image.get()) { |
- if ([[image representations] count] == 1u) { |
- NSImageRep* rep = [[image representations] objectAtIndex:0]; |
+ if (!image) |
+ return SkBitmap(); |
+ if ([[image representations] count] == 0u) |
+ return SkBitmap(); |
+ |
+ if ([[image representations] count] == 1u) { |
+ NSImageRep* rep = [[image representations] objectAtIndex:0]; |
+ NSInteger width = [rep pixelsWide]; |
+ NSInteger height = [rep pixelsHigh]; |
+ if (width != 0 && height != 0) { |
return skia::NSImageRepToSkBitmapWithColorSpace( |
- rep, NSMakeSize([rep pixelsWide], [rep pixelsHigh]), |
- /*is_opaque=*/false, base::mac::GetSystemColorSpace()); |
+ rep, NSMakeSize(width, height), /*is_opaque=*/false, |
+ base::mac::GetSystemColorSpace()); |
} |
- return skia::NSImageToSkBitmapWithColorSpace( |
- image.get(), /*is_opaque=*/false, base::mac::GetSystemColorSpace()); |
} |
- return SkBitmap(); |
+ return skia::NSImageToSkBitmapWithColorSpace( |
+ image.get(), /*is_opaque=*/false, base::mac::GetSystemColorSpace()); |
Avi (use Gerrit)
2016/12/22 03:22:03
Wait... why don't we always go this path? Why do w
erikchen
2016/12/22 04:51:49
this loses pixels from retina images:
https://code
Avi (use Gerrit)
2016/12/22 05:42:25
Can you mention this in a comment?
erikchen
2016/12/22 18:19:21
Done.
|
} |
SkBitmap ClipboardMac::ReadImage(ClipboardType type) const { |