Commit 3a1c9723 authored by tdresser's avatar tdresser Committed by Commit bot

EventSender::GestureFlingStart takes a source_device.

This is the first of three patches.

The second patch (in blink) will make all existing uses of
window.eventSender.gestureFlingStart pass a source device.
(https://codereview.chromium.org/901323004)

The third patch (in chrome) will change
EventSenderBindings::GestureFlingStart to require a source device.

BUG=456136
TEST=LayoutTests/fast/events/touch/

Review URL: https://codereview.chromium.org/902173003

Cr-Commit-Position: refs/heads/master@{#316221}
parent 616dbf25
...@@ -347,6 +347,9 @@ bool IsSystemKeyEvent(const WebKeyboardEvent& event) { ...@@ -347,6 +347,9 @@ bool IsSystemKeyEvent(const WebKeyboardEvent& event) {
#endif #endif
} }
const char* kSourceDeviceStringTouchpad = "touchpad";
const char* kSourceDeviceStringTouchscreen = "touchscreen";
} // namespace } // namespace
class EventSenderBindings : public gin::Wrappable<EventSenderBindings> { class EventSenderBindings : public gin::Wrappable<EventSenderBindings> {
...@@ -384,7 +387,11 @@ class EventSenderBindings : public gin::Wrappable<EventSenderBindings> { ...@@ -384,7 +387,11 @@ class EventSenderBindings : public gin::Wrappable<EventSenderBindings> {
void SetTouchCancelable(bool cancelable); void SetTouchCancelable(bool cancelable);
void DumpFilenameBeingDragged(); void DumpFilenameBeingDragged();
void GestureFlingCancel(); 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 GestureScrollFirstPoint(int x, int y);
void TouchStart(); void TouchStart();
void TouchMove(); void TouchMove();
...@@ -722,9 +729,10 @@ void EventSenderBindings::GestureFlingCancel() { ...@@ -722,9 +729,10 @@ void EventSenderBindings::GestureFlingCancel() {
void EventSenderBindings::GestureFlingStart(float x, void EventSenderBindings::GestureFlingStart(float x,
float y, float y,
float velocity_x, float velocity_x,
float velocity_y) { float velocity_y,
gin::Arguments* args) {
if (sender_) 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) { void EventSenderBindings::GestureScrollFirstPoint(int x, int y) {
...@@ -1646,12 +1654,33 @@ void EventSender::GestureFlingCancel() { ...@@ -1646,12 +1654,33 @@ void EventSender::GestureFlingCancel() {
} }
void EventSender::GestureFlingStart(float x, void EventSender::GestureFlingStart(float x,
float y, float y,
float velocity_x, float velocity_x,
float velocity_y) { float velocity_y,
gin::Arguments* args) {
WebGestureEvent event; WebGestureEvent event;
event.type = WebInputEvent::GestureFlingStart; 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.x = x;
event.y = y; event.y = y;
event.globalX = event.x; event.globalX = event.x;
...@@ -2037,9 +2066,9 @@ void EventSender::GestureEvent(WebInputEvent::Type type, ...@@ -2037,9 +2066,9 @@ void EventSender::GestureEvent(WebInputEvent::Type type,
args->ThrowError(); args->ThrowError();
return; return;
} }
if (device_string == "touchpad") { if (device_string == kSourceDeviceStringTouchpad) {
event.sourceDevice = blink::WebGestureDeviceTouchpad; event.sourceDevice = blink::WebGestureDeviceTouchpad;
} else if (device_string == "touchscreen") { } else if (device_string == kSourceDeviceStringTouchscreen) {
event.sourceDevice = blink::WebGestureDeviceTouchscreen; event.sourceDevice = blink::WebGestureDeviceTouchscreen;
} else { } else {
args->ThrowError(); args->ThrowError();
......
...@@ -115,7 +115,11 @@ class EventSender : public base::SupportsWeakPtr<EventSender> { ...@@ -115,7 +115,11 @@ class EventSender : public base::SupportsWeakPtr<EventSender> {
void DumpFilenameBeingDragged(); void DumpFilenameBeingDragged();
void GestureFlingCancel(); 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 GestureScrollFirstPoint(int x, int y);
void TouchStart(); void TouchStart();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment