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

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

Issue 10446103: GestureScrollEnd event had non-zero velocity causing overscroll on software fling path. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed unit tests 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/aura/gestures/gesture_recognizer_unittest.cc ('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 (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 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 float x_velocity, 475 float x_velocity,
476 float y_velocity) { 476 float y_velocity) {
477 float railed_x_velocity = x_velocity; 477 float railed_x_velocity = x_velocity;
478 float railed_y_velocity = y_velocity; 478 float railed_y_velocity = y_velocity;
479 479
480 if (scroll_type_ == ST_HORIZONTAL) 480 if (scroll_type_ == ST_HORIZONTAL)
481 railed_y_velocity = 0; 481 railed_y_velocity = 0;
482 else if (scroll_type_ == ST_VERTICAL) 482 else if (scroll_type_ == ST_VERTICAL)
483 railed_x_velocity = 0; 483 railed_x_velocity = 0;
484 484
485 // TODO(rjkroege): It is conceivable that we could suppress sending the
486 // GestureScrollEnd if it is immediately followed by a GestureFlingStart.
485 gestures->push_back(helper_->CreateGestureEvent( 487 gestures->push_back(helper_->CreateGestureEvent(
486 ui::ET_GESTURE_SCROLL_END, 488 ui::ET_GESTURE_SCROLL_END,
487 location, 489 location,
488 flags_, 490 flags_,
489 base::Time::FromDoubleT(point.last_touch_time()), 491 base::Time::FromDoubleT(point.last_touch_time()),
490 railed_x_velocity, railed_y_velocity, 1 << point.touch_id())); 492 0., 0., 1 << point.touch_id()));
491 493
492 if (railed_x_velocity != 0 || railed_y_velocity != 0) { 494 if (railed_x_velocity != 0 || railed_y_velocity != 0) {
493 // TODO(sad|rjkroege): fling-curve is currently configured to work well with 495 // TODO(sad|rjkroege): fling-curve is currently configured to work well with
494 // touchpad scroll-events. This curve needs to be adjusted to work correctly 496 // touchpad scroll-events. This curve needs to be adjusted to work correctly
495 // with both touchpad and touchscreen. Until then, multiply the velocity for 497 // with both touchpad and touchscreen. Until then, scale quadratically.
496 // touchscreen with a constant.
497 // http://crbug.com/120154 498 // http://crbug.com/120154
499 const float velocity_scaling = 1.f / 900.f;
500
498 gestures->push_back(helper_->CreateGestureEvent( 501 gestures->push_back(helper_->CreateGestureEvent(
499 ui::ET_SCROLL_FLING_START, 502 ui::ET_SCROLL_FLING_START,
500 location, 503 location,
501 flags_, 504 flags_,
502 base::Time::FromDoubleT(point.last_touch_time()), 505 base::Time::FromDoubleT(point.last_touch_time()),
503 railed_x_velocity * 2.5, railed_y_velocity * 2.5, 506 velocity_scaling * railed_x_velocity * fabsf(railed_x_velocity),
507 velocity_scaling * railed_y_velocity * fabsf(railed_y_velocity),
504 1 << point.touch_id())); 508 1 << point.touch_id()));
505 } 509 }
506 } 510 }
507 511
508 void GestureSequence::AppendScrollGestureUpdate(const GesturePoint& point, 512 void GestureSequence::AppendScrollGestureUpdate(const GesturePoint& point,
509 const gfx::Point& location, 513 const gfx::Point& location,
510 Gestures* gestures) { 514 Gestures* gestures) {
511 int dx = location.x() - bounding_box_last_center_.x(); 515 int dx = location.x() - bounding_box_last_center_.x();
512 int dy = location.y() - bounding_box_last_center_.y(); 516 int dy = location.y() - bounding_box_last_center_.y();
513 if (dx == 0 && dy == 0) 517 if (dx == 0 && dy == 0)
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
786 sign_y = 0; 790 sign_y = 0;
787 else 791 else
788 sign_x = 0; 792 sign_x = 0;
789 793
790 AppendSwipeGesture(point, sign_x, sign_y, gestures); 794 AppendSwipeGesture(point, sign_x, sign_y, gestures);
791 795
792 return true; 796 return true;
793 } 797 }
794 798
795 } // namespace ui 799 } // namespace ui
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_recognizer_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698