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 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 } | 395 } |
396 | 396 |
397 RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const { | 397 RenderWidgetHost* RenderWidgetHostViewWin::GetRenderWidgetHost() const { |
398 return render_widget_host_; | 398 return render_widget_host_; |
399 } | 399 } |
400 | 400 |
401 void RenderWidgetHostViewWin::DidBecomeSelected() { | 401 void RenderWidgetHostViewWin::DidBecomeSelected() { |
402 if (!is_hidden_) | 402 if (!is_hidden_) |
403 return; | 403 return; |
404 | 404 |
405 if (tab_switch_paint_time_.is_null()) | 405 if (web_contents_switch_paint_time_.is_null()) |
406 tab_switch_paint_time_ = TimeTicks::Now(); | 406 web_contents_switch_paint_time_ = TimeTicks::Now(); |
407 is_hidden_ = false; | 407 is_hidden_ = false; |
408 EnsureTooltip(); | 408 EnsureTooltip(); |
409 | 409 |
410 // |render_widget_host_| may be NULL if the TabContents is in the process of | 410 // |render_widget_host_| may be NULL if the WebContentsImpl is in the process |
411 // closing. | 411 // of closing. |
412 if (render_widget_host_) | 412 if (render_widget_host_) |
413 render_widget_host_->WasRestored(); | 413 render_widget_host_->WasRestored(); |
414 } | 414 } |
415 | 415 |
416 void RenderWidgetHostViewWin::WasHidden() { | 416 void RenderWidgetHostViewWin::WasHidden() { |
417 if (is_hidden_) | 417 if (is_hidden_) |
418 return; | 418 return; |
419 | 419 |
420 // If we receive any more paint messages while we are hidden, we want to | 420 // If we receive any more paint messages while we are hidden, we want to |
421 // ignore them so we don't re-allocate the backing store. We will paint | 421 // ignore them so we don't re-allocate the backing store. We will paint |
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 DrawBackground(r, &paint_dc); | 1169 DrawBackground(r, &paint_dc); |
1170 } | 1170 } |
1171 if (!whiteout_start_time_.is_null()) { | 1171 if (!whiteout_start_time_.is_null()) { |
1172 TimeDelta whiteout_duration = TimeTicks::Now() - whiteout_start_time_; | 1172 TimeDelta whiteout_duration = TimeTicks::Now() - whiteout_start_time_; |
1173 UMA_HISTOGRAM_TIMES("MPArch.RWHH_WhiteoutDuration", whiteout_duration); | 1173 UMA_HISTOGRAM_TIMES("MPArch.RWHH_WhiteoutDuration", whiteout_duration); |
1174 | 1174 |
1175 // Reset the start time to 0 so that we start recording again the next | 1175 // Reset the start time to 0 so that we start recording again the next |
1176 // time the backing store is NULL... | 1176 // time the backing store is NULL... |
1177 whiteout_start_time_ = TimeTicks(); | 1177 whiteout_start_time_ = TimeTicks(); |
1178 } | 1178 } |
1179 if (!tab_switch_paint_time_.is_null()) { | 1179 if (!web_contents_switch_paint_time_.is_null()) { |
1180 TimeDelta tab_switch_paint_duration = TimeTicks::Now() - | 1180 TimeDelta web_contents_switch_paint_duration = TimeTicks::Now() - |
1181 tab_switch_paint_time_; | 1181 web_contents_switch_paint_time_; |
1182 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", | 1182 UMA_HISTOGRAM_TIMES("MPArch.RWH_TabSwitchPaintDuration", |
1183 tab_switch_paint_duration); | 1183 web_contents_switch_paint_duration); |
1184 // Reset tab_switch_paint_time_ to 0 so future tab selections are | 1184 // Reset contents_switch_paint_time_ to 0 so future tab selections are |
1185 // recorded. | 1185 // recorded. |
1186 tab_switch_paint_time_ = TimeTicks(); | 1186 web_contents_switch_paint_time_ = TimeTicks(); |
1187 } | 1187 } |
1188 } else { | 1188 } else { |
1189 DrawBackground(paint_dc.m_ps.rcPaint, &paint_dc); | 1189 DrawBackground(paint_dc.m_ps.rcPaint, &paint_dc); |
1190 if (whiteout_start_time_.is_null()) | 1190 if (whiteout_start_time_.is_null()) |
1191 whiteout_start_time_ = TimeTicks::Now(); | 1191 whiteout_start_time_ = TimeTicks::Now(); |
1192 } | 1192 } |
1193 } | 1193 } |
1194 | 1194 |
1195 void RenderWidgetHostViewWin::DrawBackground(const RECT& dirty_rect, | 1195 void RenderWidgetHostViewWin::DrawBackground(const RECT& dirty_rect, |
1196 CPaintDC* dc) { | 1196 CPaintDC* dc) { |
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1523 MSG msg; | 1523 MSG msg; |
1524 msg.hwnd = m_hWnd; | 1524 msg.hwnd = m_hWnd; |
1525 msg.message = message; | 1525 msg.message = message; |
1526 msg.wParam = wparam; | 1526 msg.wParam = wparam; |
1527 msg.lParam = lparam; | 1527 msg.lParam = lparam; |
1528 SendMessage(tooltip_hwnd_, TTM_RELAYEVENT, NULL, | 1528 SendMessage(tooltip_hwnd_, TTM_RELAYEVENT, NULL, |
1529 reinterpret_cast<LPARAM>(&msg)); | 1529 reinterpret_cast<LPARAM>(&msg)); |
1530 } | 1530 } |
1531 | 1531 |
1532 // TODO(jcampan): I am not sure if we should forward the message to the | 1532 // TODO(jcampan): I am not sure if we should forward the message to the |
1533 // TabContents first in the case of popups. If we do, we would need to | 1533 // WebContentsImpl first in the case of popups. If we do, we would need to |
1534 // convert the click from the popup window coordinates to the TabContents' | 1534 // convert the click from the popup window coordinates to the WebContentsImpl' |
1535 // window coordinates. For now we don't forward the message in that case to | 1535 // window coordinates. For now we don't forward the message in that case to |
1536 // address bug #907474. | 1536 // address bug #907474. |
1537 // Note: GetParent() on popup windows returns the top window and not the | 1537 // Note: GetParent() on popup windows returns the top window and not the |
1538 // parent the window was created with (the parent and the owner of the popup | 1538 // parent the window was created with (the parent and the owner of the popup |
1539 // is the first non-child view of the view that was specified to the create | 1539 // is the first non-child view of the view that was specified to the create |
1540 // call). So the TabContents window would have to be specified to the | 1540 // call). So the WebContentsImpl's window would have to be specified to the |
1541 // RenderViewHostHWND as there is no way to retrieve it from the HWND. | 1541 // RenderViewHostHWND as there is no way to retrieve it from the HWND. |
1542 | 1542 |
1543 // Don't forward if the container is a popup or fullscreen widget. | 1543 // Don't forward if the container is a popup or fullscreen widget. |
1544 if (!is_fullscreen_ && !close_on_deactivate_) { | 1544 if (!is_fullscreen_ && !close_on_deactivate_) { |
1545 switch (message) { | 1545 switch (message) { |
1546 case WM_LBUTTONDOWN: | 1546 case WM_LBUTTONDOWN: |
1547 case WM_MBUTTONDOWN: | 1547 case WM_MBUTTONDOWN: |
1548 case WM_RBUTTONDOWN: | 1548 case WM_RBUTTONDOWN: |
1549 // Finish the ongoing composition whenever a mouse click happens. | 1549 // Finish the ongoing composition whenever a mouse click happens. |
1550 // It matches IE's behavior. | 1550 // It matches IE's behavior. |
1551 ime_input_.CleanupComposition(m_hWnd); | 1551 ime_input_.CleanupComposition(m_hWnd); |
1552 // Fall through. | 1552 // Fall through. |
1553 case WM_MOUSEMOVE: | 1553 case WM_MOUSEMOVE: |
1554 case WM_MOUSELEAVE: { | 1554 case WM_MOUSELEAVE: { |
1555 // Give the TabContents first crack at the message. It may want to | 1555 // Give the WebContentsImpl first crack at the message. It may want to |
1556 // prevent forwarding to the renderer if some higher level browser | 1556 // prevent forwarding to the renderer if some higher level browser |
1557 // functionality is invoked. | 1557 // functionality is invoked. |
1558 LPARAM parent_msg_lparam = lparam; | 1558 LPARAM parent_msg_lparam = lparam; |
1559 if (message != WM_MOUSELEAVE) { | 1559 if (message != WM_MOUSELEAVE) { |
1560 // For the messages except WM_MOUSELEAVE, before forwarding them to | 1560 // For the messages except WM_MOUSELEAVE, before forwarding them to |
1561 // parent window, we should adjust cursor position from client | 1561 // parent window, we should adjust cursor position from client |
1562 // coordinates in current window to client coordinates in its parent | 1562 // coordinates in current window to client coordinates in its parent |
1563 // window. | 1563 // window. |
1564 CPoint cursor_pos(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); | 1564 CPoint cursor_pos(GET_X_LPARAM(lparam), GET_Y_LPARAM(lparam)); |
1565 ClientToScreen(&cursor_pos); | 1565 ClientToScreen(&cursor_pos); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1689 // we have any owned popup windows in the foreground and dismiss them. | 1689 // we have any owned popup windows in the foreground and dismiss them. |
1690 if (m_hWnd != GetForegroundWindow()) { | 1690 if (m_hWnd != GetForegroundWindow()) { |
1691 HWND toplevel_hwnd = ::GetAncestor(m_hWnd, GA_ROOT); | 1691 HWND toplevel_hwnd = ::GetAncestor(m_hWnd, GA_ROOT); |
1692 EnumThreadWindows( | 1692 EnumThreadWindows( |
1693 GetCurrentThreadId(), | 1693 GetCurrentThreadId(), |
1694 DismissOwnedPopups, | 1694 DismissOwnedPopups, |
1695 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 1695 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
1696 } | 1696 } |
1697 | 1697 |
1698 // This is a bit of a hack, but will work for now since we don't want to | 1698 // This is a bit of a hack, but will work for now since we don't want to |
1699 // pollute this object with TabContents-specific functionality... | 1699 // pollute this object with WebContentsImpl-specific functionality... |
1700 bool handled_by_TabContents = false; | 1700 bool handled_by_WebContentsImpl = false; |
1701 if (!is_fullscreen_ && GetParent()) { | 1701 if (!is_fullscreen_ && GetParent()) { |
1702 // Use a special reflected message to break recursion. If we send | 1702 // Use a special reflected message to break recursion. If we send |
1703 // WM_MOUSEWHEEL, the focus manager subclass of web contents will | 1703 // WM_MOUSEWHEEL, the focus manager subclass of web contents will |
1704 // route it back here. | 1704 // route it back here. |
1705 MSG new_message = {0}; | 1705 MSG new_message = {0}; |
1706 new_message.hwnd = m_hWnd; | 1706 new_message.hwnd = m_hWnd; |
1707 new_message.message = message; | 1707 new_message.message = message; |
1708 new_message.wParam = wparam; | 1708 new_message.wParam = wparam; |
1709 new_message.lParam = lparam; | 1709 new_message.lParam = lparam; |
1710 | 1710 |
1711 handled_by_TabContents = | 1711 handled_by_WebContentsImpl = |
1712 !!::SendMessage(GetParent(), base::win::kReflectedMessage, 0, | 1712 !!::SendMessage(GetParent(), base::win::kReflectedMessage, 0, |
1713 reinterpret_cast<LPARAM>(&new_message)); | 1713 reinterpret_cast<LPARAM>(&new_message)); |
1714 } | 1714 } |
1715 | 1715 |
1716 if (!handled_by_TabContents && render_widget_host_) { | 1716 if (!handled_by_WebContentsImpl && render_widget_host_) { |
1717 render_widget_host_->ForwardWheelEvent( | 1717 render_widget_host_->ForwardWheelEvent( |
1718 WebInputEventFactory::mouseWheelEvent(m_hWnd, message, wparam, | 1718 WebInputEventFactory::mouseWheelEvent(m_hWnd, message, wparam, |
1719 lparam)); | 1719 lparam)); |
1720 } | 1720 } |
1721 handled = TRUE; | 1721 handled = TRUE; |
1722 return 0; | 1722 return 0; |
1723 } | 1723 } |
1724 | 1724 |
1725 RenderWidgetHostViewWin::WebTouchState::WebTouchState(const CWindowImpl* window) | 1725 RenderWidgetHostViewWin::WebTouchState::WebTouchState(const CWindowImpl* window) |
1726 : window_(window) { } | 1726 : window_(window) { } |
(...skipping 957 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2684 void RenderWidgetHostViewWin::ResetPointerDownContext() { | 2684 void RenderWidgetHostViewWin::ResetPointerDownContext() { |
2685 // If the default focus on the page is on an edit field and we did not | 2685 // If the default focus on the page is on an edit field and we did not |
2686 // receive a focus change in the context of a pointer down message, it means | 2686 // receive a focus change in the context of a pointer down message, it means |
2687 // that the pointer down message occurred on the edit field and we should | 2687 // that the pointer down message occurred on the edit field and we should |
2688 // display the on screen keyboard | 2688 // display the on screen keyboard |
2689 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) | 2689 if (!received_focus_change_after_pointer_down_ && virtual_keyboard_) |
2690 DisplayOnScreenKeyboardIfNeeded(); | 2690 DisplayOnScreenKeyboardIfNeeded(); |
2691 received_focus_change_after_pointer_down_ = false; | 2691 received_focus_change_after_pointer_down_ = false; |
2692 pointer_down_context_ = false; | 2692 pointer_down_context_ = false; |
2693 } | 2693 } |
OLD | NEW |