| 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 <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/auto_reset.h" | 11 #include "base/auto_reset.h" |
| 12 #include "base/command_line.h" | 12 #include "base/command_line.h" |
| 13 #include "base/memory/ptr_util.h" | 13 #include "base/memory/ptr_util.h" |
| 14 #include "base/metrics/histogram_macros.h" | 14 #include "base/metrics/histogram_macros.h" |
| 15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
| 16 #include "content/browser/renderer_host/input/gesture_event_queue.h" | 16 #include "content/browser/renderer_host/input/gesture_event_queue.h" |
| 17 #include "content/browser/renderer_host/input/input_ack_handler.h" | 17 #include "content/browser/renderer_host/input/input_ack_handler.h" |
| 18 #include "content/browser/renderer_host/input/input_router_client.h" | 18 #include "content/browser/renderer_host/input/input_router_client.h" |
| 19 #include "content/browser/renderer_host/input/legacy_touch_event_queue.h" | 19 #include "content/browser/renderer_host/input/legacy_touch_event_queue.h" |
| 20 #include "content/browser/renderer_host/input/passthrough_touch_event_queue.h" | 20 #include "content/browser/renderer_host/input/passthrough_touch_event_queue.h" |
| 21 #include "content/browser/renderer_host/input/touch_event_queue.h" | 21 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| 22 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" | 22 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle
r.h" |
| 23 #include "content/common/content_constants_internal.h" | 23 #include "content/common/content_constants_internal.h" |
| 24 #include "content/common/edit_command.h" | 24 #include "content/common/edit_command.h" |
| 25 #include "content/common/input/input_event_ack_state.h" | 25 #include "content/common/input/input_event_ack_state.h" |
| 26 #include "content/common/input/touch_action.h" | |
| 27 #include "content/common/input/web_touch_event_traits.h" | 26 #include "content/common/input/web_touch_event_traits.h" |
| 28 #include "content/common/input_messages.h" | 27 #include "content/common/input_messages.h" |
| 29 #include "content/common/view_messages.h" | 28 #include "content/common/view_messages.h" |
| 30 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 31 #include "content/public/browser/notification_types.h" | 30 #include "content/public/browser/notification_types.h" |
| 32 #include "content/public/common/content_features.h" | 31 #include "content/public/common/content_features.h" |
| 33 #include "content/public/common/content_switches.h" | 32 #include "content/public/common/content_switches.h" |
| 34 #include "ipc/ipc_sender.h" | 33 #include "ipc/ipc_sender.h" |
| 35 #include "ui/events/blink/blink_event_util.h" | 34 #include "ui/events/blink/blink_event_util.h" |
| 36 #include "ui/events/blink/web_input_event_traits.h" | 35 #include "ui/events/blink/web_input_event_traits.h" |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 // modifiers or that all its touch-action modifiers are auto. Resetting the | 493 // modifiers or that all its touch-action modifiers are auto. Resetting the |
| 495 // touch-action here allows forwarding of subsequent gestures even if the | 494 // touch-action here allows forwarding of subsequent gestures even if the |
| 496 // underlying touches never reach the router. | 495 // underlying touches never reach the router. |
| 497 if (!has_handlers) | 496 if (!has_handlers) |
| 498 touch_action_filter_.ResetTouchAction(); | 497 touch_action_filter_.ResetTouchAction(); |
| 499 | 498 |
| 500 touch_event_queue_->OnHasTouchEventHandlers(has_handlers); | 499 touch_event_queue_->OnHasTouchEventHandlers(has_handlers); |
| 501 client_->OnHasTouchEventHandlers(has_handlers); | 500 client_->OnHasTouchEventHandlers(has_handlers); |
| 502 } | 501 } |
| 503 | 502 |
| 504 void InputRouterImpl::OnSetTouchAction(TouchAction touch_action) { | 503 void InputRouterImpl::OnSetTouchAction(cc::TouchAction touch_action) { |
| 505 // Synthetic touchstart events should get filtered out in RenderWidget. | 504 // Synthetic touchstart events should get filtered out in RenderWidget. |
| 506 DCHECK(touch_event_queue_->IsPendingAckTouchStart()); | 505 DCHECK(touch_event_queue_->IsPendingAckTouchStart()); |
| 507 TRACE_EVENT1("input", "InputRouterImpl::OnSetTouchAction", | 506 TRACE_EVENT1("input", "InputRouterImpl::OnSetTouchAction", |
| 508 "action", touch_action); | 507 "action", touch_action); |
| 509 | 508 |
| 510 touch_action_filter_.OnSetTouchAction(touch_action); | 509 touch_action_filter_.OnSetTouchAction(touch_action); |
| 511 | 510 |
| 512 // TOUCH_ACTION_NONE should disable the touch ack timeout. | 511 // kTouchActionNone should disable the touch ack timeout. |
| 513 UpdateTouchAckTimeoutEnabled(); | 512 UpdateTouchAckTimeoutEnabled(); |
| 514 } | 513 } |
| 515 | 514 |
| 516 void InputRouterImpl::OnDidStopFlinging() { | 515 void InputRouterImpl::OnDidStopFlinging() { |
| 517 DCHECK_GT(active_renderer_fling_count_, 0); | 516 DCHECK_GT(active_renderer_fling_count_, 0); |
| 518 // Note that we're only guaranteed to get a fling end notification from the | 517 // Note that we're only guaranteed to get a fling end notification from the |
| 519 // renderer, not from any other consumers. Consequently, the GestureEventQueue | 518 // renderer, not from any other consumers. Consequently, the GestureEventQueue |
| 520 // cannot use this bookkeeping for logic like tap suppression. | 519 // cannot use this bookkeeping for logic like tap suppression. |
| 521 --active_renderer_fling_count_; | 520 --active_renderer_fling_count_; |
| 522 SignalFlushedIfNecessary(); | 521 SignalFlushedIfNecessary(); |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 617 |
| 619 void InputRouterImpl::ProcessTouchAck(InputEventAckState ack_result, | 618 void InputRouterImpl::ProcessTouchAck(InputEventAckState ack_result, |
| 620 const ui::LatencyInfo& latency, | 619 const ui::LatencyInfo& latency, |
| 621 uint32_t unique_touch_event_id) { | 620 uint32_t unique_touch_event_id) { |
| 622 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. | 621 // |touch_event_queue_| will forward to OnTouchEventAck when appropriate. |
| 623 touch_event_queue_->ProcessTouchAck(ack_result, latency, | 622 touch_event_queue_->ProcessTouchAck(ack_result, latency, |
| 624 unique_touch_event_id); | 623 unique_touch_event_id); |
| 625 } | 624 } |
| 626 | 625 |
| 627 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { | 626 void InputRouterImpl::UpdateTouchAckTimeoutEnabled() { |
| 628 // TOUCH_ACTION_NONE will prevent scrolling, in which case the timeout serves | 627 // kTouchActionNone will prevent scrolling, in which case the timeout serves |
| 629 // little purpose. It's also a strong signal that touch handling is critical | 628 // little purpose. It's also a strong signal that touch handling is critical |
| 630 // to page functionality, so the timeout could do more harm than good. | 629 // to page functionality, so the timeout could do more harm than good. |
| 631 const bool touch_ack_timeout_enabled = | 630 const bool touch_ack_timeout_enabled = |
| 632 touch_action_filter_.allowed_touch_action() != TOUCH_ACTION_NONE; | 631 touch_action_filter_.allowed_touch_action() != cc::kTouchActionNone; |
| 633 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled); | 632 touch_event_queue_->SetAckTimeoutEnabled(touch_ack_timeout_enabled); |
| 634 } | 633 } |
| 635 | 634 |
| 636 void InputRouterImpl::SignalFlushedIfNecessary() { | 635 void InputRouterImpl::SignalFlushedIfNecessary() { |
| 637 if (!flush_requested_) | 636 if (!flush_requested_) |
| 638 return; | 637 return; |
| 639 | 638 |
| 640 if (HasPendingEvents()) | 639 if (HasPendingEvents()) |
| 641 return; | 640 return; |
| 642 | 641 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 669 DCHECK(global_touch_position_.find(touch_point->id) == | 668 DCHECK(global_touch_position_.find(touch_point->id) == |
| 670 global_touch_position_.end()); | 669 global_touch_position_.end()); |
| 671 global_touch_position_[touch_point->id] = gfx::Point( | 670 global_touch_position_[touch_point->id] = gfx::Point( |
| 672 touch_point->screen_position.x, touch_point->screen_position.y); | 671 touch_point->screen_position.x, touch_point->screen_position.y); |
| 673 } | 672 } |
| 674 } | 673 } |
| 675 } | 674 } |
| 676 } | 675 } |
| 677 | 676 |
| 678 } // namespace content | 677 } // namespace content |
| OLD | NEW |