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

Side by Side Diff: ui/base/dragdrop/drag_utils.cc

Issue 11269022: Add Vector2d classes that represent offsets, instead of using Point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebasefinal Created 8 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "googleurl/src/gurl.h" 10 #include "googleurl/src/gurl.h"
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 void CreateDragImageForFile(const FilePath& file_name, 86 void CreateDragImageForFile(const FilePath& file_name,
87 const gfx::ImageSkia* icon, 87 const gfx::ImageSkia* icon,
88 ui::OSExchangeData* data_object) { 88 ui::OSExchangeData* data_object) {
89 DCHECK(icon); 89 DCHECK(icon);
90 DCHECK(data_object); 90 DCHECK(data_object);
91 gfx::CanvasImageSource* source = new FileDragImageSource(file_name, *icon); 91 gfx::CanvasImageSource* source = new FileDragImageSource(file_name, *icon);
92 gfx::Size size = source->size(); 92 gfx::Size size = source->size();
93 // ImageSkia takes ownership of |source|. 93 // ImageSkia takes ownership of |source|.
94 gfx::ImageSkia image = gfx::ImageSkia(source, size); 94 gfx::ImageSkia image = gfx::ImageSkia(source, size);
95 95
96 SetDragImageOnDataObject(image, size, 96 gfx::Vector2d cursor_offset(size.width() / 2, kLinkDragImageVPadding);
danakj 2012/10/29 19:17:20 Left this, inlining it makes it into a 4-line func
97 gfx::Point(size.width() / 2, kLinkDragImageVPadding), 97 SetDragImageOnDataObject(image, size, cursor_offset, data_object);
98 data_object);
99 } 98 }
100 99
101 void SetDragImageOnDataObject(const gfx::Canvas& canvas, 100 void SetDragImageOnDataObject(const gfx::Canvas& canvas,
102 const gfx::Size& size, 101 const gfx::Size& size,
103 const gfx::Point& cursor_offset, 102 const gfx::Vector2d& cursor_offset,
104 ui::OSExchangeData* data_object) { 103 ui::OSExchangeData* data_object) {
105 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep()); 104 gfx::ImageSkia image = gfx::ImageSkia(canvas.ExtractImageRep());
106 SetDragImageOnDataObject(image, size, cursor_offset, data_object); 105 SetDragImageOnDataObject(image, size, cursor_offset, data_object);
107 } 106 }
108 107
109 } // namespace drag_utils 108 } // namespace drag_utils
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698