| 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/touch_event_queue.h" | 5 #include "content/browser/renderer_host/input/touch_event_queue.h" |
| 6 | 6 |
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/metrics/histogram_macros.h" | 8 #include "base/metrics/histogram_macros.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/trace_event/trace_event.h" | 10 #include "base/trace_event/trace_event.h" |
| (...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 629 !drop_remaining_touches_in_sequence_) { | 629 !drop_remaining_touches_in_sequence_) { |
| 630 DCHECK(!touchmove_slop_suppressor_->suppressing_touchmoves()) | 630 DCHECK(!touchmove_slop_suppressor_->suppressing_touchmoves()) |
| 631 << "A touch handler should be offered a touchmove before scrolling."; | 631 << "A touch handler should be offered a touchmove before scrolling."; |
| 632 } | 632 } |
| 633 | 633 |
| 634 pending_async_touchmove_.reset(); | 634 pending_async_touchmove_.reset(); |
| 635 | 635 |
| 636 return; | 636 return; |
| 637 } | 637 } |
| 638 | 638 |
| 639 if (gesture_event.event.type == blink::WebInputEvent::GestureScrollUpdate) | 639 if (gesture_event.event.type == blink::WebInputEvent::GestureScrollUpdate && |
| 640 gesture_event.event.resendingPluginId == -1) { |
| 640 send_touch_events_async_ = true; | 641 send_touch_events_async_ = true; |
| 642 } |
| 641 } | 643 } |
| 642 | 644 |
| 643 void TouchEventQueue::OnGestureEventAck( | 645 void TouchEventQueue::OnGestureEventAck( |
| 644 const GestureEventWithLatencyInfo& event, | 646 const GestureEventWithLatencyInfo& event, |
| 645 InputEventAckState ack_result) { | 647 InputEventAckState ack_result) { |
| 646 // Throttle sending touchmove events as long as the scroll events are handled. | 648 // Throttle sending touchmove events as long as the scroll events are handled. |
| 647 // Note that there's no guarantee that this ACK is for the most recent | 649 // Note that there's no guarantee that this ACK is for the most recent |
| 648 // gesture event (or even part of the current sequence). Worst case, the | 650 // gesture event (or even part of the current sequence). Worst case, the |
| 649 // delay in updating the absorption state will result in minor UI glitches. | 651 // delay in updating the absorption state will result in minor UI glitches. |
| 650 // A valid |pending_async_touchmove_| will be flushed when the next event is | 652 // A valid |pending_async_touchmove_| will be flushed when the next event is |
| 651 // forwarded. | 653 // forwarded. Scroll updates that are being resent from a GuestView are |
| 652 if (event.event.type == blink::WebInputEvent::GestureScrollUpdate) | 654 // ignored. |
| 655 if (event.event.type == blink::WebInputEvent::GestureScrollUpdate && |
| 656 event.event.resendingPluginId == -1) { |
| 653 send_touch_events_async_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); | 657 send_touch_events_async_ = (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED); |
| 658 } |
| 654 } | 659 } |
| 655 | 660 |
| 656 void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { | 661 void TouchEventQueue::OnHasTouchEventHandlers(bool has_handlers) { |
| 657 DCHECK(!dispatching_touch_ack_); | 662 DCHECK(!dispatching_touch_ack_); |
| 658 DCHECK(!dispatching_touch_); | 663 DCHECK(!dispatching_touch_); |
| 659 has_handlers_ = has_handlers; | 664 has_handlers_ = has_handlers; |
| 660 } | 665 } |
| 661 | 666 |
| 662 bool TouchEventQueue::IsPendingAckTouchStart() const { | 667 bool TouchEventQueue::IsPendingAckTouchStart() const { |
| 663 DCHECK(!dispatching_touch_ack_); | 668 DCHECK(!dispatching_touch_ack_); |
| (...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) | 872 if (ack_result == INPUT_EVENT_ACK_STATE_CONSUMED) |
| 868 send_touch_events_async_ = false; | 873 send_touch_events_async_ = false; |
| 869 has_handler_for_current_sequence_ |= | 874 has_handler_for_current_sequence_ |= |
| 870 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; | 875 ack_result != INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS; |
| 871 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { | 876 } else if (WebTouchEventTraits::IsTouchSequenceEnd(event)) { |
| 872 has_handler_for_current_sequence_ = false; | 877 has_handler_for_current_sequence_ = false; |
| 873 } | 878 } |
| 874 } | 879 } |
| 875 | 880 |
| 876 } // namespace content | 881 } // namespace content |
| OLD | NEW |