summaryrefslogtreecommitdiffstats
path: root/webkit/tools/test_shell/event_sending_controller.cc
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-06 23:23:34 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-06 23:23:34 +0000
commitad4e7fa778963f9fdc54df345d9a1a1791fe955c (patch)
tree9631d6d61e93e0c0769e075d9eeeffc54238ffe0 /webkit/tools/test_shell/event_sending_controller.cc
parent099eeed66d3217d466abcae8433a106eca7f1419 (diff)
downloadchromium_src-ad4e7fa778963f9fdc54df345d9a1a1791fe955c.zip
chromium_src-ad4e7fa778963f9fdc54df345d9a1a1791fe955c.tar.gz
chromium_src-ad4e7fa778963f9fdc54df345d9a1a1791fe955c.tar.bz2
This fixes http://code.google.com/p/chromium/issues/detail?id=3007, which is the mouse-click-events.html
layout test failure. Fix as per below:- 1. The test shell mouse event generating mechanism now tracks the last mouse button number received. This is used to determine whether the click count continues to increment or not. 2. We now default to middle button if the button number passed in from js contains anything other than 0 or 2. This is as per the event sending mechanism in webkit mac. We still need to re-baseline this test as the number of events printed on the page cause a scrollbar to show up for the 4th mouse event test. This causes the middle mouse button to be eaten as per recent changes in EventHandler.cpp. Bug=3007 R=tony Review URL: http://codereview.chromium.org/6261 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@2917 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell/event_sending_controller.cc')
-rw-r--r--webkit/tools/test_shell/event_sending_controller.cc52
1 files changed, 38 insertions, 14 deletions
diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc
index 9314f8d..53bde83 100644
--- a/webkit/tools/test_shell/event_sending_controller.cc
+++ b/webkit/tools/test_shell/event_sending_controller.cc
@@ -35,6 +35,8 @@ gfx::Point EventSendingController::last_mouse_pos_;
WebMouseEvent::Button EventSendingController::pressed_button_ =
WebMouseEvent::BUTTON_NONE;
+int EventSendingController::last_button_number_ = -1;
+
namespace {
#if defined(OS_WIN)
@@ -149,6 +151,7 @@ void EventSendingController::Reset() {
dragMode.Set(true);
last_click_time_sec = 0;
click_count = 0;
+ last_button_number_ = -1;
}
/* static */ WebView* EventSendingController::webview() {
@@ -170,19 +173,27 @@ void EventSendingController::Reset() {
}
#endif
+WebMouseEvent::Button EventSendingController::GetButtonTypeFromButtonNumber(
+ int button_code) {
+ if (button_code == 0)
+ return WebMouseEvent::BUTTON_LEFT;
+ else if (button_code == 2)
+ return WebMouseEvent::BUTTON_RIGHT;
+
+ return WebMouseEvent::BUTTON_MIDDLE;
+}
+
// static
-WebMouseEvent::Button EventSendingController::GetButtonTypeFromSingleArg(
+int EventSendingController::GetButtonNumberFromSingleArg(
const CppArgumentList& args) {
+ int button_code = 0;
+
if (args.size() > 0 && args[0].isNumber()) {
- int button_code = args[0].ToInt32();
- if (button_code == 1)
- return WebMouseEvent::BUTTON_MIDDLE;
- else if (button_code == 2)
- return WebMouseEvent::BUTTON_RIGHT;
+ button_code = args[0].ToInt32();
}
- return WebMouseEvent::BUTTON_LEFT;
-}
+ return button_code;
+}
//
// Implemented javascript methods.
//
@@ -193,15 +204,22 @@ WebMouseEvent::Button EventSendingController::GetButtonTypeFromSingleArg(
webview()->Layout();
- WebMouseEvent::Button button_type = GetButtonTypeFromSingleArg(args);
+ int button_number = GetButtonNumberFromSingleArg(args);
+ DCHECK(button_number != -1);
- if ((GetCurrentEventTimeSec() - last_click_time_sec >= kMultiClickTimeSec) ||
- outside_multiclick_radius(last_mouse_pos_, last_click_pos)) {
- click_count = 1;
- } else {
+ WebMouseEvent::Button button_type = GetButtonTypeFromButtonNumber(
+ button_number);
+
+ if ((GetCurrentEventTimeSec() - last_click_time_sec < kMultiClickTimeSec) &&
+ (!outside_multiclick_radius(last_mouse_pos_, last_click_pos)) &&
+ (button_number == last_button_number_)) {
++click_count;
+ } else {
+ click_count = 1;
}
+ last_button_number_ = button_number;
+
WebMouseEvent event;
pressed_button_ = button_type;
InitMouseEvent(WebInputEvent::MOUSE_DOWN, button_type,
@@ -215,7 +233,13 @@ WebMouseEvent::Button EventSendingController::GetButtonTypeFromSingleArg(
webview()->Layout();
- WebMouseEvent::Button button_type = GetButtonTypeFromSingleArg(args);
+ int button_number = GetButtonNumberFromSingleArg(args);
+ DCHECK(button_number != -1);
+
+ WebMouseEvent::Button button_type = GetButtonTypeFromButtonNumber(
+ button_number);
+
+ last_button_number_ = button_number;
WebMouseEvent event;
InitMouseEvent(WebInputEvent::MOUSE_UP, button_type,