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

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

Issue 2573073003: Collapse the API surface on WebInputEvent via accessor functions. (Closed)
Patch Set: Created 4 years 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
OLDNEW
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 #include "content/browser/renderer_host/input/gesture_event_queue.h" 5 #include "content/browser/renderer_host/input/gesture_event_queue.h"
6 6
7 #include "base/trace_event/trace_event.h" 7 #include "base/trace_event/trace_event.h"
8 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle r.h" 8 #include "content/browser/renderer_host/input/touchpad_tap_suppression_controlle r.h"
9 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro ller.h" 9 #include "content/browser/renderer_host/input/touchscreen_tap_suppression_contro ller.h"
10 #include "ui/events/blink/web_input_event_traits.h" 10 #include "ui/events/blink/web_input_event_traits.h"
11 11
12 using blink::WebGestureEvent; 12 using blink::WebGestureEvent;
13 using blink::WebInputEvent; 13 using blink::WebInputEvent;
14 14
15 namespace content { 15 namespace content {
16 namespace { 16 namespace {
17 17
18 // Whether |event_in_queue| is GesturePinchUpdate or GestureScrollUpdate and 18 // Whether |event_in_queue| is GesturePinchUpdate or GestureScrollUpdate and
19 // has the same modifiers/source as the new scroll/pinch event. Compatible 19 // has the same modifiers/source as the new scroll/pinch event. Compatible
20 // scroll and pinch event pairs can be logically coalesced. 20 // scroll and pinch event pairs can be logically coalesced.
21 bool IsCompatibleScrollorPinch( 21 bool IsCompatibleScrollorPinch(
22 const GestureEventWithLatencyInfo& new_event, 22 const GestureEventWithLatencyInfo& new_event,
23 const GestureEventWithLatencyInfo& event_in_queue) { 23 const GestureEventWithLatencyInfo& event_in_queue) {
24 DCHECK(new_event.event.type == WebInputEvent::GestureScrollUpdate || 24 DCHECK(new_event.event.type() == WebInputEvent::GestureScrollUpdate ||
25 new_event.event.type == WebInputEvent::GesturePinchUpdate) 25 new_event.event.type() == WebInputEvent::GesturePinchUpdate)
26 << "Invalid event type for pinch/scroll coalescing: " 26 << "Invalid event type for pinch/scroll coalescing: "
27 << WebInputEvent::GetName(new_event.event.type); 27 << WebInputEvent::GetName(new_event.event.type());
28 DLOG_IF(WARNING, new_event.event.timeStampSeconds < 28 DLOG_IF(WARNING, new_event.event.timeStampSeconds() <
29 event_in_queue.event.timeStampSeconds) 29 event_in_queue.event.timeStampSeconds())
30 << "Event time not monotonic?\n"; 30 << "Event time not monotonic?\n";
31 return (event_in_queue.event.type == WebInputEvent::GestureScrollUpdate || 31 return (event_in_queue.event.type() == WebInputEvent::GestureScrollUpdate ||
32 event_in_queue.event.type == WebInputEvent::GesturePinchUpdate) && 32 event_in_queue.event.type() == WebInputEvent::GesturePinchUpdate) &&
33 event_in_queue.event.modifiers == new_event.event.modifiers && 33 event_in_queue.event.modifiers() == new_event.event.modifiers() &&
34 event_in_queue.event.sourceDevice == new_event.event.sourceDevice; 34 event_in_queue.event.sourceDevice == new_event.event.sourceDevice;
35 } 35 }
36 36
37 // Returns the transform matrix corresponding to the gesture event. 37 // Returns the transform matrix corresponding to the gesture event.
38 gfx::Transform GetTransformForEvent( 38 gfx::Transform GetTransformForEvent(
39 const GestureEventWithLatencyInfo& gesture_event) { 39 const GestureEventWithLatencyInfo& gesture_event) {
40 gfx::Transform gesture_transform; 40 gfx::Transform gesture_transform;
41 if (gesture_event.event.type == WebInputEvent::GestureScrollUpdate) { 41 if (gesture_event.event.type() == WebInputEvent::GestureScrollUpdate) {
42 gesture_transform.Translate(gesture_event.event.data.scrollUpdate.deltaX, 42 gesture_transform.Translate(gesture_event.event.data.scrollUpdate.deltaX,
43 gesture_event.event.data.scrollUpdate.deltaY); 43 gesture_event.event.data.scrollUpdate.deltaY);
44 } else if (gesture_event.event.type == WebInputEvent::GesturePinchUpdate) { 44 } else if (gesture_event.event.type() == WebInputEvent::GesturePinchUpdate) {
45 float scale = gesture_event.event.data.pinchUpdate.scale; 45 float scale = gesture_event.event.data.pinchUpdate.scale;
46 gesture_transform.Translate(-gesture_event.event.x, -gesture_event.event.y); 46 gesture_transform.Translate(-gesture_event.event.x, -gesture_event.event.y);
47 gesture_transform.Scale(scale, scale); 47 gesture_transform.Scale(scale, scale);
48 gesture_transform.Translate(gesture_event.event.x, gesture_event.event.y); 48 gesture_transform.Translate(gesture_event.event.x, gesture_event.event.y);
49 } else { 49 } else {
50 NOTREACHED() << "Invalid event type for transform retrieval: " 50 NOTREACHED() << "Invalid event type for transform retrieval: "
51 << WebInputEvent::GetName(gesture_event.event.type); 51 << WebInputEvent::GetName(gesture_event.event.type());
52 } 52 }
53 return gesture_transform; 53 return gesture_transform;
54 } 54 }
55 55
56 } // namespace 56 } // namespace
57 57
58 GestureEventQueue::Config::Config() { 58 GestureEventQueue::Config::Config() {
59 } 59 }
60 60
61 GestureEventQueue::GestureEventQueue( 61 GestureEventQueue::GestureEventQueue(
(...skipping 29 matching lines...) Expand all
91 QueueAndForwardIfNecessary(gesture_event); 91 QueueAndForwardIfNecessary(gesture_event);
92 } 92 }
93 93
94 bool GestureEventQueue::ShouldDiscardFlingCancelEvent( 94 bool GestureEventQueue::ShouldDiscardFlingCancelEvent(
95 const GestureEventWithLatencyInfo& gesture_event) const { 95 const GestureEventWithLatencyInfo& gesture_event) const {
96 if (coalesced_gesture_events_.empty() && fling_in_progress_) 96 if (coalesced_gesture_events_.empty() && fling_in_progress_)
97 return false; 97 return false;
98 GestureQueue::const_reverse_iterator it = 98 GestureQueue::const_reverse_iterator it =
99 coalesced_gesture_events_.rbegin(); 99 coalesced_gesture_events_.rbegin();
100 while (it != coalesced_gesture_events_.rend()) { 100 while (it != coalesced_gesture_events_.rend()) {
101 if (it->event.type == WebInputEvent::GestureFlingStart) 101 if (it->event.type() == WebInputEvent::GestureFlingStart)
102 return false; 102 return false;
103 if (it->event.type == WebInputEvent::GestureFlingCancel) 103 if (it->event.type() == WebInputEvent::GestureFlingCancel)
104 return true; 104 return true;
105 it++; 105 it++;
106 } 106 }
107 return true; 107 return true;
108 } 108 }
109 109
110 bool GestureEventQueue::ShouldForwardForBounceReduction( 110 bool GestureEventQueue::ShouldForwardForBounceReduction(
111 const GestureEventWithLatencyInfo& gesture_event) { 111 const GestureEventWithLatencyInfo& gesture_event) {
112 if (debounce_interval_ <= base::TimeDelta()) 112 if (debounce_interval_ <= base::TimeDelta())
113 return true; 113 return true;
114 switch (gesture_event.event.type) { 114 switch (gesture_event.event.type()) {
115 case WebInputEvent::GestureScrollUpdate: 115 case WebInputEvent::GestureScrollUpdate:
116 if (!scrolling_in_progress_) { 116 if (!scrolling_in_progress_) {
117 debounce_deferring_timer_.Start( 117 debounce_deferring_timer_.Start(
118 FROM_HERE, 118 FROM_HERE,
119 debounce_interval_, 119 debounce_interval_,
120 this, 120 this,
121 &GestureEventQueue::SendScrollEndingEventsNow); 121 &GestureEventQueue::SendScrollEndingEventsNow);
122 } else { 122 } else {
123 // Extend the bounce interval. 123 // Extend the bounce interval.
124 debounce_deferring_timer_.Reset(); 124 debounce_deferring_timer_.Reset();
(...skipping 11 matching lines...) Expand all
136 if (scrolling_in_progress_) { 136 if (scrolling_in_progress_) {
137 debouncing_deferral_queue_.push_back(gesture_event); 137 debouncing_deferral_queue_.push_back(gesture_event);
138 return false; 138 return false;
139 } 139 }
140 return true; 140 return true;
141 } 141 }
142 } 142 }
143 143
144 bool GestureEventQueue::ShouldForwardForGFCFiltering( 144 bool GestureEventQueue::ShouldForwardForGFCFiltering(
145 const GestureEventWithLatencyInfo& gesture_event) const { 145 const GestureEventWithLatencyInfo& gesture_event) const {
146 return gesture_event.event.type != WebInputEvent::GestureFlingCancel || 146 return gesture_event.event.type() != WebInputEvent::GestureFlingCancel ||
147 !ShouldDiscardFlingCancelEvent(gesture_event); 147 !ShouldDiscardFlingCancelEvent(gesture_event);
148 } 148 }
149 149
150 bool GestureEventQueue::ShouldForwardForTapSuppression( 150 bool GestureEventQueue::ShouldForwardForTapSuppression(
151 const GestureEventWithLatencyInfo& gesture_event) { 151 const GestureEventWithLatencyInfo& gesture_event) {
152 switch (gesture_event.event.type) { 152 switch (gesture_event.event.type()) {
153 case WebInputEvent::GestureFlingCancel: 153 case WebInputEvent::GestureFlingCancel:
154 if (gesture_event.event.sourceDevice == 154 if (gesture_event.event.sourceDevice ==
155 blink::WebGestureDeviceTouchscreen) 155 blink::WebGestureDeviceTouchscreen)
156 touchscreen_tap_suppression_controller_.GestureFlingCancel(); 156 touchscreen_tap_suppression_controller_.GestureFlingCancel();
157 else 157 else
158 touchpad_tap_suppression_controller_.GestureFlingCancel(); 158 touchpad_tap_suppression_controller_.GestureFlingCancel();
159 return true; 159 return true;
160 case WebInputEvent::GestureTapDown: 160 case WebInputEvent::GestureTapDown:
161 case WebInputEvent::GestureShowPress: 161 case WebInputEvent::GestureShowPress:
162 case WebInputEvent::GestureTapUnconfirmed: 162 case WebInputEvent::GestureTapUnconfirmed:
163 case WebInputEvent::GestureTapCancel: 163 case WebInputEvent::GestureTapCancel:
164 case WebInputEvent::GestureTap: 164 case WebInputEvent::GestureTap:
165 case WebInputEvent::GestureDoubleTap: 165 case WebInputEvent::GestureDoubleTap:
166 case WebInputEvent::GestureLongPress: 166 case WebInputEvent::GestureLongPress:
167 case WebInputEvent::GestureLongTap: 167 case WebInputEvent::GestureLongTap:
168 case WebInputEvent::GestureTwoFingerTap: 168 case WebInputEvent::GestureTwoFingerTap:
169 if (gesture_event.event.sourceDevice == 169 if (gesture_event.event.sourceDevice ==
170 blink::WebGestureDeviceTouchscreen) { 170 blink::WebGestureDeviceTouchscreen) {
171 return !touchscreen_tap_suppression_controller_.FilterTapEvent( 171 return !touchscreen_tap_suppression_controller_.FilterTapEvent(
172 gesture_event); 172 gesture_event);
173 } 173 }
174 return true; 174 return true;
175 default: 175 default:
176 return true; 176 return true;
177 } 177 }
178 } 178 }
179 179
180 void GestureEventQueue::QueueAndForwardIfNecessary( 180 void GestureEventQueue::QueueAndForwardIfNecessary(
181 const GestureEventWithLatencyInfo& gesture_event) { 181 const GestureEventWithLatencyInfo& gesture_event) {
182 switch (gesture_event.event.type) { 182 switch (gesture_event.event.type()) {
183 case WebInputEvent::GestureFlingCancel: 183 case WebInputEvent::GestureFlingCancel:
184 fling_in_progress_ = false; 184 fling_in_progress_ = false;
185 break; 185 break;
186 case WebInputEvent::GestureFlingStart: 186 case WebInputEvent::GestureFlingStart:
187 fling_in_progress_ = true; 187 fling_in_progress_ = true;
188 break; 188 break;
189 case WebInputEvent::GesturePinchUpdate: 189 case WebInputEvent::GesturePinchUpdate:
190 case WebInputEvent::GestureScrollUpdate: 190 case WebInputEvent::GestureScrollUpdate:
191 QueueScrollOrPinchAndForwardIfNecessary(gesture_event); 191 QueueScrollOrPinchAndForwardIfNecessary(gesture_event);
192 return; 192 return;
(...skipping 12 matching lines...) Expand all
205 bool GestureEventQueue::OnScrollBegin( 205 bool GestureEventQueue::OnScrollBegin(
206 const GestureEventWithLatencyInfo& gesture_event) { 206 const GestureEventWithLatencyInfo& gesture_event) {
207 // If a synthetic scroll begin is encountered, it can cancel out a previous 207 // If a synthetic scroll begin is encountered, it can cancel out a previous
208 // synthetic scroll end. This allows a later gesture scroll update to coalesce 208 // synthetic scroll end. This allows a later gesture scroll update to coalesce
209 // with the previous one. crbug.com/607340. 209 // with the previous one. crbug.com/607340.
210 bool synthetic = gesture_event.event.data.scrollBegin.synthetic; 210 bool synthetic = gesture_event.event.data.scrollBegin.synthetic;
211 bool have_unsent_events = 211 bool have_unsent_events =
212 EventsInFlightCount() < coalesced_gesture_events_.size(); 212 EventsInFlightCount() < coalesced_gesture_events_.size();
213 if (synthetic && have_unsent_events) { 213 if (synthetic && have_unsent_events) {
214 GestureEventWithLatencyInfo* last_event = &coalesced_gesture_events_.back(); 214 GestureEventWithLatencyInfo* last_event = &coalesced_gesture_events_.back();
215 if (last_event->event.type == WebInputEvent::GestureScrollEnd && 215 if (last_event->event.type() == WebInputEvent::GestureScrollEnd &&
216 last_event->event.data.scrollEnd.synthetic) { 216 last_event->event.data.scrollEnd.synthetic) {
217 coalesced_gesture_events_.pop_back(); 217 coalesced_gesture_events_.pop_back();
218 return true; 218 return true;
219 } 219 }
220 } 220 }
221 return false; 221 return false;
222 } 222 }
223 223
224 void GestureEventQueue::ProcessGestureAck(InputEventAckState ack_result, 224 void GestureEventQueue::ProcessGestureAck(InputEventAckState ack_result,
225 WebInputEvent::Type type, 225 WebInputEvent::Type type,
226 const ui::LatencyInfo& latency) { 226 const ui::LatencyInfo& latency) {
227 TRACE_EVENT0("input", "GestureEventQueue::ProcessGestureAck"); 227 TRACE_EVENT0("input", "GestureEventQueue::ProcessGestureAck");
228 228
229 if (coalesced_gesture_events_.empty()) { 229 if (coalesced_gesture_events_.empty()) {
230 DLOG(ERROR) << "Received unexpected ACK for event type " << type; 230 DLOG(ERROR) << "Received unexpected ACK for event type " << type;
231 return; 231 return;
232 } 232 }
233 233
234 // It's possible that the ack for the second event in an in-flight, coalesced 234 // It's possible that the ack for the second event in an in-flight, coalesced
235 // Gesture{Scroll,Pinch}Update pair is received prior to the first event ack. 235 // Gesture{Scroll,Pinch}Update pair is received prior to the first event ack.
236 size_t event_index = 0; 236 size_t event_index = 0;
237 if (ignore_next_ack_ && 237 if (ignore_next_ack_ && coalesced_gesture_events_.size() > 1 &&
238 coalesced_gesture_events_.size() > 1 && 238 coalesced_gesture_events_[0].event.type() != type &&
239 coalesced_gesture_events_[0].event.type != type && 239 coalesced_gesture_events_[1].event.type() == type) {
240 coalesced_gesture_events_[1].event.type == type) {
241 event_index = 1; 240 event_index = 1;
242 } 241 }
243 GestureEventWithLatencyInfo event_with_latency = 242 GestureEventWithLatencyInfo event_with_latency =
244 coalesced_gesture_events_[event_index]; 243 coalesced_gesture_events_[event_index];
245 DCHECK_EQ(event_with_latency.event.type, type); 244 DCHECK_EQ(event_with_latency.event.type(), type);
246 event_with_latency.latency.AddNewLatencyFrom(latency); 245 event_with_latency.latency.AddNewLatencyFrom(latency);
247 246
248 // Ack'ing an event may enqueue additional gesture events. By ack'ing the 247 // Ack'ing an event may enqueue additional gesture events. By ack'ing the
249 // event before the forwarding of queued events below, such additional events 248 // event before the forwarding of queued events below, such additional events
250 // can be coalesced with existing queued events prior to dispatch. 249 // can be coalesced with existing queued events prior to dispatch.
251 client_->OnGestureEventAck(event_with_latency, ack_result); 250 client_->OnGestureEventAck(event_with_latency, ack_result);
252 251
253 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result); 252 const bool processed = (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result);
254 if (type == WebInputEvent::GestureFlingCancel) { 253 if (type == WebInputEvent::GestureFlingCancel) {
255 if (event_with_latency.event.sourceDevice == 254 if (event_with_latency.event.sourceDevice ==
(...skipping 13 matching lines...) Expand all
269 268
270 if (coalesced_gesture_events_.empty()) 269 if (coalesced_gesture_events_.empty())
271 return; 270 return;
272 271
273 const GestureEventWithLatencyInfo& first_gesture_event = 272 const GestureEventWithLatencyInfo& first_gesture_event =
274 coalesced_gesture_events_.front(); 273 coalesced_gesture_events_.front();
275 274
276 // Check for the coupled GesturePinchUpdate before sending either event, 275 // Check for the coupled GesturePinchUpdate before sending either event,
277 // handling the case where the first GestureScrollUpdate ack is synchronous. 276 // handling the case where the first GestureScrollUpdate ack is synchronous.
278 GestureEventWithLatencyInfo second_gesture_event; 277 GestureEventWithLatencyInfo second_gesture_event;
279 if (first_gesture_event.event.type == WebInputEvent::GestureScrollUpdate && 278 if (first_gesture_event.event.type() == WebInputEvent::GestureScrollUpdate &&
280 coalesced_gesture_events_.size() > 1 && 279 coalesced_gesture_events_.size() > 1 &&
281 coalesced_gesture_events_[1].event.type == 280 coalesced_gesture_events_[1].event.type() ==
282 WebInputEvent::GesturePinchUpdate) { 281 WebInputEvent::GesturePinchUpdate) {
283 second_gesture_event = coalesced_gesture_events_[1]; 282 second_gesture_event = coalesced_gesture_events_[1];
284 ignore_next_ack_ = true; 283 ignore_next_ack_ = true;
285 } 284 }
286 285
287 client_->SendGestureEventImmediately(first_gesture_event); 286 client_->SendGestureEventImmediately(first_gesture_event);
288 if (second_gesture_event.event.type != WebInputEvent::Undefined) 287 if (second_gesture_event.event.type() != WebInputEvent::Undefined)
289 client_->SendGestureEventImmediately(second_gesture_event); 288 client_->SendGestureEventImmediately(second_gesture_event);
290 } 289 }
291 290
292 TouchpadTapSuppressionController* 291 TouchpadTapSuppressionController*
293 GestureEventQueue::GetTouchpadTapSuppressionController() { 292 GestureEventQueue::GetTouchpadTapSuppressionController() {
294 return &touchpad_tap_suppression_controller_; 293 return &touchpad_tap_suppression_controller_;
295 } 294 }
296 295
297 void GestureEventQueue::FlingHasBeenHalted() { 296 void GestureEventQueue::FlingHasBeenHalted() {
298 fling_in_progress_ = false; 297 fling_in_progress_ = false;
(...skipping 28 matching lines...) Expand all
327 coalesced_gesture_events_.push_back(gesture_event); 326 coalesced_gesture_events_.push_back(gesture_event);
328 if (coalesced_gesture_events_.size() == 1) { 327 if (coalesced_gesture_events_.size() == 1) {
329 client_->SendGestureEventImmediately(gesture_event); 328 client_->SendGestureEventImmediately(gesture_event);
330 } else if (coalesced_gesture_events_.size() == 2) { 329 } else if (coalesced_gesture_events_.size() == 2) {
331 DCHECK(!ignore_next_ack_); 330 DCHECK(!ignore_next_ack_);
332 // If there is an in-flight scroll, the new pinch can be forwarded 331 // If there is an in-flight scroll, the new pinch can be forwarded
333 // immediately, avoiding a potential frame delay between the two 332 // immediately, avoiding a potential frame delay between the two
334 // (similarly for an in-flight pinch with a new scroll). 333 // (similarly for an in-flight pinch with a new scroll).
335 const GestureEventWithLatencyInfo& first_event = 334 const GestureEventWithLatencyInfo& first_event =
336 coalesced_gesture_events_.front(); 335 coalesced_gesture_events_.front();
337 if (gesture_event.event.type != first_event.event.type && 336 if (gesture_event.event.type() != first_event.event.type() &&
338 IsCompatibleScrollorPinch(gesture_event, first_event)) { 337 IsCompatibleScrollorPinch(gesture_event, first_event)) {
339 ignore_next_ack_ = true; 338 ignore_next_ack_ = true;
340 client_->SendGestureEventImmediately(gesture_event); 339 client_->SendGestureEventImmediately(gesture_event);
341 } 340 }
342 } 341 }
343 return; 342 return;
344 } 343 }
345 344
346 GestureEventWithLatencyInfo* last_event = &coalesced_gesture_events_.back(); 345 GestureEventWithLatencyInfo* last_event = &coalesced_gesture_events_.back();
347 if (last_event->CanCoalesceWith(gesture_event)) { 346 if (last_event->CanCoalesceWith(gesture_event)) {
348 last_event->CoalesceWith(gesture_event); 347 last_event->CoalesceWith(gesture_event);
349 return; 348 return;
350 } 349 }
351 350
352 if (!IsCompatibleScrollorPinch(gesture_event, *last_event)) { 351 if (!IsCompatibleScrollorPinch(gesture_event, *last_event)) {
353 coalesced_gesture_events_.push_back(gesture_event); 352 coalesced_gesture_events_.push_back(gesture_event);
354 return; 353 return;
355 } 354 }
356 355
357 // Keep the oldest LatencyInfo. 356 // Keep the oldest LatencyInfo.
358 DCHECK_LE(last_event->latency.trace_id(), gesture_event.latency.trace_id()); 357 DCHECK_LE(last_event->latency.trace_id(), gesture_event.latency.trace_id());
359 GestureEventWithLatencyInfo scroll_event( 358 GestureEventWithLatencyInfo scroll_event(
360 WebInputEvent::GestureScrollUpdate, gesture_event.event.modifiers, 359 WebInputEvent::GestureScrollUpdate, gesture_event.event.modifiers(),
361 gesture_event.event.timeStampSeconds, last_event->latency); 360 gesture_event.event.timeStampSeconds(), last_event->latency);
362 GestureEventWithLatencyInfo pinch_event( 361 GestureEventWithLatencyInfo pinch_event(
363 WebInputEvent::GesturePinchUpdate, gesture_event.event.modifiers, 362 WebInputEvent::GesturePinchUpdate, gesture_event.event.modifiers(),
364 gesture_event.event.timeStampSeconds, last_event->latency); 363 gesture_event.event.timeStampSeconds(), last_event->latency);
365 pinch_event.event.sourceDevice = scroll_event.event.sourceDevice = 364 pinch_event.event.sourceDevice = scroll_event.event.sourceDevice =
366 gesture_event.event.sourceDevice; 365 gesture_event.event.sourceDevice;
367 pinch_event.event.x = 366 pinch_event.event.x =
368 gesture_event.event.type == WebInputEvent::GesturePinchUpdate 367 gesture_event.event.type() == WebInputEvent::GesturePinchUpdate
369 ? gesture_event.event.x 368 ? gesture_event.event.x
370 : last_event->event.x; 369 : last_event->event.x;
371 pinch_event.event.y = 370 pinch_event.event.y =
372 gesture_event.event.type == WebInputEvent::GesturePinchUpdate 371 gesture_event.event.type() == WebInputEvent::GesturePinchUpdate
373 ? gesture_event.event.y 372 ? gesture_event.event.y
374 : last_event->event.y; 373 : last_event->event.y;
375 374
376 gfx::Transform combined_scroll_pinch = GetTransformForEvent(*last_event); 375 gfx::Transform combined_scroll_pinch = GetTransformForEvent(*last_event);
377 // Only include the second-to-last event in the coalesced pair if it exists 376 // Only include the second-to-last event in the coalesced pair if it exists
378 // and can be combined with the new event. 377 // and can be combined with the new event.
379 if (unsent_events_count > 1) { 378 if (unsent_events_count > 1) {
380 const GestureEventWithLatencyInfo& second_last_event = 379 const GestureEventWithLatencyInfo& second_last_event =
381 coalesced_gesture_events_[coalesced_gesture_events_.size() - 2]; 380 coalesced_gesture_events_[coalesced_gesture_events_.size() - 2];
382 if (IsCompatibleScrollorPinch(gesture_event, second_last_event)) { 381 if (IsCompatibleScrollorPinch(gesture_event, second_last_event)) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 return 0; 414 return 0;
416 415
417 if (!ignore_next_ack_) 416 if (!ignore_next_ack_)
418 return 1; 417 return 1;
419 418
420 DCHECK_GT(coalesced_gesture_events_.size(), 1U); 419 DCHECK_GT(coalesced_gesture_events_.size(), 1U);
421 return 2; 420 return 2;
422 } 421 }
423 422
424 } // namespace content 423 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698