OLD | NEW |
---|---|
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 #include "ui/events/gesture_detection/mock_motion_event.h" | 5 #include "ui/events/gesture_detection/mock_motion_event.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 | 8 |
9 using base::TimeTicks; | 9 using base::TimeTicks; |
10 | 10 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 cancel_event->action = MotionEvent::ACTION_CANCEL; | 130 cancel_event->action = MotionEvent::ACTION_CANCEL; |
131 return cancel_event.PassAs<MotionEvent>(); | 131 return cancel_event.PassAs<MotionEvent>(); |
132 } | 132 } |
133 | 133 |
134 void MockMotionEvent::PressPoint(float x, float y) { | 134 void MockMotionEvent::PressPoint(float x, float y) { |
135 // Reset the pointer count if the previously released and/or cancelled pointer | 135 // Reset the pointer count if the previously released and/or cancelled pointer |
136 // was the last pointer in the event. | 136 // was the last pointer in the event. |
137 if (pointer_count == 1 && (action == ACTION_UP || action == ACTION_CANCEL)) | 137 if (pointer_count == 1 && (action == ACTION_UP || action == ACTION_CANCEL)) |
138 pointer_count = 0; | 138 pointer_count = 0; |
139 | 139 |
140 DCHECK_LT(pointer_count + 1, static_cast<size_t>(MAX_POINTERS)); | 140 DCHECK_LT(pointer_count, static_cast<size_t>(MAX_POINTERS)); |
tdresser
2014/04/25 19:26:48
I believe this was a bug, can you double check?
jdduke (slow)
2014/04/25 19:38:55
It should be correct, note the |pointer_count++| c
tdresser
2014/04/25 19:43:25
So if I have 2 fingers down, and I press another f
jdduke (slow)
2014/04/25 19:45:26
It evaluates 2 < 3, then does the increment.
jdduke (slow)
2014/04/25 19:46:58
Ugg, lol yeah I was checking *your* code, not the
| |
141 points[pointer_count++] = gfx::PointF(x, y); | 141 points[pointer_count++] = gfx::PointF(x, y); |
142 action = pointer_count > 1 ? ACTION_POINTER_DOWN : ACTION_DOWN; | 142 action = pointer_count > 1 ? ACTION_POINTER_DOWN : ACTION_DOWN; |
143 } | 143 } |
144 | 144 |
145 void MockMotionEvent::MovePoint(size_t index, float x, float y) { | 145 void MockMotionEvent::MovePoint(size_t index, float x, float y) { |
146 DCHECK_LT(index, pointer_count); | 146 DCHECK_LT(index, pointer_count); |
147 points[index] = gfx::PointF(x, y); | 147 points[index] = gfx::PointF(x, y); |
148 action = ACTION_MOVE; | 148 action = ACTION_MOVE; |
149 } | 149 } |
150 | 150 |
151 void MockMotionEvent::ReleasePoint() { | 151 void MockMotionEvent::ReleasePoint() { |
152 DCHECK_GT(pointer_count, 0U); | 152 DCHECK_GT(pointer_count, 0U); |
153 if (pointer_count > 1) { | 153 if (pointer_count > 1) { |
154 --pointer_count; | 154 --pointer_count; |
155 action = ACTION_POINTER_UP; | 155 action = ACTION_POINTER_UP; |
156 } else { | 156 } else { |
157 action = ACTION_UP; | 157 action = ACTION_UP; |
158 } | 158 } |
159 } | 159 } |
160 | 160 |
161 void MockMotionEvent::CancelPoint() { | 161 void MockMotionEvent::CancelPoint() { |
162 DCHECK_GT(pointer_count, 0U); | 162 DCHECK_GT(pointer_count, 0U); |
163 if (pointer_count > 1) | 163 if (pointer_count > 1) |
164 --pointer_count; | 164 --pointer_count; |
165 action = ACTION_CANCEL; | 165 action = ACTION_CANCEL; |
166 } | 166 } |
167 | 167 |
168 } // namespace ui | 168 } // namespace ui |
OLD | NEW |