Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(83)

Side by Side Diff: content/browser/renderer_host/input/touch_event_queue.cc

Issue 24312009: Properly forward queued touch events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Unit test Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/debug/trace_event.h" 8 #include "base/debug/trace_event.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 10
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 STLDeleteElements(&touch_queue_); 101 STLDeleteElements(&touch_queue_);
102 } 102 }
103 103
104 void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) { 104 void TouchEventQueue::QueueEvent(const TouchEventWithLatencyInfo& event) {
105 // If the queueing of |event| was triggered by an ack dispatch, defer 105 // If the queueing of |event| was triggered by an ack dispatch, defer
106 // processing the event until the dispatch has finished. 106 // processing the event until the dispatch has finished.
107 if (touch_queue_.empty() && !dispatching_touch_ack_) { 107 if (touch_queue_.empty() && !dispatching_touch_ack_) {
108 // There is no touch event in the queue. Forward it to the renderer 108 // There is no touch event in the queue. Forward it to the renderer
109 // immediately. 109 // immediately.
110 touch_queue_.push_back(new CoalescedWebTouchEvent(event)); 110 touch_queue_.push_back(new CoalescedWebTouchEvent(event));
111 if (ShouldForwardToRenderer(event.event)) 111 TryForwardNextEventToRenderer();
112 client_->SendTouchEventImmediately(event);
113 else
114 PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS,
115 ui::LatencyInfo());
116 return; 112 return;
117 } 113 }
118 114
119 // If the last queued touch-event was a touch-move, and the current event is 115 // If the last queued touch-event was a touch-move, and the current event is
120 // also a touch-move, then the events can be coalesced into a single event. 116 // also a touch-move, then the events can be coalesced into a single event.
121 if (touch_queue_.size() > 1) { 117 if (touch_queue_.size() > 1) {
122 CoalescedWebTouchEvent* last_event = touch_queue_.back(); 118 CoalescedWebTouchEvent* last_event = touch_queue_.back();
123 if (last_event->CoalesceEventIfPossible(event)) 119 if (last_event->CoalesceEventIfPossible(event))
124 return; 120 return;
125 } 121 }
(...skipping 20 matching lines...) Expand all
146 } 142 }
147 } else if (event.type == WebKit::WebInputEvent::TouchStart) { 143 } else if (event.type == WebKit::WebInputEvent::TouchStart) {
148 for (unsigned i = 0; i < event.touchesLength; ++i) { 144 for (unsigned i = 0; i < event.touchesLength; ++i) {
149 const WebKit::WebTouchPoint& point = event.touches[i]; 145 const WebKit::WebTouchPoint& point = event.touches[i];
150 if (point.state == WebKit::WebTouchPoint::StatePressed) 146 if (point.state == WebKit::WebTouchPoint::StatePressed)
151 touch_ack_states_[point.id] = ack_result; 147 touch_ack_states_[point.id] = ack_result;
152 } 148 }
153 } 149 }
154 150
155 PopTouchEventToClient(ack_result, latency_info); 151 PopTouchEventToClient(ack_result, latency_info);
152 TryForwardNextEventToRenderer();
153 }
156 154
155 void TouchEventQueue::TryForwardNextEventToRenderer() {
157 // If there are queued touch events, then try to forward them to the renderer 156 // If there are queued touch events, then try to forward them to the renderer
158 // immediately, or ACK the events back to the client if appropriate. 157 // immediately, or ACK the events back to the client if appropriate.
159 while (!touch_queue_.empty()) { 158 while (!touch_queue_.empty()) {
160 const TouchEventWithLatencyInfo& touch = 159 const TouchEventWithLatencyInfo& touch =
161 touch_queue_.front()->coalesced_event(); 160 touch_queue_.front()->coalesced_event();
162 if (ShouldForwardToRenderer(touch.event)) { 161 if (ShouldForwardToRenderer(touch.event)) {
163 client_->SendTouchEventImmediately(touch); 162 client_->SendTouchEventImmediately(touch);
164 break; 163 break;
165 } 164 }
166 PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS, 165 PopTouchEventToClient(INPUT_EVENT_ACK_STATE_NO_CONSUMER_EXISTS,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // If the ACK status of a point is unknown, then the event should be 230 // If the ACK status of a point is unknown, then the event should be
232 // forwarded to the renderer. 231 // forwarded to the renderer.
233 return true; 232 return true;
234 } 233 }
235 } 234 }
236 235
237 return false; 236 return false;
238 } 237 }
239 238
240 } // namespace content 239 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_event_queue.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698