Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2869)

Unified Diff: content/shell/renderer/test_runner/event_sender.cc

Issue 902173003: EventSender::GestureFlingStart takes a source_device. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Throw on invalid source device. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 f4948b60df0def7b27cfd9309fe802bd4de9b0bf..4352db34655fe3334edba3f1d4b12b7ea1556606 100644
--- a/content/shell/renderer/test_runner/event_sender.cc
+++ b/content/shell/renderer/test_runner/event_sender.cc
@@ -347,6 +347,9 @@ bool IsSystemKeyEvent(const WebKeyboardEvent& event) {
#endif
}
+const char* kSourceDeviceStringTouchpad = "touchpad";
+const char* kSourceDeviceStringTouchscreen = "touchscreen";
+
} // namespace
class EventSenderBindings : public gin::Wrappable<EventSenderBindings> {
@@ -384,7 +387,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();
@@ -722,9 +729,10 @@ void EventSenderBindings::GestureFlingCancel() {
void EventSenderBindings::GestureFlingStart(float x,
float y,
float velocity_x,
- float velocity_y) {
+ float velocity_y,
+ gin::Arguments* args) {
if (sender_)
- sender_->GestureFlingStart(x, y, velocity_x, velocity_y);
+ sender_->GestureFlingStart(x, y, velocity_x, velocity_y, args);
}
void EventSenderBindings::GestureScrollFirstPoint(int x, int y) {
@@ -1646,12 +1654,33 @@ void EventSender::GestureFlingCancel() {
}
void EventSender::GestureFlingStart(float x,
- float y,
- float velocity_x,
- float velocity_y) {
+ float y,
+ float velocity_x,
+ float velocity_y,
+ gin::Arguments* args) {
WebGestureEvent event;
event.type = WebInputEvent::GestureFlingStart;
+ // TODO(tdresser): Once we've migrated all calls to GestureFlingStart
+ // to pass the device string, throw an error if args is empty. See
+ // crbug.com/456136 for details.
+ std::string device_string = kSourceDeviceStringTouchpad;
+ if (!args->PeekNext().IsEmpty() && args->PeekNext()->IsString()) {
+ if (!args->GetNext(&device_string)) {
+ args->ThrowError();
+ return;
+ }
+ }
+
+ if (device_string == kSourceDeviceStringTouchpad) {
+ event.sourceDevice = blink::WebGestureDeviceTouchpad;
+ } else if (device_string == kSourceDeviceStringTouchscreen) {
+ event.sourceDevice = blink::WebGestureDeviceTouchscreen;
+ } else {
+ args->ThrowError();
+ return;
+ }
+
event.x = x;
event.y = y;
event.globalX = event.x;
@@ -2037,9 +2066,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();
« no previous file with comments | « content/shell/renderer/test_runner/event_sender.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698