Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(33)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_win.cc

Issue 10826176: Merge 150162 - Prevent Flash from dropping focus on fullscreen change (Closed) Base URL: svn://svn.chromium.org/chrome/branches/1180/src/
Patch Set: Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_win.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 615 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: 626 // RenderWidgetHostViewWin, RenderWidgetHostView implementation:
627 627
628 void RenderWidgetHostViewWin::InitAsChild( 628 void RenderWidgetHostViewWin::InitAsChild(
629 gfx::NativeView parent_view) { 629 gfx::NativeView parent_view) {
630 parent_hwnd_ = parent_view; 630 parent_hwnd_ = parent_view;
631 CreateWnd(parent_view); 631 CreateWnd(parent_view);
632 } 632 }
633 633
634 void RenderWidgetHostViewWin::InitAsPopup( 634 void RenderWidgetHostViewWin::InitAsPopup(
635 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { 635 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
636 close_on_deactivate_ = true;
636 DoPopupOrFullscreenInit(parent_host_view->GetNativeView(), pos, 637 DoPopupOrFullscreenInit(parent_host_view->GetNativeView(), pos,
637 WS_EX_TOOLWINDOW); 638 WS_EX_TOOLWINDOW);
638 } 639 }
639 640
640 void RenderWidgetHostViewWin::InitAsFullscreen( 641 void RenderWidgetHostViewWin::InitAsFullscreen(
641 RenderWidgetHostView* reference_host_view) { 642 RenderWidgetHostView* reference_host_view) {
642 gfx::Rect pos = gfx::Screen::GetDisplayNearestWindow( 643 gfx::Rect pos = gfx::Screen::GetDisplayNearestWindow(
643 reference_host_view->GetNativeView()).bounds(); 644 reference_host_view->GetNativeView()).bounds();
644 is_fullscreen_ = true; 645 is_fullscreen_ = true;
645 DoPopupOrFullscreenInit(ui::GetWindowToParentTo(true), pos, 0); 646 DoPopupOrFullscreenInit(ui::GetWindowToParentTo(true), pos, 0);
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCaptureChanged"); 1595 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCaptureChanged");
1595 if (render_widget_host_) 1596 if (render_widget_host_)
1596 render_widget_host_->LostCapture(); 1597 render_widget_host_->LostCapture();
1597 } 1598 }
1598 1599
1599 void RenderWidgetHostViewWin::OnCancelMode() { 1600 void RenderWidgetHostViewWin::OnCancelMode() {
1600 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCancelMode"); 1601 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCancelMode");
1601 if (render_widget_host_) 1602 if (render_widget_host_)
1602 render_widget_host_->LostCapture(); 1603 render_widget_host_->LostCapture();
1603 1604
1604 if (close_on_deactivate_ && !weak_factory_.HasWeakPtrs()) { 1605 if ((is_fullscreen_ || close_on_deactivate_) &&
1606 !weak_factory_.HasWeakPtrs()) {
1605 // Dismiss popups and menus. We do this asynchronously to avoid changing 1607 // Dismiss popups and menus. We do this asynchronously to avoid changing
1606 // activation within this callstack, which may interfere with another window 1608 // activation within this callstack, which may interfere with another window
1607 // being activated. We can synchronously hide the window, but we need to 1609 // being activated. We can synchronously hide the window, but we need to
1608 // not change activation while doing so. 1610 // not change activation while doing so.
1609 SetWindowPos(NULL, 0, 0, 0, 0, 1611 SetWindowPos(NULL, 0, 0, 0, 0,
1610 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | 1612 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
1611 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); 1613 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
1612 MessageLoop::current()->PostTask(FROM_HERE, 1614 MessageLoop::current()->PostTask(FROM_HERE,
1613 base::Bind(&RenderWidgetHostViewWin::ShutdownHost, 1615 base::Bind(&RenderWidgetHostViewWin::ShutdownHost,
1614 weak_factory_.GetWeakPtr())); 1616 weak_factory_.GetWeakPtr()));
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 // convert the click from the popup window coordinates to the WebContentsImpl' 1873 // convert the click from the popup window coordinates to the WebContentsImpl'
1872 // window coordinates. For now we don't forward the message in that case to 1874 // window coordinates. For now we don't forward the message in that case to
1873 // address bug #907474. 1875 // address bug #907474.
1874 // Note: GetParent() on popup windows returns the top window and not the 1876 // Note: GetParent() on popup windows returns the top window and not the
1875 // parent the window was created with (the parent and the owner of the popup 1877 // parent the window was created with (the parent and the owner of the popup
1876 // is the first non-child view of the view that was specified to the create 1878 // is the first non-child view of the view that was specified to the create
1877 // call). So the WebContentsImpl's window would have to be specified to the 1879 // call). So the WebContentsImpl's window would have to be specified to the
1878 // RenderViewHostHWND as there is no way to retrieve it from the HWND. 1880 // RenderViewHostHWND as there is no way to retrieve it from the HWND.
1879 1881
1880 // Don't forward if the container is a popup or fullscreen widget. 1882 // Don't forward if the container is a popup or fullscreen widget.
1881 if (!close_on_deactivate_) { 1883 if (!is_fullscreen_ && !close_on_deactivate_) {
1882 switch (message) { 1884 switch (message) {
1883 case WM_LBUTTONDOWN: 1885 case WM_LBUTTONDOWN:
1884 case WM_MBUTTONDOWN: 1886 case WM_MBUTTONDOWN:
1885 case WM_RBUTTONDOWN: 1887 case WM_RBUTTONDOWN:
1886 // Finish the ongoing composition whenever a mouse click happens. 1888 // Finish the ongoing composition whenever a mouse click happens.
1887 // It matches IE's behavior. 1889 // It matches IE's behavior.
1888 ime_input_.CleanupComposition(m_hWnd); 1890 ime_input_.CleanupComposition(m_hWnd);
1889 // Fall through. 1891 // Fall through.
1890 case WM_MOUSEMOVE: 1892 case WM_MOUSEMOVE:
1891 case WM_MOUSELEAVE: { 1893 case WM_MOUSELEAVE: {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1926 SendMessage(WM_CANCELMODE); 1928 SendMessage(WM_CANCELMODE);
1927 return 0; 1929 return 0;
1928 } 1930 }
1929 } 1931 }
1930 1932
1931 // If we are a pop-up, forward tab related messages to our parent HWND, so 1933 // If we are a pop-up, forward tab related messages to our parent HWND, so
1932 // that we are dismissed appropriately and so that the focus advance in our 1934 // that we are dismissed appropriately and so that the focus advance in our
1933 // parent. 1935 // parent.
1934 // TODO(jcampan): http://b/issue?id=1192881 Could be abstracted in the 1936 // TODO(jcampan): http://b/issue?id=1192881 Could be abstracted in the
1935 // FocusManager. 1937 // FocusManager.
1936 if (close_on_deactivate_ && !is_fullscreen_ && 1938 if (close_on_deactivate_ &&
1937 (((message == WM_KEYDOWN || message == WM_KEYUP) && (wparam == VK_TAB)) || 1939 (((message == WM_KEYDOWN || message == WM_KEYUP) && (wparam == VK_TAB)) ||
1938 (message == WM_CHAR && wparam == L'\t'))) { 1940 (message == WM_CHAR && wparam == L'\t'))) {
1939 DCHECK(parent_hwnd_); 1941 DCHECK(parent_hwnd_);
1940 // First close the pop-up. 1942 // First close the pop-up.
1941 SendMessage(WM_CANCELMODE); 1943 SendMessage(WM_CANCELMODE);
1942 // Then move the focus by forwarding the tab key to the parent. 1944 // Then move the focus by forwarding the tab key to the parent.
1943 return ::SendMessage(parent_hwnd_, message, wparam, lparam); 1945 return ::SendMessage(parent_hwnd_, message, wparam, lparam);
1944 } 1946 }
1945 1947
1946 if (!render_widget_host_) 1948 if (!render_widget_host_)
(...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after
2911 weak_factory_.InvalidateWeakPtrs(); 2913 weak_factory_.InvalidateWeakPtrs();
2912 if (render_widget_host_) 2914 if (render_widget_host_)
2913 render_widget_host_->Shutdown(); 2915 render_widget_host_->Shutdown();
2914 // Do not touch any members at this point, |this| has been deleted. 2916 // Do not touch any members at this point, |this| has been deleted.
2915 } 2917 }
2916 2918
2917 void RenderWidgetHostViewWin::DoPopupOrFullscreenInit(HWND parent_hwnd, 2919 void RenderWidgetHostViewWin::DoPopupOrFullscreenInit(HWND parent_hwnd,
2918 const gfx::Rect& pos, 2920 const gfx::Rect& pos,
2919 DWORD ex_style) { 2921 DWORD ex_style) {
2920 parent_hwnd_ = parent_hwnd; 2922 parent_hwnd_ = parent_hwnd;
2921 close_on_deactivate_ = true;
2922 Create(parent_hwnd_, NULL, NULL, WS_POPUP, ex_style); 2923 Create(parent_hwnd_, NULL, NULL, WS_POPUP, ex_style);
2923 MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE); 2924 MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE);
2924 ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA); 2925 ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA);
2925 } 2926 }
2926 2927
2927 CPoint RenderWidgetHostViewWin::GetClientCenter() const { 2928 CPoint RenderWidgetHostViewWin::GetClientCenter() const {
2928 CRect rect; 2929 CRect rect;
2929 GetClientRect(&rect); 2930 GetClientRect(&rect);
2930 return rect.CenterPoint(); 2931 return rect.CenterPoint();
2931 } 2932 }
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
3089 void RenderWidgetHostViewWin::ResetPointerDownContext() { 3090 void RenderWidgetHostViewWin::ResetPointerDownContext() {
3090 // If the default focus on the page is on an edit field and we did not 3091 // If the default focus on the page is on an edit field and we did not
3091 // receive a focus change in the context of a pointer down message, it means 3092 // receive a focus change in the context of a pointer down message, it means
3092 // that the pointer down message occurred on the edit field and we should 3093 // that the pointer down message occurred on the edit field and we should
3093 // display the on screen keyboard 3094 // display the on screen keyboard
3094 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) 3095 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_)
3095 DisplayOnScreenKeyboardIfNeeded(); 3096 DisplayOnScreenKeyboardIfNeeded();
3096 received_focus_change_after_pointer_down_ = false; 3097 received_focus_change_after_pointer_down_ = false;
3097 pointer_down_context_ = false; 3098 pointer_down_context_ = false;
3098 } 3099 }
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_win.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698