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

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

Issue 9452024: Gestures are now possible using touch events with any ids (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Ignore events which haven't been preceded by a press. Fix pinch. Created 8 years, 9 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
« no previous file with comments | « ui/aura/gestures/gesture_sequence.h ('k') | ui/aura/window_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/aura/gestures/gesture_sequence.h" 5 #include "ui/aura/gestures/gesture_sequence.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "ui/aura/event.h" 10 #include "ui/aura/event.h"
11 #include "ui/aura/root_window.h" 11 #include "ui/aura/root_window.h"
12 #include "ui/aura/gestures/gesture_configuration.h" 12 #include "ui/aura/gestures/gesture_configuration.h"
13 #include "ui/base/events.h" 13 #include "ui/base/events.h"
14 14
15 // TODO(sad): Pinch gestures currently always assume that the first two
16 // touch-points (i.e. at indices 0 and 1) are involved. This may not
17 // always be the case. This needs to be fixed eventually.
18 // http://crbug.com/113144
19
20 namespace { 15 namespace {
21 16
22 // TODO(girard): Make these configurable in sync with this CL 17 // TODO(girard): Make these configurable in sync with this CL
23 // http://crbug.com/100773 18 // http://crbug.com/100773
24 const float kMinimumPinchUpdateDistance = 5; // in pixels 19 const float kMinimumPinchUpdateDistance = 5; // in pixels
25 const float kMinimumDistanceForPinchScroll = 20; 20 const float kMinimumDistanceForPinchScroll = 20;
26 const float kLongPressTimeInMilliseconds = 500; 21 const float kLongPressTimeInMilliseconds = 500;
27 22
28 } // namespace 23 } // namespace
29 24
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 87
93 GST_SCROLL_FIRST_RELEASED = 88 GST_SCROLL_FIRST_RELEASED =
94 G(GS_SCROLL, 0, TS_RELEASED, false), 89 G(GS_SCROLL, 0, TS_RELEASED, false),
95 90
96 GST_SCROLL_FIRST_MOVED = 91 GST_SCROLL_FIRST_MOVED =
97 G(GS_SCROLL, 0, TS_MOVED, false), 92 G(GS_SCROLL, 0, TS_MOVED, false),
98 93
99 GST_SCROLL_FIRST_CANCELLED = 94 GST_SCROLL_FIRST_CANCELLED =
100 G(GS_SCROLL, 0, TS_CANCELLED, false), 95 G(GS_SCROLL, 0, TS_CANCELLED, false),
101 96
102 GST_SCROLL_FIRST_PRESSED =
103 G(GS_SCROLL, 0, TS_PRESSED, false),
104
105 GST_SCROLL_SECOND_RELEASED =
106 G(GS_SCROLL, 1, TS_RELEASED, false),
107
108 GST_SCROLL_SECOND_MOVED =
109 G(GS_SCROLL, 1, TS_MOVED, false),
110
111 GST_SCROLL_SECOND_CANCELLED =
112 G(GS_SCROLL, 1, TS_CANCELLED, false),
113
114 GST_SCROLL_SECOND_PRESSED = 97 GST_SCROLL_SECOND_PRESSED =
115 G(GS_SCROLL, 1, TS_PRESSED, false), 98 G(GS_SCROLL, 1, TS_PRESSED, false),
116 99
117 GST_PINCH_FIRST_MOVED = 100 GST_PINCH_FIRST_MOVED =
118 G(GS_PINCH, 0, TS_MOVED, false), 101 G(GS_PINCH, 0, TS_MOVED, false),
119 102
120 GST_PINCH_SECOND_MOVED = 103 GST_PINCH_SECOND_MOVED =
121 G(GS_PINCH, 1, TS_MOVED, false), 104 G(GS_PINCH, 1, TS_MOVED, false),
122 105
123 GST_PINCH_FIRST_RELEASED = 106 GST_PINCH_FIRST_RELEASED =
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // GestureSequence Public: 140 // GestureSequence Public:
158 141
159 GestureSequence::GestureSequence(RootWindow* root_window) 142 GestureSequence::GestureSequence(RootWindow* root_window)
160 : state_(GS_NO_GESTURE), 143 : state_(GS_NO_GESTURE),
161 flags_(0), 144 flags_(0),
162 pinch_distance_start_(0.f), 145 pinch_distance_start_(0.f),
163 pinch_distance_current_(0.f), 146 pinch_distance_current_(0.f),
164 long_press_timer_(CreateTimer()), 147 long_press_timer_(CreateTimer()),
165 point_count_(0), 148 point_count_(0),
166 root_window_(root_window) { 149 root_window_(root_window) {
167 for (int i = 0; i < kMaxGesturePoints; ++i) {
168 points_[i].set_touch_id(i);
169 }
170 } 150 }
171 151
172 GestureSequence::~GestureSequence() { 152 GestureSequence::~GestureSequence() {
173 } 153 }
174 154
175 GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture( 155 GestureSequence::Gestures* GestureSequence::ProcessTouchEventForGesture(
176 const TouchEvent& event, 156 const TouchEvent& event,
177 ui::TouchStatus status) { 157 ui::TouchStatus status) {
178 if (status != ui::TOUCH_STATUS_UNKNOWN) 158 if (status != ui::TOUCH_STATUS_UNKNOWN)
179 return NULL; // The event was consumed by a touch sequence. 159 return NULL; // The event was consumed by a touch sequence.
180 160
181 // Set a limit on the number of simultaneous touches in a gesture. 161 // Set a limit on the number of simultaneous touches in a gesture.
182 if (event.touch_id() >= kMaxGesturePoints) 162 if (event.touch_id() >= kMaxGesturePoints)
183 return NULL; 163 return NULL;
184 164
185 if (event.type() == ui::ET_TOUCH_PRESSED) { 165 if (event.type() == ui::ET_TOUCH_PRESSED) {
186 if (point_count_ == kMaxGesturePoints) 166 if (point_count_ == kMaxGesturePoints)
187 return NULL; 167 return NULL;
188 ++point_count_; 168 GesturePoint* new_point = &points_[event.touch_id()];
169 // We shouldn't be able to get two PRESSED events without either
170 // a RELEASE or CANCEL
171 DCHECK(!points_[event.touch_id()].in_use());
tdresser 2012/03/02 14:04:02 Is this correct? If a touch release is preventDef
sadrul 2012/03/02 14:20:31 In such a situation, the GR should receive a touch
tdresser 2012/03/02 15:11:27 Done.
172 new_point->set_point_id(point_count_++);
189 } 173 }
190 174
191 GestureState last_state = state_; 175 GestureState last_state = state_;
192 176
193 // NOTE: when modifying these state transitions, also update gestures.dot 177 // NOTE: when modifying these state transitions, also update gestures.dot
194 scoped_ptr<Gestures> gestures(new Gestures()); 178 scoped_ptr<Gestures> gestures(new Gestures());
195 GesturePoint& point = GesturePointForEvent(event); 179 GesturePoint& point = GesturePointForEvent(event);
196 point.UpdateValues(event); 180 point.UpdateValues(event);
197 flags_ = event.flags(); 181 flags_ = event.flags();
198 switch (Signature(state_, event.touch_id(), event.type(), false)) { 182 const int point_id = points_[event.touch_id()].point_id();
183 if (point_id < 0)
184 return NULL;
185 switch (Signature(state_, point_id, event.type(), false)) {
199 case GST_NO_GESTURE_FIRST_PRESSED: 186 case GST_NO_GESTURE_FIRST_PRESSED:
200 TouchDown(event, point, gestures.get()); 187 TouchDown(event, point, gestures.get());
201 set_state(GS_PENDING_SYNTHETIC_CLICK); 188 set_state(GS_PENDING_SYNTHETIC_CLICK);
202 break; 189 break;
203 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED: 190 case GST_PENDING_SYNTHETIC_CLICK_FIRST_RELEASED:
204 if (Click(event, point, gestures.get())) 191 if (Click(event, point, gestures.get()))
205 point.UpdateForTap(); 192 point.UpdateForTap();
206 set_state(GS_NO_GESTURE); 193 set_state(GS_NO_GESTURE);
207 break; 194 break;
208 case GST_PENDING_SYNTHETIC_CLICK_FIRST_MOVED: 195 case GST_PENDING_SYNTHETIC_CLICK_FIRST_MOVED:
209 case GST_PENDING_SYNTHETIC_CLICK_FIRST_STATIONARY: 196 case GST_PENDING_SYNTHETIC_CLICK_FIRST_STATIONARY:
210 if (ScrollStart(event, point, gestures.get())) { 197 if (ScrollStart(event, point, gestures.get())) {
211 set_state(GS_SCROLL); 198 set_state(GS_SCROLL);
212 if (ScrollUpdate(event, point, gestures.get())) 199 if (ScrollUpdate(event, point, gestures.get()))
213 point.UpdateForScroll(); 200 point.UpdateForScroll();
214 } 201 }
215 break; 202 break;
216 case GST_PENDING_SYNTHETIC_CLICK_FIRST_CANCELLED: 203 case GST_PENDING_SYNTHETIC_CLICK_FIRST_CANCELLED:
217 NoGesture(event, point, gestures.get()); 204 NoGesture(event, point, gestures.get());
218 break; 205 break;
219 case GST_SCROLL_FIRST_MOVED: 206 case GST_SCROLL_FIRST_MOVED:
220 case GST_SCROLL_SECOND_MOVED:
221 if (scroll_type_ == ST_VERTICAL || 207 if (scroll_type_ == ST_VERTICAL ||
222 scroll_type_ == ST_HORIZONTAL) 208 scroll_type_ == ST_HORIZONTAL)
223 BreakRailScroll(event, point, gestures.get()); 209 BreakRailScroll(event, point, gestures.get());
224 if (ScrollUpdate(event, point, gestures.get())) 210 if (ScrollUpdate(event, point, gestures.get()))
225 point.UpdateForScroll(); 211 point.UpdateForScroll();
226 break; 212 break;
227 case GST_SCROLL_FIRST_RELEASED: 213 case GST_SCROLL_FIRST_RELEASED:
228 case GST_SCROLL_FIRST_CANCELLED: 214 case GST_SCROLL_FIRST_CANCELLED:
229 case GST_SCROLL_SECOND_RELEASED:
230 case GST_SCROLL_SECOND_CANCELLED:
231 ScrollEnd(event, point, gestures.get()); 215 ScrollEnd(event, point, gestures.get());
232 set_state(GS_NO_GESTURE); 216 set_state(GS_NO_GESTURE);
233 break; 217 break;
234 case GST_SCROLL_FIRST_PRESSED:
235 case GST_SCROLL_SECOND_PRESSED: 218 case GST_SCROLL_SECOND_PRESSED:
236 case GST_PENDING_SYNTHETIC_CLICK_SECOND_PRESSED: 219 case GST_PENDING_SYNTHETIC_CLICK_SECOND_PRESSED:
237 PinchStart(event, point, gestures.get()); 220 PinchStart(event, point, gestures.get());
238 set_state(GS_PINCH); 221 set_state(GS_PINCH);
239 break; 222 break;
240 case GST_PINCH_FIRST_MOVED: 223 case GST_PINCH_FIRST_MOVED:
241 case GST_PINCH_SECOND_MOVED: 224 case GST_PINCH_SECOND_MOVED:
242 if (PinchUpdate(event, point, gestures.get())) { 225 if (PinchUpdate(event, point, gestures.get())) {
243 points_[0].UpdateForScroll(); 226 GetPointByPointId(0)->UpdateForScroll();
244 points_[1].UpdateForScroll(); 227 GetPointByPointId(1)->UpdateForScroll();
245 } 228 }
246 break; 229 break;
247 case GST_PINCH_FIRST_RELEASED: 230 case GST_PINCH_FIRST_RELEASED:
248 case GST_PINCH_SECOND_RELEASED: 231 case GST_PINCH_SECOND_RELEASED:
249 case GST_PINCH_FIRST_CANCELLED: 232 case GST_PINCH_FIRST_CANCELLED:
250 case GST_PINCH_SECOND_CANCELLED: 233 case GST_PINCH_SECOND_CANCELLED:
251 PinchEnd(event, point, gestures.get()); 234 PinchEnd(event, point, gestures.get());
252 235
253 // Once pinch ends, it should still be possible to scroll with the 236 // Once pinch ends, it should still be possible to scroll with the
254 // remaining finger on the screen. 237 // remaining finger on the screen.
255 scroll_type_ = ST_FREE; 238 scroll_type_ = ST_FREE;
256 set_state(GS_SCROLL); 239 set_state(GS_SCROLL);
257 break; 240 break;
258 } 241 }
259 242
260 if (state_ != last_state) 243 if (state_ != last_state)
261 VLOG(4) << "Gesture Sequence" 244 VLOG(4) << "Gesture Sequence"
262 << " State: " << state_ 245 << " State: " << state_
263 << " touch id: " << event.touch_id(); 246 << " touch id: " << event.touch_id();
264 247
265 if (last_state == GS_PENDING_SYNTHETIC_CLICK && state_ != last_state) 248 if (last_state == GS_PENDING_SYNTHETIC_CLICK && state_ != last_state)
266 long_press_timer_->Stop(); 249 long_press_timer_->Stop();
267 250
268 if (event.type() == ui::ET_TOUCH_RELEASED) 251 // The set of point_ids must be contiguous and include 0.
252 // When a touch point is released, all points with ids greater than the
253 // released point must have their ids decremented, or the set of point_ids
254 // could end up with gaps.
255 if (event.type() == ui::ET_TOUCH_RELEASED) {
256 GesturePoint& old_point = points_[event.touch_id()];
257 for (int i = 0; i < kMaxGesturePoints; ++i) {
258 GesturePoint& point = points_[i];
259 if (point.point_id() > old_point.point_id())
260 point.set_point_id(point.point_id() - 1);
261 }
262 old_point.Reset();
269 --point_count_; 263 --point_count_;
264 }
270 265
271 return gestures.release(); 266 return gestures.release();
272 } 267 }
273 268
274 void GestureSequence::Reset() { 269 void GestureSequence::Reset() {
275 set_state(GS_NO_GESTURE); 270 set_state(GS_NO_GESTURE);
276 for (int i = 0; i < point_count_; ++i) 271 for (int i = 0; i < kMaxGesturePoints; ++i)
277 points_[i].Reset(); 272 points_[i].Reset();
278 } 273 }
279 274
280 //////////////////////////////////////////////////////////////////////////////// 275 ////////////////////////////////////////////////////////////////////////////////
281 // GestureSequence Protected: 276 // GestureSequence Protected:
282 277
283 base::OneShotTimer<GestureSequence>* GestureSequence::CreateTimer() { 278 base::OneShotTimer<GestureSequence>* GestureSequence::CreateTimer() {
284 return new base::OneShotTimer<GestureSequence>(); 279 return new base::OneShotTimer<GestureSequence>();
285 } 280 }
286 281
287 //////////////////////////////////////////////////////////////////////////////// 282 ////////////////////////////////////////////////////////////////////////////////
288 // GestureSequence Private: 283 // GestureSequence Private:
289 284
290 GesturePoint& GestureSequence::GesturePointForEvent( 285 GesturePoint& GestureSequence::GesturePointForEvent(
291 const TouchEvent& event) { 286 const TouchEvent& event) {
292 return points_[event.touch_id()]; 287 return points_[event.touch_id()];
293 } 288 }
294 289
290 GesturePoint* GestureSequence::GetPointByPointId(int point_id) {
291 DCHECK(0 <= point_id && point_id < kMaxGesturePoints);
292 for (int i = 0; i < kMaxGesturePoints; ++i) {
293 GesturePoint& point = points_[i];
294 if (point.in_use() && point.point_id() == point_id)
295 return &point;
296 }
297 NOTREACHED();
298 return NULL;
299 }
300
295 void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point, 301 void GestureSequence::AppendTapDownGestureEvent(const GesturePoint& point,
296 Gestures* gestures) { 302 Gestures* gestures) {
297 gestures->push_back(linked_ptr<GestureEvent>(new GestureEvent( 303 gestures->push_back(linked_ptr<GestureEvent>(new GestureEvent(
298 ui::ET_GESTURE_TAP_DOWN, 304 ui::ET_GESTURE_TAP_DOWN,
299 point.first_touch_position().x(), 305 point.first_touch_position().x(),
300 point.first_touch_position().y(), 306 point.first_touch_position().y(),
301 flags_, 307 flags_,
302 base::Time::FromDoubleT(point.last_touch_time()), 308 base::Time::FromDoubleT(point.last_touch_time()),
303 0.f, 0.f))); 309 0.f, 0.f)));
304 } 310 }
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 AppendTapDownGestureEvent(point, gestures); 481 AppendTapDownGestureEvent(point, gestures);
476 long_press_timer_->Start( 482 long_press_timer_->Start(
477 FROM_HERE, 483 FROM_HERE,
478 base::TimeDelta::FromMilliseconds(kLongPressTimeInMilliseconds), 484 base::TimeDelta::FromMilliseconds(kLongPressTimeInMilliseconds),
479 this, 485 this,
480 &GestureSequence::AppendLongPressGestureEvent); 486 &GestureSequence::AppendLongPressGestureEvent);
481 return true; 487 return true;
482 } 488 }
483 489
484 void GestureSequence::AppendLongPressGestureEvent() { 490 void GestureSequence::AppendLongPressGestureEvent() {
485 // TODO(tdresser) - this may not always be the first point 491 const GesturePoint* point = GetPointByPointId(0);
486 const GesturePoint& point = points_[0];
487 GestureEvent* gesture = new GestureEvent( 492 GestureEvent* gesture = new GestureEvent(
488 ui::ET_GESTURE_LONG_PRESS, 493 ui::ET_GESTURE_LONG_PRESS,
489 point.first_touch_position().x(), 494 point->first_touch_position().x(),
490 point.first_touch_position().y(), 495 point->first_touch_position().y(),
491 flags_, 496 flags_,
492 base::Time::FromDoubleT(point.last_touch_time()), 497 base::Time::FromDoubleT(point->last_touch_time()),
493 point.touch_id(), 0.f); 498 point->point_id(), 0.f);
494
495 root_window_->DispatchGestureEvent(gesture); 499 root_window_->DispatchGestureEvent(gesture);
496 } 500 }
497 501
498 bool GestureSequence::ScrollEnd(const TouchEvent& event, 502 bool GestureSequence::ScrollEnd(const TouchEvent& event,
499 GesturePoint& point, Gestures* gestures) { 503 GesturePoint& point, Gestures* gestures) {
500 DCHECK(state_ == GS_SCROLL); 504 DCHECK(state_ == GS_SCROLL);
501 if (point.IsInFlickWindow(event)) { 505 if (point.IsInFlickWindow(event)) {
502 AppendScrollGestureEnd(point, point.last_touch_position(), gestures, 506 AppendScrollGestureEnd(point, point.last_touch_position(), gestures,
503 point.XVelocity(), point.YVelocity()); 507 point.XVelocity(), point.YVelocity());
504 } else { 508 } else {
505 AppendScrollGestureEnd(point, point.last_touch_position(), gestures, 509 AppendScrollGestureEnd(point, point.last_touch_position(), gestures,
506 0.f, 0.f); 510 0.f, 0.f);
507 } 511 }
508 return true; 512 return true;
509 } 513 }
510 514
511 bool GestureSequence::PinchStart(const TouchEvent& event, 515 bool GestureSequence::PinchStart(const TouchEvent& event,
512 const GesturePoint& point, Gestures* gestures) { 516 const GesturePoint& point, Gestures* gestures) {
513 DCHECK(state_ == GS_SCROLL || 517 DCHECK(state_ == GS_SCROLL ||
514 state_ == GS_PENDING_SYNTHETIC_CLICK); 518 state_ == GS_PENDING_SYNTHETIC_CLICK);
515 AppendTapDownGestureEvent(point, gestures); 519 AppendTapDownGestureEvent(point, gestures);
516 520
517 pinch_distance_current_ = points_[0].Distance(points_[1]); 521 const GesturePoint* point1 = GetPointByPointId(0);
522 const GesturePoint* point2 = GetPointByPointId(1);
523
524 pinch_distance_current_ = point1->Distance(*point2);
518 pinch_distance_start_ = pinch_distance_current_; 525 pinch_distance_start_ = pinch_distance_current_;
519 AppendPinchGestureBegin(points_[0], points_[1], gestures); 526 AppendPinchGestureBegin(*point1, *point2, gestures);
520 527
521 if (state_ == GS_PENDING_SYNTHETIC_CLICK) { 528 if (state_ == GS_PENDING_SYNTHETIC_CLICK) {
522 gfx::Point center = points_[0].last_touch_position().Middle( 529 gfx::Point center = point1->last_touch_position().Middle(
523 points_[1].last_touch_position()); 530 point2->last_touch_position());
524 AppendScrollGestureBegin(point, center, gestures); 531 AppendScrollGestureBegin(point, center, gestures);
525 } 532 }
526 533
527 return true; 534 return true;
528 } 535 }
529 536
530 bool GestureSequence::PinchUpdate(const TouchEvent& event, 537 bool GestureSequence::PinchUpdate(const TouchEvent& event,
531 const GesturePoint& point, Gestures* gestures) { 538 const GesturePoint& point, Gestures* gestures) {
532 DCHECK(state_ == GS_PINCH); 539 DCHECK(state_ == GS_PINCH);
533 float distance = points_[0].Distance(points_[1]); 540
541 const GesturePoint* point1 = GetPointByPointId(0);
542 const GesturePoint* point2 = GetPointByPointId(1);
543
544 float distance = point1->Distance(*point2);
534 if (abs(distance - pinch_distance_current_) < 545 if (abs(distance - pinch_distance_current_) <
535 GestureConfiguration::minimum_pinch_update_distance_in_pixels()) { 546 GestureConfiguration::minimum_pinch_update_distance_in_pixels()) {
536 // The fingers didn't move towards each other, or away from each other, 547 // The fingers didn't move towards each other, or away from each other,
537 // enough to constitute a pinch. But perhaps they moved enough in the same 548 // enough to constitute a pinch. But perhaps they moved enough in the same
538 // direction to do a two-finger scroll. 549 // direction to do a two-finger scroll.
539 if (!points_[0].DidScroll(event, 550 if (!point1->DidScroll(event,
540 GestureConfiguration::minimum_distance_for_pinch_scroll_in_pixels()) || 551 GestureConfiguration::minimum_distance_for_pinch_scroll_in_pixels()) ||
541 !points_[1].DidScroll(event, 552 !point2->DidScroll(event,
542 GestureConfiguration::minimum_distance_for_pinch_scroll_in_pixels())) 553 GestureConfiguration::minimum_distance_for_pinch_scroll_in_pixels()))
543 return false; 554 return false;
544 555
545 gfx::Point center = points_[0].last_touch_position().Middle( 556 gfx::Point center = point1->last_touch_position().Middle(
546 points_[1].last_touch_position()); 557 point2->last_touch_position());
547 AppendScrollGestureUpdate(point, center, gestures); 558 AppendScrollGestureUpdate(point, center, gestures);
548 } else { 559 } else {
549 AppendPinchGestureUpdate(points_[0], points_[1], 560 AppendPinchGestureUpdate(*point1, *point2,
550 distance / pinch_distance_current_, gestures); 561 distance / pinch_distance_current_, gestures);
551 pinch_distance_current_ = distance; 562 pinch_distance_current_ = distance;
552 } 563 }
553 return true; 564 return true;
554 } 565 }
555 566
556 bool GestureSequence::PinchEnd(const TouchEvent& event, 567 bool GestureSequence::PinchEnd(const TouchEvent& event,
557 const GesturePoint& point, Gestures* gestures) { 568 const GesturePoint& point, Gestures* gestures) {
558 DCHECK(state_ == GS_PINCH); 569 DCHECK(state_ == GS_PINCH);
559 float distance = points_[0].Distance(points_[1]); 570
560 AppendPinchGestureEnd(points_[0], points_[1], 571 const GesturePoint* point1 = GetPointByPointId(0);
572 const GesturePoint* point2 = GetPointByPointId(1);
573
574 float distance = point1->Distance(*point2);
575 AppendPinchGestureEnd(*point1, *point2,
561 distance / pinch_distance_start_, gestures); 576 distance / pinch_distance_start_, gestures);
562 577
563 pinch_distance_start_ = 0; 578 pinch_distance_start_ = 0;
564 pinch_distance_current_ = 0; 579 pinch_distance_current_ = 0;
565 return true; 580 return true;
566 } 581 }
567 582
568 } // namespace aura 583 } // namespace aura
OLDNEW
« no previous file with comments | « ui/aura/gestures/gesture_sequence.h ('k') | ui/aura/window_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698