| Index: content/browser/renderer_host/input/immediate_input_router.cc
|
| diff --git a/content/browser/renderer_host/input/immediate_input_router.cc b/content/browser/renderer_host/input/immediate_input_router.cc
|
| index 46b59a63ca12db1ff5688c0aa073da4f21263577..cc488ef3b6c19aa005ac123425b7d37c6ac85cd1 100644
|
| --- a/content/browser/renderer_host/input/immediate_input_router.cc
|
| +++ b/content/browser/renderer_host/input/immediate_input_router.cc
|
| @@ -7,11 +7,10 @@
|
| #include "base/auto_reset.h"
|
| #include "base/command_line.h"
|
| #include "base/metrics/histogram.h"
|
| -#include "content/browser/renderer_host/input/gesture_event_filter.h"
|
| +#include "content/browser/renderer_host/input/base_gesture_event_filter.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/browser/renderer_host/overscroll_controller.h"
|
| #include "content/common/content_constants_internal.h"
|
| #include "content/common/edit_command.h"
|
| @@ -87,7 +86,8 @@ ImmediateInputRouter::ImmediateInputRouter(IPC::Sender* sender,
|
| has_touch_handler_(false),
|
| current_ack_source_(ACK_SOURCE_NONE),
|
| touch_event_queue_(new TouchEventQueue(this)),
|
| - gesture_event_filter_(new GestureEventFilter(this, this)) {
|
| + flinger_(new Flinger(this)),
|
| + event_filter_(new BaseGestureEventFilter(this)) {
|
| DCHECK(sender);
|
| DCHECK(client);
|
| DCHECK(ack_handler);
|
| @@ -119,27 +119,24 @@ bool ImmediateInputRouter::SendInput(scoped_ptr<IPC::Message> message) {
|
| void ImmediateInputRouter::SendMouseEvent(
|
| const MouseEventWithLatencyInfo& mouse_event) {
|
| // Order is important here; we need to convert all MouseEvents before they
|
| - // propagate further, e.g., to the tap suppression controller.
|
| + // propagate further.
|
| if (CommandLine::ForCurrentProcess()->HasSwitch(
|
| switches::kSimulateTouchScreenWithMouse)) {
|
| SimulateTouchGestureWithMouse(mouse_event);
|
| return;
|
| }
|
|
|
| - if (mouse_event.event.type == WebInputEvent::MouseDown &&
|
| - gesture_event_filter_->GetTouchpadTapSuppressionController()->
|
| - ShouldDeferMouseDown(mouse_event))
|
| - return;
|
| - if (mouse_event.event.type == WebInputEvent::MouseUp &&
|
| - gesture_event_filter_->GetTouchpadTapSuppressionController()->
|
| - ShouldSuppressMouseUp())
|
| - return;
|
| + if (flinger_->HandleMouseEvent(mouse_event))
|
| + return;
|
|
|
| SendMouseEventImmediately(mouse_event);
|
| }
|
|
|
| void ImmediateInputRouter::SendWheelEvent(
|
| const MouseWheelEventWithLatencyInfo& wheel_event) {
|
| + if (flinger_->HandleWheelEvent(wheel_event))
|
| + return;
|
| +
|
| // 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 (on
|
| @@ -166,14 +163,15 @@ void ImmediateInputRouter::SendKeyboardEvent(
|
| const NativeWebKeyboardEvent& key_event,
|
| const ui::LatencyInfo& latency_info,
|
| bool is_keyboard_shortcut) {
|
| + if (flinger_->HandleKeyboardEvent())
|
| + return;
|
| +
|
| // Put all WebKeyboardEvent objects in a queue since we can't trust the
|
| // renderer and we need to give something to the HandleKeyboardEvent
|
| // handler.
|
| key_queue_.push_back(key_event);
|
| HISTOGRAM_COUNTS_100("Renderer.KeyboardQueueSize", key_queue_.size());
|
|
|
| - gesture_event_filter_->FlingHasBeenHalted();
|
| -
|
| // Only forward the non-native portions of our event.
|
| FilterAndSendWebInputEvent(key_event, latency_info, is_keyboard_shortcut);
|
| }
|
| @@ -182,8 +180,11 @@ void ImmediateInputRouter::SendGestureEvent(
|
| const GestureEventWithLatencyInfo& gesture_event) {
|
| HandleGestureScroll(gesture_event);
|
|
|
| + if (flinger_->HandleGestureEvent(gesture_event))
|
| + return;
|
| +
|
| if (!IsInOverscrollGesture() &&
|
| - !gesture_event_filter_->ShouldForward(gesture_event)) {
|
| + !event_filter_->ShouldForward(gesture_event)) {
|
| OverscrollController* controller = client_->GetOverscrollController();
|
| if (controller)
|
| controller->DiscardingGestureEvent(gesture_event.event);
|
| @@ -198,8 +199,6 @@ void ImmediateInputRouter::SendTouchEvent(
|
| touch_event_queue_->QueueEvent(touch_event);
|
| }
|
|
|
| -// Forwards MouseEvent without passing it through
|
| -// TouchpadTapSuppressionController.
|
| void ImmediateInputRouter::SendMouseEventImmediately(
|
| const MouseEventWithLatencyInfo& mouse_event) {
|
| // Avoid spamming the renderer with mouse move events. It is important
|
| @@ -277,6 +276,25 @@ void ImmediateInputRouter::OnGestureEventAck(
|
| ack_handler_->OnGestureEventAck(event, ack_result);
|
| }
|
|
|
| +void ImmediateInputRouter::SendEventForFling(
|
| + const WebKit::WebInputEvent& event) {
|
| + ui::LatencyInfo latency_info;
|
| + if (Send(new InputMsg_HandleInputEvent(
|
| + routing_id(), &event, latency_info, false)))
|
| + in_process_messages_sources_.push(MESSAGE_SOURCE_FLING);
|
| +}
|
| +
|
| +void ImmediateInputRouter::FlingFinished(
|
| + WebKit::WebGestureEvent::SourceDevice source) {
|
| + if (source == WebKit::WebGestureEvent::Touchscreen) {
|
| + ui::LatencyInfo latency_info;
|
| + WebKit::WebGestureEvent synthetic_gesture;
|
| + synthetic_gesture.type = WebKit::WebInputEvent::GestureScrollEnd;
|
| + synthetic_gesture.sourceDevice = WebKit::WebGestureEvent::Touchscreen;
|
| + SendWebInputEvent(synthetic_gesture, latency_info, false);
|
| + }
|
| +}
|
| +
|
| bool ImmediateInputRouter::SendSelectRange(scoped_ptr<IPC::Message> message) {
|
| DCHECK(message->type() == InputMsg_SelectRange::ID);
|
| if (select_range_pending_) {
|
| @@ -310,6 +328,7 @@ void ImmediateInputRouter::SendWebInputEvent(
|
| input_event_start_time_ = TimeTicks::Now();
|
| if (Send(new InputMsg_HandleInputEvent(
|
| routing_id(), &input_event, latency_info, is_keyboard_shortcut))) {
|
| + in_process_messages_sources_.push(MESSAGE_SOURCE_REGULAR);
|
| client_->IncrementInFlightEventCount();
|
| }
|
| }
|
| @@ -362,7 +381,7 @@ bool ImmediateInputRouter::OfferToOverscrollController(
|
| const WebKit::WebGestureEvent& gesture_event =
|
| static_cast<const WebKit::WebGestureEvent&>(input_event);
|
| // An ACK is expected for the event, so mark it as consumed.
|
| - consumed = !gesture_event_filter_->ShouldForward(
|
| + consumed = !event_filter_->ShouldForward(
|
| GestureEventWithLatencyInfo(gesture_event, latency_info));
|
| }
|
|
|
| @@ -414,6 +433,13 @@ void ImmediateInputRouter::OnInputEventAck(
|
| TimeDelta delta = TimeTicks::Now() - input_event_start_time_;
|
| UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta);
|
|
|
| + InputMessageSource source = in_process_messages_sources_.front();
|
| + in_process_messages_sources_.pop();
|
| + if (source == MESSAGE_SOURCE_FLING) {
|
| + flinger_->ProcessEventAck(event_type, ack_result, latency_info);
|
| + return;
|
| + }
|
| +
|
| client_->DecrementInFlightEventCount();
|
|
|
| ProcessInputEventAck(event_type, ack_result, latency_info, RENDERER);
|
| @@ -552,12 +578,12 @@ void ImmediateInputRouter::ProcessGestureAck(WebInputEvent::Type type,
|
| // If |ack_result| originated from the overscroll controller, only
|
| // feed |gesture_event_filter_| the ack if it was expecting one.
|
| if (current_ack_source_ == OVERSCROLL_CONTROLLER &&
|
| - !gesture_event_filter_->HasQueuedGestureEvents()) {
|
| + !event_filter_->HasQueuedGestureEvents()) {
|
| return;
|
| }
|
|
|
| // |gesture_event_filter_| will forward to OnGestureEventAck when appropriate.
|
| - gesture_event_filter_->ProcessGestureAck(ack_result, type, latency);
|
| + event_filter_->ProcessGestureAck(ack_result, type, latency);
|
| }
|
|
|
| void ImmediateInputRouter::ProcessTouchAck(
|
|
|