OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "content/browser/renderer_host/render_widget_host_view_win.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_win.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/bind.h" | |
10 #include "base/command_line.h" | 9 #include "base/command_line.h" |
11 #include "base/i18n/rtl.h" | 10 #include "base/i18n/rtl.h" |
12 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
13 #include "base/process_util.h" | 12 #include "base/process_util.h" |
14 #include "base/threading/thread.h" | 13 #include "base/threading/thread.h" |
15 #include "base/win/scoped_comptr.h" | 14 #include "base/win/scoped_comptr.h" |
16 #include "base/win/scoped_gdi_object.h" | 15 #include "base/win/scoped_gdi_object.h" |
17 #include "base/win/win_util.h" | 16 #include "base/win/win_util.h" |
18 #include "base/win/windows_version.h" | 17 #include "base/win/windows_version.h" |
19 #include "base/win/wrapped_window_proc.h" | 18 #include "base/win/wrapped_window_proc.h" |
20 #include "content/browser/accessibility/browser_accessibility_manager.h" | 19 #include "content/browser/accessibility/browser_accessibility_manager.h" |
21 #include "content/browser/accessibility/browser_accessibility_state.h" | 20 #include "content/browser/accessibility/browser_accessibility_state.h" |
22 #include "content/browser/accessibility/browser_accessibility_win.h" | 21 #include "content/browser/accessibility/browser_accessibility_win.h" |
23 #include "content/browser/gpu/gpu_process_host.h" | |
24 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | |
25 #include "content/browser/plugin_process_host.h" | 22 #include "content/browser/plugin_process_host.h" |
26 #include "content/browser/renderer_host/backing_store.h" | 23 #include "content/browser/renderer_host/backing_store.h" |
27 #include "content/browser/renderer_host/backing_store_win.h" | 24 #include "content/browser/renderer_host/backing_store_win.h" |
28 #include "content/browser/renderer_host/render_process_host_impl.h" | 25 #include "content/browser/renderer_host/render_process_host_impl.h" |
29 #include "content/browser/renderer_host/render_widget_host.h" | 26 #include "content/browser/renderer_host/render_widget_host.h" |
30 #include "content/common/gpu/gpu_messages.h" | |
31 #include "content/common/plugin_messages.h" | 27 #include "content/common/plugin_messages.h" |
32 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
33 #include "content/public/browser/browser_thread.h" | 29 #include "content/public/browser/browser_thread.h" |
34 #include "content/public/browser/content_browser_client.h" | 30 #include "content/public/browser/content_browser_client.h" |
35 #include "content/public/browser/native_web_keyboard_event.h" | 31 #include "content/public/browser/native_web_keyboard_event.h" |
36 #include "content/public/browser/notification_service.h" | 32 #include "content/public/browser/notification_service.h" |
37 #include "content/public/browser/notification_types.h" | 33 #include "content/public/browser/notification_types.h" |
38 #include "content/public/common/content_switches.h" | 34 #include "content/public/common/content_switches.h" |
39 #include "content/public/common/page_zoom.h" | 35 #include "content/public/common/page_zoom.h" |
40 #include "skia/ext/skia_utils_win.h" | 36 #include "skia/ext/skia_utils_win.h" |
(...skipping 10 matching lines...) Expand all Loading... |
51 #include "ui/gfx/canvas_skia.h" | 47 #include "ui/gfx/canvas_skia.h" |
52 #include "ui/gfx/gdi_util.h" | 48 #include "ui/gfx/gdi_util.h" |
53 #include "ui/gfx/rect.h" | 49 #include "ui/gfx/rect.h" |
54 #include "ui/gfx/screen.h" | 50 #include "ui/gfx/screen.h" |
55 #include "webkit/glue/webaccessibility.h" | 51 #include "webkit/glue/webaccessibility.h" |
56 #include "webkit/glue/webcursor.h" | 52 #include "webkit/glue/webcursor.h" |
57 #include "webkit/plugins/npapi/plugin_constants_win.h" | 53 #include "webkit/plugins/npapi/plugin_constants_win.h" |
58 #include "webkit/plugins/npapi/webplugin.h" | 54 #include "webkit/plugins/npapi/webplugin.h" |
59 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" | 55 #include "webkit/plugins/npapi/webplugin_delegate_impl.h" |
60 | 56 |
61 #pragma comment(lib, "d3d9.lib") | |
62 | |
63 using base::TimeDelta; | 57 using base::TimeDelta; |
64 using base::TimeTicks; | 58 using base::TimeTicks; |
65 using content::BrowserThread; | 59 using content::BrowserThread; |
66 using ui::ViewProp; | 60 using ui::ViewProp; |
67 using WebKit::WebInputEvent; | 61 using WebKit::WebInputEvent; |
68 using WebKit::WebInputEventFactory; | 62 using WebKit::WebInputEventFactory; |
69 using WebKit::WebMouseEvent; | 63 using WebKit::WebMouseEvent; |
70 using WebKit::WebTextDirection; | 64 using WebKit::WebTextDirection; |
71 using webkit::npapi::WebPluginGeometry; | 65 using webkit::npapi::WebPluginGeometry; |
72 | 66 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 case WM_MBUTTONDOWN: | 196 case WM_MBUTTONDOWN: |
203 ::SendMessage(GetParent(window), message, wparam, lparam); | 197 ::SendMessage(GetParent(window), message, wparam, lparam); |
204 return 0; | 198 return 0; |
205 default: | 199 default: |
206 break; | 200 break; |
207 } | 201 } |
208 } | 202 } |
209 return ::DefWindowProc(window, message, wparam, lparam); | 203 return ::DefWindowProc(window, message, wparam, lparam); |
210 } | 204 } |
211 | 205 |
212 void SendToGpuProcessHost(int gpu_host_id, IPC::Message* message) { | |
213 GpuProcessHost* gpu_process_host = GpuProcessHost::FromID(gpu_host_id); | |
214 if (!gpu_process_host) { | |
215 delete message; | |
216 return; | |
217 } | |
218 | |
219 gpu_process_host->Send(message); | |
220 } | |
221 | |
222 void PostTaskOnIOThread(const tracked_objects::Location& from_here, | |
223 base::Closure task) { | |
224 BrowserThread::PostTask(BrowserThread::IO, FROM_HERE, task); | |
225 } | |
226 | |
227 bool DecodeZoomGesture(HWND hwnd, const GESTUREINFO& gi, | 206 bool DecodeZoomGesture(HWND hwnd, const GESTUREINFO& gi, |
228 content::PageZoom* zoom, | 207 content::PageZoom* zoom, |
229 POINT* zoom_center) { | 208 POINT* zoom_center) { |
230 static long start = 0; | 209 static long start = 0; |
231 static POINT zoom_first; | 210 static POINT zoom_first; |
232 | 211 |
233 if (gi.dwFlags == GF_BEGIN) { | 212 if (gi.dwFlags == GF_BEGIN) { |
234 start = gi.ullArguments; | 213 start = gi.ullArguments; |
235 zoom_first.x = gi.ptsLocation.x; | 214 zoom_first.x = gi.ptsLocation.x; |
236 zoom_first.y = gi.ptsLocation.y; | 215 zoom_first.y = gi.ptsLocation.y; |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 touch_state_(this) { | 331 touch_state_(this) { |
353 render_widget_host_->SetView(this); | 332 render_widget_host_->SetView(this); |
354 registrar_.Add(this, | 333 registrar_.Add(this, |
355 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, | 334 content::NOTIFICATION_RENDERER_PROCESS_TERMINATED, |
356 content::NotificationService::AllBrowserContextsAndSources()); | 335 content::NotificationService::AllBrowserContextsAndSources()); |
357 } | 336 } |
358 | 337 |
359 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { | 338 RenderWidgetHostViewWin::~RenderWidgetHostViewWin() { |
360 UnlockMouse(); | 339 UnlockMouse(); |
361 ResetTooltip(); | 340 ResetTooltip(); |
362 | |
363 if (accelerated_surface_) | |
364 accelerated_surface_->Destroy(); | |
365 } | 341 } |
366 | 342 |
367 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { | 343 void RenderWidgetHostViewWin::CreateWnd(HWND parent) { |
368 // ATL function to create the window. | 344 // ATL function to create the window. |
369 Create(parent); | 345 Create(parent); |
370 } | 346 } |
371 | 347 |
372 /////////////////////////////////////////////////////////////////////////////// | 348 /////////////////////////////////////////////////////////////////////////////// |
373 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: | 349 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: |
374 | 350 |
(...skipping 1598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1973 return 0; | 1949 return 0; |
1974 case WM_PAINT: | 1950 case WM_PAINT: |
1975 PaintCompositorHostWindow(hWnd); | 1951 PaintCompositorHostWindow(hWnd); |
1976 return 0; | 1952 return 0; |
1977 default: | 1953 default: |
1978 return DefWindowProc(hWnd, message, wParam, lParam); | 1954 return DefWindowProc(hWnd, message, wParam, lParam); |
1979 } | 1955 } |
1980 } | 1956 } |
1981 | 1957 |
1982 void RenderWidgetHostViewWin::ScheduleComposite() { | 1958 void RenderWidgetHostViewWin::ScheduleComposite() { |
1983 // If we have a previous frame then present it immediately. Otherwise request | 1959 if (render_widget_host_) |
1984 // a new frame be composited. | 1960 render_widget_host_->ScheduleComposite(); |
1985 if (accelerated_surface_.get()) { | |
1986 accelerated_surface_->Present(); | |
1987 } else { | |
1988 if (render_widget_host_) | |
1989 render_widget_host_->ScheduleComposite(); | |
1990 } | |
1991 } | 1961 } |
1992 | 1962 |
1993 // Creates a HWND within the RenderWidgetHostView that will serve as a host | 1963 // Creates a HWND within the RenderWidgetHostView that will serve as a host |
1994 // for a HWND that the GPU process will create. The host window is used | 1964 // for a HWND that the GPU process will create. The host window is used |
1995 // to Z-position the GPU's window relative to other plugin windows. | 1965 // to Z-position the GPU's window relative to other plugin windows. |
1996 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { | 1966 gfx::PluginWindowHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
1997 // If the window has been created, don't recreate it a second time | 1967 // If the window has been created, don't recreate it a second time |
1998 if (compositor_host_window_) | 1968 if (compositor_host_window_) |
1999 return compositor_host_window_; | 1969 return compositor_host_window_; |
2000 | 1970 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2076 else | 2046 else |
2077 next = compositor_host_window_; | 2047 next = compositor_host_window_; |
2078 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, | 2048 ::SetWindowPos(plugin_windows[i], next, 0, 0, 0, 0, |
2079 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); | 2049 SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE); |
2080 } | 2050 } |
2081 } else { | 2051 } else { |
2082 hide_compositor_window_at_next_paint_ = true; | 2052 hide_compositor_window_at_next_paint_ = true; |
2083 } | 2053 } |
2084 } | 2054 } |
2085 | 2055 |
2086 void RenderWidgetHostViewWin::AcceleratedSurfaceBuffersSwapped( | |
2087 const GpuHostMsg_AcceleratedSurfaceBuffersSwapped_Params& params, | |
2088 int gpu_host_id) { | |
2089 if (!accelerated_surface_.get() && compositor_host_window_) { | |
2090 accelerated_surface_ = new AcceleratedSurface(compositor_host_window_); | |
2091 accelerated_surface_->Initialize(); | |
2092 } | |
2093 | |
2094 base::Closure acknowledge_task = | |
2095 base::Bind(SendToGpuProcessHost, | |
2096 gpu_host_id, | |
2097 new AcceleratedSurfaceMsg_BuffersSwappedACK(params.route_id)); | |
2098 | |
2099 accelerated_surface_->AsyncPresentAndAcknowledge( | |
2100 params.size, | |
2101 params.surface_id, | |
2102 base::Bind(PostTaskOnIOThread, | |
2103 FROM_HERE, | |
2104 acknowledge_task)); | |
2105 } | |
2106 | |
2107 void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { | 2056 void RenderWidgetHostViewWin::SetAccessibilityFocus(int acc_obj_id) { |
2108 if (!render_widget_host_) | 2057 if (!render_widget_host_) |
2109 return; | 2058 return; |
2110 | 2059 |
2111 render_widget_host_->AccessibilitySetFocus(acc_obj_id); | 2060 render_widget_host_->AccessibilitySetFocus(acc_obj_id); |
2112 } | 2061 } |
2113 | 2062 |
2114 void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) { | 2063 void RenderWidgetHostViewWin::AccessibilityDoDefaultAction(int acc_obj_id) { |
2115 if (!render_widget_host_) | 2064 if (!render_widget_host_) |
2116 return; | 2065 return; |
(...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2480 | 2429 |
2481 size_t offset = selection_range_.GetMin() - selection_text_offset_; | 2430 size_t offset = selection_range_.GetMin() - selection_text_offset_; |
2482 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), | 2431 memcpy(reinterpret_cast<char*>(reconv) + sizeof(RECONVERTSTRING), |
2483 selection_text_.c_str() + offset, len * sizeof(WCHAR)); | 2432 selection_text_.c_str() + offset, len * sizeof(WCHAR)); |
2484 | 2433 |
2485 // According to Microsft API document, IMR_RECONVERTSTRING and | 2434 // According to Microsft API document, IMR_RECONVERTSTRING and |
2486 // IMR_DOCUMENTFEED should return reconv, but some applications return | 2435 // IMR_DOCUMENTFEED should return reconv, but some applications return |
2487 // need_size. | 2436 // need_size. |
2488 return reinterpret_cast<LRESULT>(reconv); | 2437 return reinterpret_cast<LRESULT>(reconv); |
2489 } | 2438 } |
OLD | NEW |