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/event.h" | 10 #include "ui/events/event.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 WebMouseEvent SyntheticWebMouseEventBuilder::Build( | 29 WebMouseEvent SyntheticWebMouseEventBuilder::Build( |
30 blink::WebInputEvent::Type type, | 30 blink::WebInputEvent::Type type, |
31 int window_x, | 31 int window_x, |
32 int window_y, | 32 int window_y, |
33 int modifiers, | 33 int modifiers, |
34 blink::WebPointerProperties::PointerType pointer_type) { | 34 blink::WebPointerProperties::PointerType pointer_type) { |
35 DCHECK(WebInputEvent::isMouseEventType(type)); | 35 DCHECK(WebInputEvent::isMouseEventType(type)); |
36 WebMouseEvent result(type, modifiers, | 36 WebMouseEvent result(type, modifiers, |
37 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); | 37 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
38 result.x = window_x; | 38 result.position.x = window_x; |
39 result.y = window_y; | 39 result.position.y = window_y; |
40 result.setModifiers(modifiers); | 40 result.setModifiers(modifiers); |
41 result.pointerType = pointer_type; | 41 result.pointerType = pointer_type; |
42 result.id = ui::PointerEvent::kMousePointerId; | 42 result.id = ui::PointerEvent::kMousePointerId; |
43 return result; | 43 return result; |
44 } | 44 } |
45 | 45 |
46 WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build( | 46 WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build( |
47 WebMouseWheelEvent::Phase phase) { | 47 WebMouseWheelEvent::Phase phase) { |
48 WebMouseWheelEvent result(WebInputEvent::MouseWheel, | 48 WebMouseWheelEvent result(WebInputEvent::MouseWheel, |
49 WebInputEvent::NoModifiers, | 49 WebInputEvent::NoModifiers, |
(...skipping 14 matching lines...) Expand all Loading... |
64 WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(float x, | 64 WebMouseWheelEvent SyntheticWebMouseWheelEventBuilder::Build(float x, |
65 float y, | 65 float y, |
66 float global_x, | 66 float global_x, |
67 float global_y, | 67 float global_y, |
68 float dx, | 68 float dx, |
69 float dy, | 69 float dy, |
70 int modifiers, | 70 int modifiers, |
71 bool precise) { | 71 bool precise) { |
72 WebMouseWheelEvent result(WebInputEvent::MouseWheel, modifiers, | 72 WebMouseWheelEvent result(WebInputEvent::MouseWheel, modifiers, |
73 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); | 73 ui::EventTimeStampToSeconds(ui::EventTimeForNow())); |
74 result.globalX = global_x; | 74 result.screenPosition.x = global_x; |
75 result.globalY = global_y; | 75 result.screenPosition.y = global_y; |
76 result.x = x; | 76 result.position.x = x; |
77 result.y = y; | 77 result.position.y = y; |
78 result.deltaX = dx; | 78 result.deltaX = dx; |
79 result.deltaY = dy; | 79 result.deltaY = dy; |
80 if (dx) | 80 if (dx) |
81 result.wheelTicksX = dx > 0.0f ? 1.0f : -1.0f; | 81 result.wheelTicksX = dx > 0.0f ? 1.0f : -1.0f; |
82 if (dy) | 82 if (dy) |
83 result.wheelTicksY = dy > 0.0f ? 1.0f : -1.0f; | 83 result.wheelTicksY = dy > 0.0f ? 1.0f : -1.0f; |
84 result.hasPreciseScrollingDeltas = precise; | 84 result.hasPreciseScrollingDeltas = precise; |
85 return result; | 85 return result; |
86 } | 86 } |
87 | 87 |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 | 249 |
250 int SyntheticWebTouchEvent::FirstFreeIndex() { | 250 int SyntheticWebTouchEvent::FirstFreeIndex() { |
251 for (size_t i = 0; i < kTouchesLengthCap; ++i) { | 251 for (size_t i = 0; i < kTouchesLengthCap; ++i) { |
252 if (touches[i].state == WebTouchPoint::StateUndefined) | 252 if (touches[i].state == WebTouchPoint::StateUndefined) |
253 return i; | 253 return i; |
254 } | 254 } |
255 return -1; | 255 return -1; |
256 } | 256 } |
257 | 257 |
258 } // namespace content | 258 } // namespace content |
OLD | NEW |