OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/input_router_impl.h" | 5 #include "content/browser/renderer_host/input/input_router_impl.h" |
6 | 6 |
7 #include <math.h> | 7 #include <math.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 current_view_flags_ = view_flags; | 263 current_view_flags_ = view_flags; |
264 | 264 |
265 // A fixed page scale or mobile viewport should disable the touch ack timeout. | 265 // A fixed page scale or mobile viewport should disable the touch ack timeout. |
266 UpdateTouchAckTimeoutEnabled(); | 266 UpdateTouchAckTimeoutEnabled(); |
267 } | 267 } |
268 | 268 |
269 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { | 269 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { |
270 bool handled = true; | 270 bool handled = true; |
271 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) | 271 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) |
272 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) | 272 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) |
| 273 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) |
273 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) | 274 IPC_MESSAGE_HANDLER(ViewHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) |
274 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectRange_ACK, OnSelectRangeAck) | 275 IPC_MESSAGE_HANDLER(ViewHostMsg_SelectRange_ACK, OnSelectRangeAck) |
275 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 276 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
276 OnHasTouchEventHandlers) | 277 OnHasTouchEventHandlers) |
277 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, | 278 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, |
278 OnSetTouchAction) | 279 OnSetTouchAction) |
279 IPC_MESSAGE_UNHANDLED(handled = false) | 280 IPC_MESSAGE_UNHANDLED(handled = false) |
280 IPC_END_MESSAGE_MAP() | 281 IPC_END_MESSAGE_MAP() |
281 | 282 |
282 return handled; | 283 return handled; |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 wheelEvent.deltaY = 100.0f * log(pinch_event.event.data.pinchUpdate.scale); | 480 wheelEvent.deltaY = 100.0f * log(pinch_event.event.data.pinchUpdate.scale); |
480 wheelEvent.hasPreciseScrollingDeltas = true; | 481 wheelEvent.hasPreciseScrollingDeltas = true; |
481 wheelEvent.wheelTicksX = 0; | 482 wheelEvent.wheelTicksX = 0; |
482 wheelEvent.wheelTicksY = | 483 wheelEvent.wheelTicksY = |
483 pinch_event.event.data.pinchUpdate.scale > 1 ? 1 : -1; | 484 pinch_event.event.data.pinchUpdate.scale > 1 ? 1 : -1; |
484 | 485 |
485 SendWheelEvent(QueuedWheelEvent( | 486 SendWheelEvent(QueuedWheelEvent( |
486 MouseWheelEventWithLatencyInfo(wheelEvent, pinch_event.latency), true)); | 487 MouseWheelEventWithLatencyInfo(wheelEvent, pinch_event.latency), true)); |
487 } | 488 } |
488 | 489 |
489 void InputRouterImpl::OnInputEventAck(WebInputEvent::Type event_type, | 490 void InputRouterImpl::OnInputEventAck( |
490 InputEventAckState ack_result, | 491 const InputHostMsg_HandleInputEvent_ACK_Params& ack) { |
491 const ui::LatencyInfo& latency_info) { | |
492 client_->DecrementInFlightEventCount(); | 492 client_->DecrementInFlightEventCount(); |
493 | 493 |
494 // Log the time delta for processing an input event. | 494 // Log the time delta for processing an input event. |
495 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; | 495 TimeDelta delta = TimeTicks::Now() - input_event_start_time_; |
496 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); | 496 UMA_HISTOGRAM_TIMES("MPArch.IIR_InputEventDelta", delta); |
497 | 497 |
498 ProcessInputEventAck(event_type, ack_result, latency_info, RENDERER); | 498 if (ack.overscroll) { |
| 499 DCHECK(ack.type == WebInputEvent::MouseWheel || |
| 500 ack.type == WebInputEvent::GestureScrollUpdate); |
| 501 OnDidOverscroll(*ack.overscroll); |
| 502 } |
| 503 |
| 504 ProcessInputEventAck(ack.type, ack.state, ack.latency, RENDERER); |
499 // WARNING: |this| may be deleted at this point. | 505 // WARNING: |this| may be deleted at this point. |
500 | 506 |
501 // This is used only for testing, and the other end does not use the | 507 // This is used only for testing, and the other end does not use the |
502 // source object. On linux, specifying | 508 // source object. On linux, specifying |
503 // Source<RenderWidgetHost> results in a very strange | 509 // Source<RenderWidgetHost> results in a very strange |
504 // runtime error in the epilogue of the enclosing | 510 // runtime error in the epilogue of the enclosing |
505 // (ProcessInputEventAck) method, but not on other platforms; using | 511 // (ProcessInputEventAck) method, but not on other platforms; using |
506 // 'void' instead is just as safe (since NotificationSource | 512 // 'void' instead is just as safe (since NotificationSource |
507 // is not actually typesafe) and avoids this error. | 513 // is not actually typesafe) and avoids this error. |
508 int type = static_cast<int>(event_type); | 514 int type = static_cast<int>(ack.type); |
509 NotificationService::current()->Notify( | 515 NotificationService::current()->Notify( |
510 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, | 516 NOTIFICATION_RENDER_WIDGET_HOST_DID_RECEIVE_INPUT_EVENT_ACK, |
511 Source<void>(this), | 517 Source<void>(this), |
512 Details<int>(&type)); | 518 Details<int>(&type)); |
513 } | 519 } |
514 | 520 |
| 521 void InputRouterImpl::OnDidOverscroll(const DidOverscrollParams& params) { |
| 522 client_->DidOverscroll(params); |
| 523 } |
| 524 |
515 void InputRouterImpl::OnMsgMoveCaretAck() { | 525 void InputRouterImpl::OnMsgMoveCaretAck() { |
516 move_caret_pending_ = false; | 526 move_caret_pending_ = false; |
517 if (next_move_caret_) | 527 if (next_move_caret_) |
518 SendMoveCaret(next_move_caret_.Pass()); | 528 SendMoveCaret(next_move_caret_.Pass()); |
519 } | 529 } |
520 | 530 |
521 void InputRouterImpl::OnSelectRangeAck() { | 531 void InputRouterImpl::OnSelectRangeAck() { |
522 select_range_pending_ = false; | 532 select_range_pending_ = false; |
523 if (next_selection_range_) | 533 if (next_selection_range_) |
524 SendSelectRange(next_selection_range_.Pass()); | 534 SendSelectRange(next_selection_range_.Pass()); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( | 746 InputRouterImpl::QueuedWheelEvent::QueuedWheelEvent( |
737 const MouseWheelEventWithLatencyInfo& event, | 747 const MouseWheelEventWithLatencyInfo& event, |
738 bool synthesized_from_pinch) | 748 bool synthesized_from_pinch) |
739 : event(event), synthesized_from_pinch(synthesized_from_pinch) { | 749 : event(event), synthesized_from_pinch(synthesized_from_pinch) { |
740 } | 750 } |
741 | 751 |
742 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { | 752 InputRouterImpl::QueuedWheelEvent::~QueuedWheelEvent() { |
743 } | 753 } |
744 | 754 |
745 } // namespace content | 755 } // namespace content |
OLD | NEW |