Index: content/browser/renderer_host/input/input_router_impl.cc |
diff --git a/content/browser/renderer_host/input/input_router_impl.cc b/content/browser/renderer_host/input/input_router_impl.cc |
index 8ecb37b4567999373caaed93e7c86cf445a09a7e..32297fcf5866e18d76d1a4373c9b4b4b4b41ca5a 100644 |
--- a/content/browser/renderer_host/input/input_router_impl.cc |
+++ b/content/browser/renderer_host/input/input_router_impl.cc |
@@ -10,10 +10,8 @@ |
#include "base/command_line.h" |
#include "base/metrics/histogram.h" |
#include "base/strings/string_number_conversions.h" |
-#include "content/browser/renderer_host/input/gesture_event_queue.h" |
#include "content/browser/renderer_host/input/input_ack_handler.h" |
#include "content/browser/renderer_host/input/input_router_client.h" |
-#include "content/browser/renderer_host/input/touch_event_queue.h" |
#include "content/browser/renderer_host/input/touchpad_tap_suppression_controller.h" |
#include "content/common/content_constants_internal.h" |
#include "content/common/edit_command.h" |
@@ -57,7 +55,7 @@ const char* GetEventAckName(InputEventAckState ack_result) { |
} // namespace |
-InputRouterImpl::Config::Config() {} |
+InputRouterImpl::Config::Config() : buffer_wheel_events_until_flush(false) {} |
InputRouterImpl::InputRouterImpl(IPC::Sender* sender, |
InputRouterClient* client, |
@@ -71,12 +69,12 @@ InputRouterImpl::InputRouterImpl(IPC::Sender* sender, |
select_message_pending_(false), |
move_caret_pending_(false), |
mouse_move_pending_(false), |
- mouse_wheel_pending_(false), |
current_ack_source_(ACK_SOURCE_NONE), |
flush_requested_(false), |
active_renderer_fling_count_(0), |
touch_event_queue_(this, config.touch_config), |
- gesture_event_queue_(this, this, config.gesture_config) { |
+ gesture_event_queue_(this, this, config.gesture_config), |
+ wheel_event_queue_(this, config.buffer_wheel_events_until_flush) { |
DCHECK(sender); |
DCHECK(client); |
DCHECK(ack_handler); |
@@ -106,6 +104,9 @@ bool InputRouterImpl::SendInput(scoped_ptr<IPC::Message> message) { |
void InputRouterImpl::FlushInput(base::TimeTicks flush_time) { |
flush_requested_ = true; |
+ |
+ wheel_event_queue_.Flush(); |
+ |
SignalFlushedIfNecessary(); |
} |
@@ -125,38 +126,7 @@ void InputRouterImpl::SendMouseEvent( |
void InputRouterImpl::SendWheelEvent( |
const MouseWheelEventWithLatencyInfo& wheel_event) { |
- if (mouse_wheel_pending_) { |
- // If there's already a mouse wheel event waiting to be sent to the |
- // renderer, add the new deltas to that event. Not doing so (e.g., by |
- // dropping the old event, as for mouse moves) results in very slow |
- // scrolling on the Mac. |
- if (wheel_event.event.hasPreciseScrollingDeltas) |
- DCHECK(wheel_event.event.canScroll); |
- DCHECK(!(wheel_event.event.hasPreciseScrollingDeltas && |
- !wheel_event.event.canScroll)); |
- if (coalesced_mouse_wheel_events_.empty() || |
- (!coalesced_mouse_wheel_events_.empty() && |
- !coalesced_mouse_wheel_events_.back().CanCoalesceWith(wheel_event))) { |
- coalesced_mouse_wheel_events_.push_back(wheel_event); |
- } else { |
- coalesced_mouse_wheel_events_.back().CoalesceWith(wheel_event); |
- TRACE_EVENT_INSTANT2("input", "InputRouterImpl::CoalescedWheelEvent", |
- TRACE_EVENT_SCOPE_THREAD, |
- "total_dx", |
- coalesced_mouse_wheel_events_.back().event.deltaX, |
- "total_dy", |
- coalesced_mouse_wheel_events_.back().event.deltaY); |
- } |
- return; |
- } |
- |
- mouse_wheel_pending_ = true; |
- current_wheel_event_ = wheel_event; |
- |
- LOCAL_HISTOGRAM_COUNTS_100("Renderer.WheelQueueSize", |
- coalesced_mouse_wheel_events_.size()); |
- |
- FilterAndSendWebInputEvent(wheel_event.event, wheel_event.latency); |
+ wheel_event_queue_.QueueEvent(wheel_event); |
} |
void InputRouterImpl::SendKeyboardEvent( |
@@ -250,8 +220,8 @@ bool InputRouterImpl::HasPendingEvents() const { |
return !touch_event_queue_.empty() || |
!gesture_event_queue_.empty() || |
!key_queue_.empty() || |
+ !wheel_event_queue_.empty() || |
mouse_move_pending_ || |
- mouse_wheel_pending_ || |
select_message_pending_ || |
move_caret_pending_ || |
active_renderer_fling_count_ > 0; |
@@ -296,6 +266,21 @@ void InputRouterImpl::OnGestureEventAck( |
ack_handler_->OnGestureEventAck(event, ack_result); |
} |
+void InputRouterImpl::SendWheelEventImmediately( |
+ const MouseWheelEventWithLatencyInfo& wheel_event) { |
+ FilterAndSendWebInputEvent(wheel_event.event, wheel_event.latency); |
+} |
+ |
+void InputRouterImpl::OnWheelEventAck( |
+ const MouseWheelEventWithLatencyInfo& event, |
+ InputEventAckState ack_result) { |
+ ack_handler_->OnWheelEventAck(event, ack_result); |
+} |
+ |
+void InputRouterImpl::SetNeedsFlush() { |
+ client_->SetNeedsFlushInput(); |
+} |
+ |
bool InputRouterImpl::SendSelectMessage( |
scoped_ptr<IPC::Message> message) { |
DCHECK(message->type() == InputMsg_SelectRange::ID || |
@@ -581,27 +566,7 @@ void InputRouterImpl::ProcessMouseAck(blink::WebInputEvent::Type type, |
void InputRouterImpl::ProcessWheelAck(InputEventAckState ack_result, |
const ui::LatencyInfo& latency) { |
- // TODO(miletus): Add renderer side latency to each uncoalesced mouse |
- // wheel event and add terminal component to each of them. |
- current_wheel_event_.latency.AddNewLatencyFrom(latency); |
- |
- // Process the unhandled wheel event here before calling SendWheelEvent() |
- // since it will mutate current_wheel_event_. |
- ack_handler_->OnWheelEventAck(current_wheel_event_, ack_result); |
- |
- // Mark the wheel event complete only after the ACKs have been handled above. |
- // For example, ACKing the GesturePinchUpdate could cause another |
- // GesturePinchUpdate to be sent, which should queue a wheel event rather than |
- // send it immediately. |
- mouse_wheel_pending_ = false; |
- |
- // Send the next (coalesced or synthetic) mouse wheel event. |
- if (!coalesced_mouse_wheel_events_.empty()) { |
- MouseWheelEventWithLatencyInfo next_wheel_event = |
- coalesced_mouse_wheel_events_.front(); |
- coalesced_mouse_wheel_events_.pop_front(); |
- SendWheelEvent(next_wheel_event); |
- } |
+ wheel_event_queue_.ProcessWheelAck(ack_result, latency); |
} |
void InputRouterImpl::ProcessGestureAck(WebInputEvent::Type type, |