summaryrefslogtreecommitdiffstats
path: root/webkit/tools
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-02 17:36:37 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-02 17:36:37 +0000
commit42b1b76679afb3b8a7cebd1e72a7f07b2567d4a4 (patch)
tree0e5a4d9812ff24fbd34fa821b13b7518ffcafabe /webkit/tools
parent41488522835cd6596b8984cc39583d2bf2396134 (diff)
downloadchromium_src-42b1b76679afb3b8a7cebd1e72a7f07b2567d4a4.zip
chromium_src-42b1b76679afb3b8a7cebd1e72a7f07b2567d4a4.tar.gz
chromium_src-42b1b76679afb3b8a7cebd1e72a7f07b2567d4a4.tar.bz2
Add support for [continuous]MouseScrollBy() to test_shell.
This also removes support for mouseWheelTo(), a similar idiom that isn't needed any longer. DRT side of this is in https://bugs.webkit.org/show_bug.cgi?id=45073 . BUG=none TEST=test_shell can run LayoutTests/fast/events/*wheelevent-in-scrolling-div.html Review URL: http://codereview.chromium.org/3310006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools')
-rw-r--r--webkit/tools/test_shell/event_sending_controller.cc82
-rw-r--r--webkit/tools/test_shell/event_sending_controller.h9
2 files changed, 58 insertions, 33 deletions
diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc
index a18f081..62cf0a4 100644
--- a/webkit/tools/test_shell/event_sending_controller.cc
+++ b/webkit/tools/test_shell/event_sending_controller.cc
@@ -112,9 +112,11 @@ static const int kMultiClickRadiusPixels = 5;
// 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;
+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;
}
// Used to offset the time the event hander things an event happened. This is
@@ -262,7 +264,6 @@ EventSendingController::EventSendingController(TestShell* shell)
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);
@@ -275,6 +276,9 @@ EventSendingController::EventSendingController(TestShell* shell)
BindMethod("textZoomOut", &EventSendingController::textZoomOut);
BindMethod("zoomPageIn", &EventSendingController::zoomPageIn);
BindMethod("zoomPageOut", &EventSendingController::zoomPageOut);
+ BindMethod("mouseScrollBy", &EventSendingController::mouseScrollBy);
+ BindMethod("continuousMouseScrollBy",
+ &EventSendingController::continuousMouseScrollBy);
BindMethod("scheduleAsynchronousClick",
&EventSendingController::scheduleAsynchronousClick);
BindMethod("beginDragWithFiles",
@@ -343,7 +347,8 @@ WebView* EventSendingController::webview() {
void EventSendingController::DoDragDrop(const WebDragData& drag_data,
WebDragOperationsMask mask) {
WebMouseEvent event;
- InitMouseEvent(WebInputEvent::MouseDown, pressed_button_, last_mouse_pos_, &event);
+ InitMouseEvent(WebInputEvent::MouseDown, pressed_button_, last_mouse_pos_,
+ &event);
WebPoint client_point(event.x, event.y);
WebPoint screen_point(event.globalX, event.globalY);
current_drag_data = drag_data;
@@ -498,32 +503,6 @@ void EventSendingController::mouseMoveTo(
}
}
-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);
- }
-}
-
void EventSendingController::DoMouseMove(const WebMouseEvent& e) {
last_mouse_pos_.SetPoint(e.x, e.y);
@@ -748,6 +727,17 @@ void EventSendingController::zoomPageOut(
result->SetNull();
}
+void EventSendingController::mouseScrollBy(const CppArgumentList& args,
+ CppVariant* result) {
+ handleMouseWheel(args, result, false);
+}
+
+void EventSendingController::continuousMouseScrollBy(
+ const CppArgumentList& args,
+ CppVariant* result) {
+ handleMouseWheel(args, result, true);
+}
+
void EventSendingController::ReplaySavedEvents() {
replaying_saved_events = true;
while (!mouse_event_queue.empty()) {
@@ -954,6 +944,36 @@ void EventSendingController::SendCurrentTouchEvent(
}
}
+void EventSendingController::handleMouseWheel(const CppArgumentList& args,
+ CppVariant* result,
+ bool continuous) {
+ result->SetNull();
+
+ if (args.size() < 2 || !args[0].isNumber() || !args[1].isNumber())
+ return;
+
+ // 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).
+ 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 = event.wheelTicksX;
+ event.deltaY = event.wheelTicksY;
+ if (!continuous) {
+ event.deltaX *= kScrollbarPixelsPerTick;
+ event.deltaY *= kScrollbarPixelsPerTick;
+ }
+ webview()->handleInputEvent(event);
+}
+
void EventSendingController::touchEnd(
const CppArgumentList& args, CppVariant* result) {
result->SetNull();
diff --git a/webkit/tools/test_shell/event_sending_controller.h b/webkit/tools/test_shell/event_sending_controller.h
index 95ddc05..0950868 100644
--- a/webkit/tools/test_shell/event_sending_controller.h
+++ b/webkit/tools/test_shell/event_sending_controller.h
@@ -49,7 +49,6 @@ class EventSendingController : public CppBoundClass {
void mouseDown(const CppArgumentList& args, CppVariant* result);
void mouseUp(const CppArgumentList& args, CppVariant* result);
void mouseMoveTo(const CppArgumentList& args, CppVariant* result);
- void mouseWheelTo(const CppArgumentList& args, CppVariant* result);
void leapForward(const CppArgumentList& args, CppVariant* result);
void keyDown(const CppArgumentList& args, CppVariant* result);
void dispatchMessage(const CppArgumentList& args, CppVariant* result);
@@ -57,6 +56,8 @@ class EventSendingController : public CppBoundClass {
void textZoomOut(const CppArgumentList& args, CppVariant* result);
void zoomPageIn(const CppArgumentList& args, CppVariant* result);
void zoomPageOut(const CppArgumentList& args, CppVariant* result);
+ void mouseScrollBy(const CppArgumentList& args, CppVariant* result);
+ void continuousMouseScrollBy(const CppArgumentList& args, CppVariant* result);
void scheduleAsynchronousClick(const CppArgumentList& args,
CppVariant* result);
void beginDragWithFiles(const CppArgumentList& args, CppVariant* result);
@@ -76,7 +77,8 @@ class EventSendingController : public CppBoundClass {
// Unimplemented stubs
void contextClick(const CppArgumentList& args, CppVariant* result);
void enableDOMUIEventLogging(const CppArgumentList& args, CppVariant* result);
- void fireKeyboardEventsToElement(const CppArgumentList& args, CppVariant* result);
+ void fireKeyboardEventsToElement(const CppArgumentList& args,
+ CppVariant* result);
void clearKillRing(const CppArgumentList& args, CppVariant* result);
// Properties used in layout tests.
@@ -122,6 +124,9 @@ class EventSendingController : public CppBoundClass {
// Compose a touch event from the current touch points and send it.
void SendCurrentTouchEvent(const WebKit::WebInputEvent::Type type);
+ // Handle a request to send a wheel event.
+ void handleMouseWheel(const CppArgumentList&, CppVariant*, bool continuous);
+
ScopedRunnableMethodFactory<EventSendingController> method_factory_;
// Non-owning pointer. The LayoutTestController is owned by the host.