summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authorpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-09 18:28:55 +0000
committerpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-09-09 18:28:55 +0000
commit27e64ed028a384c7c605dc3a68b1d4b87bf6a9a9 (patch)
treed352db2d3f48ec6f58b89a732bb32e0f0471a95a /webkit
parent16dd53084f02c4857d596a98dbd7f861b9dceb80 (diff)
downloadchromium_src-27e64ed028a384c7c605dc3a68b1d4b87bf6a9a9.zip
chromium_src-27e64ed028a384c7c605dc3a68b1d4b87bf6a9a9.tar.gz
chromium_src-27e64ed028a384c7c605dc3a68b1d4b87bf6a9a9.tar.bz2
if-def the event conversion code to fit with the ifdefs in WebCore.
Review URL: http://codereview.chromium.org/1846 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@1908 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/glue/event_conversion.cc38
-rw-r--r--webkit/glue/event_conversion.h2
2 files changed, 37 insertions, 3 deletions
diff --git a/webkit/glue/event_conversion.cc b/webkit/glue/event_conversion.cc
index da50489..6f5e764 100644
--- a/webkit/glue/event_conversion.cc
+++ b/webkit/glue/event_conversion.cc
@@ -3,7 +3,11 @@
// found in the LICENSE file.
#include "config.h"
+#include "build/build_config.h"
+
+#if defined(OS_WIN)
#include <windows.h>
+#endif
#include "StringImpl.h" // This is so that the KJS build works
#pragma warning(push, 0)
@@ -29,14 +33,20 @@ using namespace WebCore;
// MakePlatformMouseEvent -----------------------------------------------------
int MakePlatformMouseEvent::last_click_count_ = 0;
-long MakePlatformMouseEvent::last_click_time_ = 0;
+uint32 MakePlatformMouseEvent::last_click_time_ = 0;
MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
const WebMouseEvent& e)
+#if defined(OS_WIN)
: PlatformMouseEvent(NULL, 0, 0, 0, false /* TODO(darin): do we care? */) {
+#elif defined(OS_MACOSX)
+ : PlatformMouseEvent(e.mac_event.get()) {
+#endif
+#if defined(OS_WIN) || defined(OS_LINUX)
// TODO(mpcomplete): widget is always toplevel, unless it's a popup. We
// may be able to get rid of this once we abstract popups into a WebKit API.
m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
+#endif
m_globalPosition = IntPoint(e.global_x, e.global_y);
m_button = static_cast<MouseButton>(e.button);
m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0;
@@ -51,13 +61,17 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
static IntPoint last_click_position;
static MouseButton last_click_button = LeftButton;
- const DWORD current_time = static_cast<DWORD>(m_timestamp * 1000);
+ 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
switch (e.type) {
case WebInputEvent::MOUSE_MOVE:
@@ -67,7 +81,9 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
last_click_position = IntPoint();
last_click_time_ = 0;
}
+#if defined(OS_WIN)
setClickCount(last_click_count_);
+#endif
m_eventType = MouseEventMoved;
break;
@@ -81,12 +97,16 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
}
last_click_time_ = current_time;
last_click_button = m_button;
+#if defined(OS_WIN)
setClickCount(last_click_count_);
+#endif
m_eventType = MouseEventPressed;
break;
case WebInputEvent::MOUSE_UP:
+#if defined(OS_WIN)
setClickCount(last_click_count_);
+#endif
m_eventType = MouseEventReleased;
break;
@@ -95,7 +115,9 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
}
if (webkit_glue::IsLayoutTestMode()) {
+#if defined(OS_WIN)
setClickCount(e.layout_test_click_count);
+#endif
}
}
@@ -103,8 +125,14 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
MakePlatformWheelEvent::MakePlatformWheelEvent(Widget* widget,
const WebMouseWheelEvent& e)
+#if defined(OS_WIN)
: PlatformWheelEvent(NULL, 0, 0, false) { // TODO(jackson): Check if it's a horizontal event
+#elif defined(OS_MACOSX)
+ : PlatformWheelEvent(e.mac_event.get()) {
+#endif
+#if defined(OS_WIN) || defined(OS_LINUX)
m_position = widget->convertFromContainingWindow(IntPoint(e.x, e.y));
+#endif
m_globalPosition = IntPoint(e.global_x, e.global_y);
m_deltaX = static_cast<float>(e.delta_x);
m_deltaY = static_cast<float>(e.delta_y);
@@ -130,9 +158,13 @@ static inline const PlatformKeyboardEvent::Type platformKeyTypeForWebInputEventT
// MakePlatformKeyboardEvent --------------------------------------------------
MakePlatformKeyboardEvent::MakePlatformKeyboardEvent(const WebKeyboardEvent& e)
+#if defined(OS_WIN)
: PlatformKeyboardEvent(NULL, e.key_code, e.key_data,
platformKeyTypeForWebInputEventType(e.type),
e.system_key) {
+#elif defined(OS_MACOSX)
+ : PlatformKeyboardEvent(e.mac_event.get()) {
+#endif
m_autoRepeat = (e.modifiers & WebInputEvent::IS_AUTO_REPEAT) != 0;
m_isKeypad = (e.modifiers & WebInputEvent::IS_KEYPAD) != 0;
m_shiftKey = (e.modifiers & WebInputEvent::SHIFT_KEY) != 0;
@@ -163,8 +195,10 @@ void MakePlatformKeyboardEvent::SetKeyType(Type type) {
// which don't have associated character events.
bool MakePlatformKeyboardEvent::IsCharacterKey() const {
switch (windowsVirtualKeyCode()) {
+#if defined(OS_WIN)
case VK_BACK:
case VK_ESCAPE:
+#endif
return false;
default:
diff --git a/webkit/glue/event_conversion.h b/webkit/glue/event_conversion.h
index 9f00ef2..a8b314e 100644
--- a/webkit/glue/event_conversion.h
+++ b/webkit/glue/event_conversion.h
@@ -32,7 +32,7 @@ class MakePlatformMouseEvent : public WebCore::PlatformMouseEvent {
private:
static int last_click_count_;
- static long last_click_time_;
+ static uint32 last_click_time_;
};
class MakePlatformWheelEvent : public WebCore::PlatformWheelEvent {