Index: ash/drag_drop/drag_image_view.cc |
diff --git a/ash/drag_drop/drag_image_view.cc b/ash/drag_drop/drag_image_view.cc |
index e180d9395163f47e9a5310e3347f0711aa1b5c55..dce9c96ff2934beb975e1652960807fb818778f0 100644 |
--- a/ash/drag_drop/drag_image_view.cc |
+++ b/ash/drag_drop/drag_image_view.cc |
@@ -132,6 +132,23 @@ void DragImageView::OnPaint(gfx::Canvas* canvas) { |
if (drag_event_source_ != ui::DragDropTypes::DRAG_EVENT_SOURCE_TOUCH) |
return; |
+ gfx::Image* drag_hint = DragHint(); |
+ if (!drag_hint) |
mfomitchev
2015/12/11 15:37:01
Shouldn't this be drag_hint->IsEmpty()?
|
+ return; |
+ |
+ // Make sure drag hint image is positioned within the widget. |
+ gfx::Size drag_hint_size = drag_hint->Size(); |
+ gfx::Point drag_hint_position = touch_drag_operation_indicator_position_; |
+ drag_hint_position.Offset(-drag_hint_size.width() / 2, 0); |
+ gfx::Rect drag_hint_bounds(drag_hint_position, drag_hint_size); |
+ drag_hint_bounds.AdjustToFit(gfx::Rect(widget_size_)); |
+ |
+ // Draw image. |
+ canvas->DrawImageInt(*(drag_hint->ToImageSkia()), drag_hint_bounds.x(), |
+ drag_hint_bounds.y()); |
+} |
+ |
+gfx::Image* DragImageView::DragHint() const { |
// Select appropriate drag hint. |
gfx::Image* drag_hint = |
&ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
@@ -146,26 +163,24 @@ void DragImageView::OnPaint(gfx::Canvas* canvas) { |
drag_hint = &ui::ResourceBundle::GetSharedInstance().GetImageNamed( |
IDR_TOUCH_DRAG_TIP_LINK); |
} |
- if (!drag_hint->IsEmpty()) { |
- gfx::Size drag_hint_size = drag_hint->Size(); |
- |
- // Enlarge widget if required to fit the drag hint image. |
- if (drag_hint_size.width() > widget_size_.width() || |
- drag_hint_size.height() > widget_size_.height()) { |
- gfx::Size new_widget_size = widget_size_; |
- new_widget_size.SetToMax(drag_hint_size); |
- widget_->SetSize(new_widget_size); |
- } |
+ return drag_hint; |
+} |
+ |
+void DragImageView::Layout() { |
+ View::Layout(); |
+ |
+ gfx::Image* drag_hint = DragHint(); |
+ if (!drag_hint) |
+ return; |
- // Make sure drag hint image is positioned within the widget. |
- gfx::Point drag_hint_position = touch_drag_operation_indicator_position_; |
- drag_hint_position.Offset(-drag_hint_size.width() / 2, 0); |
- gfx::Rect drag_hint_bounds(drag_hint_position, drag_hint_size); |
- drag_hint_bounds.AdjustToFit(gfx::Rect(widget_size_)); |
+ gfx::Size drag_hint_size = drag_hint->Size(); |
- // Draw image. |
- canvas->DrawImageInt(*(drag_hint->ToImageSkia()), |
- drag_hint_bounds.x(), drag_hint_bounds.y()); |
+ // Enlarge widget if required to fit the drag hint image. |
+ if (drag_hint_size.width() > widget_size_.width() || |
+ drag_hint_size.height() > widget_size_.height()) { |
+ gfx::Size new_widget_size = widget_size_; |
+ new_widget_size.SetToMax(drag_hint_size); |
+ widget_->SetSize(new_widget_size); |
} |
} |