Chromium Code Reviews| Index: chrome/browser/renderer_host/render_widget_host_view_win.cc |
| diff --git a/chrome/browser/renderer_host/render_widget_host_view_win.cc b/chrome/browser/renderer_host/render_widget_host_view_win.cc |
| index 407bc1d3c418727a58f42e1a1e2d9563efeefa03..f912d1a142688e92977408dc92dc4f6e4447fb3c 100644 |
| --- a/chrome/browser/renderer_host/render_widget_host_view_win.cc |
| +++ b/chrome/browser/renderer_host/render_widget_host_view_win.cc |
| @@ -70,6 +70,8 @@ const wchar_t kRenderWidgetHostHWNDClass[] = L"Chrome_RenderWidgetHostHWND"; |
| namespace { |
| +const TCHAR* kRenderWidgetHVWPropStr = _T("RWHVW_P"); |
| + |
| // Tooltips will wrap after this width. Yes, wrap. Imagine that! |
| const int kTooltipMaxWidthPixels = 300; |
| @@ -221,6 +223,7 @@ RenderWidgetHostView* RenderWidgetHostView::CreateViewForWidget( |
| RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) |
| : render_widget_host_(widget), |
| compositor_host_window_(NULL), |
| + was_compositing_just_scheduled_(false), |
| hide_compositor_window_at_next_paint_(false), |
| track_mouse_leave_(false), |
| ime_notification_(false), |
| @@ -232,6 +235,7 @@ RenderWidgetHostViewWin::RenderWidgetHostViewWin(RenderWidgetHost* widget) |
| tooltip_hwnd_(NULL), |
| tooltip_showing_(false), |
| shutdown_factory_(this), |
| + method_factory_(this), |
| parent_hwnd_(NULL), |
| is_loading_(false), |
| overlay_color_(0), |
| @@ -839,7 +843,7 @@ void RenderWidgetHostViewWin::OnPaint(HDC unused_dc) { |
| // We initialize paint_dc here so that BeginPaint()/EndPaint() |
| // get called to validate the region. |
| CPaintDC paint_dc(m_hWnd); |
| - render_widget_host_->ScheduleComposite(); |
| + ScheduleCompositeIfNeeded(); |
| return; |
| } |
| @@ -1477,6 +1481,11 @@ static void PaintCompositorHostWindow(HWND hWnd) { |
| PAINTSTRUCT paint; |
| BeginPaint(hWnd, &paint); |
| + RenderWidgetHostViewWin* win = static_cast<RenderWidgetHostViewWin*>( |
| + GetProp(hWnd, kRenderWidgetHVWPropStr)); |
| + // May block unless parent window already did this. |
| + win->ScheduleCompositeIfNeeded(); |
| + |
| EndPaint(hWnd, &paint); |
| } |
| @@ -1488,6 +1497,7 @@ static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, |
| case WM_ERASEBKGND: |
| return 0; |
| case WM_DESTROY: |
| + RemoveProp(hWnd, kRenderWidgetHVWPropStr); |
| return 0; |
| case WM_PAINT: |
| PaintCompositorHostWindow(hWnd); |
| @@ -1497,6 +1507,22 @@ static LRESULT CALLBACK CompositorHostWindowProc(HWND hWnd, UINT message, |
| } |
| } |
| +void RenderWidgetHostViewWin::ScheduleCompositeIfNeeded() { |
| + // Call ScheduleComposite unless it has already occured during this set of |
| + // Windows events. |
| + if (!was_compositing_just_scheduled_) { |
| + was_compositing_just_scheduled_ = true; |
| + render_widget_host_->ScheduleComposite(); |
| + MessageLoop::current()->PostTask(FROM_HERE, |
|
darin (slow to review)
2011/05/26 23:03:06
Maybe I don't understand what you are trying to ac
jbates
2011/05/27 17:11:41
You're right - it's a mistake. The latest version
|
| + method_factory_.NewRunnableMethod( |
| + &RenderWidgetHostViewWin::ResetWasCompositingJustScheduled)); |
| + } |
| +} |
| + |
| +void RenderWidgetHostViewWin::ResetWasCompositingJustScheduled() { |
| + was_compositing_just_scheduled_ = false; |
| +} |
| + |
| // Creates a HWND within the RenderWidgetHostView that will serve as a host |
| // for a HWND that the GPU process will create. The host window is used |
| // to Z-position the GPU's window relative to other plugin windows. |
| @@ -1537,6 +1563,8 @@ gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
| 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0); |
| ui::CheckWindowCreated(compositor_host_window_); |
| + SetProp(compositor_host_window_, kRenderWidgetHVWPropStr, this); |
| + |
| return static_cast<gfx::PluginWindowHandle>(compositor_host_window_); |
| } |