OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "content/common/input/synthetic_web_input_event_builders.h" | 5 #include "content/common/input/synthetic_web_input_event_builders.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "ui/events/keycodes/keyboard_codes.h" | 8 #include "ui/events/keycodes/keyboard_codes.h" |
9 | 9 |
10 namespace content { | 10 namespace content { |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 int point = 0; | 149 int point = 0; |
150 for (unsigned int i = 0; i < touchesLength; ++i) { | 150 for (unsigned int i = 0; i < touchesLength; ++i) { |
151 if (touches[i].state == WebTouchPoint::StateReleased) | 151 if (touches[i].state == WebTouchPoint::StateReleased) |
152 continue; | 152 continue; |
153 | 153 |
154 touches[point] = touches[i]; | 154 touches[point] = touches[i]; |
155 touches[point].state = WebTouchPoint::StateStationary; | 155 touches[point].state = WebTouchPoint::StateStationary; |
156 ++point; | 156 ++point; |
157 } | 157 } |
158 touchesLength = point; | 158 touchesLength = point; |
159 type = WebInputEvent::Undefined; | 159 type = WebInputEvent::Undefined; |
jdduke (slow)
2014/04/22 18:38:55
cancelable = true;
Rick Byers
2014/04/22 19:00:59
Thanks, done.
| |
160 } | 160 } |
161 | 161 |
162 int SyntheticWebTouchEvent::PressPoint(float x, float y) { | 162 int SyntheticWebTouchEvent::PressPoint(float x, float y) { |
163 if (touchesLength == touchesLengthCap) | 163 if (touchesLength == touchesLengthCap) |
164 return -1; | 164 return -1; |
165 WebTouchPoint& point = touches[touchesLength]; | 165 WebTouchPoint& point = touches[touchesLength]; |
166 point.id = touchesLength; | 166 point.id = touchesLength; |
167 point.position.x = point.screenPosition.x = x; | 167 point.position.x = point.screenPosition.x = x; |
168 point.position.y = point.screenPosition.y = y; | 168 point.position.y = point.screenPosition.y = y; |
169 point.state = WebTouchPoint::StatePressed; | 169 point.state = WebTouchPoint::StatePressed; |
(...skipping 15 matching lines...) Expand all Loading... | |
185 void SyntheticWebTouchEvent::ReleasePoint(int index) { | 185 void SyntheticWebTouchEvent::ReleasePoint(int index) { |
186 CHECK(index >= 0 && index < touchesLengthCap); | 186 CHECK(index >= 0 && index < touchesLengthCap); |
187 touches[index].state = WebTouchPoint::StateReleased; | 187 touches[index].state = WebTouchPoint::StateReleased; |
188 type = WebInputEvent::TouchEnd; | 188 type = WebInputEvent::TouchEnd; |
189 } | 189 } |
190 | 190 |
191 void SyntheticWebTouchEvent::CancelPoint(int index) { | 191 void SyntheticWebTouchEvent::CancelPoint(int index) { |
192 CHECK(index >= 0 && index < touchesLengthCap); | 192 CHECK(index >= 0 && index < touchesLengthCap); |
193 touches[index].state = WebTouchPoint::StateCancelled; | 193 touches[index].state = WebTouchPoint::StateCancelled; |
194 type = WebInputEvent::TouchCancel; | 194 type = WebInputEvent::TouchCancel; |
195 cancelable = false; | |
195 } | 196 } |
196 | 197 |
197 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { | 198 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { |
198 timeStampSeconds = timestamp.InSecondsF(); | 199 timeStampSeconds = timestamp.InSecondsF(); |
199 } | 200 } |
200 | 201 |
201 SyntheticWebTouchEvent SyntheticWebTouchEventBuilder::Build( | 202 SyntheticWebTouchEvent SyntheticWebTouchEventBuilder::Build( |
202 WebInputEvent::Type type) { | 203 WebInputEvent::Type type) { |
203 DCHECK(WebInputEvent::isTouchEventType(type)); | 204 DCHECK(WebInputEvent::isTouchEventType(type)); |
204 SyntheticWebTouchEvent result; | 205 SyntheticWebTouchEvent result; |
205 result.type = type; | 206 result.type = type; |
206 return result; | 207 return result; |
207 }; | 208 }; |
208 | 209 |
209 } // namespace content | 210 } // namespace content |
OLD | NEW |