summaryrefslogtreecommitdiffstats
path: root/webkit/glue
diff options
context:
space:
mode:
authorpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-24 17:41:34 +0000
committerpinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2008-10-24 17:41:34 +0000
commit044dc48ab959e37a5f9960a46e7ffeeaf201fb54 (patch)
tree25d3b3fb7ecb5bbcf3836fb293f2265c1d9a7fbb /webkit/glue
parentab6513714d7bd8e5b13d99f89c2bff468b8dcce5 (diff)
downloadchromium_src-044dc48ab959e37a5f9960a46e7ffeeaf201fb54.zip
chromium_src-044dc48ab959e37a5f9960a46e7ffeeaf201fb54.tar.gz
chromium_src-044dc48ab959e37a5f9960a46e7ffeeaf201fb54.tar.bz2
Hook up mouse events with the correct coordinates. Make sure they are view-local and flipped.
Review URL: http://codereview.chromium.org/8150 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3924 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/glue')
-rw-r--r--webkit/glue/event_conversion.cc4
-rw-r--r--webkit/glue/webinputevent.h6
-rw-r--r--webkit/glue/webinputevent_mac.mm14
3 files changed, 12 insertions, 12 deletions
diff --git a/webkit/glue/event_conversion.cc b/webkit/glue/event_conversion.cc
index 84db42f..517e8c2 100644
--- a/webkit/glue/event_conversion.cc
+++ b/webkit/glue/event_conversion.cc
@@ -38,11 +38,9 @@ uint32 MakePlatformMouseEvent::last_click_time_ = 0;
MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
const WebMouseEvent& e) {
-#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;
@@ -114,9 +112,7 @@ MakePlatformMouseEvent::MakePlatformMouseEvent(Widget* widget,
MakePlatformWheelEvent::MakePlatformWheelEvent(Widget* widget,
const WebMouseWheelEvent& e)
{
-#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);
diff --git a/webkit/glue/webinputevent.h b/webkit/glue/webinputevent.h
index 308e75e..45e8af1 100644
--- a/webkit/glue/webinputevent.h
+++ b/webkit/glue/webinputevent.h
@@ -13,8 +13,10 @@
#include <wtf/RetainPtr.h>
#ifdef __OBJC__
@class NSEvent;
+@class NSView;
#else
class NSEvent;
+class NSView;
#endif // __OBJC__
#elif defined(OS_LINUX)
typedef struct _GdkEventButton GdkEventButton;
@@ -96,7 +98,7 @@ class WebMouseEvent : public WebInputEvent {
#if defined(OS_WIN)
WebMouseEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
#elif defined(OS_MACOSX)
- WebMouseEvent(NSEvent *event);
+ WebMouseEvent(NSEvent *event, NSView* view);
#elif defined(OS_LINUX)
explicit WebMouseEvent(const GdkEventButton* event);
explicit WebMouseEvent(const GdkEventMotion* event);
@@ -114,7 +116,7 @@ class WebMouseWheelEvent : public WebMouseEvent {
#if defined(OS_WIN)
WebMouseWheelEvent(HWND hwnd, UINT message, WPARAM wparam, LPARAM lparam);
#elif defined(OS_MACOSX)
- WebMouseWheelEvent(NSEvent *event);
+ WebMouseWheelEvent(NSEvent *event, NSView* view);
#elif defined(OS_LINUX)
explicit WebMouseWheelEvent(const GdkEventScroll* event);
#endif
diff --git a/webkit/glue/webinputevent_mac.mm b/webkit/glue/webinputevent_mac.mm
index 0355bcc..8fc524d 100644
--- a/webkit/glue/webinputevent_mac.mm
+++ b/webkit/glue/webinputevent_mac.mm
@@ -17,7 +17,7 @@ static const unsigned long kDefaultScrollLinesPerWheelDelta = 3;
// WebMouseEvent --------------------------------------------------------------
-WebMouseEvent::WebMouseEvent(NSEvent *event) {
+WebMouseEvent::WebMouseEvent(NSEvent *event, NSView* view) {
switch ([event type]) {
case NSMouseExited:
type = MOUSE_LEAVE;
@@ -72,9 +72,10 @@ WebMouseEvent::WebMouseEvent(NSEvent *event) {
global_x = location.x;
global_y = location.y;
- location = [event locationInWindow]; // local (to receiving window)
+ NSPoint windowLocal = [event locationInWindow];
+ location = [view convertPoint:windowLocal fromView:nil];
+ y = [view frame].size.height - location.y; // flip y
x = location.x;
- y = location.y;
// set modifiers:
@@ -95,7 +96,7 @@ WebMouseEvent::WebMouseEvent(NSEvent *event) {
// WebMouseWheelEvent ---------------------------------------------------------
-WebMouseWheelEvent::WebMouseWheelEvent(NSEvent *event) {
+WebMouseWheelEvent::WebMouseWheelEvent(NSEvent *event, NSView* view) {
type = MOUSE_WHEEL;
button = BUTTON_NONE;
@@ -103,9 +104,10 @@ WebMouseWheelEvent::WebMouseWheelEvent(NSEvent *event) {
global_x = location.x;
global_y = location.y;
- location = [event locationInWindow]; // local (to receiving window)
+ NSPoint windowLocal = [event locationInWindow];
+ location = [view convertPoint:windowLocal fromView:nil];
+ y = [view frame].size.height - location.y; // flip y
x = location.x;
- y = location.y;
int wheel_delta = [event deltaY];
const int delta_lines = wheel_delta * kDefaultScrollLinesPerWheelDelta;