| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <peninputpanel_i.c> | 8 #include <peninputpanel_i.c> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 563 if (!defer_window_pos_info) { | 563 if (!defer_window_pos_info) { |
| 564 DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored."; | 564 DCHECK(false) << "DeferWindowPos failed, so all plugin moves ignored."; |
| 565 return; | 565 return; |
| 566 } | 566 } |
| 567 } | 567 } |
| 568 | 568 |
| 569 ::EndDeferWindowPos(defer_window_pos_info); | 569 ::EndDeferWindowPos(defer_window_pos_info); |
| 570 } | 570 } |
| 571 | 571 |
| 572 HWND RenderWidgetHostViewWin::ReparentWindow(HWND window) { | 572 HWND RenderWidgetHostViewWin::ReparentWindow(HWND window) { |
| 573 static ATOM window_class = 0; | 573 static ATOM atom = 0; |
| 574 if (!window_class) { | 574 static HMODULE instance = NULL; |
| 575 WNDCLASSEX wcex; | 575 if (!atom) { |
| 576 wcex.cbSize = sizeof(WNDCLASSEX); | 576 WNDCLASSEX window_class; |
| 577 wcex.style = CS_DBLCLKS; | 577 base::win::InitializeWindowClass( |
| 578 wcex.lpfnWndProc = base::win::WrappedWindowProc<PluginWrapperWindowProc>; | 578 webkit::npapi::kWrapperNativeWindowClassName, |
| 579 wcex.cbClsExtra = 0; | 579 &base::win::WrappedWindowProc<PluginWrapperWindowProc>, |
| 580 wcex.cbWndExtra = 0; | 580 CS_DBLCLKS, |
| 581 wcex.hInstance = GetModuleHandle(NULL); | 581 0, |
| 582 wcex.hIcon = 0; | 582 0, |
| 583 wcex.hCursor = 0; | 583 NULL, |
| 584 wcex.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW+1); | 584 reinterpret_cast<HBRUSH>(COLOR_WINDOW+1), |
| 585 wcex.lpszMenuName = 0; | 585 NULL, |
| 586 wcex.lpszClassName = webkit::npapi::kWrapperNativeWindowClassName; | 586 NULL, |
| 587 wcex.hIconSm = 0; | 587 NULL, |
| 588 window_class = RegisterClassEx(&wcex); | 588 &window_class); |
| 589 instance = window_class.hInstance; |
| 590 atom = RegisterClassEx(&window_class); |
| 589 } | 591 } |
| 590 DCHECK(window_class); | 592 DCHECK(atom); |
| 591 | 593 |
| 592 HWND orig_parent = ::GetParent(window); | 594 HWND orig_parent = ::GetParent(window); |
| 593 HWND parent = CreateWindowEx( | 595 HWND parent = CreateWindowEx( |
| 594 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, | 596 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, |
| 595 MAKEINTATOM(window_class), 0, | 597 MAKEINTATOM(atom), 0, |
| 596 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, | 598 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, |
| 597 0, 0, 0, 0, orig_parent, 0, GetModuleHandle(NULL), 0); | 599 0, 0, 0, 0, orig_parent, 0, instance, 0); |
| 598 ui::CheckWindowCreated(parent); | 600 ui::CheckWindowCreated(parent); |
| 599 // If UIPI is enabled we need to add message filters for parents with | 601 // If UIPI is enabled we need to add message filters for parents with |
| 600 // children that cross process boundaries. | 602 // children that cross process boundaries. |
| 601 if (::GetPropW(orig_parent, webkit::npapi::kNativeWindowClassFilterProp)) { | 603 if (::GetPropW(orig_parent, webkit::npapi::kNativeWindowClassFilterProp)) { |
| 602 // Process-wide message filters required on Vista must be added to: | 604 // Process-wide message filters required on Vista must be added to: |
| 603 // chrome_content_client.cc ChromeContentClient::SandboxPlugin | 605 // chrome_content_client.cc ChromeContentClient::SandboxPlugin |
| 604 ChangeWindowMessageFilterEx(parent, WM_MOUSEWHEEL, MSGFLT_ALLOW, NULL); | 606 ChangeWindowMessageFilterEx(parent, WM_MOUSEWHEEL, MSGFLT_ALLOW, NULL); |
| 605 ChangeWindowMessageFilterEx(parent, WM_GESTURE, MSGFLT_ALLOW, NULL); | 607 ChangeWindowMessageFilterEx(parent, WM_GESTURE, MSGFLT_ALLOW, NULL); |
| 606 ChangeWindowMessageFilterEx(parent, WM_APPCOMMAND, MSGFLT_ALLOW, NULL); | 608 ChangeWindowMessageFilterEx(parent, WM_APPCOMMAND, MSGFLT_ALLOW, NULL); |
| 607 ::RemovePropW(orig_parent, webkit::npapi::kNativeWindowClassFilterProp); | 609 ::RemovePropW(orig_parent, webkit::npapi::kNativeWindowClassFilterProp); |
| (...skipping 1521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 } | 2131 } |
| 2130 | 2132 |
| 2131 // Creates a HWND within the RenderWidgetHostView that will serve as a host | 2133 // Creates a HWND within the RenderWidgetHostView that will serve as a host |
| 2132 // for a HWND that the GPU process will create. The host window is used | 2134 // for a HWND that the GPU process will create. The host window is used |
| 2133 // to Z-position the GPU's window relative to other plugin windows. | 2135 // to Z-position the GPU's window relative to other plugin windows. |
| 2134 gfx::GLSurfaceHandle RenderWidgetHostViewWin::GetCompositingSurface() { | 2136 gfx::GLSurfaceHandle RenderWidgetHostViewWin::GetCompositingSurface() { |
| 2135 // If the window has been created, don't recreate it a second time | 2137 // If the window has been created, don't recreate it a second time |
| 2136 if (compositor_host_window_) | 2138 if (compositor_host_window_) |
| 2137 return gfx::GLSurfaceHandle(compositor_host_window_, true); | 2139 return gfx::GLSurfaceHandle(compositor_host_window_, true); |
| 2138 | 2140 |
| 2139 static ATOM window_class = 0; | 2141 static ATOM atom = 0; |
| 2140 if (!window_class) { | 2142 static HMODULE instance = NULL; |
| 2141 WNDCLASSEX wcex; | 2143 if (!atom) { |
| 2142 wcex.cbSize = sizeof(WNDCLASSEX); | 2144 WNDCLASSEX window_class; |
| 2143 wcex.style = 0; | 2145 base::win::InitializeWindowClass( |
| 2144 wcex.lpfnWndProc = | 2146 L"CompositorHostWindowClass", |
| 2145 base::win::WrappedWindowProc<CompositorHostWindowProc>; | 2147 &base::win::WrappedWindowProc<CompositorHostWindowProc>, |
| 2146 wcex.cbClsExtra = 0; | 2148 0, 0, 0, NULL, NULL, NULL, NULL, NULL, |
| 2147 wcex.cbWndExtra = 0; | 2149 &window_class); |
| 2148 wcex.hInstance = GetModuleHandle(NULL); | 2150 instance = window_class.hInstance; |
| 2149 wcex.hIcon = 0; | 2151 atom = RegisterClassEx(&window_class); |
| 2150 wcex.hCursor = 0; | 2152 DCHECK(atom); |
| 2151 wcex.hbrBackground = NULL; | |
| 2152 wcex.lpszMenuName = 0; | |
| 2153 wcex.lpszClassName = L"CompositorHostWindowClass"; | |
| 2154 wcex.hIconSm = 0; | |
| 2155 window_class = RegisterClassEx(&wcex); | |
| 2156 DCHECK(window_class); | |
| 2157 } | 2153 } |
| 2158 | 2154 |
| 2159 RECT currentRect; | 2155 RECT currentRect; |
| 2160 GetClientRect(¤tRect); | 2156 GetClientRect(¤tRect); |
| 2161 | 2157 |
| 2162 // Ensure window does not have zero area because D3D cannot create a zero | 2158 // Ensure window does not have zero area because D3D cannot create a zero |
| 2163 // area swap chain. | 2159 // area swap chain. |
| 2164 int width = std::max(1, | 2160 int width = std::max(1, |
| 2165 static_cast<int>(currentRect.right - currentRect.left)); | 2161 static_cast<int>(currentRect.right - currentRect.left)); |
| 2166 int height = std::max(1, | 2162 int height = std::max(1, |
| 2167 static_cast<int>(currentRect.bottom - currentRect.top)); | 2163 static_cast<int>(currentRect.bottom - currentRect.top)); |
| 2168 | 2164 |
| 2169 compositor_host_window_ = CreateWindowEx( | 2165 compositor_host_window_ = CreateWindowEx( |
| 2170 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, | 2166 WS_EX_LEFT | WS_EX_LTRREADING | WS_EX_RIGHTSCROLLBAR, |
| 2171 MAKEINTATOM(window_class), 0, | 2167 MAKEINTATOM(atom), 0, |
| 2172 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, | 2168 WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS | WS_DISABLED, |
| 2173 0, 0, width, height, m_hWnd, 0, GetModuleHandle(NULL), 0); | 2169 0, 0, width, height, m_hWnd, 0, instance, 0); |
| 2174 ui::CheckWindowCreated(compositor_host_window_); | 2170 ui::CheckWindowCreated(compositor_host_window_); |
| 2175 | 2171 |
| 2176 ui::SetWindowUserData(compositor_host_window_, this); | 2172 ui::SetWindowUserData(compositor_host_window_, this); |
| 2177 | 2173 |
| 2178 gfx::GLSurfaceHandle surface_handle(compositor_host_window_, true); | 2174 gfx::GLSurfaceHandle surface_handle(compositor_host_window_, true); |
| 2179 | 2175 |
| 2180 base::win::OSInfo *os_info = base::win::OSInfo::GetInstance(); | 2176 base::win::OSInfo *os_info = base::win::OSInfo::GetInstance(); |
| 2181 if (os_info->version() >= base::win::VERSION_VISTA) { | 2177 if (os_info->version() >= base::win::VERSION_VISTA) { |
| 2182 accelerated_surface_.reset(new AcceleratedSurface(compositor_host_window_)); | 2178 accelerated_surface_.reset(new AcceleratedSurface(compositor_host_window_)); |
| 2183 } | 2179 } |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2697 void RenderWidgetHostViewWin::ResetPointerDownContext() { | 2693 void RenderWidgetHostViewWin::ResetPointerDownContext() { |
| 2698 // If the default focus on the page is on an edit field and we did not | 2694 // If the default focus on the page is on an edit field and we did not |
| 2699 // receive a focus change in the context of a pointer down message, it means | 2695 // receive a focus change in the context of a pointer down message, it means |
| 2700 // that the pointer down message occurred on the edit field and we should | 2696 // that the pointer down message occurred on the edit field and we should |
| 2701 // display the on screen keyboard | 2697 // display the on screen keyboard |
| 2702 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 2698 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
| 2703 DisplayOnScreenKeyboardIfNeeded(); | 2699 DisplayOnScreenKeyboardIfNeeded(); |
| 2704 received_focus_change_after_pointer_down_ = false; | 2700 received_focus_change_after_pointer_down_ = false; |
| 2705 pointer_down_context_ = false; | 2701 pointer_down_context_ = false; |
| 2706 } | 2702 } |
| OLD | NEW |