summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
Diffstat (limited to 'webkit')
-rw-r--r--webkit/api/public/WebInputEvent.h12
-rw-r--r--webkit/api/public/win/WebInputEventFactory.h14
-rw-r--r--webkit/api/src/gtk/WebInputEventFactory.cpp25
-rw-r--r--webkit/api/src/mac/WebInputEventFactory.mm14
-rw-r--r--webkit/api/src/win/WebInputEventFactory.cpp75
-rw-r--r--webkit/glue/event_conversion.cc58
-rw-r--r--webkit/glue/event_conversion.h16
-rw-r--r--webkit/glue/webkit_glue.cc7
-rw-r--r--webkit/glue/webview_impl.cc2
-rw-r--r--webkit/glue/webwidget_impl.cc2
-rw-r--r--webkit/tools/test_shell/event_sending_controller.cc2
11 files changed, 104 insertions, 123 deletions
diff --git a/webkit/api/public/WebInputEvent.h b/webkit/api/public/WebInputEvent.h
index 93350a5..f232ce5 100644
--- a/webkit/api/public/WebInputEvent.h
+++ b/webkit/api/public/WebInputEvent.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -72,8 +72,6 @@ namespace WebKit {
MouseUp,
MouseMove,
MouseLeave,
- MouseDoubleClick,
- MouseTripleClick,
// WebMouseWheelEvent
MouseWheel,
@@ -186,7 +184,7 @@ namespace WebKit {
int globalX;
int globalY;
double timeStampSeconds; // Seconds since epoch.
- int layoutTestClickCount; // Only used during layout tests.
+ int clickCount;
WebMouseEvent()
: button(ButtonNone)
@@ -195,7 +193,7 @@ namespace WebKit {
, globalX(0)
, globalY(0)
, timeStampSeconds(0.0)
- , layoutTestClickCount(0)
+ , clickCount(0)
{
}
};
diff --git a/webkit/api/public/win/WebInputEventFactory.h b/webkit/api/public/win/WebInputEventFactory.h
index c353ed4..b94adbd 100644
--- a/webkit/api/public/win/WebInputEventFactory.h
+++ b/webkit/api/public/win/WebInputEventFactory.h
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -46,6 +46,14 @@ namespace WebKit {
WEBKIT_API static WebKeyboardEvent keyboardEvent(HWND, UINT, WPARAM, LPARAM);
WEBKIT_API static WebMouseEvent mouseEvent(HWND, UINT, WPARAM, LPARAM);
WEBKIT_API static WebMouseWheelEvent mouseWheelEvent(HWND, UINT, WPARAM, LPARAM);
+
+ // Windows only provides information on whether a click was a single or
+ // double click, while we need to know the click count past two. The
+ // WebInputEventFactory keeps internal state to allow it to synthesize
+ // that information. In some cases, like fast-running tests, that
+ // information is known to be stale and needs to be reset; that is the
+ // function of resetLastClickState().
+ WEBKIT_API static void resetLastClickState();
};
} // namespace WebKit
diff --git a/webkit/api/src/gtk/WebInputEventFactory.cpp b/webkit/api/src/gtk/WebInputEventFactory.cpp
index 7c784d1..17506b2 100644
--- a/webkit/api/src/gtk/WebInputEventFactory.cpp
+++ b/webkit/api/src/gtk/WebInputEventFactory.cpp
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2006-2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -108,7 +108,7 @@ WebKeyboardEvent WebInputEventFactory::keyboardEvent(const GdkEventKey* event)
result.setKeyIdentifierFromWindowsKeyCode();
// FIXME: Do we need to set IsAutoRepeat or IsKeyPad?
-
+
return result;
}
@@ -125,17 +125,18 @@ WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventButton* event)
result.y = static_cast<int>(event->y);
result.globalX = static_cast<int>(event->x_root);
result.globalY = static_cast<int>(event->y_root);
- result.layoutTestClickCount = 0;
+ result.clickCount = 0;
switch (event->type) {
+ case GDK_3BUTTON_PRESS:
+ ++result.clickCount;
+ // fallthrough
+ case GDK_2BUTTON_PRESS:
+ ++result.clickCount;
+ // fallthrough
case GDK_BUTTON_PRESS:
result.type = WebInputEvent::MouseDown;
- break;
- case GDK_2BUTTON_PRESS:
- result.type = WebInputEvent::MouseDoubleClick;
- break;
- case GDK_3BUTTON_PRESS:
- result.type = WebInputEvent::MouseTripleClick;
+ ++result.clickCount;
break;
case GDK_BUTTON_RELEASE:
result.type = WebInputEvent::MouseUp;
@@ -182,7 +183,7 @@ WebMouseEvent WebInputEventFactory::mouseEvent(const GdkEventMotion* event)
result.button = WebMouseEvent::ButtonMiddle;
else if (event->state & GDK_BUTTON3_MASK)
result.button = WebMouseEvent::ButtonRight;
-
+
return result;
}
diff --git a/webkit/api/src/mac/WebInputEventFactory.mm b/webkit/api/src/mac/WebInputEventFactory.mm
index c0afa04..e9a0d59 100644
--- a/webkit/api/src/mac/WebInputEventFactory.mm
+++ b/webkit/api/src/mac/WebInputEventFactory.mm
@@ -908,24 +908,26 @@ WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view)
{
WebMouseEvent result;
+ result.clickCount = 0;
+
switch ([event type]) {
case NSMouseExited:
result.type = WebInputEvent::MouseLeave;
result.button = WebMouseEvent::ButtonNone;
break;
case NSLeftMouseDown:
- result.type = [event clickCount] == 2 ? WebInputEvent::MouseDoubleClick
- : WebInputEvent::MouseDown;
+ result.type = WebInputEvent::MouseDown;
+ result.clickCount = [event clickCount];
result.button = WebMouseEvent::ButtonLeft;
break;
case NSOtherMouseDown:
- result.type = [event clickCount] == 2 ? WebInputEvent::MouseDoubleClick
- : WebInputEvent::MouseDown;
+ result.type = WebInputEvent::MouseDown;
+ result.clickCount = [event clickCount];
result.button = WebMouseEvent::ButtonMiddle;
break;
case NSRightMouseDown:
- result.type = [event clickCount] == 2 ? WebInputEvent::MouseDoubleClick
- : WebInputEvent::MouseDown;
+ result.type = WebInputEvent::MouseDown;
+ result.clickCount = [event clickCount];
result.button = WebMouseEvent::ButtonRight;
break;
case NSLeftMouseUp:
diff --git a/webkit/api/src/win/WebInputEventFactory.cpp b/webkit/api/src/win/WebInputEventFactory.cpp
index e5bc34c..d772a54 100644
--- a/webkit/api/src/win/WebInputEventFactory.cpp
+++ b/webkit/api/src/win/WebInputEventFactory.cpp
@@ -1,10 +1,10 @@
/*
* Copyright (C) 2006-2009 Google Inc. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
- *
+ *
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
@@ -14,7 +14,7 @@
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
@@ -141,6 +141,9 @@ WebKeyboardEvent WebInputEventFactory::keyboardEvent(HWND hwnd, UINT message,
// WebMouseEvent --------------------------------------------------------------
+static int gLastClickCount;
+static double gLastClickTime;
+
static LPARAM GetRelativeCursorPos(HWND hwnd)
{
POINT pos = {-1, -1};
@@ -149,6 +152,11 @@ static LPARAM GetRelativeCursorPos(HWND hwnd)
return MAKELPARAM(pos.x, pos.y);
}
+void WebInputEventFactory::resetLastClickState()
+{
+ gLastClickTime = gLastClickCount = 0;
+}
+
WebMouseEvent WebInputEventFactory::mouseEvent(HWND hwnd, UINT message,
WPARAM wparam, LPARAM lparam)
{
@@ -174,14 +182,17 @@ WebMouseEvent WebInputEventFactory::mouseEvent(HWND hwnd, UINT message,
lparam = GetRelativeCursorPos(hwnd);
break;
case WM_LBUTTONDOWN:
+ case WM_LBUTTONDBLCLK:
result.type = WebInputEvent::MouseDown;
result.button = WebMouseEvent::ButtonLeft;
break;
case WM_MBUTTONDOWN:
+ case WM_MBUTTONDBLCLK:
result.type = WebInputEvent::MouseDown;
result.button = WebMouseEvent::ButtonMiddle;
break;
case WM_RBUTTONDOWN:
+ case WM_RBUTTONDBLCLK:
result.type = WebInputEvent::MouseDown;
result.button = WebMouseEvent::ButtonRight;
break;
@@ -197,22 +208,16 @@ WebMouseEvent WebInputEventFactory::mouseEvent(HWND hwnd, UINT message,
result.type = WebInputEvent::MouseUp;
result.button = WebMouseEvent::ButtonRight;
break;
- case WM_LBUTTONDBLCLK:
- result.type = WebInputEvent::MouseDoubleClick;
- result.button = WebMouseEvent::ButtonLeft;
- break;
- case WM_MBUTTONDBLCLK:
- result.type = WebInputEvent::MouseDoubleClick;
- result.button = WebMouseEvent::ButtonMiddle;
- break;
- case WM_RBUTTONDBLCLK:
- result.type = WebInputEvent::MouseDoubleClick;
- result.button = WebMouseEvent::ButtonRight;
- break;
default:
ASSERT_NOT_REACHED();
}
+ // TODO(pkasting): http://b/1117926 Are we guaranteed that the message that
+ // GetMessageTime() refers to is the same one that we're passed in? Perhaps
+ // one of the construction parameters should be the time passed by the
+ // caller, who would know for sure.
+ result.timeStampSeconds = GetMessageTime() / 1000.0;
+
// set position fields:
result.x = static_cast<short>(LOWORD(lparam));
@@ -224,6 +229,41 @@ WebMouseEvent WebInputEventFactory::mouseEvent(HWND hwnd, UINT message,
result.globalX = globalPoint.x;
result.globalY = globalPoint.y;
+ // calculate number of clicks:
+
+ // This differs slightly from the WebKit code in WebKit/win/WebView.cpp
+ // where their original code looks buggy.
+ static int lastClickPositionX;
+ static int lastClickPositionY;
+ static WebMouseEvent::Button lastClickButton = WebMouseEvent::ButtonLeft;
+
+ double currentTime = result.timeStampSeconds;
+ bool cancelPreviousClick =
+ (abs(lastClickPositionX - result.x) > (GetSystemMetrics(SM_CXDOUBLECLK) / 2))
+ || (abs(lastClickPositionY - result.y) > (GetSystemMetrics(SM_CYDOUBLECLK) / 2))
+ || ((currentTime - gLastClickTime) * 1000.0 > GetDoubleClickTime());
+
+ if (result.type == WebInputEvent::MouseDown) {
+ if (!cancelPreviousClick && (result.button == lastClickButton))
+ ++gLastClickCount;
+ else {
+ gLastClickCount = 1;
+ lastClickPositionX = result.x;
+ lastClickPositionY = result.y;
+ }
+ gLastClickTime = currentTime;
+ lastClickButton = result.button;
+ } else if (result.type == WebInputEvent::MouseMove
+ || result.type == WebInputEvent::MouseLeave) {
+ if (cancelPreviousClick) {
+ gLastClickCount = 0;
+ lastClickPositionX = 0;
+ lastClickPositionY = 0;
+ gLastClickTime = 0;
+ }
+ }
+ result.clickCount = gLastClickCount;
+
// set modifiers:
if (wparam & MK_CONTROL)
@@ -233,11 +273,6 @@ WebMouseEvent WebInputEventFactory::mouseEvent(HWND hwnd, UINT message,
if (GetKeyState(VK_MENU) & 0x8000)
result.modifiers |= (WebInputEvent::AltKey | WebInputEvent::MetaKey); // FIXME: set META properly
- // TODO(pkasting): http://b/1117926 Instead of using GetTickCount() here, we
- // should use GetMessageTime() on the original Windows message in the browser
- // process, and pass that in the WebMouseEvent.
- result.timeStampSeconds = GetTickCount() / 1000.0;
-
return result;
}
diff --git a/webkit/glue/event_conversion.cc b/webkit/glue/event_conversion.cc
index 6014107..2a3bbff 100644
--- a/webkit/glue/event_conversion.cc
+++ b/webkit/glue/event_conversion.cc
@@ -29,9 +29,6 @@ using WebKit::WebMouseWheelEvent;
// MakePlatformMouseEvent -----------------------------------------------------
-int MakePlatformMouseEvent::last_click_count_ = 0;
-uint32 MakePlatformMouseEvent::last_click_time_ = 0;
-
MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
const WebMouseEvent& e) {
// TODO(mpcomplete): widget is always toplevel, unless it's a popup. We
@@ -45,78 +42,25 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
m_metaKey = (e.modifiers & WebInputEvent::MetaKey) != 0;
m_modifierFlags = e.modifiers;
m_timestamp = e.timeStampSeconds;
-
- // This differs slightly from the WebKit code in WebKit/win/WebView.cpp where
- // their original code looks buggy.
- static IntPoint last_click_position;
- static MouseButton last_click_button = LeftButton;
-
- const uint32 current_time = static_cast<uint32>(m_timestamp * 1000);
-#if defined(OS_WIN)
- const bool cancel_previous_click =
- (abs(last_click_position.x() - m_position.x()) >
- (GetSystemMetrics(SM_CXDOUBLECLK) / 2)) ||
- (abs(last_click_position.y() - m_position.y()) >
- (GetSystemMetrics(SM_CYDOUBLECLK) / 2)) ||
- ((current_time - last_click_time_) > GetDoubleClickTime());
-#elif defined(OS_MACOSX) || defined(OS_LINUX)
- const bool cancel_previous_click = false;
-#endif
+ m_clickCount = e.clickCount;
switch (e.type) {
case WebInputEvent::MouseMove:
case WebInputEvent::MouseLeave: // synthesize a move event
- if (cancel_previous_click) {
- last_click_count_ = 0;
- last_click_position = IntPoint();
- last_click_time_ = 0;
- }
- m_clickCount = last_click_count_;
m_eventType = MouseEventMoved;
break;
-// TODO(port): make these platform agnostic when we restructure this code.
-#if defined(OS_LINUX) || defined(OS_MACOSX)
- case WebInputEvent::MouseTripleClick:
- ++m_clickCount;
- // fall through
- case WebInputEvent::MouseDoubleClick:
- ++m_clickCount;
- // fall through
case WebInputEvent::MouseDown:
- ++m_clickCount;
- last_click_time_ = current_time;
- last_click_button = m_button;
m_eventType = MouseEventPressed;
break;
-#else
- case WebInputEvent::MouseDown:
- case WebInputEvent::MouseDoubleClick:
- if (!cancel_previous_click && (m_button == last_click_button)) {
- ++last_click_count_;
- } else {
- last_click_count_ = 1;
- last_click_position = m_position;
- }
- last_click_time_ = current_time;
- last_click_button = m_button;
- m_clickCount = last_click_count_;
- m_eventType = MouseEventPressed;
- break;
-#endif
case WebInputEvent::MouseUp:
- m_clickCount = last_click_count_;
m_eventType = MouseEventReleased;
break;
default:
NOTREACHED() << "unexpected mouse event type";
}
-
- if (WebKit::layoutTestMode()) {
- m_clickCount = e.layoutTestClickCount;
- }
}
// MakePlatformWheelEvent -----------------------------------------------------
diff --git a/webkit/glue/event_conversion.h b/webkit/glue/event_conversion.h
index 3f49938..5b83c97 100644
--- a/webkit/glue/event_conversion.h
+++ b/webkit/glue/event_conversion.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
+// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef WEBKIT_GLUE_EVENT_CONVERSION_H__
-#define WEBKIT_GLUE_EVENT_CONVERSION_H__
+#ifndef WEBKIT_GLUE_EVENT_CONVERSION_H_
+#define WEBKIT_GLUE_EVENT_CONVERSION_H_
#include "base/basictypes.h"
#include "base/compiler_specific.h"
@@ -31,14 +31,6 @@ class MakePlatformMouseEvent : public WebCore::PlatformMouseEvent {
public:
MakePlatformMouseEvent(
WebCore::Widget* widget, const WebKit::WebMouseEvent& e);
-
- static void ResetLastClick() {
- last_click_time_ = last_click_count_ = 0;
- }
-
- private:
- static int last_click_count_;
- static uint32 last_click_time_;
};
class MakePlatformWheelEvent : public WebCore::PlatformWheelEvent {
@@ -54,4 +46,4 @@ class MakePlatformKeyboardEvent : public WebCore::PlatformKeyboardEvent {
bool IsCharacterKey() const;
};
-#endif // WEBKIT_GLUE_EVENT_CONVERSION_H__
+#endif // WEBKIT_GLUE_EVENT_CONVERSION_H_
diff --git a/webkit/glue/webkit_glue.cc b/webkit/glue/webkit_glue.cc
index 5a6ca45..09a72cd 100644
--- a/webkit/glue/webkit_glue.cc
+++ b/webkit/glue/webkit_glue.cc
@@ -36,6 +36,9 @@
#include "base/sys_string_conversions.h"
#include "skia/include/SkBitmap.h"
#include "webkit/api/public/WebString.h"
+#if defined(OS_WIN)
+#include "webkit/api/public/win/WebInputEventFactory.h"
+#endif
#include "webkit/glue/event_conversion.h"
#include "webkit/glue/glue_util.h"
#include "webkit/glue/weburlrequest_impl.h"
@@ -219,9 +222,11 @@ void ResetBeforeTestRun(WebView* view) {
if (frame && frame->script())
frame->script()->setEventHandlerLineNumber(0);
+#if defined(OS_WIN)
// Reset the last click information so the clicks generated from previous
// test aren't inherited (otherwise can mistake single/double/triple clicks)
- MakePlatformMouseEvent::ResetLastClick();
+ WebKit::WebInputEventFactory::resetLastClickState();
+#endif
}
#ifndef NDEBUG
diff --git a/webkit/glue/webview_impl.cc b/webkit/glue/webview_impl.cc
index 06a6b7e..6830fd8 100644
--- a/webkit/glue/webview_impl.cc
+++ b/webkit/glue/webview_impl.cc
@@ -1051,8 +1051,6 @@ bool WebViewImpl::HandleInputEvent(const WebInputEvent* input_event) {
break;
case WebInputEvent::MouseDown:
- case WebInputEvent::MouseDoubleClick:
- case WebInputEvent::MouseTripleClick:
MouseDown(*static_cast<const WebMouseEvent*>(input_event));
break;
diff --git a/webkit/glue/webwidget_impl.cc b/webkit/glue/webwidget_impl.cc
index 3fd60c5..8418617 100644
--- a/webkit/glue/webwidget_impl.cc
+++ b/webkit/glue/webwidget_impl.cc
@@ -182,8 +182,6 @@ bool WebWidgetImpl::HandleInputEvent(const WebInputEvent* input_event) {
return true;
case WebInputEvent::MouseDown:
- case WebInputEvent::MouseDoubleClick:
- case WebInputEvent::MouseTripleClick:
MouseDown(*static_cast<const WebMouseEvent*>(input_event));
return true;
diff --git a/webkit/tools/test_shell/event_sending_controller.cc b/webkit/tools/test_shell/event_sending_controller.cc
index 9e88f88..79e3d85 100644
--- a/webkit/tools/test_shell/event_sending_controller.cc
+++ b/webkit/tools/test_shell/event_sending_controller.cc
@@ -103,7 +103,7 @@ void InitMouseEvent(WebInputEvent::Type t, WebMouseEvent::Button b,
e->globalX = pos.x();
e->globalY = pos.y();
e->timeStampSeconds = GetCurrentEventTimeSec();
- e->layoutTestClickCount = click_count;
+ e->clickCount = click_count;
}
void ApplyKeyModifier(const std::wstring& arg, WebKeyboardEvent* event) {