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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 continue; | 145 continue; |
146 | 146 |
147 touches[point] = touches[i]; | 147 touches[point] = touches[i]; |
148 touches[point].state = WebTouchPoint::StateStationary; | 148 touches[point].state = WebTouchPoint::StateStationary; |
149 ++point; | 149 ++point; |
150 } | 150 } |
151 touchesLength = point; | 151 touchesLength = point; |
152 type = WebInputEvent::Undefined; | 152 type = WebInputEvent::Undefined; |
153 } | 153 } |
154 | 154 |
155 int SyntheticWebTouchEvent::PressPoint(int x, int y) { | 155 int SyntheticWebTouchEvent::PressPoint(float x, float y) { |
156 if (touchesLength == touchesLengthCap) | 156 if (touchesLength == touchesLengthCap) |
157 return -1; | 157 return -1; |
158 WebTouchPoint& point = touches[touchesLength]; | 158 WebTouchPoint& point = touches[touchesLength]; |
159 point.id = touchesLength; | 159 point.id = touchesLength; |
160 point.position.x = point.screenPosition.x = x; | 160 point.position.x = point.screenPosition.x = x; |
161 point.position.y = point.screenPosition.y = y; | 161 point.position.y = point.screenPosition.y = y; |
162 point.state = WebTouchPoint::StatePressed; | 162 point.state = WebTouchPoint::StatePressed; |
163 point.radiusX = point.radiusY = 1.f; | 163 point.radiusX = point.radiusY = 1.f; |
164 ++touchesLength; | 164 ++touchesLength; |
165 type = WebInputEvent::TouchStart; | 165 type = WebInputEvent::TouchStart; |
166 return point.id; | 166 return point.id; |
167 } | 167 } |
168 | 168 |
169 void SyntheticWebTouchEvent::MovePoint(int index, int x, int y) { | 169 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { |
170 CHECK(index >= 0 && index < touchesLengthCap); | 170 CHECK(index >= 0 && index < touchesLengthCap); |
171 WebTouchPoint& point = touches[index]; | 171 WebTouchPoint& point = touches[index]; |
172 point.position.x = point.screenPosition.x = x; | 172 point.position.x = point.screenPosition.x = x; |
173 point.position.y = point.screenPosition.y = y; | 173 point.position.y = point.screenPosition.y = y; |
174 touches[index].state = WebTouchPoint::StateMoved; | 174 touches[index].state = WebTouchPoint::StateMoved; |
175 type = WebInputEvent::TouchMove; | 175 type = WebInputEvent::TouchMove; |
176 } | 176 } |
177 | 177 |
178 void SyntheticWebTouchEvent::ReleasePoint(int index) { | 178 void SyntheticWebTouchEvent::ReleasePoint(int index) { |
179 CHECK(index >= 0 && index < touchesLengthCap); | 179 CHECK(index >= 0 && index < touchesLengthCap); |
(...skipping 13 matching lines...) Expand all Loading... |
193 | 193 |
194 SyntheticWebTouchEvent SyntheticWebTouchEventBuilder::Build( | 194 SyntheticWebTouchEvent SyntheticWebTouchEventBuilder::Build( |
195 WebInputEvent::Type type) { | 195 WebInputEvent::Type type) { |
196 DCHECK(WebInputEvent::isTouchEventType(type)); | 196 DCHECK(WebInputEvent::isTouchEventType(type)); |
197 SyntheticWebTouchEvent result; | 197 SyntheticWebTouchEvent result; |
198 result.type = type; | 198 result.type = type; |
199 return result; | 199 return result; |
200 }; | 200 }; |
201 | 201 |
202 } // namespace content | 202 } // namespace content |
OLD | NEW |