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

Unified Diff: ui/base/gestures/gesture_sequence.cc

Issue 10837107: gesture recognizer: Make sure the pinch/scroll only when the finger is moved for real. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/gestures/gesture_sequence.cc
diff --git a/ui/base/gestures/gesture_sequence.cc b/ui/base/gestures/gesture_sequence.cc
index 1cf4cba9d66523eb8051ad23ce5bd6184410dfed..157cb11fde0736ffc39e70caec336dfe979b511e 100644
--- a/ui/base/gestures/gesture_sequence.cc
+++ b/ui/base/gestures/gesture_sequence.cc
@@ -674,12 +674,12 @@ void GestureSequence::AppendScrollGestureUpdate(const GesturePoint& point,
gfx::Point current_center = bounding_box_.CenterPoint();
int dx = current_center.x() - bounding_box_last_center_.x();
int dy = current_center.y() - bounding_box_last_center_.y();
- if (dx == 0 && dy == 0)
- return;
if (scroll_type_ == ST_HORIZONTAL)
dy = 0;
else if (scroll_type_ == ST_VERTICAL)
dx = 0;
+ if (dx == 0 && dy == 0)
+ return;
gestures->push_back(CreateGestureEvent(
GestureEventDetails(ui::ET_GESTURE_SCROLL_UPDATE, dx, dy),
@@ -906,6 +906,22 @@ bool GestureSequence::PinchUpdate(const TouchEvent& event,
const GesturePoint& point, Gestures* gestures) {
DCHECK(state_ == GS_PINCH);
+ // It is possible that the none of the touch-points changed their position,
+ // but their radii changed, and that caused the bounding box to also change.
+ // But in such cases, we do not want to either pinch or scroll.
+ // To avoid small jiggles, it is also necessary to make sure that at least one
+ // of the fingers moved enough before a pinch or scroll update is created.
+ bool did_scroll = false;
+ for (int i = 0; i < kMaxGesturePoints; ++i) {
+ if (!points_[i].in_use() || !points_[i].DidScroll(event, 2))
rjkroege 2012/08/07 15:02:51 aside: the difference between DidScroll and the ma
sadrul 2012/08/07 20:28:10 DidScroll looks for movement in any one direction,
+ continue;
+ did_scroll = true;
+ break;
+ }
+
+ if (!did_scroll)
+ return false;
+
float distance = BoundingBoxDiagonal(bounding_box_);
if (abs(distance - pinch_distance_current_) >=
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698