| 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" |
| 11 #include "content/browser/renderer_host/event_with_latency_info.h" | 11 #include "content/browser/renderer_host/event_with_latency_info.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "content/common/input/input_event_ack_state.h" | 13 #include "content/common/input/input_event_ack_state.h" |
| 14 #include "third_party/WebKit/public/web/WebInputEvent.h" | 14 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 15 | 15 |
| 16 namespace content { | 16 namespace content { |
| 17 | 17 |
| 18 // The duration in which a ScrollEnd will be sent after the last | 18 // The duration in which a ScrollEnd will be sent after the last |
| 19 // ScrollUpdate was sent for wheel based gesture scrolls. | 19 // ScrollUpdate was sent for wheel based gesture scrolls. |
| 20 // Set the default wheel transaction to 0ms until | 20 // Set the default wheel transaction to 0ms until |
| 21 // crbug.com/526463 is fully implemented. | 21 // crbug.com/526463 is fully implemented. |
| 22 const int64_t kDefaultWheelScrollTransactionMs = 0; // 100; | 22 const int64_t kDefaultWheelScrollTransactionMs = 0; |
| 23 const int64_t kDefaultWheelScrollLatchingTransactionMs = 100; |
| 23 | 24 |
| 24 class QueuedWebMouseWheelEvent; | 25 class QueuedWebMouseWheelEvent; |
| 25 | 26 |
| 26 // Interface with which MouseWheelEventQueue can forward mouse wheel events, | 27 // Interface with which MouseWheelEventQueue can forward mouse wheel events, |
| 27 // and dispatch mouse wheel event responses. | 28 // and dispatch mouse wheel event responses. |
| 28 class CONTENT_EXPORT MouseWheelEventQueueClient { | 29 class CONTENT_EXPORT MouseWheelEventQueueClient { |
| 29 public: | 30 public: |
| 30 virtual ~MouseWheelEventQueueClient() {} | 31 virtual ~MouseWheelEventQueueClient() {} |
| 31 | 32 |
| 32 virtual void SendMouseWheelEventImmediately( | 33 virtual void SendMouseWheelEventImmediately( |
| 33 const MouseWheelEventWithLatencyInfo& event) = 0; | 34 const MouseWheelEventWithLatencyInfo& event) = 0; |
| 34 virtual void ForwardGestureEventWithLatencyInfo( | 35 virtual void ForwardGestureEventWithLatencyInfo( |
| 35 const blink::WebGestureEvent& event, | 36 const blink::WebGestureEvent& event, |
| 36 const ui::LatencyInfo& latency_info) = 0; | 37 const ui::LatencyInfo& latency_info) = 0; |
| 37 virtual void OnMouseWheelEventAck(const MouseWheelEventWithLatencyInfo& event, | 38 virtual void OnMouseWheelEventAck(const MouseWheelEventWithLatencyInfo& event, |
| 38 InputEventAckState ack_result) = 0; | 39 InputEventAckState ack_result) = 0; |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 // A queue for throttling and coalescing mouse wheel events. | 42 // A queue for throttling and coalescing mouse wheel events. |
| 42 class CONTENT_EXPORT MouseWheelEventQueue { | 43 class CONTENT_EXPORT MouseWheelEventQueue { |
| 43 public: | 44 public: |
| 44 // The |client| must outlive the MouseWheelEventQueue. |send_gestures| | 45 // The |client| must outlive the MouseWheelEventQueue. |send_gestures| |
| 45 // indicates whether mouse wheel events should generate | 46 // indicates whether mouse wheel events should generate |
| 46 // Scroll[Begin|Update|End] on unhandled acknowledge events. | 47 // Scroll[Begin|Update|End] on unhandled acknowledge events. |
| 47 // |scroll_transaction_ms| is the duration in which the | 48 // |scroll_transaction_ms| is the duration in which the |
| 48 // ScrollEnd should be sent after a ScrollUpdate. | 49 // ScrollEnd should be sent after a ScrollUpdate. |
| 49 MouseWheelEventQueue(MouseWheelEventQueueClient* client, | 50 MouseWheelEventQueue(MouseWheelEventQueueClient* client, |
| 50 int64_t scroll_transaction_ms); | 51 bool touchpad_scroll_latching); |
| 51 | 52 |
| 52 ~MouseWheelEventQueue(); | 53 ~MouseWheelEventQueue(); |
| 53 | 54 |
| 54 // Adds an event to the queue. The event may be coalesced with previously | 55 // Adds an event to the queue. The event may be coalesced with previously |
| 55 // queued events (e.g. consecutive mouse-wheel events can be coalesced into a | 56 // queued events (e.g. consecutive mouse-wheel events can be coalesced into a |
| 56 // single mouse-wheel event). The event may also be immediately forwarded to | 57 // single mouse-wheel event). The event may also be immediately forwarded to |
| 57 // the renderer (e.g. when there are no other queued mouse-wheel event). | 58 // the renderer (e.g. when there are no other queued mouse-wheel event). |
| 58 void QueueEvent(const MouseWheelEventWithLatencyInfo& event); | 59 void QueueEvent(const MouseWheelEventWithLatencyInfo& event); |
| 59 | 60 |
| 60 // Notifies the queue that a mouse wheel event has been processed by the | 61 // Notifies the queue that a mouse wheel event has been processed by the |
| (...skipping 29 matching lines...) Expand all Loading... |
| 90 WheelEventQueue wheel_queue_; | 91 WheelEventQueue wheel_queue_; |
| 91 std::unique_ptr<QueuedWebMouseWheelEvent> event_sent_for_gesture_ack_; | 92 std::unique_ptr<QueuedWebMouseWheelEvent> event_sent_for_gesture_ack_; |
| 92 | 93 |
| 93 // True if a non-synthetic GSB needs to be sent before a GSU is sent. | 94 // True if a non-synthetic GSB needs to be sent before a GSU is sent. |
| 94 bool needs_scroll_begin_; | 95 bool needs_scroll_begin_; |
| 95 | 96 |
| 96 // True if a non-synthetic GSE needs to be sent because a non-synthetic | 97 // True if a non-synthetic GSE needs to be sent because a non-synthetic |
| 97 // GSB has been sent in the past. | 98 // GSB has been sent in the past. |
| 98 bool needs_scroll_end_; | 99 bool needs_scroll_end_; |
| 99 | 100 |
| 101 // True if the touchpad scroll latching is enabled. |
| 102 bool touchpad_scroll_latching_; |
| 103 |
| 100 int64_t scroll_transaction_ms_; | 104 int64_t scroll_transaction_ms_; |
| 101 blink::WebGestureDevice scrolling_device_; | 105 blink::WebGestureDevice scrolling_device_; |
| 102 | 106 |
| 103 DISALLOW_COPY_AND_ASSIGN(MouseWheelEventQueue); | 107 DISALLOW_COPY_AND_ASSIGN(MouseWheelEventQueue); |
| 104 }; | 108 }; |
| 105 | 109 |
| 106 } // namespace content | 110 } // namespace content |
| 107 | 111 |
| 108 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOUSE_WHEEL_EVENT_QUEUE_H_ | 112 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_MOUSE_WHEEL_EVENT_QUEUE_H_ |
| OLD | NEW |