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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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; |
160 } | 160 } |
161 | 161 |
162 int SyntheticWebTouchEvent::PressPoint(int x, int 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; |
170 point.radiusX = point.radiusY = 1.f; | 170 point.radiusX = point.radiusY = 1.f; |
171 ++touchesLength; | 171 ++touchesLength; |
172 type = WebInputEvent::TouchStart; | 172 type = WebInputEvent::TouchStart; |
173 return point.id; | 173 return point.id; |
174 } | 174 } |
175 | 175 |
176 void SyntheticWebTouchEvent::MovePoint(int index, int x, int y) { | 176 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { |
177 CHECK(index >= 0 && index < touchesLengthCap); | 177 CHECK(index >= 0 && index < touchesLengthCap); |
178 WebTouchPoint& point = touches[index]; | 178 WebTouchPoint& point = touches[index]; |
179 point.position.x = point.screenPosition.x = x; | 179 point.position.x = point.screenPosition.x = x; |
180 point.position.y = point.screenPosition.y = y; | 180 point.position.y = point.screenPosition.y = y; |
181 touches[index].state = WebTouchPoint::StateMoved; | 181 touches[index].state = WebTouchPoint::StateMoved; |
182 type = WebInputEvent::TouchMove; | 182 type = WebInputEvent::TouchMove; |
183 } | 183 } |
184 | 184 |
185 void SyntheticWebTouchEvent::ReleasePoint(int index) { | 185 void SyntheticWebTouchEvent::ReleasePoint(int index) { |
186 CHECK(index >= 0 && index < touchesLengthCap); | 186 CHECK(index >= 0 && index < touchesLengthCap); |
(...skipping 13 matching lines...) Expand all Loading... |
200 | 200 |
201 SyntheticWebTouchEvent SyntheticWebTouchEventBuilder::Build( | 201 SyntheticWebTouchEvent SyntheticWebTouchEventBuilder::Build( |
202 WebInputEvent::Type type) { | 202 WebInputEvent::Type type) { |
203 DCHECK(WebInputEvent::isTouchEventType(type)); | 203 DCHECK(WebInputEvent::isTouchEventType(type)); |
204 SyntheticWebTouchEvent result; | 204 SyntheticWebTouchEvent result; |
205 result.type = type; | 205 result.type = type; |
206 return result; | 206 return result; |
207 }; | 207 }; |
208 | 208 |
209 } // namespace content | 209 } // namespace content |
OLD | NEW |