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

Unified Diff: webkit/tools/test_shell/event_sending_controller.cc

Issue 387002: Implement EventSender.mouseWheelTo method.... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « webkit/tools/test_shell/event_sending_controller.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webkit/tools/test_shell/event_sending_controller.cc
===================================================================
--- webkit/tools/test_shell/event_sending_controller.cc (revision 32002)
+++ webkit/tools/test_shell/event_sending_controller.cc (working copy)
@@ -56,6 +56,7 @@
using WebKit::WebInputEvent;
using WebKit::WebKeyboardEvent;
using WebKit::WebMouseEvent;
+using WebKit::WebMouseWheelEvent;
using WebKit::WebPoint;
using WebKit::WebString;
using WebKit::WebView;
@@ -106,6 +107,10 @@
static const double kMultiClickTimeSec = 1;
static const int kMultiClickRadiusPixels = 5;
+// How much we should scroll per event - the value here is chosen to
+// match the WebKit impl and layout test results.
+static const float kScrollbarPixelsPerTick = 40.0f;
+
inline bool outside_multiclick_radius(const gfx::Point &a, const gfx::Point &b) {
return ((a.x() - b.x()) * (a.x() - b.x()) + (a.y() - b.y()) * (a.y() - b.y())) >
kMultiClickRadiusPixels * kMultiClickRadiusPixels;
@@ -183,6 +188,7 @@
BindMethod("mouseUp", &EventSendingController::mouseUp);
BindMethod("contextClick", &EventSendingController::contextClick);
BindMethod("mouseMoveTo", &EventSendingController::mouseMoveTo);
+ BindMethod("mouseWheelTo", &EventSendingController::mouseWheelTo);
BindMethod("leapForward", &EventSendingController::leapForward);
BindMethod("keyDown", &EventSendingController::keyDown);
BindMethod("dispatchMessage", &EventSendingController::dispatchMessage);
@@ -403,6 +409,32 @@
}
}
+void EventSendingController::mouseWheelTo(
+ const CppArgumentList& args, CppVariant* result) {
+ result->SetNull();
+
+ if (args.size() >= 2 && args[0].isNumber() && args[1].isNumber()) {
+ // Force a layout here just to make sure every position has been
+ // determined before we send events (as well as all the other methods
+ // that send an event do). The layout test calling this
+ // (scrollbars/overflow-scrollbar-horizontal-wheel-scroll.html, only one
+ // for now) does not rely on this though.
+ webview()->layout();
+
+ int horizontal = args[0].ToInt32();
+ int vertical = args[1].ToInt32();
+
+ WebMouseWheelEvent event;
+ InitMouseEvent(WebInputEvent::MouseWheel, pressed_button_,
+ last_mouse_pos_, &event);
+ event.wheelTicksX = static_cast<float>(horizontal);
+ event.wheelTicksY = static_cast<float>(vertical);
+ event.deltaX = -horizontal * kScrollbarPixelsPerTick;
+ event.deltaY = -vertical * kScrollbarPixelsPerTick;
+ webview()->handleInputEvent(event);
+ }
+}
+
// static
void EventSendingController::DoMouseMove(const WebMouseEvent& e) {
last_mouse_pos_.SetPoint(e.x, e.y);
« no previous file with comments | « webkit/tools/test_shell/event_sending_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698