| 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 "chrome/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "chrome/browser/renderer_host/render_widget_host_view_win.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/gfx/gdi_util.h" | 8 #include "base/gfx/gdi_util.h" |
| 9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
| 10 #include "base/histogram.h" | 10 #include "base/histogram.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 } | 127 } |
| 128 | 128 |
| 129 /////////////////////////////////////////////////////////////////////////////// | 129 /////////////////////////////////////////////////////////////////////////////// |
| 130 // RenderWidgetHostViewWin, public: | 130 // RenderWidgetHostViewWin, public: |
| 131 | 131 |
| 132 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) | 132 RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) |
| 133 : render_widget_host_(widget), | 133 : render_widget_host_(widget), |
| 134 track_mouse_leave_(false), | 134 track_mouse_leave_(false), |
| 135 ime_notification_(false), | 135 ime_notification_(false), |
| 136 is_hidden_(false), | 136 is_hidden_(false), |
| 137 about_to_validate_and_paint_(false), |
| 137 close_on_deactivate_(false), | 138 close_on_deactivate_(false), |
| 138 tooltip_hwnd_(NULL), | 139 tooltip_hwnd_(NULL), |
| 139 tooltip_showing_(false), | 140 tooltip_showing_(false), |
| 140 shutdown_factory_(this), | 141 shutdown_factory_(this), |
| 141 parent_hwnd_(NULL), | 142 parent_hwnd_(NULL), |
| 142 is_loading_(false) { | 143 is_loading_(false) { |
| 143 render_widget_host_->set_view(this); | 144 render_widget_host_->set_view(this); |
| 144 renderer_accessible_ = | 145 renderer_accessible_ = |
| 145 CommandLine::ForCurrentProcess()->HasSwitch( | 146 CommandLine::ForCurrentProcess()->HasSwitch( |
| 146 switches::kEnableRendererAccessibility); | 147 switches::kEnableRendererAccessibility); |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 bitmap->height(), NULL); | 441 bitmap->height(), NULL); |
| 441 if (rtl_dir) | 442 if (rtl_dir) |
| 442 canvas.restore(); | 443 canvas.restore(); |
| 443 } | 444 } |
| 444 } | 445 } |
| 445 | 446 |
| 446 void RenderWidgetHostViewWin::DidPaintRect(const gfx::Rect& rect) { | 447 void RenderWidgetHostViewWin::DidPaintRect(const gfx::Rect& rect) { |
| 447 if (is_hidden_) | 448 if (is_hidden_) |
| 448 return; | 449 return; |
| 449 | 450 |
| 450 Redraw(rect); | 451 if (about_to_validate_and_paint_) |
| 452 InvalidateRect(&rect.ToRECT(), false); |
| 453 else |
| 454 Redraw(rect); |
| 451 } | 455 } |
| 452 | 456 |
| 453 void RenderWidgetHostViewWin::DidScrollRect( | 457 void RenderWidgetHostViewWin::DidScrollRect( |
| 454 const gfx::Rect& rect, int dx, int dy) { | 458 const gfx::Rect& rect, int dx, int dy) { |
| 455 if (is_hidden_) | 459 if (is_hidden_) |
| 456 return; | 460 return; |
| 457 | 461 |
| 458 // We need to pass in SW_INVALIDATE to ScrollWindowEx. The MSDN | 462 // We need to pass in SW_INVALIDATE to ScrollWindowEx. The MSDN |
| 459 // documentation states that it only applies to the HRGN argument, which is | 463 // documentation states that it only applies to the HRGN argument, which is |
| 460 // wrong. Not passing in this flag does not invalidate the region which was | 464 // wrong. Not passing in this flag does not invalidate the region which was |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 ResetTooltip(); | 549 ResetTooltip(); |
| 546 TrackMouseLeave(false); | 550 TrackMouseLeave(false); |
| 547 #ifdef ENABLE_TRACK_HWND_DESTRUCTION | 551 #ifdef ENABLE_TRACK_HWND_DESTRUCTION |
| 548 TRACK_HWND_DESTRUCTION(m_hWnd); | 552 TRACK_HWND_DESTRUCTION(m_hWnd); |
| 549 #endif // ENABLE_TRACK_HWND_DESTRUCTION | 553 #endif // ENABLE_TRACK_HWND_DESTRUCTION |
| 550 } | 554 } |
| 551 | 555 |
| 552 void RenderWidgetHostViewWin::OnPaint(HDC dc) { | 556 void RenderWidgetHostViewWin::OnPaint(HDC dc) { |
| 553 DCHECK(render_widget_host_->process()->channel()); | 557 DCHECK(render_widget_host_->process()->channel()); |
| 554 | 558 |
| 555 CPaintDC paint_dc(m_hWnd); | 559 about_to_validate_and_paint_ = true; |
| 556 HBRUSH white_brush = reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); | |
| 557 | |
| 558 BackingStore* backing_store = render_widget_host_->GetBackingStore(); | 560 BackingStore* backing_store = render_widget_host_->GetBackingStore(); |
| 559 | 561 |
| 562 // We initialize |paint_dc| (and thus call BeginPaint()) after calling |
| 563 // GetBackingStore(), so that if it updates the invalid rect we'll catch the |
| 564 // changes and repaint them. |
| 565 about_to_validate_and_paint_ = false; |
| 566 CPaintDC paint_dc(m_hWnd); |
| 567 |
| 568 HBRUSH white_brush = reinterpret_cast<HBRUSH>(GetStockObject(WHITE_BRUSH)); |
| 560 if (backing_store) { | 569 if (backing_store) { |
| 561 gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint); | 570 gfx::Rect damaged_rect(paint_dc.m_ps.rcPaint); |
| 562 | 571 |
| 563 gfx::Rect bitmap_rect( | 572 gfx::Rect bitmap_rect( |
| 564 0, 0, backing_store->size().width(), backing_store->size().height()); | 573 0, 0, backing_store->size().width(), backing_store->size().height()); |
| 565 | 574 |
| 566 gfx::Rect paint_rect = bitmap_rect.Intersect(damaged_rect); | 575 gfx::Rect paint_rect = bitmap_rect.Intersect(damaged_rect); |
| 567 if (!paint_rect.IsEmpty()) { | 576 if (!paint_rect.IsEmpty()) { |
| 568 DrawResizeCorner(paint_rect, backing_store->hdc()); | 577 DrawResizeCorner(paint_rect, backing_store->hdc()); |
| 569 BitBlt(paint_dc.m_hDC, | 578 BitBlt(paint_dc.m_hDC, |
| (...skipping 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 // WM_LBUTTONDOWN. | 1154 // WM_LBUTTONDOWN. |
| 1146 SetFocus(); | 1155 SetFocus(); |
| 1147 } | 1156 } |
| 1148 } | 1157 } |
| 1149 | 1158 |
| 1150 void RenderWidgetHostViewWin::ShutdownHost() { | 1159 void RenderWidgetHostViewWin::ShutdownHost() { |
| 1151 shutdown_factory_.RevokeAll(); | 1160 shutdown_factory_.RevokeAll(); |
| 1152 render_widget_host_->Shutdown(); | 1161 render_widget_host_->Shutdown(); |
| 1153 // Do not touch any members at this point, |this| has been deleted. | 1162 // Do not touch any members at this point, |this| has been deleted. |
| 1154 } | 1163 } |
| OLD | NEW |