| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_MOUSE_WHEEL_EVENT_QUEUE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_MOUSE_WHEEL_EVENT_QUEUE_H_ |
| 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_MOUSE_WHEEL_EVENT_QUEUE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_MOUSE_WHEEL_EVENT_QUEUE_H_ |
| 7 | 7 |
| 8 #include <deque> | 8 #include <deque> |
| 9 | 9 |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 class QueuedWebMouseWheelEvent; | 24 class QueuedWebMouseWheelEvent; |
| 25 | 25 |
| 26 // Interface with which MouseWheelEventQueue can forward mouse wheel events, | 26 // Interface with which MouseWheelEventQueue can forward mouse wheel events, |
| 27 // and dispatch mouse wheel event responses. | 27 // and dispatch mouse wheel event responses. |
| 28 class CONTENT_EXPORT MouseWheelEventQueueClient { | 28 class CONTENT_EXPORT MouseWheelEventQueueClient { |
| 29 public: | 29 public: |
| 30 virtual ~MouseWheelEventQueueClient() {} | 30 virtual ~MouseWheelEventQueueClient() {} |
| 31 | 31 |
| 32 virtual void SendMouseWheelEventImmediately( | 32 virtual void SendMouseWheelEventImmediately( |
| 33 const MouseWheelEventWithLatencyInfo& event) = 0; | 33 const MouseWheelEventWithLatencyInfo& event) = 0; |
| 34 virtual void SendGestureEvent(const GestureEventWithLatencyInfo& event) = 0; | 34 virtual void ForwardGestureEvent(const blink::WebGestureEvent& event) = 0; |
| 35 virtual void OnMouseWheelEventAck(const MouseWheelEventWithLatencyInfo& event, | 35 virtual void OnMouseWheelEventAck(const MouseWheelEventWithLatencyInfo& event, |
| 36 InputEventAckState ack_result) = 0; | 36 InputEventAckState ack_result) = 0; |
| 37 }; | 37 }; |
| 38 | 38 |
| 39 // A queue for throttling and coalescing mouse wheel events. | 39 // A queue for throttling and coalescing mouse wheel events. |
| 40 class CONTENT_EXPORT MouseWheelEventQueue { | 40 class CONTENT_EXPORT MouseWheelEventQueue { |
| 41 public: | 41 public: |
| 42 // The |client| must outlive the MouseWheelEventQueue. |send_gestures| | 42 // The |client| must outlive the MouseWheelEventQueue. |send_gestures| |
| 43 // indicates whether mouse wheel events should generate | 43 // indicates whether mouse wheel events should generate |
| 44 // Scroll[Begin|Update|End] on unhandled acknowledge events. | 44 // Scroll[Begin|Update|End] on unhandled acknowledge events. |
| (...skipping 27 matching lines...) Expand all Loading... |
| 72 } | 72 } |
| 73 | 73 |
| 74 size_t queued_size() const { return wheel_queue_.size(); } | 74 size_t queued_size() const { return wheel_queue_.size(); } |
| 75 bool event_in_flight() const { | 75 bool event_in_flight() const { |
| 76 return event_sent_for_gesture_ack_ != nullptr; | 76 return event_sent_for_gesture_ack_ != nullptr; |
| 77 } | 77 } |
| 78 | 78 |
| 79 private: | 79 private: |
| 80 void TryForwardNextEventToRenderer(); | 80 void TryForwardNextEventToRenderer(); |
| 81 void SendScrollEnd(blink::WebGestureEvent update_event, bool synthetic); | 81 void SendScrollEnd(blink::WebGestureEvent update_event, bool synthetic); |
| 82 void SendScrollBegin(const GestureEventWithLatencyInfo& gesture_update, | 82 void SendScrollBegin(const blink::WebGestureEvent& gesture_update, |
| 83 bool synthetic); | 83 bool synthetic); |
| 84 | 84 |
| 85 MouseWheelEventQueueClient* client_; | 85 MouseWheelEventQueueClient* client_; |
| 86 base::OneShotTimer scroll_end_timer_; | 86 base::OneShotTimer scroll_end_timer_; |
| 87 | 87 |
| 88 typedef std::deque<QueuedWebMouseWheelEvent*> WheelEventQueue; | 88 typedef std::deque<QueuedWebMouseWheelEvent*> WheelEventQueue; |
| 89 WheelEventQueue wheel_queue_; | 89 WheelEventQueue wheel_queue_; |
| 90 scoped_ptr<QueuedWebMouseWheelEvent> event_sent_for_gesture_ack_; | 90 scoped_ptr<QueuedWebMouseWheelEvent> event_sent_for_gesture_ack_; |
| 91 | 91 |
| 92 // True if a non-synthetic GSB needs to be sent before a GSU is sent. | 92 // True if a non-synthetic GSB needs to be sent before a GSU is sent. |
| 93 bool needs_scroll_begin_; | 93 bool needs_scroll_begin_; |
| 94 | 94 |
| 95 // True if a non-synthetic GSE needs to be sent because a non-synthetic | 95 // True if a non-synthetic GSE needs to be sent because a non-synthetic |
| 96 // GSB has been sent in the past. | 96 // GSB has been sent in the past. |
| 97 bool needs_scroll_end_; | 97 bool needs_scroll_end_; |
| 98 | 98 |
| 99 bool send_gestures_; | 99 bool send_gestures_; |
| 100 int64_t scroll_transaction_ms_; | 100 int64_t scroll_transaction_ms_; |
| 101 blink::WebGestureDevice scrolling_device_; | 101 blink::WebGestureDevice scrolling_device_; |
| 102 | 102 |
| 103 DISALLOW_COPY_AND_ASSIGN(MouseWheelEventQueue); | 103 DISALLOW_COPY_AND_ASSIGN(MouseWheelEventQueue); |
| 104 }; | 104 }; |
| 105 | 105 |
| 106 } // namespace content | 106 } // namespace content |
| 107 | 107 |
| 108 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOUSE_WHEEL_EVENT_QUEUE_H_ | 108 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOUSE_WHEEL_EVENT_QUEUE_H_ |
| OLD | NEW |