| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 // MSVC++ requires this to be set before any other includes to get M_PI. | 5 // MSVC++ requires this to be set before any other includes to get M_PI. |
| 6 #define _USE_MATH_DEFINES | 6 #define _USE_MATH_DEFINES |
| 7 | 7 |
| 8 #include "ui/events/blink/blink_event_util.h" | 8 #include "ui/events/blink/blink_event_util.h" |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 172 touch.tiltX = touch.tiltY = 0; | 172 touch.tiltX = touch.tiltY = 0; |
| 173 } | 173 } |
| 174 | 174 |
| 175 return touch; | 175 return touch; |
| 176 } | 176 } |
| 177 | 177 |
| 178 } // namespace | 178 } // namespace |
| 179 | 179 |
| 180 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( | 180 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( |
| 181 const MotionEvent& event, | 181 const MotionEvent& event, |
| 182 bool may_cause_scrolling) { | 182 bool moved_beyond_slop_region) { |
| 183 static_assert(static_cast<int>(MotionEvent::MAX_TOUCH_POINT_COUNT) == | 183 static_assert(static_cast<int>(MotionEvent::MAX_TOUCH_POINT_COUNT) == |
| 184 static_cast<int>(blink::WebTouchEvent::touchesLengthCap), | 184 static_cast<int>(blink::WebTouchEvent::touchesLengthCap), |
| 185 "inconsistent maximum number of active touch points"); | 185 "inconsistent maximum number of active touch points"); |
| 186 | 186 |
| 187 blink::WebTouchEvent result; | 187 blink::WebTouchEvent result; |
| 188 | 188 |
| 189 result.type = ToWebInputEventType(event.GetAction()); | 189 result.type = ToWebInputEventType(event.GetAction()); |
| 190 result.cancelable = (result.type != WebInputEvent::TouchCancel); | 190 result.cancelable = (result.type != WebInputEvent::TouchCancel); |
| 191 result.timeStampSeconds = | 191 result.timeStampSeconds = |
| 192 (event.GetEventTime() - base::TimeTicks()).InSecondsF(), | 192 (event.GetEventTime() - base::TimeTicks()).InSecondsF(); |
| 193 result.causesScrollingIfUncanceled = may_cause_scrolling; | 193 result.movedBeyondSlopRegion = moved_beyond_slop_region; |
| 194 result.modifiers = EventFlagsToWebEventModifiers(event.GetFlags()); | 194 result.modifiers = EventFlagsToWebEventModifiers(event.GetFlags()); |
| 195 DCHECK_NE(event.GetUniqueEventId(), 0U); | 195 DCHECK_NE(event.GetUniqueEventId(), 0U); |
| 196 result.uniqueTouchEventId = event.GetUniqueEventId(); | 196 result.uniqueTouchEventId = event.GetUniqueEventId(); |
| 197 result.touchesLength = | 197 result.touchesLength = |
| 198 std::min(static_cast<unsigned>(event.GetPointerCount()), | 198 std::min(static_cast<unsigned>(event.GetPointerCount()), |
| 199 static_cast<unsigned>(WebTouchEvent::touchesLengthCap)); | 199 static_cast<unsigned>(WebTouchEvent::touchesLengthCap)); |
| 200 DCHECK_GT(result.touchesLength, 0U); | 200 DCHECK_GT(result.touchesLength, 0U); |
| 201 | 201 |
| 202 for (size_t i = 0; i < result.touchesLength; ++i) | 202 for (size_t i = 0; i < result.touchesLength; ++i) |
| 203 result.touches[i] = CreateWebTouchPoint(event, i); | 203 result.touches[i] = CreateWebTouchPoint(event, i); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 465 | 465 |
| 466 // TODO(oshima): Find out if ContextMenu needs to be scaled. | 466 // TODO(oshima): Find out if ContextMenu needs to be scaled. |
| 467 default: | 467 default: |
| 468 break; | 468 break; |
| 469 } | 469 } |
| 470 } | 470 } |
| 471 return scaled_event; | 471 return scaled_event; |
| 472 } | 472 } |
| 473 | 473 |
| 474 } // namespace ui | 474 } // namespace ui |
| OLD | NEW |