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_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 using WebKit::WebGestureEvent; | 78 using WebKit::WebGestureEvent; |
79 using WebKit::WebInputEvent; | 79 using WebKit::WebInputEvent; |
80 using WebKit::WebKeyboardEvent; | 80 using WebKit::WebKeyboardEvent; |
81 using WebKit::WebMouseEvent; | 81 using WebKit::WebMouseEvent; |
82 using WebKit::WebMouseWheelEvent; | 82 using WebKit::WebMouseWheelEvent; |
83 using WebKit::WebTextDirection; | 83 using WebKit::WebTextDirection; |
84 | 84 |
85 namespace content { | 85 namespace content { |
86 namespace { | 86 namespace { |
87 | 87 |
| 88 bool g_check_for_pending_resize_ack = true; |
| 89 |
88 // How long to (synchronously) wait for the renderer to respond with a | 90 // How long to (synchronously) wait for the renderer to respond with a |
89 // PaintRect message, when our backing-store is invalid, before giving up and | 91 // PaintRect message, when our backing-store is invalid, before giving up and |
90 // returning a null or incorrectly sized backing-store from GetBackingStore. | 92 // returning a null or incorrectly sized backing-store from GetBackingStore. |
91 // This timeout impacts the "choppiness" of our window resize perf. | 93 // This timeout impacts the "choppiness" of our window resize perf. |
92 const int kPaintMsgTimeoutMS = 50; | 94 const int kPaintMsgTimeoutMS = 50; |
93 | 95 |
94 // Returns |true| if the two wheel events should be coalesced. | 96 // Returns |true| if the two wheel events should be coalesced. |
95 bool ShouldCoalesceMouseWheelEvents(const WebMouseWheelEvent& last_event, | 97 bool ShouldCoalesceMouseWheelEvents(const WebMouseWheelEvent& last_event, |
96 const WebMouseWheelEvent& new_event) { | 98 const WebMouseWheelEvent& new_event) { |
97 return last_event.modifiers == new_event.modifiers && | 99 return last_event.modifiers == new_event.modifiers && |
(...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1208 } | 1210 } |
1209 | 1211 |
1210 void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) { | 1212 void RenderWidgetHostImpl::SendCursorVisibilityState(bool is_visible) { |
1211 Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible)); | 1213 Send(new InputMsg_CursorVisibilityChange(GetRoutingID(), is_visible)); |
1212 } | 1214 } |
1213 | 1215 |
1214 int64 RenderWidgetHostImpl::GetLatencyComponentId() { | 1216 int64 RenderWidgetHostImpl::GetLatencyComponentId() { |
1215 return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32); | 1217 return GetRoutingID() | (static_cast<int64>(GetProcess()->GetID()) << 32); |
1216 } | 1218 } |
1217 | 1219 |
| 1220 // static |
| 1221 void RenderWidgetHostImpl::DisableResizeAckCheckForTesting() { |
| 1222 g_check_for_pending_resize_ack = false; |
| 1223 } |
| 1224 |
1218 ui::LatencyInfo RenderWidgetHostImpl::NewInputLatencyInfo() { | 1225 ui::LatencyInfo RenderWidgetHostImpl::NewInputLatencyInfo() { |
1219 ui::LatencyInfo info; | 1226 ui::LatencyInfo info; |
1220 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_COMPONENT, | 1227 info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_COMPONENT, |
1221 GetLatencyComponentId(), | 1228 GetLatencyComponentId(), |
1222 ++last_input_number_); | 1229 ++last_input_number_); |
1223 return info; | 1230 return info; |
1224 } | 1231 } |
1225 | 1232 |
1226 void RenderWidgetHostImpl::SendInputEvent(const WebInputEvent& input_event, | 1233 void RenderWidgetHostImpl::SendInputEvent(const WebInputEvent& input_event, |
1227 int event_size, | 1234 int event_size, |
(...skipping 502 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 current_size_ = params.view_size; | 1737 current_size_ = params.view_size; |
1731 // Update our knowledge of the RenderWidget's scroll offset. | 1738 // Update our knowledge of the RenderWidget's scroll offset. |
1732 last_scroll_offset_ = params.scroll_offset; | 1739 last_scroll_offset_ = params.scroll_offset; |
1733 | 1740 |
1734 bool is_resize_ack = | 1741 bool is_resize_ack = |
1735 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); | 1742 ViewHostMsg_UpdateRect_Flags::is_resize_ack(params.flags); |
1736 | 1743 |
1737 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since | 1744 // resize_ack_pending_ needs to be cleared before we call DidPaintRect, since |
1738 // that will end up reaching GetBackingStore. | 1745 // that will end up reaching GetBackingStore. |
1739 if (is_resize_ack) { | 1746 if (is_resize_ack) { |
1740 DCHECK(resize_ack_pending_); | 1747 DCHECK(!g_check_for_pending_resize_ack || resize_ack_pending_); |
1741 resize_ack_pending_ = false; | 1748 resize_ack_pending_ = false; |
1742 in_flight_size_.SetSize(0, 0); | 1749 in_flight_size_.SetSize(0, 0); |
1743 } | 1750 } |
1744 | 1751 |
1745 bool is_repaint_ack = | 1752 bool is_repaint_ack = |
1746 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags); | 1753 ViewHostMsg_UpdateRect_Flags::is_repaint_ack(params.flags); |
1747 if (is_repaint_ack) { | 1754 if (is_repaint_ack) { |
1748 DCHECK(repaint_ack_pending_); | 1755 DCHECK(repaint_ack_pending_); |
1749 TRACE_EVENT_ASYNC_END0( | 1756 TRACE_EVENT_ASYNC_END0( |
1750 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); | 1757 "renderer_host", "RenderWidgetHostImpl::repaint_ack_pending_", this); |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2503 } | 2510 } |
2504 | 2511 |
2505 void RenderWidgetHostImpl::DetachDelegate() { | 2512 void RenderWidgetHostImpl::DetachDelegate() { |
2506 delegate_ = NULL; | 2513 delegate_ = NULL; |
2507 } | 2514 } |
2508 | 2515 |
2509 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { | 2516 void RenderWidgetHostImpl::FrameSwapped(const ui::LatencyInfo& latency_info) { |
2510 } | 2517 } |
2511 | 2518 |
2512 } // namespace content | 2519 } // namespace content |
OLD | NEW |