| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "views/widget/root_view.h" | 5 #include "views/widget/root_view.h" |
| 6 | 6 |
| 7 #include "app/drag_drop_types.h" | 7 #include "app/drag_drop_types.h" |
| 8 #include "app/os_exchange_data.h" | 8 #include "app/os_exchange_data.h" |
| 9 #include "app/os_exchange_data_provider_win.h" | 9 #include "app/os_exchange_data_provider_win.h" |
| 10 #include "base/base_drag_source.h" | 10 #include "base/base_drag_source.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "gfx/canvas_2.h" | |
| 13 #include "gfx/canvas_skia.h" | 12 #include "gfx/canvas_skia.h" |
| 14 | 13 |
| 15 namespace views { | 14 namespace views { |
| 16 | 15 |
| 17 void RootView::OnPaint(HWND hwnd) { | 16 void RootView::OnPaint(HWND hwnd) { |
| 18 gfx::Rect original_dirty_region = GetScheduledPaintRectConstrainedToSize(); | 17 gfx::Rect original_dirty_region = GetScheduledPaintRectConstrainedToSize(); |
| 19 if (!original_dirty_region.IsEmpty()) { | 18 if (!original_dirty_region.IsEmpty()) { |
| 20 // Invoke InvalidateRect so that the dirty region of the window includes the | 19 // Invoke InvalidateRect so that the dirty region of the window includes the |
| 21 // region we need to paint. If we didn't do this and the region didn't | 20 // region we need to paint. If we didn't do this and the region didn't |
| 22 // include the dirty region, ProcessPaint would incorrectly mark everything | 21 // include the dirty region, ProcessPaint would incorrectly mark everything |
| 23 // as clean. This can happen if a WM_PAINT is generated by the system before | 22 // as clean. This can happen if a WM_PAINT is generated by the system before |
| 24 // the InvokeLater schedule by RootView is processed. | 23 // the InvokeLater schedule by RootView is processed. |
| 25 RECT win_version = original_dirty_region.ToRECT(); | 24 RECT win_version = original_dirty_region.ToRECT(); |
| 26 InvalidateRect(hwnd, &win_version, FALSE); | 25 InvalidateRect(hwnd, &win_version, FALSE); |
| 27 } | 26 } |
| 28 scoped_ptr<gfx::CanvasPaint2> canvas( | 27 scoped_ptr<gfx::CanvasPaint> canvas( |
| 29 gfx::CanvasPaint2::CreateCanvasPaint(hwnd)); | 28 gfx::CanvasPaint::CreateCanvasPaint(hwnd)); |
| 30 if (!canvas->IsValid()) { | 29 if (!canvas->IsValid()) { |
| 31 SchedulePaint(canvas->GetInvalidRect(), false); | 30 SchedulePaint(canvas->GetInvalidRect(), false); |
| 32 if (NeedsPainting(false)) | 31 if (NeedsPainting(false)) |
| 33 ProcessPaint(canvas->AsCanvas2()->AsCanvas()); | 32 ProcessPaint(canvas->AsCanvas()); |
| 34 } | 33 } |
| 35 } | 34 } |
| 36 | 35 |
| 37 void RootView::StartDragForViewFromMouseEvent( | 36 void RootView::StartDragForViewFromMouseEvent( |
| 38 View* view, | 37 View* view, |
| 39 const OSExchangeData& data, | 38 const OSExchangeData& data, |
| 40 int operation) { | 39 int operation) { |
| 41 // NOTE: view may be null. | 40 // NOTE: view may be null. |
| 42 drag_view_ = view; | 41 drag_view_ = view; |
| 43 scoped_refptr<BaseDragSource> drag_source(new BaseDragSource); | 42 scoped_refptr<BaseDragSource> drag_source(new BaseDragSource); |
| 44 DWORD effects; | 43 DWORD effects; |
| 45 DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source, | 44 DoDragDrop(OSExchangeDataProviderWin::GetIDataObject(data), drag_source, |
| 46 DragDropTypes::DragOperationToDropEffect(operation), &effects); | 45 DragDropTypes::DragOperationToDropEffect(operation), &effects); |
| 47 // If the view is removed during the drag operation, drag_view_ is set to | 46 // If the view is removed during the drag operation, drag_view_ is set to |
| 48 // NULL. | 47 // NULL. |
| 49 if (view && drag_view_ == view) { | 48 if (view && drag_view_ == view) { |
| 50 View* drag_view = drag_view_; | 49 View* drag_view = drag_view_; |
| 51 drag_view_ = NULL; | 50 drag_view_ = NULL; |
| 52 drag_view->OnDragDone(); | 51 drag_view->OnDragDone(); |
| 53 } | 52 } |
| 54 } | 53 } |
| 55 | 54 |
| 56 } | 55 } |
| OLD | NEW |