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 1121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1132 // touch-events do not reset or contribute to the overscroll gesture. | 1132 // touch-events do not reset or contribute to the overscroll gesture. |
1133 // However, the touch-events are not sent to the renderer. So send and ACK | 1133 // However, the touch-events are not sent to the renderer. So send and ACK |
1134 // to the touch-event queue immediately. Mark the event as not processed, | 1134 // to the touch-event queue immediately. Mark the event as not processed, |
1135 // to make sure that the touch-scroll gesture that initiated the | 1135 // to make sure that the touch-scroll gesture that initiated the |
1136 // overscroll is updated properly. | 1136 // overscroll is updated properly. |
1137 touch_event_queue_->ProcessTouchAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 1137 touch_event_queue_->ProcessTouchAck(INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
1138 } | 1138 } |
1139 return; | 1139 return; |
1140 } | 1140 } |
1141 | 1141 |
1142 in_process_event_types_.push(input_event.type); | 1142 in_process_event_types_.push_back(input_event.type); |
1143 | 1143 |
1144 // Transmit any pending wheel events on a non-wheel event. This ensures that | 1144 // Transmit any pending wheel events on a non-wheel event. This ensures that |
1145 // the renderer receives the final PhaseEnded wheel event, which is necessary | 1145 // the renderer receives the final PhaseEnded wheel event, which is necessary |
1146 // to terminate rubber-banding, for example. | 1146 // to terminate rubber-banding, for example. |
1147 if (input_event.type != WebInputEvent::MouseWheel) { | 1147 if (input_event.type != WebInputEvent::MouseWheel) { |
1148 for (size_t i = 0; i < coalesced_mouse_wheel_events_.size(); ++i) { | 1148 for (size_t i = 0; i < coalesced_mouse_wheel_events_.size(); ++i) { |
1149 SendInputEvent(coalesced_mouse_wheel_events_[i], | 1149 SendInputEvent(coalesced_mouse_wheel_events_[i], |
1150 sizeof(WebMouseWheelEvent), false); | 1150 sizeof(WebMouseWheelEvent), false); |
1151 } | 1151 } |
1152 coalesced_mouse_wheel_events_.clear(); | 1152 coalesced_mouse_wheel_events_.clear(); |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1686 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); | 1686 UMA_HISTOGRAM_TIMES("MPArch.RWH_TotalPaintTime", delta); |
1687 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectComplete", | 1687 UNSHIPPED_TRACE_EVENT_INSTANT1("test_latency", "UpdateRectComplete", |
1688 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y()); | 1688 "x+y", params.bitmap_rect.x() + params.bitmap_rect.y()); |
1689 } | 1689 } |
1690 | 1690 |
1691 void RenderWidgetHostImpl::OnInputEventAck( | 1691 void RenderWidgetHostImpl::OnInputEventAck( |
1692 WebInputEvent::Type event_type, InputEventAckState ack_result) { | 1692 WebInputEvent::Type event_type, InputEventAckState ack_result) { |
1693 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnInputEventAck"); | 1693 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::OnInputEventAck"); |
1694 bool processed = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); | 1694 bool processed = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); |
1695 | 1695 |
1696 if (!in_process_event_types_.empty() && | 1696 if (!in_process_event_types_.empty()) { |
1697 in_process_event_types_.front() == event_type) | 1697 bool found = false; |
nduca
2013/01/10 20:34:33
Should we pull this edit out to its own cl? This s
bulach
2013/01/11 10:42:07
good idea! I split it into:
https://codereview.chr
| |
1698 in_process_event_types_.pop(); | 1698 for (std::deque<WebKit::WebInputEvent::Type>::iterator i = |
1699 in_process_event_types_.begin(); | |
1700 i != in_process_event_types_.end(); ++ i) { | |
Sami
2013/01/10 19:45:34
Nit: no space between ++ and i.
bulach
2013/01/11 10:42:07
Done.
| |
1701 if (*i == event_type) { | |
1702 in_process_event_types_.erase(i); | |
1703 found = true; | |
1704 break; | |
1705 } else { | |
1706 // Ensure we're not ACK'ing out of |type| order. The reason is that | |
1707 // we push the event stream in system order |in_process_event_types_|, | |
1708 // however there are various internal queues for gesture / touch / etc | |
1709 // that may ACK in their own internal order. When traversing | |
1710 // |in_process_event_types_|, ensure we don't jump over an event of the | |
1711 // the same category. | |
1712 int ack_type = static_cast<int>(event_type); | |
1713 int queue_type = static_cast<int>(*i); | |
1714 bool out_of_order = | |
1715 ack_type == WebInputEvent::MouseMove || | |
Sami
2013/01/10 19:45:34
Why not use WebInputEvent::isMouseEventType? Becau
bulach
2013/01/11 10:42:07
Done.
| |
1716 ack_type == WebInputEvent::MouseWheel || | |
1717 (WebInputEvent::isKeyboardEventType(ack_type) && | |
1718 WebInputEvent::isKeyboardEventType(queue_type)) || | |
1719 (WebInputEvent::isTouchEventType(ack_type) && | |
1720 WebInputEvent::isTouchEventType(queue_type)) || | |
1721 (WebInputEvent::isGestureEventType(ack_type) && | |
1722 WebInputEvent::isGestureEventType(queue_type)); | |
1723 if (out_of_order) { | |
1724 DVLOG(1) << "OnInputEventAck out of order " << ack_type << " " | |
1725 << queue_type; | |
1726 break; | |
1727 } | |
1728 } | |
1729 } | |
1730 if (!found) | |
1731 DVLOG(1) << "OnInputEventAck not found " << event_type; | |
1732 } | |
1699 | 1733 |
1700 // Log the time delta for processing an input event. | 1734 // Log the time delta for processing an input event. |
1701 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 1735 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
1702 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); | 1736 UMA_HISTOGRAM_TIMES("MPArch.RWH_InputEventDelta", delta); |
1703 | 1737 |
1704 // Cancel pending hung renderer checks since the renderer is responsive. | 1738 // Cancel pending hung renderer checks since the renderer is responsive. |
1705 if (decrement_in_flight_event_count() == 0) | 1739 if (decrement_in_flight_event_count() == 0) |
1706 StopHangMonitorTimeout(); | 1740 StopHangMonitorTimeout(); |
1707 | 1741 |
1708 // If an input ack is pending, then hold off ticking the gesture | 1742 // If an input ack is pending, then hold off ticking the gesture |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1755 active_smooth_scroll_gestures_.insert( | 1789 active_smooth_scroll_gestures_.insert( |
1756 std::make_pair(gesture_id, | 1790 std::make_pair(gesture_id, |
1757 view_->CreateSmoothScrollGesture( | 1791 view_->CreateSmoothScrollGesture( |
1758 params.scroll_down, params.pixels_to_scroll, | 1792 params.scroll_down, params.pixels_to_scroll, |
1759 params.mouse_event_x, params.mouse_event_y))); | 1793 params.mouse_event_x, params.mouse_event_y))); |
1760 | 1794 |
1761 // If an input ack is pending, then hold off ticking the gesture | 1795 // If an input ack is pending, then hold off ticking the gesture |
1762 // until we get an input ack. | 1796 // until we get an input ack. |
1763 if (!in_process_event_types_.empty()) | 1797 if (!in_process_event_types_.empty()) |
1764 return; | 1798 return; |
1799 | |
1765 if (tick_active_smooth_scroll_gestures_task_posted_) | 1800 if (tick_active_smooth_scroll_gestures_task_posted_) |
1766 return; | 1801 return; |
1767 TickActiveSmoothScrollGesture(); | 1802 TickActiveSmoothScrollGesture(); |
1768 } | 1803 } |
1769 | 1804 |
1770 void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { | 1805 void RenderWidgetHostImpl::TickActiveSmoothScrollGesture() { |
1771 TRACE_EVENT0("input", "RenderWidgetHostImpl::TickActiveSmoothScrollGesture"); | 1806 TRACE_EVENT0("input", "RenderWidgetHostImpl::TickActiveSmoothScrollGesture"); |
1772 tick_active_smooth_scroll_gestures_task_posted_ = false; | 1807 tick_active_smooth_scroll_gestures_task_posted_ = false; |
1773 if (active_smooth_scroll_gestures_.empty()) { | 1808 if (active_smooth_scroll_gestures_.empty()) { |
1774 TRACE_EVENT_INSTANT0("input", "EarlyOut_NoActiveScrollGesture"); | 1809 TRACE_EVENT_INSTANT0("input", "EarlyOut_NoActiveScrollGesture"); |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2336 return; | 2371 return; |
2337 | 2372 |
2338 OnRenderAutoResized(new_size); | 2373 OnRenderAutoResized(new_size); |
2339 } | 2374 } |
2340 | 2375 |
2341 void RenderWidgetHostImpl::DetachDelegate() { | 2376 void RenderWidgetHostImpl::DetachDelegate() { |
2342 delegate_ = NULL; | 2377 delegate_ = NULL; |
2343 } | 2378 } |
2344 | 2379 |
2345 } // namespace content | 2380 } // namespace content |
OLD | NEW |