| 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 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 | 157 |
| 158 return touch; | 158 return touch; |
| 159 } | 159 } |
| 160 | 160 |
| 161 } // namespace | 161 } // namespace |
| 162 | 162 |
| 163 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( | 163 blink::WebTouchEvent CreateWebTouchEventFromMotionEvent( |
| 164 const MotionEvent& event, | 164 const MotionEvent& event, |
| 165 bool moved_beyond_slop_region) { | 165 bool moved_beyond_slop_region) { |
| 166 static_assert(static_cast<int>(MotionEvent::MAX_TOUCH_POINT_COUNT) == | 166 static_assert(static_cast<int>(MotionEvent::MAX_TOUCH_POINT_COUNT) == |
| 167 static_cast<int>(blink::WebTouchEvent::touchesLengthCap), | 167 static_cast<int>(blink::WebTouchEvent::kTouchesLengthCap), |
| 168 "inconsistent maximum number of active touch points"); | 168 "inconsistent maximum number of active touch points"); |
| 169 | 169 |
| 170 blink::WebTouchEvent result; | 170 blink::WebTouchEvent result; |
| 171 | 171 |
| 172 result.type = ToWebInputEventType(event.GetAction()); | 172 result.type = ToWebInputEventType(event.GetAction()); |
| 173 result.dispatchType = result.type == WebInputEvent::TouchCancel | 173 result.dispatchType = result.type == WebInputEvent::TouchCancel |
| 174 ? WebInputEvent::EventNonBlocking | 174 ? WebInputEvent::EventNonBlocking |
| 175 : WebInputEvent::Blocking; | 175 : WebInputEvent::Blocking; |
| 176 result.timeStampSeconds = ui::EventTimeStampToSeconds(event.GetEventTime()); | 176 result.timeStampSeconds = ui::EventTimeStampToSeconds(event.GetEventTime()); |
| 177 result.movedBeyondSlopRegion = moved_beyond_slop_region; | 177 result.movedBeyondSlopRegion = moved_beyond_slop_region; |
| 178 result.modifiers = EventFlagsToWebEventModifiers(event.GetFlags()); | 178 result.modifiers = EventFlagsToWebEventModifiers(event.GetFlags()); |
| 179 DCHECK_NE(event.GetUniqueEventId(), 0U); | 179 DCHECK_NE(event.GetUniqueEventId(), 0U); |
| 180 result.uniqueTouchEventId = event.GetUniqueEventId(); | 180 result.uniqueTouchEventId = event.GetUniqueEventId(); |
| 181 result.touchesLength = | 181 result.touchesLength = |
| 182 std::min(static_cast<unsigned>(event.GetPointerCount()), | 182 std::min(static_cast<unsigned>(event.GetPointerCount()), |
| 183 static_cast<unsigned>(WebTouchEvent::touchesLengthCap)); | 183 static_cast<unsigned>(WebTouchEvent::kTouchesLengthCap)); |
| 184 DCHECK_GT(result.touchesLength, 0U); | 184 DCHECK_GT(result.touchesLength, 0U); |
| 185 | 185 |
| 186 for (size_t i = 0; i < result.touchesLength; ++i) | 186 for (size_t i = 0; i < result.touchesLength; ++i) |
| 187 result.touches[i] = CreateWebTouchPoint(event, i); | 187 result.touches[i] = CreateWebTouchPoint(event, i); |
| 188 | 188 |
| 189 return result; | 189 return result; |
| 190 } | 190 } |
| 191 | 191 |
| 192 int EventFlagsToWebEventModifiers(int flags) { | 192 int EventFlagsToWebEventModifiers(int flags) { |
| 193 int modifiers = 0; | 193 int modifiers = 0; |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 case MotionEvent::TOOL_TYPE_MOUSE: | 474 case MotionEvent::TOOL_TYPE_MOUSE: |
| 475 return WebPointerProperties::PointerType::Mouse; | 475 return WebPointerProperties::PointerType::Mouse; |
| 476 case MotionEvent::TOOL_TYPE_ERASER: | 476 case MotionEvent::TOOL_TYPE_ERASER: |
| 477 return WebPointerProperties::PointerType::Unknown; | 477 return WebPointerProperties::PointerType::Unknown; |
| 478 } | 478 } |
| 479 NOTREACHED() << "Invalid MotionEvent::ToolType = " << tool_type; | 479 NOTREACHED() << "Invalid MotionEvent::ToolType = " << tool_type; |
| 480 return WebPointerProperties::PointerType::Unknown; | 480 return WebPointerProperties::PointerType::Unknown; |
| 481 } | 481 } |
| 482 | 482 |
| 483 } // namespace ui | 483 } // namespace ui |
| OLD | NEW |