| 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 <map> | 8 #include <map> |
| 9 #include <peninputpanel_i.c> | 9 #include <peninputpanel_i.c> |
| 10 #include <stack> | 10 #include <stack> |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 /////////////////////////////////////////////////////////////////////////////// | 654 /////////////////////////////////////////////////////////////////////////////// |
| 655 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: | 655 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: |
| 656 | 656 |
| 657 void RenderWidgetHostViewWin::InitAsChild( | 657 void RenderWidgetHostViewWin::InitAsChild( |
| 658 gfx::NativeView parent_view) { | 658 gfx::NativeView parent_view) { |
| 659 CreateWnd(parent_view); | 659 CreateWnd(parent_view); |
| 660 } | 660 } |
| 661 | 661 |
| 662 void RenderWidgetHostViewWin::InitAsPopup( | 662 void RenderWidgetHostViewWin::InitAsPopup( |
| 663 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { | 663 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { |
| 664 close_on_deactivate_ = true; |
| 664 DoPopupOrFullscreenInit(parent_host_view->GetNativeView(), pos, | 665 DoPopupOrFullscreenInit(parent_host_view->GetNativeView(), pos, |
| 665 WS_EX_TOOLWINDOW); | 666 WS_EX_TOOLWINDOW); |
| 666 } | 667 } |
| 667 | 668 |
| 668 void RenderWidgetHostViewWin::InitAsFullscreen( | 669 void RenderWidgetHostViewWin::InitAsFullscreen( |
| 669 RenderWidgetHostView* reference_host_view) { | 670 RenderWidgetHostView* reference_host_view) { |
| 670 gfx::Rect pos = gfx::Screen::GetDisplayNearestWindow( | 671 gfx::Rect pos = gfx::Screen::GetDisplayNearestWindow( |
| 671 reference_host_view->GetNativeView()).bounds(); | 672 reference_host_view->GetNativeView()).bounds(); |
| 672 is_fullscreen_ = true; | 673 is_fullscreen_ = true; |
| 673 DoPopupOrFullscreenInit(ui::GetWindowToParentTo(true), pos, 0); | 674 DoPopupOrFullscreenInit(ui::GetWindowToParentTo(true), pos, 0); |
| (...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCaptureChanged"); | 1611 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCaptureChanged"); |
| 1611 if (render_widget_host_) | 1612 if (render_widget_host_) |
| 1612 render_widget_host_->LostCapture(); | 1613 render_widget_host_->LostCapture(); |
| 1613 } | 1614 } |
| 1614 | 1615 |
| 1615 void RenderWidgetHostViewWin::OnCancelMode() { | 1616 void RenderWidgetHostViewWin::OnCancelMode() { |
| 1616 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCancelMode"); | 1617 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCancelMode"); |
| 1617 if (render_widget_host_) | 1618 if (render_widget_host_) |
| 1618 render_widget_host_->LostCapture(); | 1619 render_widget_host_->LostCapture(); |
| 1619 | 1620 |
| 1620 if (close_on_deactivate_ && !weak_factory_.HasWeakPtrs()) { | 1621 if ((is_fullscreen_ || close_on_deactivate_) && |
| 1622 !weak_factory_.HasWeakPtrs()) { |
| 1621 // Dismiss popups and menus. We do this asynchronously to avoid changing | 1623 // Dismiss popups and menus. We do this asynchronously to avoid changing |
| 1622 // activation within this callstack, which may interfere with another window | 1624 // activation within this callstack, which may interfere with another window |
| 1623 // being activated. We can synchronously hide the window, but we need to | 1625 // being activated. We can synchronously hide the window, but we need to |
| 1624 // not change activation while doing so. | 1626 // not change activation while doing so. |
| 1625 SetWindowPos(NULL, 0, 0, 0, 0, | 1627 SetWindowPos(NULL, 0, 0, 0, 0, |
| 1626 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | | 1628 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | |
| 1627 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); | 1629 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); |
| 1628 MessageLoop::current()->PostTask(FROM_HERE, | 1630 MessageLoop::current()->PostTask(FROM_HERE, |
| 1629 base::Bind(&RenderWidgetHostViewWin::ShutdownHost, | 1631 base::Bind(&RenderWidgetHostViewWin::ShutdownHost, |
| 1630 weak_factory_.GetWeakPtr())); | 1632 weak_factory_.GetWeakPtr())); |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1880 // convert the click from the popup window coordinates to the WebContentsImpl' | 1882 // convert the click from the popup window coordinates to the WebContentsImpl' |
| 1881 // window coordinates. For now we don't forward the message in that case to | 1883 // window coordinates. For now we don't forward the message in that case to |
| 1882 // address bug #907474. | 1884 // address bug #907474. |
| 1883 // Note: GetParent() on popup windows returns the top window and not the | 1885 // Note: GetParent() on popup windows returns the top window and not the |
| 1884 // parent the window was created with (the parent and the owner of the popup | 1886 // parent the window was created with (the parent and the owner of the popup |
| 1885 // is the first non-child view of the view that was specified to the create | 1887 // is the first non-child view of the view that was specified to the create |
| 1886 // call). So the WebContentsImpl's window would have to be specified to the | 1888 // call). So the WebContentsImpl's window would have to be specified to the |
| 1887 // RenderViewHostHWND as there is no way to retrieve it from the HWND. | 1889 // RenderViewHostHWND as there is no way to retrieve it from the HWND. |
| 1888 | 1890 |
| 1889 // Don't forward if the container is a popup or fullscreen widget. | 1891 // Don't forward if the container is a popup or fullscreen widget. |
| 1890 if (!close_on_deactivate_) { | 1892 if (!is_fullscreen_ && !close_on_deactivate_) { |
| 1891 switch (message) { | 1893 switch (message) { |
| 1892 case WM_LBUTTONDOWN: | 1894 case WM_LBUTTONDOWN: |
| 1893 case WM_MBUTTONDOWN: | 1895 case WM_MBUTTONDOWN: |
| 1894 case WM_RBUTTONDOWN: | 1896 case WM_RBUTTONDOWN: |
| 1895 // Finish the ongoing composition whenever a mouse click happens. | 1897 // Finish the ongoing composition whenever a mouse click happens. |
| 1896 // It matches IE's behavior. | 1898 // It matches IE's behavior. |
| 1897 ime_input_.CleanupComposition(m_hWnd); | 1899 ime_input_.CleanupComposition(m_hWnd); |
| 1898 // Fall through. | 1900 // Fall through. |
| 1899 case WM_MOUSEMOVE: | 1901 case WM_MOUSEMOVE: |
| 1900 case WM_MOUSELEAVE: { | 1902 case WM_MOUSELEAVE: { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1935 SendMessage(WM_CANCELMODE); | 1937 SendMessage(WM_CANCELMODE); |
| 1936 return 0; | 1938 return 0; |
| 1937 } | 1939 } |
| 1938 } | 1940 } |
| 1939 | 1941 |
| 1940 // If we are a pop-up, forward tab related messages to our parent HWND, so | 1942 // If we are a pop-up, forward tab related messages to our parent HWND, so |
| 1941 // that we are dismissed appropriately and so that the focus advance in our | 1943 // that we are dismissed appropriately and so that the focus advance in our |
| 1942 // parent. | 1944 // parent. |
| 1943 // TODO(jcampan): http://b/issue?id=1192881 Could be abstracted in the | 1945 // TODO(jcampan): http://b/issue?id=1192881 Could be abstracted in the |
| 1944 // FocusManager. | 1946 // FocusManager. |
| 1945 if (close_on_deactivate_ && !is_fullscreen_ && | 1947 if (close_on_deactivate_ && |
| 1946 (((message == WM_KEYDOWN || message == WM_KEYUP) && (wparam == VK_TAB)) || | 1948 (((message == WM_KEYDOWN || message == WM_KEYUP) && (wparam == VK_TAB)) || |
| 1947 (message == WM_CHAR && wparam == L'\t'))) { | 1949 (message == WM_CHAR && wparam == L'\t'))) { |
| 1948 // First close the pop-up. | 1950 // First close the pop-up. |
| 1949 SendMessage(WM_CANCELMODE); | 1951 SendMessage(WM_CANCELMODE); |
| 1950 // Then move the focus by forwarding the tab key to the parent. | 1952 // Then move the focus by forwarding the tab key to the parent. |
| 1951 return ::SendMessage(GetParent(), message, wparam, lparam); | 1953 return ::SendMessage(GetParent(), message, wparam, lparam); |
| 1952 } | 1954 } |
| 1953 | 1955 |
| 1954 if (!render_widget_host_) | 1956 if (!render_widget_host_) |
| 1955 return 0; | 1957 return 0; |
| (...skipping 988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2944 void RenderWidgetHostViewWin::ShutdownHost() { | 2946 void RenderWidgetHostViewWin::ShutdownHost() { |
| 2945 weak_factory_.InvalidateWeakPtrs(); | 2947 weak_factory_.InvalidateWeakPtrs(); |
| 2946 if (render_widget_host_) | 2948 if (render_widget_host_) |
| 2947 render_widget_host_->Shutdown(); | 2949 render_widget_host_->Shutdown(); |
| 2948 // Do not touch any members at this point, |this| has been deleted. | 2950 // Do not touch any members at this point, |this| has been deleted. |
| 2949 } | 2951 } |
| 2950 | 2952 |
| 2951 void RenderWidgetHostViewWin::DoPopupOrFullscreenInit(HWND parent_hwnd, | 2953 void RenderWidgetHostViewWin::DoPopupOrFullscreenInit(HWND parent_hwnd, |
| 2952 const gfx::Rect& pos, | 2954 const gfx::Rect& pos, |
| 2953 DWORD ex_style) { | 2955 DWORD ex_style) { |
| 2954 close_on_deactivate_ = true; | |
| 2955 Create(parent_hwnd, NULL, NULL, WS_POPUP, ex_style); | 2956 Create(parent_hwnd, NULL, NULL, WS_POPUP, ex_style); |
| 2956 MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE); | 2957 MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE); |
| 2957 ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA); | 2958 ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA); |
| 2958 } | 2959 } |
| 2959 | 2960 |
| 2960 CPoint RenderWidgetHostViewWin::GetClientCenter() const { | 2961 CPoint RenderWidgetHostViewWin::GetClientCenter() const { |
| 2961 CRect rect; | 2962 CRect rect; |
| 2962 GetClientRect(&rect); | 2963 GetClientRect(&rect); |
| 2963 return rect.CenterPoint(); | 2964 return rect.CenterPoint(); |
| 2964 } | 2965 } |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3148 // receive a focus change in the context of a pointer down message, it means | 3149 // receive a focus change in the context of a pointer down message, it means |
| 3149 // that the pointer down message occurred on the edit field and we should | 3150 // that the pointer down message occurred on the edit field and we should |
| 3150 // display the on screen keyboard | 3151 // display the on screen keyboard |
| 3151 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 3152 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
| 3152 DisplayOnScreenKeyboardIfNeeded(); | 3153 DisplayOnScreenKeyboardIfNeeded(); |
| 3153 received_focus_change_after_pointer_down_ = false; | 3154 received_focus_change_after_pointer_down_ = false; |
| 3154 pointer_down_context_ = false; | 3155 pointer_down_context_ = false; |
| 3155 } | 3156 } |
| 3156 | 3157 |
| 3157 } // namespace content | 3158 } // namespace content |
| OLD | NEW |