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

Unified Diff: content/browser/renderer_host/render_widget_host_impl.cc

Issue 10825192: Add debugging flag --simulate-touch-screen-with-mouse. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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/render_widget_host_impl.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_impl.cc
diff --git a/content/browser/renderer_host/render_widget_host_impl.cc b/content/browser/renderer_host/render_widget_host_impl.cc
index 3b93544dbc9bd8efccc9bd2e4549160fc561c4dd..ddf287403271fb29e00c1bb08f625d92c7f39e3a 100644
--- a/content/browser/renderer_host/render_widget_host_impl.cc
+++ b/content/browser/renderer_host/render_widget_host_impl.cc
@@ -4,6 +4,7 @@
#include "content/browser/renderer_host/render_widget_host_impl.h"
+#include <math.h>
#include <utility>
#include "base/auto_reset.h"
@@ -747,12 +748,105 @@ void RenderWidgetHostImpl::EnableFullAccessibilityMode() {
SetAccessibilityMode(AccessibilityModeComplete);
}
+static WebGestureEvent makeGestureEvent(WebInputEvent::Type type,
+ double timeStampSeconds,
+ int x,
+ int y,
+ float deltaX,
+ float deltaY,
+ int modifiers)
+{
jam 2012/08/06 18:33:21 nit: this function is using webkit style, please c
aelias_OOO_until_Jul13 2012/08/06 18:46:30 Done. By the way, is there a style checker tool I
+ WebGestureEvent result;
+
+ result.type = type;
+ result.x = x;
+ result.y = y;
+ result.deltaX = deltaX;
+ result.deltaY = deltaY;
+ result.timeStampSeconds = timeStampSeconds;
+ result.modifiers = modifiers;
+
+ return result;
+}
+
+void RenderWidgetHostImpl::SimulateTouchGestureWithMouse(
+ const WebMouseEvent& mouse_event) {
+ int x = mouse_event.x, y = mouse_event.y;
+ float dx = mouse_event.movementX, dy = mouse_event.movementY;
+ static int startX = 0, startY = 0;
+
+ switch (mouse_event.button) {
+ case WebMouseEvent::ButtonLeft:
+ if (mouse_event.type == WebInputEvent::MouseDown) {
+ startX = x;
+ startY = y;
+ ForwardGestureEvent(makeGestureEvent(
+ WebInputEvent::GestureScrollBegin, mouse_event.timeStampSeconds,
+ x, y, 0, 0, 0));
+ }
+ if (dx != 0 || dy != 0) {
+ ForwardGestureEvent(makeGestureEvent(
+ WebInputEvent::GestureScrollUpdate, mouse_event.timeStampSeconds,
+ x, y, dx, dy, 0));
+ }
+ if (mouse_event.type == WebInputEvent::MouseUp) {
+ ForwardGestureEvent(makeGestureEvent(
+ WebInputEvent::GestureScrollEnd, mouse_event.timeStampSeconds,
+ x, y, dx, dy, 0));
+ }
+ break;
+ case WebMouseEvent::ButtonMiddle:
+ if (mouse_event.type == WebInputEvent::MouseDown) {
+ startX = x;
+ startY = y;
+ ForwardGestureEvent(makeGestureEvent(
+ WebInputEvent::GestureTapDown, mouse_event.timeStampSeconds,
+ x, y, 0, 0, 0));
+ }
+ if (mouse_event.type == WebInputEvent::MouseUp) {
+ ForwardGestureEvent(makeGestureEvent(
+ WebInputEvent::GestureTap, mouse_event.timeStampSeconds,
+ x, y, dx, dy, 0));
+ }
+ break;
+ case WebMouseEvent::ButtonRight:
+ if (mouse_event.type == WebInputEvent::MouseDown) {
+ startX = x;
+ startY = y;
+ ForwardGestureEvent(makeGestureEvent(
+ WebInputEvent::GesturePinchBegin, mouse_event.timeStampSeconds,
+ x, y, 1, 1, 0));
+ }
+ if (dx != 0 || dy != 0) {
+ dx = pow(dy < 0 ? 0.998 : 1.002, abs(dy));
+ dy = dx;
+ ForwardGestureEvent(makeGestureEvent(
+ WebInputEvent::GesturePinchUpdate, mouse_event.timeStampSeconds,
+ startX, startY, dx, dy, 0));
+ }
+ if (mouse_event.type == WebInputEvent::MouseUp) {
+ ForwardGestureEvent(makeGestureEvent(
+ WebInputEvent::GesturePinchEnd, mouse_event.timeStampSeconds,
+ x, y, dx, dy, 0));
+ }
+ break;
+ case WebMouseEvent::ButtonNone:
+ break;
+ }
+}
+
void RenderWidgetHostImpl::ForwardMouseEvent(const WebMouseEvent& mouse_event) {
TRACE_EVENT2("renderer_host", "RenderWidgetHostImpl::ForwardMouseEvent",
"x", mouse_event.x, "y", mouse_event.y);
if (ignore_input_events_ || process_->IgnoreInputEvents())
return;
+ if (CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kSimulateTouchScreenWithMouse)) {
+ SimulateTouchGestureWithMouse(mouse_event);
+ return;
+ }
+
// Avoid spamming the renderer with mouse move events. It is important
// to note that WM_MOUSEMOVE events are anyways synthetic, but since our
// thread is able to rapidly consume WM_MOUSEMOVE events, we may get way
« no previous file with comments | « content/browser/renderer_host/render_widget_host_impl.h ('k') | content/public/common/content_switches.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698