Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1512)

Unified Diff: ui/base/clipboard/clipboard_mac.mm

Issue 2599643002: Fix reading PDF images from NSPasteboard. (Closed)
Patch Set: Cleanup. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/base/clipboard/clipboard_mac.h ('k') | ui/base/clipboard/clipboard_mac_unittest.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 {
« no previous file with comments | « ui/base/clipboard/clipboard_mac.h ('k') | ui/base/clipboard/clipboard_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698