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

Unified Diff: content/browser/renderer_host/input/web_input_event_util.cc

Issue 182383007: Make the ContentGestureProvider a ui::FilteredGestureProvider (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Lower similarity Created 6 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/browser/renderer_host/input/web_input_event_util.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/input/web_input_event_util.cc
diff --git a/content/browser/renderer_host/input/web_input_event_util.cc b/content/browser/renderer_host/input/web_input_event_util.cc
index 46d5fcbc6d3c7b654e56cf81bc9c732f862de783..4d9c59fcba70fa16109005dee6667d709f4ecb06 100644
--- a/content/browser/renderer_host/input/web_input_event_util.cc
+++ b/content/browser/renderer_host/input/web_input_event_util.cc
@@ -5,8 +5,10 @@
#include "content/browser/renderer_host/input/web_input_event_util.h"
#include "base/strings/string_util.h"
+#include "ui/events/gesture_detection/gesture_event_data.h"
#include "ui/events/gesture_detection/motion_event.h"
+using blink::WebGestureEvent;
using blink::WebInputEvent;
using blink::WebTouchEvent;
using blink::WebTouchPoint;
@@ -232,4 +234,101 @@ blink::WebTouchEvent CreateWebTouchEventFromMotionEvent(
return result;
}
+WebGestureEvent CreateWebGestureEventFromGestureEventData(
+ const ui::GestureEventData& data,
+ float scale) {
+ WebGestureEvent gesture;
+ gesture.x = data.x * scale;
+ gesture.y = data.y * scale;
+ gesture.timeStampSeconds = (data.time - base::TimeTicks()).InSecondsF();
+ gesture.sourceDevice = WebGestureEvent::Touchscreen;
+
+ switch (data.type) {
+ case ui::ET_GESTURE_SHOW_PRESS:
+ gesture.type = WebInputEvent::GestureShowPress;
+ gesture.data.showPress.width = data.details.show_press.width * scale;
+ gesture.data.showPress.width = data.details.show_press.width * scale;
+ break;
+ case ui::ET_GESTURE_DOUBLE_TAP:
+ gesture.type = WebInputEvent::GestureDoubleTap;
+ break;
+ case ui::ET_GESTURE_TAP:
+ gesture.type = WebInputEvent::GestureTap;
+ gesture.data.tap.tapCount = data.details.tap.tap_count;
+ gesture.data.tap.width = data.details.tap.width * scale;
+ gesture.data.tap.height = data.details.tap.height * scale;
+ break;
+ case ui::ET_GESTURE_TAP_UNCONFIRMED:
+ gesture.type = WebInputEvent::GestureTapUnconfirmed;
+ gesture.data.tap.tapCount = data.details.tap.tap_count;
+ gesture.data.tap.width = data.details.tap.width * scale;
+ gesture.data.tap.height = data.details.tap.height * scale;
+ break;
+ case ui::ET_GESTURE_LONG_PRESS:
+ gesture.type = WebInputEvent::GestureLongPress;
+ gesture.data.longPress.width = data.details.long_press.width * scale;
+ gesture.data.longPress.height = data.details.long_press.height * scale;
+ break;
+ case ui::ET_GESTURE_LONG_TAP:
+ gesture.type = WebInputEvent::GestureLongTap;
+ gesture.data.longPress.width = data.details.long_press.width * scale;
+ gesture.data.longPress.height = data.details.long_press.height * scale;
+ break;
+ case ui::ET_GESTURE_SCROLL_BEGIN:
+ gesture.type = WebInputEvent::GestureScrollBegin;
+ gesture.data.scrollBegin.deltaXHint =
+ data.details.scroll_begin.delta_x_hint * scale;
+ gesture.data.scrollBegin.deltaYHint =
+ data.details.scroll_begin.delta_y_hint * scale;
+ break;
+ case ui::ET_GESTURE_SCROLL_UPDATE:
+ gesture.type = WebInputEvent::GestureScrollUpdate;
+ gesture.data.scrollUpdate.deltaX =
+ data.details.scroll_update.delta_x * scale;
+ gesture.data.scrollUpdate.deltaY =
+ data.details.scroll_update.delta_y * scale;
+ gesture.data.scrollUpdate.velocityX =
+ data.details.scroll_update.velocity_x * scale;
+ gesture.data.scrollUpdate.velocityY =
+ data.details.scroll_update.velocity_y * scale;
+ break;
+ case ui::ET_GESTURE_SCROLL_END:
+ gesture.type = WebInputEvent::GestureScrollEnd;
+ break;
+ case ui::ET_SCROLL_FLING_START:
+ gesture.type = WebInputEvent::GestureFlingStart;
+ gesture.data.flingStart.velocityX =
+ data.details.fling_start.velocity_x * scale;
+ gesture.data.flingStart.velocityY =
+ data.details.fling_start.velocity_y * scale;
+ break;
+ case ui::ET_SCROLL_FLING_CANCEL:
+ gesture.type = WebInputEvent::GestureFlingCancel;
+ break;
+ case ui::ET_GESTURE_PINCH_BEGIN:
+ gesture.type = WebInputEvent::GesturePinchBegin;
+ break;
+ case ui::ET_GESTURE_PINCH_UPDATE:
+ gesture.type = WebInputEvent::GesturePinchUpdate;
+ gesture.data.pinchUpdate.scale = data.details.pinch_update.scale;
+ break;
+ case ui::ET_GESTURE_PINCH_END:
+ gesture.type = WebInputEvent::GesturePinchEnd;
+ break;
+ case ui::ET_GESTURE_TAP_CANCEL:
+ gesture.type = WebInputEvent::GestureTapCancel;
+ break;
+ case ui::ET_GESTURE_TAP_DOWN:
+ gesture.type = WebInputEvent::GestureTapDown;
+ gesture.data.tapDown.width = data.details.tap_down.width * scale;
+ gesture.data.tapDown.height = data.details.tap_down.height * scale;
+ break;
+ default:
+ NOTREACHED() << "ui::EventType provided wasn't a valid gesture event.";
+ break;
+ }
+
+ return gesture;
+}
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/input/web_input_event_util.h ('k') | content/content_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698