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

Side by Side Diff: ui/base/gestures/gesture_sequence.cc

Issue 10533029: Fix TAP_DOWN gesture event: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/base/gestures/gesture_sequence.h" 5 #include "ui/base/gestures/gesture_sequence.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 241
242 // NOTE: when modifying these state transitions, also update gestures.dot 242 // NOTE: when modifying these state transitions, also update gestures.dot
243 scoped_ptr<Gestures> gestures(new Gestures()); 243 scoped_ptr<Gestures> gestures(new Gestures());
244 GesturePoint& point = GesturePointForEvent(event); 244 GesturePoint& point = GesturePointForEvent(event);
245 point.UpdateValues(event); 245 point.UpdateValues(event);
246 RecreateBoundingBox(); 246 RecreateBoundingBox();
247 flags_ = event.GetEventFlags(); 247 flags_ = event.GetEventFlags();
248 const int point_id = points_[event.GetTouchId()].point_id(); 248 const int point_id = points_[event.GetTouchId()].point_id();
249 if (point_id < 0) 249 if (point_id < 0)
250 return NULL; 250 return NULL;
251
252 // Send GESTURE_BEGIN for any touch pressed.
253 if (event.GetEventType() == ui::ET_TOUCH_PRESSED)
254 AppendBeginGestureEvent(point, gestures.get());
255
251 switch (Signature(state_, point_id, event.GetEventType(), false)) { 256 switch (Signature(state_, point_id, event.GetEventType(), false)) {
252 case GST_NO_GESTURE_FIRST_PRESSED: 257 case GST_NO_GESTURE_FIRST_PRESSED:
253 TouchDown(event, point, gestures.get()); 258 TouchDown(event, point, gestures.get());
254 set_state(GS_PENDING_SYNTHETIC_CLICK); 259 set_state(GS_PENDING_SYNTHETIC_CLICK);
255 break; 260 break;
256 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED: 261 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED:
257 if (Click(event, point, gestures.get())) 262 if (Click(event, point, gestures.get()))
258 point.UpdateForTap(); 263 point.UpdateForTap();
259 set_state(GS_NO_GESTURE); 264 set_state(GS_NO_GESTURE);
260 break; 265 break;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // Nothing else to do if we have more than 2 fingers active, since after 349 // Nothing else to do if we have more than 2 fingers active, since after
345 // the release/cancel, there are still enough fingers to do pinch. 350 // the release/cancel, there are still enough fingers to do pinch.
346 // pinch_distance_current_ and pinch_distance_start_ will be updated 351 // pinch_distance_current_ and pinch_distance_start_ will be updated
347 // when the bounding-box is updated. 352 // when the bounding-box is updated.
348 } 353 }
349 ResetVelocities(); 354 ResetVelocities();
350 break; 355 break;
351 case GST_PINCH_THIRD_PRESSED: 356 case GST_PINCH_THIRD_PRESSED:
352 case GST_PINCH_FOURTH_PRESSED: 357 case GST_PINCH_FOURTH_PRESSED:
353 case GST_PINCH_FIFTH_PRESSED: 358 case GST_PINCH_FIFTH_PRESSED:
354 AppendTapDownGestureEvent(point, gestures.get());
355 pinch_distance_current_ = BoundingBoxDiagonal(bounding_box_); 359 pinch_distance_current_ = BoundingBoxDiagonal(bounding_box_);
356 pinch_distance_start_ = pinch_distance_current_; 360 pinch_distance_start_ = pinch_distance_current_;
357 break; 361 break;
358 } 362 }
359 363
360 if (event.GetEventType() == ui::ET_TOUCH_RELEASED || 364 if (event.GetEventType() == ui::ET_TOUCH_RELEASED ||
361 event.GetEventType() == ui::ET_TOUCH_CANCELLED) 365 event.GetEventType() == ui::ET_TOUCH_CANCELLED)
362 AppendTapUpGestureEvent(point, gestures.get()); 366 AppendEndGestureEvent(point, gestures.get());
363 367
364 if (state_ != last_state) 368 if (state_ != last_state)
365 DVLOG(4) << "Gesture Sequence" 369 DVLOG(4) << "Gesture Sequence"
366 << " State: " << state_ 370 << " State: " << state_
367 << " touch id: " << event.GetTouchId(); 371 << " touch id: " << event.GetTouchId();
368 372
369 if (last_state == GS_PENDING_SYNTHETIC_CLICK && state_ != last_state) 373 if (last_state == GS_PENDING_SYNTHETIC_CLICK && state_ != last_state)
370 long_press_timer_->Stop(); 374 long_press_timer_->Stop();
371 375
372 // The set of point_ids must be contiguous and include 0. 376 // The set of point_ids must be contiguous and include 0.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 return false; 473 return false;
470 } 474 }
471 475
472 void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point, 476 void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point,
473 Gestures* gestures) { 477 Gestures* gestures) {
474 gestures->push_back(helper_->CreateGestureEvent( 478 gestures->push_back(helper_->CreateGestureEvent(
475 ui::ET_GESTURE_TAP_DOWN, 479 ui::ET_GESTURE_TAP_DOWN,
476 point.first_touch_position(), 480 point.first_touch_position(),
477 flags_, 481 flags_,
478 base::Time::FromDoubleT(point.last_touch_time()), 482 base::Time::FromDoubleT(point.last_touch_time()),
479 point_count_, 0.f, 1 << point.touch_id())); 483 point_count_, 0.f, 1 << point.touch_id()));
sadrul 2012/06/06 19:51:14 We don't need to send point_count_ here anymore. S
varunjain 2012/06/06 21:52:53 Done.
480 } 484 }
481 485
482 void GestureSequence::AppendTapUpGestureEvent(const GesturePoint& point, 486 void GestureSequence::AppendBeginGestureEvent(const GesturePoint& point,
483 Gestures* gestures) { 487 Gestures* gestures) {
484 gestures->push_back(helper_->CreateGestureEvent( 488 gestures->push_back(helper_->CreateGestureEvent(
485 ui::ET_GESTURE_TAP_UP, 489 ui::ET_GESTURE_BEGIN,
486 point.first_touch_position(), 490 point.first_touch_position(),
487 flags_, 491 flags_,
488 base::Time::FromDoubleT(point.last_touch_time()), 492 base::Time::FromDoubleT(point.last_touch_time()),
493 point_count_, 0.f, 1 << point.touch_id()));
494 }
495
496 void GestureSequence::AppendEndGestureEvent(const GesturePoint& point,
497 Gestures* gestures) {
498 gestures->push_back(helper_->CreateGestureEvent(
499 ui::ET_GESTURE_END,
500 point.first_touch_position(),
501 flags_,
502 base::Time::FromDoubleT(point.last_touch_time()),
489 point_count_, 0.f, 1 << point.touch_id())); 503 point_count_, 0.f, 1 << point.touch_id()));
490 } 504 }
491 505
492 void GestureSequence::AppendClickGestureEvent(const GesturePoint& point, 506 void GestureSequence::AppendClickGestureEvent(const GesturePoint& point,
493 Gestures* gestures) { 507 Gestures* gestures) {
494 gfx::Rect er = point.enclosing_rectangle(); 508 gfx::Rect er = point.enclosing_rectangle();
495 gfx::Point center = er.CenterPoint(); 509 gfx::Point center = er.CenterPoint();
496 gestures->push_back(helper_->CreateGestureEvent( 510 gestures->push_back(helper_->CreateGestureEvent(
497 ui::ET_GESTURE_TAP, 511 ui::ET_GESTURE_TAP,
498 center, 512 center,
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 sign_y = 0; 909 sign_y = 0;
896 else 910 else
897 sign_x = 0; 911 sign_x = 0;
898 912
899 AppendSwipeGesture(point, sign_x, sign_y, gestures); 913 AppendSwipeGesture(point, sign_x, sign_y, gestures);
900 914
901 return true; 915 return true;
902 } 916 }
903 917
904 } // namespace ui 918 } // namespace ui
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698