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

Unified Diff: ash/drag_drop/drag_image_view.cc

Issue 1514743002: cc: turn on strict paint property checking (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix DragImageView to not resize during paint Created 5 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 | « ash/drag_drop/drag_image_view.h ('k') | blimp/client/compositor/blimp_layer_tree_settings.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
}
}
« no previous file with comments | « ash/drag_drop/drag_image_view.h ('k') | blimp/client/compositor/blimp_layer_tree_settings.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698