OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_GESTURE_EVENT_QUEUE_H_ | 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ |
6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ | 6 #define CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <queue> | 9 #include <queue> |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 void UpdateState(InputEventAckState ack_state); | 56 void UpdateState(InputEventAckState ack_state); |
57 bool IsGesturePrevented() const; | 57 bool IsGesturePrevented() const; |
58 bool IsEmpty() const; | 58 bool IsEmpty() const; |
59 | 59 |
60 private: | 60 private: |
61 std::queue<GestureEventPacket> packets_; | 61 std::queue<GestureEventPacket> packets_; |
62 enum GestureHandlingState { | 62 enum GestureHandlingState { |
63 PENDING, // The sequence has yet to receive an ack. | 63 PENDING, // The sequence has yet to receive an ack. |
64 ALLOWED_UNTIL_PREVENTED, // Gestures in the sequence are allowed until | 64 ALLOWED_UNTIL_PREVENTED, // Gestures in the sequence are allowed until |
65 // a source touch is preventDefault'ed. | 65 // a source touch is preventDefault'ed. |
66 ALWAYS_ALLOWED, // All remaining sequence gestures are forwarded. | 66 ALWAYS_ALLOWED, // All remaining sequence gestures are forwarded |
67 ALWAYS_PREVENTED // All remaining sequence gestures are dropped. | 67 // except for independent packets whose |
| 68 // corresponding touch was consumed. |
| 69 ALWAYS_PREVENTED // All remaining sequence gestures are dropped, |
| 70 // except for 'ending' gestures which are |
| 71 // needed to complete a previous sequence. |
68 }; | 72 }; |
69 GestureHandlingState state_; | 73 GestureHandlingState state_; |
70 }; | 74 }; |
71 void UpdateAndDispatchPackets(GestureSequence* sequence, | 75 void UpdateAndDispatchPackets(GestureSequence* sequence, |
72 InputEventAckState ack_result); | 76 InputEventAckState ack_result); |
73 void SendPacket(const GestureEventPacket& packet); | 77 void FilterAndSendPacket(const GestureEventPacket& packet, |
| 78 bool gesturePrevented, |
| 79 InputEventAckState ack_state); |
74 void SendGesture(const blink::WebGestureEvent& gesture); | 80 void SendGesture(const blink::WebGestureEvent& gesture); |
75 void CancelTapIfNecessary(); | 81 void CancelTapIfNecessary(); |
76 void CancelFlingIfNecessary(); | 82 void CancelFlingIfNecessary(); |
77 GestureSequence& Head(); | 83 GestureSequence& Head(); |
78 GestureSequence& Tail(); | 84 GestureSequence& Tail(); |
79 | 85 |
80 GestureEventQueueClient* client_; | 86 GestureEventQueueClient* client_; |
81 std::queue<GestureSequence> sequences_; | 87 std::queue<GestureSequence> sequences_; |
82 | 88 |
83 // Bookkeeping for inserting synthetic Gesture{Tap,Fling}Cancel events | 89 // Bookkeeping for inserting synthetic Gesture{Tap,Fling}Cancel events |
84 // when necessary, e.g., GestureTapCancel when scrolling begins, or | 90 // when necessary, e.g., GestureTapCancel when scrolling begins, or |
85 // GestureFlingCancel when a user taps following a GestureFlingStart. | 91 // GestureFlingCancel when a user taps following a GestureFlingStart. |
86 bool needs_tap_ending_event_; | 92 bool needs_tap_ending_event_; |
87 bool needs_fling_ending_event_; | 93 bool needs_fling_ending_event_; |
88 | 94 |
| 95 // Bookkeeping to ensure that scroll/pinch sequences are terminated |
| 96 // whenever they are started, regardless of the disposition. |
| 97 bool needs_scroll_ending_event_; |
| 98 bool needs_pinch_ending_event_; |
| 99 |
89 DISALLOW_COPY_AND_ASSIGN(GestureEventQueue); | 100 DISALLOW_COPY_AND_ASSIGN(GestureEventQueue); |
90 }; | 101 }; |
91 | 102 |
92 } // namespace content | 103 } // namespace content |
93 | 104 |
94 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ | 105 #endif // CONTENT_BROWSER_RENDERER_HOST_INPUT_GESTURE_EVENT_QUEUE_H_ |
OLD | NEW |