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

Side by Side Diff: ui/events/gestures/motion_event_aura.cc

Issue 873283003: Invalid press events don't create multiple pointers with the same id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use a fake touch cancel. Created 5 years, 10 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 | « no previous file | ui/events/gestures/motion_event_aura_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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 7
8 #include "ui/events/gestures/motion_event_aura.h" 8 #include "ui/events/gestures/motion_event_aura.h"
9 9
10 #include <cmath> 10 #include <cmath>
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 } 75 }
76 76
77 MotionEventAura::~MotionEventAura() { 77 MotionEventAura::~MotionEventAura() {
78 } 78 }
79 79
80 bool MotionEventAura::OnTouch(const TouchEvent& touch) { 80 bool MotionEventAura::OnTouch(const TouchEvent& touch) {
81 int index = FindPointerIndexOfId(touch.touch_id()); 81 int index = FindPointerIndexOfId(touch.touch_id());
82 bool pointer_id_is_active = index != -1; 82 bool pointer_id_is_active = index != -1;
83 83
84 if (touch.type() == ET_TOUCH_PRESSED && pointer_id_is_active) { 84 if (touch.type() == ET_TOUCH_PRESSED && pointer_id_is_active) {
85 // Ignore touch press events if we already believe the pointer is down. 85 // TODO(tdresser): This should return false (or NOTREACHED()), and
86 // ignore the touch; however, there is at least one case where we
87 // need to allow a touch press from a currently used touch id. See
88 // crbug.com/446852 for details.
86 89
87 // TODO(tdresser): this should return false (or NOTREACHED()); 90 // Cancel the existing touch, before handling the touch press.
88 // however, there is at least one case where we need to allow a 91 TouchEvent cancel(ET_TOUCH_CANCELLED, touch.location(), touch.touch_id(),
89 // touch press from a currently used touch id. See 92 touch.time_stamp());
90 // crbug.com/446852 for details. 93 OnTouch(cancel);
jdduke (slow) 2015/01/26 17:51:11 Oh, I forgot about this cleanup dependency =/.
94 CleanupRemovedTouchPoints(cancel);
95 DCHECK_EQ(-1, FindPointerIndexOfId(touch.touch_id()));
91 } else if (touch.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) { 96 } else if (touch.type() != ET_TOUCH_PRESSED && !pointer_id_is_active) {
92 // We could have an active touch stream transfered to us, resulting in touch 97 // We could have an active touch stream transfered to us, resulting in touch
93 // move or touch up events without associated touch down events. Ignore 98 // move or touch up events without associated touch down events. Ignore
94 // them. 99 // them.
95 return false; 100 return false;
96 } 101 }
97 102
98 if (touch.type() == ET_TOUCH_MOVED && touch.x() == GetX(index) && 103 if (touch.type() == ET_TOUCH_MOVED && touch.x() == GetX(index) &&
99 touch.y() == GetY(index)) { 104 touch.y() == GetY(index)) {
100 return false; 105 return false;
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 196 }
192 197
193 int MotionEventAura::GetIndexFromId(int id) const { 198 int MotionEventAura::GetIndexFromId(int id) const {
194 int index = FindPointerIndexOfId(id); 199 int index = FindPointerIndexOfId(id);
195 DCHECK_GE(index, 0); 200 DCHECK_GE(index, 0);
196 DCHECK_LT(index, static_cast<int>(GetPointerCount())); 201 DCHECK_LT(index, static_cast<int>(GetPointerCount()));
197 return index; 202 return index;
198 } 203 }
199 204
200 } // namespace ui 205 } // namespace ui
OLDNEW
« no previous file with comments | « no previous file | ui/events/gestures/motion_event_aura_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698