| Index: ui/aura/gestures/gesture_point.cc
|
| diff --git a/ui/aura/gestures/gesture_point.cc b/ui/aura/gestures/gesture_point.cc
|
| index 3402e56673331098a3d8e60233bda7736d52a91e..8791c3428450c91280fa0e56201b60dc9c9257ac 100644
|
| --- a/ui/aura/gestures/gesture_point.cc
|
| +++ b/ui/aura/gestures/gesture_point.cc
|
| @@ -6,6 +6,7 @@
|
|
|
| #include "ui/aura/event.h"
|
| #include "ui/base/events.h"
|
| +#include "base/basictypes.h"
|
|
|
| namespace {
|
|
|
| @@ -16,8 +17,9 @@ const double kMinimumTouchDownDurationInSecondsForClick = 0.01;
|
| const double kMaximumSecondsBetweenDoubleClick = 0.7;
|
| const int kMaximumTouchMoveInPixelsForClick = 20;
|
| const float kMinFlickSpeedSquared = 550.f * 550.f;
|
| +const int kBufferedPoints = 10;
|
|
|
| -} // namespace aura
|
| +} // namespace
|
|
|
| namespace aura {
|
|
|
| @@ -25,20 +27,21 @@ GesturePoint::GesturePoint()
|
| : first_touch_time_(0.0),
|
| last_touch_time_(0.0),
|
| last_tap_time_(0.0),
|
| - x_velocity_(0.0),
|
| - y_velocity_(0.0) {
|
| + velocity_calculator_(kBufferedPoints) {
|
| }
|
|
|
| void GesturePoint::Reset() {
|
| first_touch_time_ = last_touch_time_ = 0.0;
|
| - x_velocity_ = y_velocity_ = 0.0;
|
| + velocity_calculator_.ClearHistory();
|
| }
|
|
|
| void GesturePoint::UpdateValues(const TouchEvent& event, GestureState state) {
|
| + const int64 event_timestamp_microseconds =
|
| + event.time_stamp().InMicroseconds();
|
| if (state != GS_NO_GESTURE && event.type() == ui::ET_TOUCH_MOVED) {
|
| - double interval(event.time_stamp().InSecondsF() - last_touch_time_);
|
| - x_velocity_ = (event.x() - last_touch_position_.x()) / interval;
|
| - y_velocity_ = (event.y() - last_touch_position_.y()) / interval;
|
| + velocity_calculator_.PointSeen(event.x(),
|
| + event.y(),
|
| + event_timestamp_microseconds);
|
| }
|
|
|
| last_touch_time_ = event.time_stamp().InSecondsF();
|
| @@ -47,8 +50,10 @@ void GesturePoint::UpdateValues(const TouchEvent& event, GestureState state) {
|
| if (state == GS_NO_GESTURE) {
|
| first_touch_time_ = last_touch_time_;
|
| first_touch_position_ = event.location();
|
| - x_velocity_ = 0.0;
|
| - y_velocity_ = 0.0;
|
| + velocity_calculator_.ClearHistory();
|
| + velocity_calculator_.PointSeen(event.x(),
|
| + event.y(),
|
| + event_timestamp_microseconds);
|
| }
|
| }
|
|
|
| @@ -115,8 +120,7 @@ bool GesturePoint::IsSecondClickInsideManhattanSquare(
|
| }
|
|
|
| bool GesturePoint::IsOverMinFlickSpeed() const {
|
| - return (x_velocity_ * x_velocity_ + y_velocity_ * y_velocity_) >
|
| - kMinFlickSpeedSquared;
|
| + return velocity_calculator_.VelocitySquared() > kMinFlickSpeedSquared;
|
| }
|
|
|
| } // namespace aura
|
|
|