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/render_widget_host_view_win.h" | 5 #include "chrome/browser/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" |
11 #include "base/win_util.h" | 11 #include "base/win_util.h" |
12 #include "chrome/browser/browser_accessibility.h" | 12 #include "chrome/browser/browser_accessibility.h" |
13 #include "chrome/browser/browser_accessibility_manager.h" | 13 #include "chrome/browser/browser_accessibility_manager.h" |
14 #include "chrome/browser/browser_trial.h" | 14 #include "chrome/browser/browser_trial.h" |
15 #include "chrome/browser/renderer_host/render_process_host.h" | 15 #include "chrome/browser/renderer_host/render_process_host.h" |
16 // TODO(beng): (Cleanup) we should not need to include this file... see comment | 16 // TODO(beng): (Cleanup) we should not need to include this file... see comment |
17 // in |DidBecomeSelected|. | 17 // in |DidBecomeSelected|. |
18 #include "chrome/browser/render_view_host.h" | 18 #include "chrome/browser/render_view_host.h" |
19 #include "chrome/browser/render_widget_host.h" | 19 #include "chrome/browser/render_widget_host.h" |
20 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
21 #include "chrome/common/chrome_switches.h" | 21 #include "chrome/common/chrome_switches.h" |
22 #include "chrome/common/l10n_util.h" | 22 #include "chrome/common/l10n_util.h" |
23 #include "chrome/common/plugin_messages.h" | 23 #include "chrome/common/plugin_messages.h" |
24 #include "chrome/common/win_util.h" | 24 #include "chrome/common/win_util.h" |
25 // Included for views::kReflectedMessage - TODO(beng): move this to win_util.h! | 25 // Included for views::kReflectedMessage - TODO(beng): move this to win_util.h! |
26 #include "chrome/views/widget_win.h" | 26 #include "chrome/views/widget_win.h" |
27 #include "webkit/glue/plugins/plugin_constants_win.h" | |
28 #include "webkit/glue/plugins/webplugin_delegate_impl.h" | |
27 #include "webkit/glue/webcursor.h" | 29 #include "webkit/glue/webcursor.h" |
28 | 30 |
29 using base::TimeDelta; | 31 using base::TimeDelta; |
30 using base::TimeTicks; | 32 using base::TimeTicks; |
31 | 33 |
32 namespace { | 34 namespace { |
33 | 35 |
34 // Tooltips will wrap after this width. Yes, wrap. Imagine that! | 36 // Tooltips will wrap after this width. Yes, wrap. Imagine that! |
35 const int kTooltipMaxWidthPixels = 300; | 37 const int kTooltipMaxWidthPixels = 300; |
36 | 38 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
251 void RenderWidgetHostViewWin::IMEUpdateStatus(ViewHostMsg_ImeControl control, | 253 void RenderWidgetHostViewWin::IMEUpdateStatus(ViewHostMsg_ImeControl control, |
252 const gfx::Rect& caret_rect) { | 254 const gfx::Rect& caret_rect) { |
253 if (control == IME_DISABLE) { | 255 if (control == IME_DISABLE) { |
254 ime_input_.DisableIME(m_hWnd); | 256 ime_input_.DisableIME(m_hWnd); |
255 } else { | 257 } else { |
256 ime_input_.EnableIME(m_hWnd, caret_rect, | 258 ime_input_.EnableIME(m_hWnd, caret_rect, |
257 control == IME_COMPLETE_COMPOSITION); | 259 control == IME_COMPLETE_COMPOSITION); |
258 } | 260 } |
259 } | 261 } |
260 | 262 |
263 BOOL CALLBACK EnumChildProc(HWND hwnd, LPARAM lparam) { | |
264 if (!WebPluginDelegateImpl::IsPluginDelegateWindow(hwnd)) | |
265 return TRUE; | |
266 | |
267 gfx::Rect* rect = reinterpret_cast<gfx::Rect*>(lparam); | |
268 static UINT msg = RegisterWindowMessage(kPaintMessageName); | |
269 WPARAM wparam = rect->x() << 16 | rect->y(); | |
270 lparam = rect->width() << 16 | rect->height(); | |
271 | |
272 // SendMessage gets the message across much quicker than PostMessage, since it | |
273 // doesn't get queued. When the plugin thread calls PeakMessage or other | |
darin (slow to review)
2009/01/22 00:40:03
s/PeakMessage/PeekMessage/
jam
2009/01/22 01:03:10
Done.
| |
274 // Win32 APIs, sent messages are dispatched automatically. | |
275 SendNotifyMessage(hwnd, msg, wparam, lparam); | |
276 | |
277 return TRUE; | |
278 } | |
279 | |
280 void RenderWidgetHostViewWin::Redraw(const gfx::Rect& rect) { | |
281 // Paint the invalid region synchronously. Our caller will not paint again | |
282 // until we return, so by painting to the screen here, we ensure effective | |
283 // rate-limiting of backing store updates. This helps a lot on pages that | |
284 // have animations or fairly expensive layout (e.g., google maps). | |
285 // | |
286 // We paint this window synchronously, however child windows (i.e. plugins) | |
287 // are painted asynchronously. By avoiding synchronous cross-process window | |
288 // message dispatching we allow scrolling to be smooth, and also avoid the | |
289 // browser process locking up if the plugin process is hung. | |
290 // | |
291 RedrawWindow( | |
292 &rect.ToRECT(), NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_NOCHILDREN); | |
293 | |
294 // Send the invalid rect in screen coordinates. | |
295 gfx::Rect screen_rect = GetViewBounds(); | |
296 gfx::Rect invalid_screen_rect = rect; | |
297 invalid_screen_rect.Offset(screen_rect.x(), screen_rect.y()); | |
298 | |
299 LPARAM lparam = reinterpret_cast<LPARAM>(&invalid_screen_rect); | |
300 EnumChildWindows(m_hWnd, EnumChildProc, lparam); | |
301 } | |
302 | |
261 void RenderWidgetHostViewWin::DidPaintRect(const gfx::Rect& rect) { | 303 void RenderWidgetHostViewWin::DidPaintRect(const gfx::Rect& rect) { |
262 if (is_hidden_) | 304 if (is_hidden_) |
263 return; | 305 return; |
264 | 306 |
265 RECT invalid_rect = rect.ToRECT(); | 307 Redraw(rect); |
266 | |
267 // Paint the invalid region synchronously. Our caller will not paint again | |
268 // until we return, so by painting to the screen here, we ensure effective | |
269 // rate-limiting of backing store updates. This helps a lot on pages that | |
270 // have animations or fairly expensive layout (e.g., google maps). | |
271 // | |
272 // Please refer to the RenderWidgetHostViewWin::DidScrollRect function for the | |
273 // reasoning behind the combination of flags passed to RedrawWindow. | |
274 // | |
275 RedrawWindow(&invalid_rect, NULL, | |
276 RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_FRAME); | |
277 } | 308 } |
278 | 309 |
279 void RenderWidgetHostViewWin::DidScrollRect( | 310 void RenderWidgetHostViewWin::DidScrollRect( |
280 const gfx::Rect& rect, int dx, int dy) { | 311 const gfx::Rect& rect, int dx, int dy) { |
281 if (is_hidden_) | 312 if (is_hidden_) |
282 return; | 313 return; |
283 | 314 |
284 // We need to pass in SW_INVALIDATE to ScrollWindowEx. The MSDN | 315 // We need to pass in SW_INVALIDATE to ScrollWindowEx. The MSDN |
285 // documentation states that it only applies to the HRGN argument, which is | 316 // documentation states that it only applies to the HRGN argument, which is |
286 // wrong. Not passing in this flag does not invalidate the region which was | 317 // wrong. Not passing in this flag does not invalidate the region which was |
287 // scrolled from, thus causing painting issues. | 318 // scrolled from, thus causing painting issues. |
288 RECT clip_rect = rect.ToRECT(); | 319 RECT clip_rect = rect.ToRECT(); |
289 ScrollWindowEx(dx, dy, NULL, &clip_rect, NULL, NULL, SW_INVALIDATE); | 320 ScrollWindowEx(dx, dy, NULL, &clip_rect, NULL, NULL, SW_INVALIDATE); |
290 | 321 |
291 RECT invalid_rect = {0}; | 322 RECT invalid_rect = {0}; |
292 GetUpdateRect(&invalid_rect); | 323 GetUpdateRect(&invalid_rect); |
293 | 324 Redraw(gfx::Rect(invalid_rect)); |
294 // Paint the invalid region synchronously. Our caller will not paint again | |
295 // until we return, so by painting to the screen here, we ensure effective | |
296 // rate-limiting of backing store updates. This helps a lot on pages that | |
297 // have animations or fairly expensive layout (e.g., google maps). | |
298 // | |
299 // Our RenderWidgetHostViewWin does not have a non-client area, whereas the | |
300 // children (plugin windows) may. If we don't pass in RDW_FRAME then the | |
301 // children don't receive WM_NCPAINT messages while scrolling, which causes | |
302 // painting problems (http://b/issue?id=923945). We need to pass | |
303 // RDW_INVALIDATE as it is required for RDW_FRAME to work. | |
304 // | |
305 RedrawWindow(&invalid_rect, NULL, | |
306 RDW_INVALIDATE | RDW_UPDATENOW | RDW_ALLCHILDREN | RDW_FRAME); | |
307 } | 325 } |
308 | 326 |
309 void RenderWidgetHostViewWin::RendererGone() { | 327 void RenderWidgetHostViewWin::RendererGone() { |
310 // TODO(darin): keep this around, and draw sad-tab into it. | 328 // TODO(darin): keep this around, and draw sad-tab into it. |
311 UpdateCursorIfOverSelf(); | 329 UpdateCursorIfOverSelf(); |
312 DestroyWindow(); | 330 DestroyWindow(); |
313 } | 331 } |
314 | 332 |
315 void RenderWidgetHostViewWin::Destroy() { | 333 void RenderWidgetHostViewWin::Destroy() { |
316 // We've been told to destroy. | 334 // We've been told to destroy. |
(...skipping 580 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
897 if (::IsWindow(tooltip_hwnd_)) | 915 if (::IsWindow(tooltip_hwnd_)) |
898 ::DestroyWindow(tooltip_hwnd_); | 916 ::DestroyWindow(tooltip_hwnd_); |
899 tooltip_hwnd_ = NULL; | 917 tooltip_hwnd_ = NULL; |
900 } | 918 } |
901 | 919 |
902 void RenderWidgetHostViewWin::ShutdownHost() { | 920 void RenderWidgetHostViewWin::ShutdownHost() { |
903 shutdown_factory_.RevokeAll(); | 921 shutdown_factory_.RevokeAll(); |
904 render_widget_host_->Shutdown(); | 922 render_widget_host_->Shutdown(); |
905 // Do not touch any members at this point, |this| has been deleted. | 923 // Do not touch any members at this point, |this| has been deleted. |
906 } | 924 } |
OLD | NEW |