| 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/keycodes/keyboard_codes.h" | 9 #include "ui/events/keycodes/keyboard_codes.h" |
| 10 | 10 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 WebInputEvent::Type type) { | 75 WebInputEvent::Type type) { |
| 76 DCHECK(WebInputEvent::isKeyboardEventType(type)); | 76 DCHECK(WebInputEvent::isKeyboardEventType(type)); |
| 77 WebKeyboardEvent result; | 77 WebKeyboardEvent result; |
| 78 result.type = type; | 78 result.type = type; |
| 79 result.windowsKeyCode = ui::VKEY_L; // non-null made up value. | 79 result.windowsKeyCode = ui::VKEY_L; // non-null made up value. |
| 80 return result; | 80 return result; |
| 81 } | 81 } |
| 82 | 82 |
| 83 WebGestureEvent SyntheticWebGestureEventBuilder::Build( | 83 WebGestureEvent SyntheticWebGestureEventBuilder::Build( |
| 84 WebInputEvent::Type type, | 84 WebInputEvent::Type type, |
| 85 WebGestureEvent::SourceDevice source_device) { | 85 blink::WebGestureDevice source_device) { |
| 86 DCHECK(WebInputEvent::isGestureEventType(type)); | 86 DCHECK(WebInputEvent::isGestureEventType(type)); |
| 87 WebGestureEvent result; | 87 WebGestureEvent result; |
| 88 result.type = type; | 88 result.type = type; |
| 89 result.sourceDevice = source_device; | 89 result.sourceDevice = source_device; |
| 90 if (type == WebInputEvent::GestureTap || | 90 if (type == WebInputEvent::GestureTap || |
| 91 type == WebInputEvent::GestureTapUnconfirmed || | 91 type == WebInputEvent::GestureTapUnconfirmed || |
| 92 type == WebInputEvent::GestureDoubleTap) { | 92 type == WebInputEvent::GestureDoubleTap) { |
| 93 result.data.tap.tapCount = 1; | 93 result.data.tap.tapCount = 1; |
| 94 result.data.tap.width = 10; | 94 result.data.tap.width = 10; |
| 95 result.data.tap.height = 10; | 95 result.data.tap.height = 10; |
| 96 } | 96 } |
| 97 return result; | 97 return result; |
| 98 } | 98 } |
| 99 | 99 |
| 100 WebGestureEvent SyntheticWebGestureEventBuilder::BuildScrollBegin( | 100 WebGestureEvent SyntheticWebGestureEventBuilder::BuildScrollBegin( |
| 101 float dx_hint, | 101 float dx_hint, |
| 102 float dy_hint) { | 102 float dy_hint) { |
| 103 WebGestureEvent result = Build(WebInputEvent::GestureScrollBegin, | 103 WebGestureEvent result = |
| 104 WebGestureEvent::Touchscreen); | 104 Build(WebInputEvent::GestureScrollBegin, blink::WebGestureDeviceTouchpad); |
| 105 result.data.scrollBegin.deltaXHint = dx_hint; | 105 result.data.scrollBegin.deltaXHint = dx_hint; |
| 106 result.data.scrollBegin.deltaYHint = dy_hint; | 106 result.data.scrollBegin.deltaYHint = dy_hint; |
| 107 return result; | 107 return result; |
| 108 } | 108 } |
| 109 | 109 |
| 110 WebGestureEvent SyntheticWebGestureEventBuilder::BuildScrollUpdate( | 110 WebGestureEvent SyntheticWebGestureEventBuilder::BuildScrollUpdate( |
| 111 float dx, | 111 float dx, |
| 112 float dy, | 112 float dy, |
| 113 int modifiers) { | 113 int modifiers) { |
| 114 WebGestureEvent result = Build(WebInputEvent::GestureScrollUpdate, | 114 WebGestureEvent result = Build(WebInputEvent::GestureScrollUpdate, |
| 115 WebGestureEvent::Touchscreen); | 115 blink::WebGestureDeviceTouchpad); |
| 116 result.data.scrollUpdate.deltaX = dx; | 116 result.data.scrollUpdate.deltaX = dx; |
| 117 result.data.scrollUpdate.deltaY = dy; | 117 result.data.scrollUpdate.deltaY = dy; |
| 118 result.modifiers = modifiers; | 118 result.modifiers = modifiers; |
| 119 return result; | 119 return result; |
| 120 } | 120 } |
| 121 | 121 |
| 122 WebGestureEvent SyntheticWebGestureEventBuilder::BuildPinchUpdate( | 122 WebGestureEvent SyntheticWebGestureEventBuilder::BuildPinchUpdate( |
| 123 float scale, | 123 float scale, |
| 124 float anchor_x, | 124 float anchor_x, |
| 125 float anchor_y, | 125 float anchor_y, |
| 126 int modifiers, | 126 int modifiers, |
| 127 WebGestureEvent::SourceDevice source_device) { | 127 blink::WebGestureDevice source_device) { |
| 128 WebGestureEvent result = | 128 WebGestureEvent result = |
| 129 Build(WebInputEvent::GesturePinchUpdate, source_device); | 129 Build(WebInputEvent::GesturePinchUpdate, source_device); |
| 130 result.data.pinchUpdate.scale = scale; | 130 result.data.pinchUpdate.scale = scale; |
| 131 result.x = anchor_x; | 131 result.x = anchor_x; |
| 132 result.y = anchor_y; | 132 result.y = anchor_y; |
| 133 result.globalX = anchor_x; | 133 result.globalX = anchor_x; |
| 134 result.globalY = anchor_y; | 134 result.globalY = anchor_y; |
| 135 result.modifiers = modifiers; | 135 result.modifiers = modifiers; |
| 136 return result; | 136 return result; |
| 137 } | 137 } |
| 138 | 138 |
| 139 WebGestureEvent SyntheticWebGestureEventBuilder::BuildFling( | 139 WebGestureEvent SyntheticWebGestureEventBuilder::BuildFling( |
| 140 float velocity_x, | 140 float velocity_x, |
| 141 float velocity_y, | 141 float velocity_y, |
| 142 WebGestureEvent::SourceDevice source_device) { | 142 blink::WebGestureDevice source_device) { |
| 143 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, | 143 WebGestureEvent result = Build(WebInputEvent::GestureFlingStart, |
| 144 source_device); | 144 source_device); |
| 145 result.data.flingStart.velocityX = velocity_x; | 145 result.data.flingStart.velocityX = velocity_x; |
| 146 result.data.flingStart.velocityY = velocity_y; | 146 result.data.flingStart.velocityY = velocity_y; |
| 147 return result; | 147 return result; |
| 148 } | 148 } |
| 149 | 149 |
| 150 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() {} | 150 SyntheticWebTouchEvent::SyntheticWebTouchEvent() : WebTouchEvent() {} |
| 151 | 151 |
| 152 void SyntheticWebTouchEvent::ResetPoints() { | 152 void SyntheticWebTouchEvent::ResetPoints() { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 touches[index].state = WebTouchPoint::StateCancelled; | 200 touches[index].state = WebTouchPoint::StateCancelled; |
| 201 WebTouchEventTraits::ResetType( | 201 WebTouchEventTraits::ResetType( |
| 202 WebInputEvent::TouchCancel, timeStampSeconds, this); | 202 WebInputEvent::TouchCancel, timeStampSeconds, this); |
| 203 } | 203 } |
| 204 | 204 |
| 205 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { | 205 void SyntheticWebTouchEvent::SetTimestamp(base::TimeDelta timestamp) { |
| 206 timeStampSeconds = timestamp.InSecondsF(); | 206 timeStampSeconds = timestamp.InSecondsF(); |
| 207 } | 207 } |
| 208 | 208 |
| 209 } // namespace content | 209 } // namespace content |
| OLD | NEW |