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

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

Issue 10779023: Fix focus notification for Flash fullscreen. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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
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 <map> 8 #include <map>
9 #include <peninputpanel_i.c> 9 #include <peninputpanel_i.c>
10 #include <stack> 10 #include <stack>
(...skipping 641 matching lines...) Expand 10 before | Expand all | Expand 10 after
652 /////////////////////////////////////////////////////////////////////////////// 652 ///////////////////////////////////////////////////////////////////////////////
653 // RenderWidgetHostViewWin, RenderWidgetHostView implementation: 653 // RenderWidgetHostViewWin, RenderWidgetHostView implementation:
654 654
655 void RenderWidgetHostViewWin::InitAsChild( 655 void RenderWidgetHostViewWin::InitAsChild(
656 gfx::NativeView parent_view) { 656 gfx::NativeView parent_view) {
657 CreateWnd(parent_view); 657 CreateWnd(parent_view);
658 } 658 }
659 659
660 void RenderWidgetHostViewWin::InitAsPopup( 660 void RenderWidgetHostViewWin::InitAsPopup(
661 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) { 661 RenderWidgetHostView* parent_host_view, const gfx::Rect& pos) {
662 close_on_deactivate_ = true;
663 DoPopupOrFullscreenInit(parent_host_view->GetNativeView(), pos, 662 DoPopupOrFullscreenInit(parent_host_view->GetNativeView(), pos,
664 WS_EX_TOOLWINDOW); 663 WS_EX_TOOLWINDOW);
665 } 664 }
666 665
667 void RenderWidgetHostViewWin::InitAsFullscreen( 666 void RenderWidgetHostViewWin::InitAsFullscreen(
668 RenderWidgetHostView* reference_host_view) { 667 RenderWidgetHostView* reference_host_view) {
669 gfx::Rect pos = gfx::Screen::GetDisplayNearestWindow( 668 gfx::Rect pos = gfx::Screen::GetDisplayNearestWindow(
670 reference_host_view->GetNativeView()).bounds(); 669 reference_host_view->GetNativeView()).bounds();
671 is_fullscreen_ = true; 670 is_fullscreen_ = true;
672 DoPopupOrFullscreenInit(ui::GetWindowToParentTo(true), pos, 0); 671 DoPopupOrFullscreenInit(ui::GetWindowToParentTo(true), pos, 0);
(...skipping 936 matching lines...) Expand 10 before | Expand all | Expand 10 after
1609 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCaptureChanged"); 1608 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCaptureChanged");
1610 if (render_widget_host_) 1609 if (render_widget_host_)
1611 render_widget_host_->LostCapture(); 1610 render_widget_host_->LostCapture();
1612 } 1611 }
1613 1612
1614 void RenderWidgetHostViewWin::OnCancelMode() { 1613 void RenderWidgetHostViewWin::OnCancelMode() {
1615 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCancelMode"); 1614 TRACE_EVENT0("browser", "RenderWidgetHostViewWin::OnCancelMode");
1616 if (render_widget_host_) 1615 if (render_widget_host_)
1617 render_widget_host_->LostCapture(); 1616 render_widget_host_->LostCapture();
1618 1617
1619 if ((is_fullscreen_ || close_on_deactivate_) && 1618 if (close_on_deactivate_ && !weak_factory_.HasWeakPtrs()) {
1620 !weak_factory_.HasWeakPtrs()) {
1621 // Dismiss popups and menus. We do this asynchronously to avoid changing 1619 // Dismiss popups and menus. We do this asynchronously to avoid changing
1622 // activation within this callstack, which may interfere with another window 1620 // activation within this callstack, which may interfere with another window
1623 // being activated. We can synchronously hide the window, but we need to 1621 // being activated. We can synchronously hide the window, but we need to
1624 // not change activation while doing so. 1622 // not change activation while doing so.
1625 SetWindowPos(NULL, 0, 0, 0, 0, 1623 SetWindowPos(NULL, 0, 0, 0, 0,
1626 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE | 1624 SWP_HIDEWINDOW | SWP_NOACTIVATE | SWP_NOMOVE |
1627 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER); 1625 SWP_NOREPOSITION | SWP_NOSIZE | SWP_NOZORDER);
1628 MessageLoop::current()->PostTask(FROM_HERE, 1626 MessageLoop::current()->PostTask(FROM_HERE,
1629 base::Bind(&RenderWidgetHostViewWin::ShutdownHost, 1627 base::Bind(&RenderWidgetHostViewWin::ShutdownHost,
1630 weak_factory_.GetWeakPtr())); 1628 weak_factory_.GetWeakPtr()));
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1889 // convert the click from the popup window coordinates to the WebContentsImpl' 1887 // convert the click from the popup window coordinates to the WebContentsImpl'
1890 // window coordinates. For now we don't forward the message in that case to 1888 // window coordinates. For now we don't forward the message in that case to
1891 // address bug #907474. 1889 // address bug #907474.
1892 // Note: GetParent() on popup windows returns the top window and not the 1890 // Note: GetParent() on popup windows returns the top window and not the
1893 // parent the window was created with (the parent and the owner of the popup 1891 // parent the window was created with (the parent and the owner of the popup
1894 // is the first non-child view of the view that was specified to the create 1892 // is the first non-child view of the view that was specified to the create
1895 // call). So the WebContentsImpl's window would have to be specified to the 1893 // call). So the WebContentsImpl's window would have to be specified to the
1896 // RenderViewHostHWND as there is no way to retrieve it from the HWND. 1894 // RenderViewHostHWND as there is no way to retrieve it from the HWND.
1897 1895
1898 // Don't forward if the container is a popup or fullscreen widget. 1896 // Don't forward if the container is a popup or fullscreen widget.
1899 if (!is_fullscreen_ && !close_on_deactivate_) { 1897 if (!close_on_deactivate_) {
1900 switch (message) { 1898 switch (message) {
1901 case WM_LBUTTONDOWN: 1899 case WM_LBUTTONDOWN:
1902 case WM_MBUTTONDOWN: 1900 case WM_MBUTTONDOWN:
1903 case WM_RBUTTONDOWN: 1901 case WM_RBUTTONDOWN:
1904 // Finish the ongoing composition whenever a mouse click happens. 1902 // Finish the ongoing composition whenever a mouse click happens.
1905 // It matches IE's behavior. 1903 // It matches IE's behavior.
1906 ime_input_.CleanupComposition(m_hWnd); 1904 ime_input_.CleanupComposition(m_hWnd);
1907 // Fall through. 1905 // Fall through.
1908 case WM_MOUSEMOVE: 1906 case WM_MOUSEMOVE:
1909 case WM_MOUSELEAVE: { 1907 case WM_MOUSELEAVE: {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1944 SendMessage(WM_CANCELMODE); 1942 SendMessage(WM_CANCELMODE);
1945 return 0; 1943 return 0;
1946 } 1944 }
1947 } 1945 }
1948 1946
1949 // If we are a pop-up, forward tab related messages to our parent HWND, so 1947 // If we are a pop-up, forward tab related messages to our parent HWND, so
1950 // that we are dismissed appropriately and so that the focus advance in our 1948 // that we are dismissed appropriately and so that the focus advance in our
1951 // parent. 1949 // parent.
1952 // TODO(jcampan): http://b/issue?id=1192881 Could be abstracted in the 1950 // TODO(jcampan): http://b/issue?id=1192881 Could be abstracted in the
1953 // FocusManager. 1951 // FocusManager.
1954 if (close_on_deactivate_ && 1952 if (close_on_deactivate_ && !is_fullscreen_ &&
1955 (((message == WM_KEYDOWN || message == WM_KEYUP) && (wparam == VK_TAB)) || 1953 (((message == WM_KEYDOWN || message == WM_KEYUP) && (wparam == VK_TAB)) ||
1956 (message == WM_CHAR && wparam == L'\t'))) { 1954 (message == WM_CHAR && wparam == L'\t'))) {
1957 // First close the pop-up. 1955 // First close the pop-up.
1958 SendMessage(WM_CANCELMODE); 1956 SendMessage(WM_CANCELMODE);
1959 // Then move the focus by forwarding the tab key to the parent. 1957 // Then move the focus by forwarding the tab key to the parent.
1960 return ::SendMessage(GetParent(), message, wparam, lparam); 1958 return ::SendMessage(GetParent(), message, wparam, lparam);
1961 } 1959 }
1962 1960
1963 if (!render_widget_host_) 1961 if (!render_widget_host_)
1964 return 0; 1962 return 0;
(...skipping 1001 matching lines...) Expand 10 before | Expand all | Expand 10 after
2966 void RenderWidgetHostViewWin::ShutdownHost() { 2964 void RenderWidgetHostViewWin::ShutdownHost() {
2967 weak_factory_.InvalidateWeakPtrs(); 2965 weak_factory_.InvalidateWeakPtrs();
2968 if (render_widget_host_) 2966 if (render_widget_host_)
2969 render_widget_host_->Shutdown(); 2967 render_widget_host_->Shutdown();
2970 // Do not touch any members at this point, |this| has been deleted. 2968 // Do not touch any members at this point, |this| has been deleted.
2971 } 2969 }
2972 2970
2973 void RenderWidgetHostViewWin::DoPopupOrFullscreenInit(HWND parent_hwnd, 2971 void RenderWidgetHostViewWin::DoPopupOrFullscreenInit(HWND parent_hwnd,
2974 const gfx::Rect& pos, 2972 const gfx::Rect& pos,
2975 DWORD ex_style) { 2973 DWORD ex_style) {
2974 close_on_deactivate_ = true;
2976 Create(parent_hwnd, NULL, NULL, WS_POPUP, ex_style); 2975 Create(parent_hwnd, NULL, NULL, WS_POPUP, ex_style);
2977 MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE); 2976 MoveWindow(pos.x(), pos.y(), pos.width(), pos.height(), TRUE);
2978 ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA); 2977 ShowWindow(IsActivatable() ? SW_SHOW : SW_SHOWNA);
2979 } 2978 }
2980 2979
2981 CPoint RenderWidgetHostViewWin::GetClientCenter() const { 2980 CPoint RenderWidgetHostViewWin::GetClientCenter() const {
2982 CRect rect; 2981 CRect rect;
2983 GetClientRect(&rect); 2982 GetClientRect(&rect);
2984 return rect.CenterPoint(); 2983 return rect.CenterPoint();
2985 } 2984 }
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
3167 void RenderWidgetHostViewWin::ResetPointerDownContext() { 3166 void RenderWidgetHostViewWin::ResetPointerDownContext() {
3168 // If the default focus on the page is on an edit field and we did not 3167 // If the default focus on the page is on an edit field and we did not
3169 // receive a focus change in the context of a pointer down message, it means 3168 // receive a focus change in the context of a pointer down message, it means
3170 // that the pointer down message occurred on the edit field and we should 3169 // that the pointer down message occurred on the edit field and we should
3171 // display the on screen keyboard 3170 // display the on screen keyboard
3172 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) 3171 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_)
3173 DisplayOnScreenKeyboardIfNeeded(); 3172 DisplayOnScreenKeyboardIfNeeded();
3174 received_focus_change_after_pointer_down_ = false; 3173 received_focus_change_after_pointer_down_ = false;
3175 pointer_down_context_ = false; 3174 pointer_down_context_ = false;
3176 } 3175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698