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 #include "ui/events/gesture_detection/gesture_provider.h" | 5 #include "ui/events/gesture_detection/gesture_provider.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 tap_details.set_bounding_box( | 87 tap_details.set_bounding_box( |
88 gfx::RectF(event.GetTouchMajor(), event.GetTouchMajor())); | 88 gfx::RectF(event.GetTouchMajor(), event.GetTouchMajor())); |
89 return tap_details; | 89 return tap_details; |
90 } | 90 } |
91 | 91 |
92 } // namespace | 92 } // namespace |
93 | 93 |
94 // GestureProvider:::Config | 94 // GestureProvider:::Config |
95 | 95 |
96 GestureProvider::Config::Config() | 96 GestureProvider::Config::Config() |
97 : disable_click_delay(false), gesture_begin_end_types_enabled(false) {} | 97 : display(gfx::Display::kInvalidDisplayID, gfx::Rect(1, 1)), |
| 98 disable_click_delay(false), |
| 99 gesture_begin_end_types_enabled(false) {} |
98 | 100 |
99 GestureProvider::Config::~Config() {} | 101 GestureProvider::Config::~Config() {} |
100 | 102 |
101 // GestureProvider::ScaleGestureListener | 103 // GestureProvider::ScaleGestureListener |
102 | 104 |
103 class GestureProvider::ScaleGestureListenerImpl | 105 class GestureProvider::ScaleGestureListenerImpl |
104 : public ScaleGestureDetector::ScaleGestureListener { | 106 : public ScaleGestureDetector::ScaleGestureListener { |
105 public: | 107 public: |
106 ScaleGestureListenerImpl(const ScaleGestureDetector::Config& config, | 108 ScaleGestureListenerImpl(const ScaleGestureDetector::Config& config, |
107 float device_scale_factor, | |
108 GestureProvider* provider) | 109 GestureProvider* provider) |
109 : scale_gesture_detector_(config, this), | 110 : scale_gesture_detector_(config, this), |
110 provider_(provider), | 111 provider_(provider), |
111 px_to_dp_(1.0f / device_scale_factor), | |
112 ignore_multitouch_events_(false), | 112 ignore_multitouch_events_(false), |
113 pinch_event_sent_(false) {} | 113 pinch_event_sent_(false) {} |
114 | 114 |
115 bool OnTouchEvent(const MotionEvent& event) { | 115 bool OnTouchEvent(const MotionEvent& event) { |
116 // TODO: Need to deal with multi-touch transition. | 116 // TODO: Need to deal with multi-touch transition. |
117 const bool in_scale_gesture = IsScaleGestureDetectionInProgress(); | 117 const bool in_scale_gesture = IsScaleGestureDetectionInProgress(); |
118 bool handled = scale_gesture_detector_.OnTouchEvent(event); | 118 bool handled = scale_gesture_detector_.OnTouchEvent(event); |
119 if (!in_scale_gesture && | 119 if (!in_scale_gesture && |
120 (event.GetAction() == MotionEvent::ACTION_UP || | 120 (event.GetAction() == MotionEvent::ACTION_UP || |
121 event.GetAction() == MotionEvent::ACTION_CANCEL)) { | 121 event.GetAction() == MotionEvent::ACTION_CANCEL)) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 if (detector.InDoubleTapMode()) { | 167 if (detector.InDoubleTapMode()) { |
168 // Relative changes in the double-tap scale factor computed by |detector| | 168 // Relative changes in the double-tap scale factor computed by |detector| |
169 // diminish as the touch moves away from the original double-tap focus. | 169 // diminish as the touch moves away from the original double-tap focus. |
170 // For historical reasons, Chrome has instead adopted a scale factor | 170 // For historical reasons, Chrome has instead adopted a scale factor |
171 // computation that is invariant to the focal distance, where | 171 // computation that is invariant to the focal distance, where |
172 // the scale delta remains constant if the touch velocity is constant. | 172 // the scale delta remains constant if the touch velocity is constant. |
173 float dy = | 173 float dy = |
174 (detector.GetCurrentSpanY() - detector.GetPreviousSpanY()) * 0.5f; | 174 (detector.GetCurrentSpanY() - detector.GetPreviousSpanY()) * 0.5f; |
175 scale = std::pow(scale > 1 ? 1.0f + kDoubleTapDragZoomSpeed | 175 scale = std::pow(scale > 1 ? 1.0f + kDoubleTapDragZoomSpeed |
176 : 1.0f - kDoubleTapDragZoomSpeed, | 176 : 1.0f - kDoubleTapDragZoomSpeed, |
177 std::abs(dy * px_to_dp_)); | 177 std::abs(dy)); |
178 } | 178 } |
179 GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE, scale, 0); | 179 GestureEventDetails pinch_details(ET_GESTURE_PINCH_UPDATE, scale, 0); |
180 provider_->Send(CreateGesture(ET_GESTURE_PINCH_UPDATE, | 180 provider_->Send(CreateGesture(ET_GESTURE_PINCH_UPDATE, |
181 e.GetId(), | 181 e.GetId(), |
182 detector.GetEventTime(), | 182 detector.GetEventTime(), |
183 detector.GetFocusX(), | 183 detector.GetFocusX(), |
184 detector.GetFocusY(), | 184 detector.GetFocusY(), |
185 e.GetPointerCount(), | 185 e.GetPointerCount(), |
186 pinch_details)); | 186 pinch_details)); |
187 return true; | 187 return true; |
(...skipping 22 matching lines...) Expand all Loading... |
210 | 210 |
211 private: | 211 private: |
212 bool InDoubleTapMode() const { | 212 bool InDoubleTapMode() const { |
213 return scale_gesture_detector_.InDoubleTapMode(); | 213 return scale_gesture_detector_.InDoubleTapMode(); |
214 } | 214 } |
215 | 215 |
216 ScaleGestureDetector scale_gesture_detector_; | 216 ScaleGestureDetector scale_gesture_detector_; |
217 | 217 |
218 GestureProvider* const provider_; | 218 GestureProvider* const provider_; |
219 | 219 |
220 // TODO(jdduke): Remove this when all MotionEvent's use DIPs. | |
221 const float px_to_dp_; | |
222 | |
223 // Completely silence multi-touch (pinch) scaling events. Used in WebView when | 220 // Completely silence multi-touch (pinch) scaling events. Used in WebView when |
224 // zoom support is turned off. | 221 // zoom support is turned off. |
225 bool ignore_multitouch_events_; | 222 bool ignore_multitouch_events_; |
226 | 223 |
227 // Whether any pinch zoom event has been sent to native. | 224 // Whether any pinch zoom event has been sent to native. |
228 bool pinch_event_sent_; | 225 bool pinch_event_sent_; |
229 | 226 |
230 DISALLOW_COPY_AND_ASSIGN(ScaleGestureListenerImpl); | 227 DISALLOW_COPY_AND_ASSIGN(ScaleGestureListenerImpl); |
231 }; | 228 }; |
232 | 229 |
233 // GestureProvider::GestureListener | 230 // GestureProvider::GestureListener |
234 | 231 |
235 class GestureProvider::GestureListenerImpl | 232 class GestureProvider::GestureListenerImpl |
236 : public GestureDetector::GestureListener, | 233 : public GestureDetector::GestureListener, |
237 public GestureDetector::DoubleTapListener { | 234 public GestureDetector::DoubleTapListener { |
238 public: | 235 public: |
239 GestureListenerImpl( | 236 GestureListenerImpl( |
| 237 const gfx::Display& display, |
240 const GestureDetector::Config& gesture_detector_config, | 238 const GestureDetector::Config& gesture_detector_config, |
241 const SnapScrollController::Config& snap_scroll_controller_config, | |
242 bool disable_click_delay, | 239 bool disable_click_delay, |
243 GestureProvider* provider) | 240 GestureProvider* provider) |
244 : gesture_detector_(gesture_detector_config, this, this), | 241 : gesture_detector_(gesture_detector_config, this, this), |
245 snap_scroll_controller_(snap_scroll_controller_config), | 242 snap_scroll_controller_(display), |
246 provider_(provider), | 243 provider_(provider), |
247 disable_click_delay_(disable_click_delay), | 244 disable_click_delay_(disable_click_delay), |
248 scaled_touch_slop_(gesture_detector_config.scaled_touch_slop), | 245 touch_slop_(gesture_detector_config.touch_slop), |
249 scaled_touch_slop_square_(scaled_touch_slop_ * scaled_touch_slop_), | |
250 double_tap_timeout_(gesture_detector_config.double_tap_timeout), | 246 double_tap_timeout_(gesture_detector_config.double_tap_timeout), |
251 ignore_single_tap_(false), | 247 ignore_single_tap_(false), |
252 seen_first_scroll_event_(false), | 248 seen_first_scroll_event_(false) {} |
253 last_raw_x_(0), | |
254 last_raw_y_(0), | |
255 accumulated_scroll_error_x_(0), | |
256 accumulated_scroll_error_y_(0) {} | |
257 | 249 |
258 virtual ~GestureListenerImpl() {} | 250 virtual ~GestureListenerImpl() {} |
259 | 251 |
260 bool OnTouchEvent(const MotionEvent& e, | 252 bool OnTouchEvent(const MotionEvent& e, |
261 bool is_scale_gesture_detection_in_progress) { | 253 bool is_scale_gesture_detection_in_progress) { |
262 snap_scroll_controller_.SetSnapScrollingMode( | 254 snap_scroll_controller_.SetSnapScrollingMode( |
263 e, is_scale_gesture_detection_in_progress); | 255 e, is_scale_gesture_detection_in_progress); |
264 | 256 |
265 if (is_scale_gesture_detection_in_progress) | 257 if (is_scale_gesture_detection_in_progress) |
266 SetIgnoreSingleTap(true); | 258 SetIgnoreSingleTap(true); |
267 | 259 |
268 if (e.GetAction() == MotionEvent::ACTION_DOWN) | 260 if (e.GetAction() == MotionEvent::ACTION_DOWN) |
269 gesture_detector_.set_is_longpress_enabled(true); | 261 gesture_detector_.set_is_longpress_enabled(true); |
270 | 262 |
271 return gesture_detector_.OnTouchEvent(e); | 263 return gesture_detector_.OnTouchEvent(e); |
272 } | 264 } |
273 | 265 |
274 // GestureDetector::GestureListener implementation. | 266 // GestureDetector::GestureListener implementation. |
275 virtual bool OnDown(const MotionEvent& e) OVERRIDE { | 267 virtual bool OnDown(const MotionEvent& e) OVERRIDE { |
276 current_down_time_ = e.GetEventTime(); | 268 current_down_time_ = e.GetEventTime(); |
277 ignore_single_tap_ = false; | 269 ignore_single_tap_ = false; |
278 seen_first_scroll_event_ = false; | 270 seen_first_scroll_event_ = false; |
279 last_raw_x_ = e.GetRawX(); | |
280 last_raw_y_ = e.GetRawY(); | |
281 accumulated_scroll_error_x_ = 0; | |
282 accumulated_scroll_error_y_ = 0; | |
283 | 271 |
284 GestureEventDetails tap_details(ET_GESTURE_TAP_DOWN, 0, 0); | 272 GestureEventDetails tap_details(ET_GESTURE_TAP_DOWN, 0, 0); |
285 tap_details.set_bounding_box( | 273 tap_details.set_bounding_box( |
286 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); | 274 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); |
287 provider_->Send(CreateGesture(ET_GESTURE_TAP_DOWN, e, tap_details)); | 275 provider_->Send(CreateGesture(ET_GESTURE_TAP_DOWN, e, tap_details)); |
288 | 276 |
289 // Return true to indicate that we want to handle touch. | 277 // Return true to indicate that we want to handle touch. |
290 return true; | 278 return true; |
291 } | 279 } |
292 | 280 |
293 virtual bool OnScroll(const MotionEvent& e1, | 281 virtual bool OnScroll(const MotionEvent& e1, |
294 const MotionEvent& e2, | 282 const MotionEvent& e2, |
295 float raw_distance_x, | 283 float raw_distance_x, |
296 float raw_distance_y) OVERRIDE { | 284 float raw_distance_y) OVERRIDE { |
297 float distance_x = raw_distance_x; | 285 float distance_x = raw_distance_x; |
298 float distance_y = raw_distance_y; | 286 float distance_y = raw_distance_y; |
299 if (!seen_first_scroll_event_) { | 287 if (!seen_first_scroll_event_) { |
300 // Remove the touch slop region from the first scroll event to avoid a | 288 // Remove the touch slop region from the first scroll event to avoid a |
301 // jump. | 289 // jump. |
302 seen_first_scroll_event_ = true; | 290 seen_first_scroll_event_ = true; |
303 double distance = | 291 double distance = |
304 std::sqrt(distance_x * distance_x + distance_y * distance_y); | 292 std::sqrt(distance_x * distance_x + distance_y * distance_y); |
305 double epsilon = 1e-3; | 293 double epsilon = 1e-3; |
306 if (distance > epsilon) { | 294 if (distance > epsilon) { |
307 double ratio = std::max(0., distance - scaled_touch_slop_) / distance; | 295 double ratio = std::max(0., distance - touch_slop_) / distance; |
308 distance_x *= ratio; | 296 distance_x *= ratio; |
309 distance_y *= ratio; | 297 distance_y *= ratio; |
310 } | 298 } |
311 } | 299 } |
312 snap_scroll_controller_.UpdateSnapScrollMode(distance_x, distance_y); | 300 snap_scroll_controller_.UpdateSnapScrollMode(distance_x, distance_y); |
313 if (snap_scroll_controller_.IsSnappingScrolls()) { | 301 if (snap_scroll_controller_.IsSnappingScrolls()) { |
314 if (snap_scroll_controller_.IsSnapHorizontal()) { | 302 if (snap_scroll_controller_.IsSnapHorizontal()) { |
315 distance_y = 0; | 303 distance_y = 0; |
316 } else { | 304 } else { |
317 distance_x = 0; | 305 distance_x = 0; |
318 } | 306 } |
319 } | 307 } |
320 | 308 |
321 last_raw_x_ = e2.GetRawX(); | |
322 last_raw_y_ = e2.GetRawY(); | |
323 if (!provider_->IsScrollInProgress()) { | 309 if (!provider_->IsScrollInProgress()) { |
324 // Note that scroll start hints are in distance traveled, where | 310 // Note that scroll start hints are in distance traveled, where |
325 // scroll deltas are in the opposite direction. | 311 // scroll deltas are in the opposite direction. |
326 GestureEventDetails scroll_details( | 312 GestureEventDetails scroll_details( |
327 ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y); | 313 ET_GESTURE_SCROLL_BEGIN, -raw_distance_x, -raw_distance_y); |
328 | 314 |
329 // Use the co-ordinates from the touch down, as these co-ordinates are | 315 // Use the co-ordinates from the touch down, as these co-ordinates are |
330 // used to determine which layer the scroll should affect. | 316 // used to determine which layer the scroll should affect. |
331 provider_->Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN, | 317 provider_->Send(CreateGesture(ET_GESTURE_SCROLL_BEGIN, |
332 e2.GetId(), | 318 e2.GetId(), |
333 e2.GetEventTime(), | 319 e2.GetEventTime(), |
334 e1.GetX(), | 320 e1.GetX(), |
335 e1.GetY(), | 321 e1.GetY(), |
336 e2.GetPointerCount(), | 322 e2.GetPointerCount(), |
337 scroll_details)); | 323 scroll_details)); |
338 } | 324 } |
339 | 325 |
340 // distance_x and distance_y is the scrolling offset since last OnScroll. | 326 if (distance_x || distance_y) { |
341 // Because we are passing integers to Blink, this could introduce | 327 GestureEventDetails scroll_details( |
342 // rounding errors. The rounding errors will accumulate overtime. | 328 ET_GESTURE_SCROLL_UPDATE, -distance_x, -distance_y); |
343 // To solve this, we should be adding back the rounding errors each time | |
344 // when we calculate the new offset. | |
345 // TODO(jdduke): Determine if we can simpy use floating point deltas, as | |
346 // WebGestureEvent also takes floating point deltas for GestureScrollUpdate. | |
347 int dx = (int)(distance_x + accumulated_scroll_error_x_); | |
348 int dy = (int)(distance_y + accumulated_scroll_error_y_); | |
349 accumulated_scroll_error_x_ += (distance_x - dx); | |
350 accumulated_scroll_error_y_ += (distance_y - dy); | |
351 | |
352 if (dx || dy) { | |
353 GestureEventDetails scroll_details(ET_GESTURE_SCROLL_UPDATE, -dx, -dy); | |
354 provider_->Send( | 329 provider_->Send( |
355 CreateGesture(ET_GESTURE_SCROLL_UPDATE, e2, scroll_details)); | 330 CreateGesture(ET_GESTURE_SCROLL_UPDATE, e2, scroll_details)); |
356 } | 331 } |
357 | 332 |
358 return true; | 333 return true; |
359 } | 334 } |
360 | 335 |
361 virtual bool OnFling(const MotionEvent& e1, | 336 virtual bool OnFling(const MotionEvent& e1, |
362 const MotionEvent& e2, | 337 const MotionEvent& e2, |
363 float velocity_x, | 338 float velocity_x, |
(...skipping 13 matching lines...) Expand all Loading... |
377 virtual void OnShowPress(const MotionEvent& e) OVERRIDE { | 352 virtual void OnShowPress(const MotionEvent& e) OVERRIDE { |
378 GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); | 353 GestureEventDetails show_press_details(ET_GESTURE_SHOW_PRESS, 0, 0); |
379 // TODO(jdduke): Expose minor axis length and rotation in |MotionEvent|. | 354 // TODO(jdduke): Expose minor axis length and rotation in |MotionEvent|. |
380 show_press_details.set_bounding_box( | 355 show_press_details.set_bounding_box( |
381 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); | 356 gfx::RectF(e.GetTouchMajor(), e.GetTouchMajor())); |
382 provider_->Send( | 357 provider_->Send( |
383 CreateGesture(ET_GESTURE_SHOW_PRESS, e, show_press_details)); | 358 CreateGesture(ET_GESTURE_SHOW_PRESS, e, show_press_details)); |
384 } | 359 } |
385 | 360 |
386 virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE { | 361 virtual bool OnSingleTapUp(const MotionEvent& e) OVERRIDE { |
387 if (IsPointOutsideCurrentSlopRegion(e.GetRawX(), e.GetRawY())) { | |
388 ignore_single_tap_ = true; | |
389 return true; | |
390 } | |
391 // This is a hack to address the issue where user hovers | 362 // This is a hack to address the issue where user hovers |
392 // over a link for longer than double_tap_timeout_, then | 363 // over a link for longer than double_tap_timeout_, then |
393 // OnSingleTapConfirmed() is not triggered. But we still | 364 // OnSingleTapConfirmed() is not triggered. But we still |
394 // want to trigger the tap event at UP. So we override | 365 // want to trigger the tap event at UP. So we override |
395 // OnSingleTapUp() in this case. This assumes singleTapUp | 366 // OnSingleTapUp() in this case. This assumes singleTapUp |
396 // gets always called before singleTapConfirmed. | 367 // gets always called before singleTapConfirmed. |
397 if (!ignore_single_tap_) { | 368 if (!ignore_single_tap_) { |
398 if (e.GetEventTime() - current_down_time_ > double_tap_timeout_) { | 369 if (e.GetEventTime() - current_down_time_ > double_tap_timeout_) { |
399 return OnSingleTapConfirmed(e); | 370 return OnSingleTapConfirmed(e); |
400 } else if (!IsDoubleTapEnabled() || disable_click_delay_) { | 371 } else if (!IsDoubleTapEnabled() || disable_click_delay_) { |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
480 } | 451 } |
481 } | 452 } |
482 | 453 |
483 bool IsClickDelayDisabled() const { return disable_click_delay_; } | 454 bool IsClickDelayDisabled() const { return disable_click_delay_; } |
484 | 455 |
485 bool IsDoubleTapInProgress() const { | 456 bool IsDoubleTapInProgress() const { |
486 return gesture_detector_.is_double_tapping(); | 457 return gesture_detector_.is_double_tapping(); |
487 } | 458 } |
488 | 459 |
489 private: | 460 private: |
490 bool IsPointOutsideCurrentSlopRegion(float x, float y) const { | |
491 return IsDistanceGreaterThanTouchSlop(last_raw_x_ - x, last_raw_y_ - y); | |
492 } | |
493 | |
494 bool IsDistanceGreaterThanTouchSlop(float distance_x, | |
495 float distance_y) const { | |
496 return distance_x * distance_x + distance_y * distance_y > | |
497 scaled_touch_slop_square_; | |
498 } | |
499 | |
500 void SetIgnoreSingleTap(bool value) { ignore_single_tap_ = value; } | 461 void SetIgnoreSingleTap(bool value) { ignore_single_tap_ = value; } |
501 | 462 |
502 bool IsDoubleTapEnabled() const { | 463 bool IsDoubleTapEnabled() const { |
503 return gesture_detector_.has_doubletap_listener(); | 464 return gesture_detector_.has_doubletap_listener(); |
504 } | 465 } |
505 | 466 |
506 GestureDetector gesture_detector_; | 467 GestureDetector gesture_detector_; |
507 SnapScrollController snap_scroll_controller_; | 468 SnapScrollController snap_scroll_controller_; |
508 | 469 |
509 GestureProvider* const provider_; | 470 GestureProvider* const provider_; |
510 | 471 |
511 // Whether the click delay should always be disabled by sending clicks for | 472 // Whether the click delay should always be disabled by sending clicks for |
512 // double-tap gestures. | 473 // double-tap gestures. |
513 const bool disable_click_delay_; | 474 const bool disable_click_delay_; |
514 | 475 |
515 const int scaled_touch_slop_; | 476 const float touch_slop_; |
516 | |
517 // Cache of square of the scaled touch slop so we don't have to calculate it | |
518 // on every touch. | |
519 const int scaled_touch_slop_square_; | |
520 | 477 |
521 const base::TimeDelta double_tap_timeout_; | 478 const base::TimeDelta double_tap_timeout_; |
522 | 479 |
523 base::TimeTicks current_down_time_; | 480 base::TimeTicks current_down_time_; |
524 | 481 |
525 // TODO(klobag): This is to avoid a bug in GestureDetector. With multi-touch, | 482 // TODO(klobag): This is to avoid a bug in GestureDetector. With multi-touch, |
526 // always_in_tap_region_ is not reset. So when the last finger is up, | 483 // always_in_tap_region_ is not reset. So when the last finger is up, |
527 // OnSingleTapUp() will be mistakenly fired. | 484 // OnSingleTapUp() will be mistakenly fired. |
528 bool ignore_single_tap_; | 485 bool ignore_single_tap_; |
529 | 486 |
530 // Used to remove the touch slop from the initial scroll event in a scroll | 487 // Used to remove the touch slop from the initial scroll event in a scroll |
531 // gesture. | 488 // gesture. |
532 bool seen_first_scroll_event_; | 489 bool seen_first_scroll_event_; |
533 | 490 |
534 // Used to track the last rawX/Y coordinates for moves. This gives absolute | |
535 // scroll distance. | |
536 // Useful for full screen tracking. | |
537 float last_raw_x_; | |
538 float last_raw_y_; | |
539 | |
540 // Used to track the accumulated scroll error over time. This is used to | |
541 // remove the | |
542 // rounding error we introduced by passing integers to webkit. | |
543 float accumulated_scroll_error_x_; | |
544 float accumulated_scroll_error_y_; | |
545 | |
546 DISALLOW_COPY_AND_ASSIGN(GestureListenerImpl); | 491 DISALLOW_COPY_AND_ASSIGN(GestureListenerImpl); |
547 }; | 492 }; |
548 | 493 |
549 // GestureProvider | 494 // GestureProvider |
550 | 495 |
551 GestureProvider::GestureProvider(const Config& config, | 496 GestureProvider::GestureProvider(const Config& config, |
552 GestureProviderClient* client) | 497 GestureProviderClient* client) |
553 : client_(client), | 498 : client_(client), |
554 touch_scroll_in_progress_(false), | 499 touch_scroll_in_progress_(false), |
555 pinch_in_progress_(false), | 500 pinch_in_progress_(false), |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 return double_tap_support_for_page_ && double_tap_support_for_platform_; | 565 return double_tap_support_for_page_ && double_tap_support_for_platform_; |
621 } | 566 } |
622 | 567 |
623 bool GestureProvider::IsClickDelayDisabled() const { | 568 bool GestureProvider::IsClickDelayDisabled() const { |
624 return gesture_listener_->IsClickDelayDisabled(); | 569 return gesture_listener_->IsClickDelayDisabled(); |
625 } | 570 } |
626 | 571 |
627 void GestureProvider::InitGestureDetectors(const Config& config) { | 572 void GestureProvider::InitGestureDetectors(const Config& config) { |
628 TRACE_EVENT0("input", "GestureProvider::InitGestureDetectors"); | 573 TRACE_EVENT0("input", "GestureProvider::InitGestureDetectors"); |
629 gesture_listener_.reset( | 574 gesture_listener_.reset( |
630 new GestureListenerImpl(config.gesture_detector_config, | 575 new GestureListenerImpl(config.display, |
631 config.snap_scroll_controller_config, | 576 config.gesture_detector_config, |
632 config.disable_click_delay, | 577 config.disable_click_delay, |
633 this)); | 578 this)); |
634 | 579 |
635 scale_gesture_listener_.reset(new ScaleGestureListenerImpl( | 580 scale_gesture_listener_.reset( |
636 config.scale_gesture_detector_config, | 581 new ScaleGestureListenerImpl(config.scale_gesture_detector_config, this)); |
637 config.snap_scroll_controller_config.device_scale_factor, | |
638 this)); | |
639 | 582 |
640 UpdateDoubleTapDetectionSupport(); | 583 UpdateDoubleTapDetectionSupport(); |
641 } | 584 } |
642 | 585 |
643 bool GestureProvider::CanHandle(const MotionEvent& event) const { | 586 bool GestureProvider::CanHandle(const MotionEvent& event) const { |
644 return event.GetAction() == MotionEvent::ACTION_DOWN || current_down_event_; | 587 return event.GetAction() == MotionEvent::ACTION_DOWN || current_down_event_; |
645 } | 588 } |
646 | 589 |
647 void GestureProvider::Fling(const MotionEvent& event, | 590 void GestureProvider::Fling(const MotionEvent& event, |
648 float velocity_x, | 591 float velocity_x, |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
801 Send(CreateGesture(ET_GESTURE_END, event)); | 744 Send(CreateGesture(ET_GESTURE_END, event)); |
802 break; | 745 break; |
803 case MotionEvent::ACTION_DOWN: | 746 case MotionEvent::ACTION_DOWN: |
804 case MotionEvent::ACTION_POINTER_DOWN: | 747 case MotionEvent::ACTION_POINTER_DOWN: |
805 case MotionEvent::ACTION_MOVE: | 748 case MotionEvent::ACTION_MOVE: |
806 break; | 749 break; |
807 } | 750 } |
808 } | 751 } |
809 | 752 |
810 } // namespace ui | 753 } // namespace ui |
OLD | NEW |