summaryrefslogtreecommitdiffstats
path: root/WebKit/chromium/src/mac/WebInputEventFactory.mm
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2010-04-27 16:31:00 +0100
committerSteve Block <steveblock@google.com>2010-05-11 14:42:12 +0100
commitdcc8cf2e65d1aa555cce12431a16547e66b469ee (patch)
tree92a8d65cd5383bca9749f5327fb5e440563926e6 /WebKit/chromium/src/mac/WebInputEventFactory.mm
parentccac38a6b48843126402088a309597e682f40fe6 (diff)
downloadexternal_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.zip
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.gz
external_webkit-dcc8cf2e65d1aa555cce12431a16547e66b469ee.tar.bz2
Merge webkit.org at r58033 : Initial merge by git
Change-Id: If006c38561af287c50cd578d251629b51e4d8cd1
Diffstat (limited to 'WebKit/chromium/src/mac/WebInputEventFactory.mm')
-rw-r--r--WebKit/chromium/src/mac/WebInputEventFactory.mm45
1 files changed, 25 insertions, 20 deletions
diff --git a/WebKit/chromium/src/mac/WebInputEventFactory.mm b/WebKit/chromium/src/mac/WebInputEventFactory.mm
index 46b0afe..694155f 100644
--- a/WebKit/chromium/src/mac/WebInputEventFactory.mm
+++ b/WebKit/chromium/src/mac/WebInputEventFactory.mm
@@ -861,6 +861,29 @@ static inline int modifiersFromEvent(NSEvent* event) {
return modifiers;
}
+static inline void setWebEventLocationFromEventInView(WebMouseEvent* result,
+ NSEvent* event,
+ NSView* view) {
+ NSPoint windowLocal = [event locationInWindow];
+
+ NSPoint screenLocal = [[view window] convertBaseToScreen:windowLocal];
+ result->globalX = screenLocal.x;
+ // Flip y.
+ NSScreen* primaryScreen = ([[NSScreen screens] count] > 0) ?
+ [[NSScreen screens] objectAtIndex:0] : nil;
+ if (primaryScreen)
+ result->globalY = [primaryScreen frame].size.height - screenLocal.y;
+ else
+ result->globalY = screenLocal.y;
+
+ NSPoint contentLocal = [view convertPoint:windowLocal fromView:nil];
+ result->x = contentLocal.x;
+ result->y = [view frame].size.height - contentLocal.y; // Flip y.
+
+ result->windowX = result->x;
+ result->windowY = result->y;
+}
+
WebKeyboardEvent WebInputEventFactory::keyboardEvent(NSEvent* event)
{
WebKeyboardEvent result;
@@ -1021,16 +1044,7 @@ WebMouseEvent WebInputEventFactory::mouseEvent(NSEvent* event, NSView* view)
ASSERT_NOT_REACHED();
}
- NSPoint location = [NSEvent mouseLocation]; // global coordinates
- result.globalX = location.x;
- result.globalY = [[[view window] screen] frame].size.height - location.y;
-
- NSPoint windowLocal = [event locationInWindow];
- location = [view convertPoint:windowLocal fromView:nil];
- result.y = [view frame].size.height - location.y; // flip y
- result.x = location.x;
- result.windowX = result.x;
- result.windowY = result.y;
+ setWebEventLocationFromEventInView(&result, event, view);
result.modifiers = modifiersFromEvent(event);
@@ -1050,16 +1064,7 @@ WebMouseWheelEvent WebInputEventFactory::mouseWheelEvent(NSEvent* event, NSView*
result.modifiers = modifiersFromEvent(event);
- // Set coordinates by translating event coordinates from screen to client.
- NSPoint location = [NSEvent mouseLocation]; // global coordinates
- result.globalX = location.x;
- result.globalY = location.y;
- NSPoint windowLocal = [event locationInWindow];
- location = [view convertPoint:windowLocal fromView:nil];
- result.x = location.x;
- result.y = [view frame].size.height - location.y; // flip y
- result.windowX = result.x;
- result.windowY = result.y;
+ setWebEventLocationFromEventInView(&result, event, view);
// Of Mice and Men
// ---------------