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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 if (flags & EF_TOUCH_ACCESSIBILITY) | 219 if (flags & EF_TOUCH_ACCESSIBILITY) |
220 modifiers |= blink::WebInputEvent::IsTouchAccessibility; | 220 modifiers |= blink::WebInputEvent::IsTouchAccessibility; |
221 | 221 |
222 return modifiers; | 222 return modifiers; |
223 } | 223 } |
224 | 224 |
225 WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details, | 225 WebGestureEvent CreateWebGestureEvent(const GestureEventDetails& details, |
226 base::TimeDelta timestamp, | 226 base::TimeDelta timestamp, |
227 const gfx::PointF& location, | 227 const gfx::PointF& location, |
228 const gfx::PointF& raw_location, | 228 const gfx::PointF& raw_location, |
229 int flags) { | 229 int flags, |
| 230 uint32_t unique_touch_event_id) { |
230 WebGestureEvent gesture; | 231 WebGestureEvent gesture; |
231 gesture.timeStampSeconds = timestamp.InSecondsF(); | 232 gesture.timeStampSeconds = timestamp.InSecondsF(); |
232 gesture.x = gfx::ToFlooredInt(location.x()); | 233 gesture.x = gfx::ToFlooredInt(location.x()); |
233 gesture.y = gfx::ToFlooredInt(location.y()); | 234 gesture.y = gfx::ToFlooredInt(location.y()); |
234 gesture.globalX = gfx::ToFlooredInt(raw_location.x()); | 235 gesture.globalX = gfx::ToFlooredInt(raw_location.x()); |
235 gesture.globalY = gfx::ToFlooredInt(raw_location.y()); | 236 gesture.globalY = gfx::ToFlooredInt(raw_location.y()); |
236 gesture.modifiers = EventFlagsToWebEventModifiers(flags); | 237 gesture.modifiers = EventFlagsToWebEventModifiers(flags); |
237 gesture.sourceDevice = blink::WebGestureDeviceTouchscreen; | 238 gesture.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| 239 gesture.uniqueTouchEventId = unique_touch_event_id; |
238 | 240 |
239 switch (details.type()) { | 241 switch (details.type()) { |
240 case ET_GESTURE_SHOW_PRESS: | 242 case ET_GESTURE_SHOW_PRESS: |
241 gesture.type = WebInputEvent::GestureShowPress; | 243 gesture.type = WebInputEvent::GestureShowPress; |
242 gesture.data.showPress.width = details.bounding_box_f().width(); | 244 gesture.data.showPress.width = details.bounding_box_f().width(); |
243 gesture.data.showPress.height = details.bounding_box_f().height(); | 245 gesture.data.showPress.height = details.bounding_box_f().height(); |
244 break; | 246 break; |
245 case ET_GESTURE_DOUBLE_TAP: | 247 case ET_GESTURE_DOUBLE_TAP: |
246 gesture.type = WebInputEvent::GestureDoubleTap; | 248 gesture.type = WebInputEvent::GestureDoubleTap; |
247 DCHECK_EQ(1, details.tap_count()); | 249 DCHECK_EQ(1, details.tap_count()); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 << details.type(); | 333 << details.type(); |
332 } | 334 } |
333 | 335 |
334 return gesture; | 336 return gesture; |
335 } | 337 } |
336 | 338 |
337 WebGestureEvent CreateWebGestureEventFromGestureEventData( | 339 WebGestureEvent CreateWebGestureEventFromGestureEventData( |
338 const GestureEventData& data) { | 340 const GestureEventData& data) { |
339 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), | 341 return CreateWebGestureEvent(data.details, data.time - base::TimeTicks(), |
340 gfx::PointF(data.x, data.y), | 342 gfx::PointF(data.x, data.y), |
341 gfx::PointF(data.raw_x, data.raw_y), data.flags); | 343 gfx::PointF(data.raw_x, data.raw_y), data.flags, |
| 344 data.unique_touch_event_id); |
342 } | 345 } |
343 | 346 |
344 std::unique_ptr<blink::WebInputEvent> ScaleWebInputEvent( | 347 std::unique_ptr<blink::WebInputEvent> ScaleWebInputEvent( |
345 const blink::WebInputEvent& event, | 348 const blink::WebInputEvent& event, |
346 float scale) { | 349 float scale) { |
347 std::unique_ptr<blink::WebInputEvent> scaled_event; | 350 std::unique_ptr<blink::WebInputEvent> scaled_event; |
348 if (scale == 1.f) | 351 if (scale == 1.f) |
349 return scaled_event; | 352 return scaled_event; |
350 if (event.type == blink::WebMouseEvent::MouseWheel) { | 353 if (event.type == blink::WebMouseEvent::MouseWheel) { |
351 blink::WebMouseWheelEvent* wheel_event = new blink::WebMouseWheelEvent; | 354 blink::WebMouseWheelEvent* wheel_event = new blink::WebMouseWheelEvent; |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 case MotionEvent::TOOL_TYPE_MOUSE: | 461 case MotionEvent::TOOL_TYPE_MOUSE: |
459 return WebPointerProperties::PointerType::Mouse; | 462 return WebPointerProperties::PointerType::Mouse; |
460 case MotionEvent::TOOL_TYPE_ERASER: | 463 case MotionEvent::TOOL_TYPE_ERASER: |
461 return WebPointerProperties::PointerType::Unknown; | 464 return WebPointerProperties::PointerType::Unknown; |
462 } | 465 } |
463 NOTREACHED() << "Invalid MotionEvent::ToolType = " << tool_type; | 466 NOTREACHED() << "Invalid MotionEvent::ToolType = " << tool_type; |
464 return WebPointerProperties::PointerType::Unknown; | 467 return WebPointerProperties::PointerType::Unknown; |
465 } | 468 } |
466 | 469 |
467 } // namespace ui | 470 } // namespace ui |
OLD | NEW |