Chromium Code Reviews| Index: content/shell/renderer/test_runner/event_sender.cc |
| diff --git a/content/shell/renderer/test_runner/event_sender.cc b/content/shell/renderer/test_runner/event_sender.cc |
| index e02fe0cef1c2ca25679949bc5cd748cdb726e9ee..de90e38342f6588b0a8ce48566c7e436a6296bf4 100644 |
| --- a/content/shell/renderer/test_runner/event_sender.cc |
| +++ b/content/shell/renderer/test_runner/event_sender.cc |
| @@ -345,6 +345,9 @@ bool IsSystemKeyEvent(const WebKeyboardEvent& event) { |
| #endif |
| } |
| +const char* kSourceDeviceStringTouchpad = "touchpad"; |
| +const char* kSourceDeviceStringTouchscreen = "touchscreen"; |
| + |
| } // namespace |
| class EventSenderBindings : public gin::Wrappable<EventSenderBindings> { |
| @@ -382,7 +385,11 @@ class EventSenderBindings : public gin::Wrappable<EventSenderBindings> { |
| void SetTouchCancelable(bool cancelable); |
| void DumpFilenameBeingDragged(); |
| void GestureFlingCancel(); |
| - void GestureFlingStart(float x, float y, float velocity_x, float velocity_y); |
| + void GestureFlingStart(float x, |
| + float y, |
| + float velocity_x, |
| + float velocity_y, |
| + gin::Arguments* args); |
| void GestureScrollFirstPoint(int x, int y); |
| void TouchStart(); |
| void TouchMove(); |
| @@ -717,12 +724,23 @@ void EventSenderBindings::GestureFlingCancel() { |
| sender_->GestureFlingCancel(); |
| } |
| +// TODO(tdresser): Once we've migrated all calls to GestureFlingStart |
| +// to pass the device_string, change |args| to |std::string |
| +// device_string|. See crbug.com/456136 for details. |
| void EventSenderBindings::GestureFlingStart(float x, |
| float y, |
| float velocity_x, |
| - float velocity_y) { |
| + float velocity_y, |
| + gin::Arguments* args) { |
| + std::string device_string = kSourceDeviceStringTouchpad; |
| + if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) { |
| + if (!args->GetNext(&device_string)) { |
| + args->ThrowError(); |
| + return; |
| + } |
| + } |
| if (sender_) |
| - sender_->GestureFlingStart(x, y, velocity_x, velocity_y); |
| + sender_->GestureFlingStart(x, y, velocity_x, velocity_y, device_string); |
| } |
| void EventSenderBindings::GestureScrollFirstPoint(int x, int y) { |
| @@ -1607,12 +1625,17 @@ void EventSender::GestureFlingCancel() { |
| } |
| void EventSender::GestureFlingStart(float x, |
| - float y, |
| - float velocity_x, |
| - float velocity_y) { |
| + float y, |
| + float velocity_x, |
| + float velocity_y, |
| + std::string device_string) { |
| WebGestureEvent event; |
| event.type = WebInputEvent::GestureFlingStart; |
| + event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
|
Rick Byers
2015/02/07 11:20:23
This should probably have logic similar to Gesture
tdresser
2015/02/09 14:48:08
My plan was to switch to use |std::string| instead
|
| + if (device_string == kSourceDeviceStringTouchpad) |
| + event.sourceDevice = blink::WebGestureDeviceTouchpad; |
| + |
| event.x = x; |
| event.y = y; |
| event.globalX = event.x; |
| @@ -1998,9 +2021,9 @@ void EventSender::GestureEvent(WebInputEvent::Type type, |
| args->ThrowError(); |
| return; |
| } |
| - if (device_string == "touchpad") { |
| + if (device_string == kSourceDeviceStringTouchpad) { |
| event.sourceDevice = blink::WebGestureDeviceTouchpad; |
| - } else if (device_string == "touchscreen") { |
| + } else if (device_string == kSourceDeviceStringTouchscreen) { |
| event.sourceDevice = blink::WebGestureDeviceTouchscreen; |
| } else { |
| args->ThrowError(); |