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