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

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

Issue 10539041: It broke win aura bot (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
« no previous file with comments | « ui/base/gestures/gesture_sequence.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
256 switch (Signature(state_, point_id, event.GetEventType(), false)) { 251 switch (Signature(state_, point_id, event.GetEventType(), false)) {
257 case GST_NO_GESTURE_FIRST_PRESSED: 252 case GST_NO_GESTURE_FIRST_PRESSED:
258 TouchDown(event, point, gestures.get()); 253 TouchDown(event, point, gestures.get());
259 set_state(GS_PENDING_SYNTHETIC_CLICK); 254 set_state(GS_PENDING_SYNTHETIC_CLICK);
260 break; 255 break;
261 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED: 256 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED:
262 if (Click(event, point, gestures.get())) 257 if (Click(event, point, gestures.get()))
263 point.UpdateForTap(); 258 point.UpdateForTap();
264 set_state(GS_NO_GESTURE); 259 set_state(GS_NO_GESTURE);
265 break; 260 break;
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 // Nothing else to do if we have more than 2 fingers active, since after 344 // Nothing else to do if we have more than 2 fingers active, since after
350 // the release/cancel, there are still enough fingers to do pinch. 345 // the release/cancel, there are still enough fingers to do pinch.
351 // pinch_distance_current_ and pinch_distance_start_ will be updated 346 // pinch_distance_current_ and pinch_distance_start_ will be updated
352 // when the bounding-box is updated. 347 // when the bounding-box is updated.
353 } 348 }
354 ResetVelocities(); 349 ResetVelocities();
355 break; 350 break;
356 case GST_PINCH_THIRD_PRESSED: 351 case GST_PINCH_THIRD_PRESSED:
357 case GST_PINCH_FOURTH_PRESSED: 352 case GST_PINCH_FOURTH_PRESSED:
358 case GST_PINCH_FIFTH_PRESSED: 353 case GST_PINCH_FIFTH_PRESSED:
354 AppendTapDownGestureEvent(point, gestures.get());
359 pinch_distance_current_ = BoundingBoxDiagonal(bounding_box_); 355 pinch_distance_current_ = BoundingBoxDiagonal(bounding_box_);
360 pinch_distance_start_ = pinch_distance_current_; 356 pinch_distance_start_ = pinch_distance_current_;
361 break; 357 break;
362 } 358 }
363 359
364 if (event.GetEventType() == ui::ET_TOUCH_RELEASED || 360 if (event.GetEventType() == ui::ET_TOUCH_RELEASED ||
365 event.GetEventType() == ui::ET_TOUCH_CANCELLED) 361 event.GetEventType() == ui::ET_TOUCH_CANCELLED)
366 AppendEndGestureEvent(point, gestures.get()); 362 AppendTapUpGestureEvent(point, gestures.get());
367 363
368 if (state_ != last_state) 364 if (state_ != last_state)
369 DVLOG(4) << "Gesture Sequence" 365 DVLOG(4) << "Gesture Sequence"
370 << " State: " << state_ 366 << " State: " << state_
371 << " touch id: " << event.GetTouchId(); 367 << " touch id: " << event.GetTouchId();
372 368
373 if (last_state == GS_PENDING_SYNTHETIC_CLICK && state_ != last_state) 369 if (last_state == GS_PENDING_SYNTHETIC_CLICK && state_ != last_state)
374 long_press_timer_->Stop(); 370 long_press_timer_->Stop();
375 371
376 // The set of point_ids must be contiguous and include 0. 372 // The set of point_ids must be contiguous and include 0.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 return false; 469 return false;
474 } 470 }
475 471
476 void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point, 472 void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point,
477 Gestures* gestures) { 473 Gestures* gestures) {
478 gestures->push_back(helper_->CreateGestureEvent( 474 gestures->push_back(helper_->CreateGestureEvent(
479 ui::ET_GESTURE_TAP_DOWN, 475 ui::ET_GESTURE_TAP_DOWN,
480 point.first_touch_position(), 476 point.first_touch_position(),
481 flags_, 477 flags_,
482 base::Time::FromDoubleT(point.last_touch_time()), 478 base::Time::FromDoubleT(point.last_touch_time()),
483 0, 0.f, 1 << point.touch_id()));
484 }
485
486 void GestureSequence::AppendBeginGestureEvent(const GesturePoint& point,
487 Gestures* gestures) {
488 gestures->push_back(helper_->CreateGestureEvent(
489 ui::ET_GESTURE_BEGIN,
490 point.first_touch_position(),
491 flags_,
492 base::Time::FromDoubleT(point.last_touch_time()),
493 point_count_, 0.f, 1 << point.touch_id())); 479 point_count_, 0.f, 1 << point.touch_id()));
494 } 480 }
495 481
496 void GestureSequence::AppendEndGestureEvent(const GesturePoint& point, 482 void GestureSequence::AppendTapUpGestureEvent(const GesturePoint& point,
497 Gestures* gestures) { 483 Gestures* gestures) {
498 gestures->push_back(helper_->CreateGestureEvent( 484 gestures->push_back(helper_->CreateGestureEvent(
499 ui::ET_GESTURE_END, 485 ui::ET_GESTURE_TAP_UP,
500 point.first_touch_position(), 486 point.first_touch_position(),
501 flags_, 487 flags_,
502 base::Time::FromDoubleT(point.last_touch_time()), 488 base::Time::FromDoubleT(point.last_touch_time()),
503 point_count_, 0.f, 1 << point.touch_id())); 489 point_count_, 0.f, 1 << point.touch_id()));
504 } 490 }
505 491
506 void GestureSequence::AppendClickGestureEvent(const GesturePoint& point, 492 void GestureSequence::AppendClickGestureEvent(const GesturePoint& point,
507 Gestures* gestures) { 493 Gestures* gestures) {
508 gfx::Rect er = point.enclosing_rectangle(); 494 gfx::Rect er = point.enclosing_rectangle();
509 gfx::Point center = er.CenterPoint(); 495 gfx::Point center = er.CenterPoint();
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 sign_y = 0; 895 sign_y = 0;
910 else 896 else
911 sign_x = 0; 897 sign_x = 0;
912 898
913 AppendSwipeGesture(point, sign_x, sign_y, gestures); 899 AppendSwipeGesture(point, sign_x, sign_y, gestures);
914 900
915 return true; 901 return true;
916 } 902 }
917 903
918 } // namespace ui 904 } // namespace ui
OLDNEW
« no previous file with comments | « ui/base/gestures/gesture_sequence.h ('k') | ui/views/view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698