OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/base/dragdrop/drag_utils.h" | 5 #include "ui/base/dragdrop/drag_utils.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "ui/base/dragdrop/os_exchange_data.h" | 10 #include "ui/base/dragdrop/os_exchange_data.h" |
11 #include "ui/gfx/canvas.h" | 11 #include "ui/gfx/canvas.h" |
12 #include "ui/gfx/font_list.h" | 12 #include "ui/gfx/font_list.h" |
13 #include "ui/gfx/geometry/point.h" | 13 #include "ui/gfx/geometry/point.h" |
14 #include "ui/gfx/geometry/rect.h" | 14 #include "ui/gfx/geometry/rect.h" |
15 #include "ui/gfx/geometry/size.h" | 15 #include "ui/gfx/geometry/size.h" |
16 #include "ui/gfx/geometry/size_conversions.h" | |
16 #include "ui/gfx/image/canvas_image_source.h" | 17 #include "ui/gfx/image/canvas_image_source.h" |
17 #include "url/gurl.h" | 18 #include "url/gurl.h" |
18 | 19 |
19 namespace drag_utils { | 20 namespace drag_utils { |
20 | 21 |
21 namespace { | 22 namespace { |
22 | 23 |
23 // Maximum width of the link drag image in pixels. | 24 // Maximum width of the link drag image in pixels. |
24 static const int kLinkDragImageVPadding = 3; | 25 static const int kLinkDragImageVPadding = 3; |
25 | 26 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
89 gfx::CanvasImageSource* source = new FileDragImageSource(file_name, icon); | 90 gfx::CanvasImageSource* source = new FileDragImageSource(file_name, icon); |
90 gfx::Size size = source->size(); | 91 gfx::Size size = source->size(); |
91 // ImageSkia takes ownership of |source|. | 92 // ImageSkia takes ownership of |source|. |
92 gfx::ImageSkia image = gfx::ImageSkia(source, size); | 93 gfx::ImageSkia image = gfx::ImageSkia(source, size); |
93 | 94 |
94 gfx::Vector2d cursor_offset(size.width() / 2, kLinkDragImageVPadding); | 95 gfx::Vector2d cursor_offset(size.width() / 2, kLinkDragImageVPadding); |
95 SetDragImageOnDataObject(image, size, cursor_offset, data_object); | 96 SetDragImageOnDataObject(image, size, cursor_offset, data_object); |
96 } | 97 } |
97 | 98 |
98 void SetDragImageOnDataObject(const gfx::Canvas& canvas, | 99 void SetDragImageOnDataObject(const gfx::Canvas& canvas, |
99 const gfx::Size& size, | 100 const gfx::Size& size_in_dips, |
100 const gfx::Vector2d& cursor_offset, | 101 const gfx::Vector2d& cursor_offset, |
101 ui::OSExchangeData* data_object) { | 102 ui::OSExchangeData* data_object) { |
102 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep()); | 103 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep()); |
103 SetDragImageOnDataObject(image, size, cursor_offset, data_object); | 104 SetDragImageOnDataObject( |
105 image, | |
106 gfx::ToCeiledSize(gfx::ScaleSize(size_in_dips, canvas.image_scale())), | |
sky
2014/06/11 15:57:17
With few exceptions every where should take dips.
ananta
2014/06/11 18:54:03
As per our discussion removed the size parameter f
| |
107 cursor_offset, data_object); | |
104 } | 108 } |
105 | 109 |
106 } // namespace drag_utils | 110 } // namespace drag_utils |
OLD | NEW |