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" |
11 #include "base/metrics/histogram.h" | 11 #include "base/metrics/histogram.h" |
12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
13 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 13 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
14 #include "content/browser/renderer_host/input/input_ack_handler.h" | 14 #include "content/browser/renderer_host/input/input_ack_handler.h" |
15 #include "content/browser/renderer_host/input/input_router_client.h" | 15 #include "content/browser/renderer_host/input/input_router_client.h" |
16 #include "content/browser/renderer_host/input/touch_event_queue.h" | 16 #include "content/browser/renderer_host/input/touch_event_queue.h" |
17 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" | 17 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" |
18 #include "content/common/content_constants_internal.h" | 18 #include "content/common/content_constants_internal.h" |
19 #include "content/common/edit_command.h" | 19 #include "content/common/edit_command.h" |
20 #include "content/common/input/input_event_ack_state.h" | 20 #include "content/common/input/input_event_ack_state.h" |
21 #include "content/common/input/touch_action.h" | 21 #include "content/common/input/touch_action.h" |
22 #include "content/common/input/web_touch_event_traits.h" | 22 #include "content/common/input/web_touch_event_traits.h" |
23 #include "content/common/input_messages.h" | 23 #include "content/common/input_messages.h" |
24 #include "content/common/view_messages.h" | |
25 #include "content/public/browser/notification_service.h" | 24 #include "content/public/browser/notification_service.h" |
26 #include "content/public/browser/notification_types.h" | 25 #include "content/public/browser/notification_types.h" |
27 #include "content/public/browser/user_metrics.h" | 26 #include "content/public/browser/user_metrics.h" |
28 #include "content/public/common/content_switches.h" | 27 #include "content/public/common/content_switches.h" |
29 #include "ipc/ipc_sender.h" | 28 #include "ipc/ipc_sender.h" |
30 #include "ui/events/event.h" | 29 #include "ui/events/event.h" |
31 #include "ui/events/keycodes/keyboard_codes.h" | 30 #include "ui/events/keycodes/keyboard_codes.h" |
32 | 31 |
33 using base::Time; | 32 using base::Time; |
34 using base::TimeDelta; | 33 using base::TimeDelta; |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 | 262 |
264 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { | 263 bool InputRouterImpl::OnMessageReceived(const IPC::Message& message) { |
265 bool handled = true; | 264 bool handled = true; |
266 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) | 265 IPC_BEGIN_MESSAGE_MAP(InputRouterImpl, message) |
267 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) | 266 IPC_MESSAGE_HANDLER(InputHostMsg_HandleInputEvent_ACK, OnInputEventAck) |
268 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) | 267 IPC_MESSAGE_HANDLER(InputHostMsg_DidOverscroll, OnDidOverscroll) |
269 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) | 268 IPC_MESSAGE_HANDLER(InputHostMsg_MoveCaret_ACK, OnMsgMoveCaretAck) |
270 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) | 269 IPC_MESSAGE_HANDLER(InputHostMsg_SelectRange_ACK, OnSelectMessageAck) |
271 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, | 270 IPC_MESSAGE_HANDLER(InputHostMsg_MoveRangeSelectionExtent_ACK, |
272 OnSelectMessageAck) | 271 OnSelectMessageAck) |
273 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 272 IPC_MESSAGE_HANDLER(InputHostMsg_HasTouchEventHandlers, |
274 OnHasTouchEventHandlers) | 273 OnHasTouchEventHandlers) |
| 274 IPC_MESSAGE_HANDLER(InputHostMsg_HasTouchMoveEventHandlers, |
| 275 OnHasTouchMoveEventHandlers) |
275 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, | 276 IPC_MESSAGE_HANDLER(InputHostMsg_SetTouchAction, |
276 OnSetTouchAction) | 277 OnSetTouchAction) |
277 IPC_MESSAGE_HANDLER(InputHostMsg_DidStopFlinging, OnDidStopFlinging) | 278 IPC_MESSAGE_HANDLER(InputHostMsg_DidStopFlinging, OnDidStopFlinging) |
278 IPC_MESSAGE_UNHANDLED(handled = false) | 279 IPC_MESSAGE_UNHANDLED(handled = false) |
279 IPC_END_MESSAGE_MAP() | 280 IPC_END_MESSAGE_MAP() |
280 | 281 |
281 return handled; | 282 return handled; |
282 } | 283 } |
283 | 284 |
284 void InputRouterImpl::OnTouchEventAck(const TouchEventWithLatencyInfo& event, | 285 void InputRouterImpl::OnTouchEventAck(const TouchEventWithLatencyInfo& event, |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 // underlying touches never reach the router. | 480 // underlying touches never reach the router. |
480 // TODO(jdduke): Reset touch-action only at the end of a touch sequence to | 481 // TODO(jdduke): Reset touch-action only at the end of a touch sequence to |
481 // prevent potentially strange mid-sequence behavior, crbug.com/375940. | 482 // prevent potentially strange mid-sequence behavior, crbug.com/375940. |
482 if (!has_handlers) | 483 if (!has_handlers) |
483 touch_action_filter_.ResetTouchAction(); | 484 touch_action_filter_.ResetTouchAction(); |
484 | 485 |
485 touch_event_queue_.OnHasTouchEventHandlers(has_handlers); | 486 touch_event_queue_.OnHasTouchEventHandlers(has_handlers); |
486 client_->OnHasTouchEventHandlers(has_handlers); | 487 client_->OnHasTouchEventHandlers(has_handlers); |
487 } | 488 } |
488 | 489 |
| 490 void InputRouterImpl::OnHasTouchMoveEventHandlers(bool has_handlers) { |
| 491 TRACE_EVENT1("input", "InputRouterImpl::OnHasTouchMoveEventHandlers", |
| 492 "has_handlers", has_handlers); |
| 493 |
| 494 touch_event_queue_.OnHasTouchMoveEventHandlers(has_handlers); |
| 495 } |
| 496 |
489 void InputRouterImpl::OnSetTouchAction(TouchAction touch_action) { | 497 void InputRouterImpl::OnSetTouchAction(TouchAction touch_action) { |
490 // Synthetic touchstart events should get filtered out in RenderWidget. | 498 // Synthetic touchstart events should get filtered out in RenderWidget. |
491 DCHECK(touch_event_queue_.IsPendingAckTouchStart()); | 499 DCHECK(touch_event_queue_.IsPendingAckTouchStart()); |
492 TRACE_EVENT1("input", "InputRouterImpl::OnSetTouchAction", | 500 TRACE_EVENT1("input", "InputRouterImpl::OnSetTouchAction", |
493 "action", touch_action); | 501 "action", touch_action); |
494 | 502 |
495 touch_action_filter_.OnSetTouchAction(touch_action); | 503 touch_action_filter_.OnSetTouchAction(touch_action); |
496 | 504 |
497 // TOUCH_ACTION_NONE should disable the touch ack timeout. | 505 // TOUCH_ACTION_NONE should disable the touch ack timeout. |
498 UpdateTouchAckTimeoutEnabled(); | 506 UpdateTouchAckTimeoutEnabled(); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
647 return; | 655 return; |
648 | 656 |
649 if (HasPendingEvents()) | 657 if (HasPendingEvents()) |
650 return; | 658 return; |
651 | 659 |
652 flush_requested_ = false; | 660 flush_requested_ = false; |
653 client_->DidFlush(); | 661 client_->DidFlush(); |
654 } | 662 } |
655 | 663 |
656 } // namespace content | 664 } // namespace content |
OLD | NEW |