| 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 "content/common/input/web_touch_event_traits.h" | 8 #include "content/common/input/web_touch_event_traits.h" |
| 9 #include "ui/events/base_event_utils.h" | 9 #include "ui/events/base_event_utils.h" |
| 10 #include "ui/events/keycodes/keyboard_codes.h" | 10 #include "ui/events/keycodes/keyboard_codes.h" |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 int point = 0; | 174 int point = 0; |
| 175 for (unsigned int i = 0; i < touchesLength; ++i) { | 175 for (unsigned int i = 0; i < touchesLength; ++i) { |
| 176 if (touches[i].state == WebTouchPoint::StateReleased) | 176 if (touches[i].state == WebTouchPoint::StateReleased) |
| 177 continue; | 177 continue; |
| 178 | 178 |
| 179 touches[point] = touches[i]; | 179 touches[point] = touches[i]; |
| 180 touches[point].state = WebTouchPoint::StateStationary; | 180 touches[point].state = WebTouchPoint::StateStationary; |
| 181 ++point; | 181 ++point; |
| 182 } | 182 } |
| 183 touchesLength = point; | 183 touchesLength = point; |
| 184 type = WebInputEvent::Undefined; | 184 m_type = WebInputEvent::Undefined; |
| 185 movedBeyondSlopRegion = false; | 185 movedBeyondSlopRegion = false; |
| 186 uniqueTouchEventId = ui::GetNextTouchEventId(); | 186 uniqueTouchEventId = ui::GetNextTouchEventId(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 int SyntheticWebTouchEvent::PressPoint(float x, float y) { | 189 int SyntheticWebTouchEvent::PressPoint(float x, float y) { |
| 190 if (touchesLength == kTouchesLengthCap) | 190 if (touchesLength == kTouchesLengthCap) |
| 191 return -1; | 191 return -1; |
| 192 WebTouchPoint& point = touches[touchesLength]; | 192 WebTouchPoint& point = touches[touchesLength]; |
| 193 point.id = touchesLength; | 193 point.id = touchesLength; |
| 194 point.position.x = point.screenPosition.x = x; | 194 point.position.x = point.screenPosition.x = x; |
| 195 point.position.y = point.screenPosition.y = y; | 195 point.position.y = point.screenPosition.y = y; |
| 196 point.state = WebTouchPoint::StatePressed; | 196 point.state = WebTouchPoint::StatePressed; |
| 197 point.radiusX = point.radiusY = 1.f; | 197 point.radiusX = point.radiusY = 1.f; |
| 198 point.rotationAngle = 1.f; | 198 point.rotationAngle = 1.f; |
| 199 point.force = 1.f; | 199 point.force = 1.f; |
| 200 point.tiltX = point.tiltY = 0; | 200 point.tiltX = point.tiltY = 0; |
| 201 ++touchesLength; | 201 ++touchesLength; |
| 202 WebTouchEventTraits::ResetType(WebInputEvent::TouchStart, timeStampSeconds, | 202 WebTouchEventTraits::ResetType(WebInputEvent::TouchStart, timeStampSeconds(), |
| 203 this); | 203 this); |
| 204 return point.id; | 204 return point.id; |
| 205 } | 205 } |
| 206 | 206 |
| 207 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { | 207 void SyntheticWebTouchEvent::MovePoint(int index, float x, float y) { |
| 208 CHECK_GE(index, 0); | 208 CHECK_GE(index, 0); |
| 209 CHECK_LT(index, kTouchesLengthCap); | 209 CHECK_LT(index, kTouchesLengthCap); |
| 210 // Always set this bit to avoid otherwise unexpected touchmove suppression. | 210 // Always set this bit to avoid otherwise unexpected touchmove suppression. |
| 211 // The caller can opt-out explicitly, if necessary. | 211 // The caller can opt-out explicitly, if necessary. |
| 212 movedBeyondSlopRegion = true; | 212 movedBeyondSlopRegion = true; |
| 213 WebTouchPoint& point = touches[index]; | 213 WebTouchPoint& point = touches[index]; |
| 214 point.position.x = point.screenPosition.x = x; | 214 point.position.x = point.screenPosition.x = x; |
| 215 point.position.y = point.screenPosition.y = y; | 215 point.position.y = point.screenPosition.y = y; |
| 216 touches[index].state = WebTouchPoint::StateMoved; | 216 touches[index].state = WebTouchPoint::StateMoved; |
| 217 WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, timeStampSeconds, | 217 WebTouchEventTraits::ResetType(WebInputEvent::TouchMove, timeStampSeconds(), |
| 218 this); | 218 this); |
| 219 } | 219 } |
| 220 | 220 |
| 221 void SyntheticWebTouchEvent::ReleasePoint(int index) { | 221 void SyntheticWebTouchEvent::ReleasePoint(int index) { |
| 222 CHECK_GE(index, 0); | 222 CHECK_GE(index, 0); |
| 223 CHECK_LT(index, kTouchesLengthCap); | 223 CHECK_LT(index, kTouchesLengthCap); |
| 224 touches[index].state = WebTouchPoint::StateReleased; | 224 touches[index].state = WebTouchPoint::StateReleased; |
| 225 WebTouchEventTraits::ResetType(WebInputEvent::TouchEnd, timeStampSeconds, | 225 WebTouchEventTraits::ResetType(WebInputEvent::TouchEnd, timeStampSeconds(), |
| 226 this); | 226 this); |
| 227 } | 227 } |
| 228 | 228 |
| 229 void SyntheticWebTouchEvent::CancelPoint(int index) { | 229 void SyntheticWebTouchEvent::CancelPoint(int index) { |
| 230 CHECK_GE(index, 0); | 230 CHECK_GE(index, 0); |
| 231 CHECK_LT(index, kTouchesLengthCap); | 231 CHECK_LT(index, kTouchesLengthCap); |
| 232 touches[index].state = WebTouchPoint::StateCancelled; | 232 touches[index].state = WebTouchPoint::StateCancelled; |
| 233 WebTouchEventTraits::ResetType(WebInputEvent::TouchCancel, timeStampSeconds, | 233 WebTouchEventTraits::ResetType(WebInputEvent::TouchCancel, timeStampSeconds(), |
| 234 this); | 234 this); |
| 235 } | 235 } |
| 236 | 236 |
| 237 void SyntheticWebTouchEvent::SetTimestamp(base::TimeTicks timestamp) { | 237 void SyntheticWebTouchEvent::SetTimestamp(base::TimeTicks timestamp) { |
| 238 setTimeStampSeconds(ui::EventTimeStampToSeconds(timestamp)); | 238 setTimeStampSeconds(ui::EventTimeStampToSeconds(timestamp)); |
| 239 } | 239 } |
| 240 | 240 |
| 241 } // namespace content | 241 } // namespace content |
| OLD | NEW |