OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 /* | 5 /* |
6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. | 6 * Copyright (C) 2004, 2006, 2007 Apple Inc. All rights reserved. |
7 * Copyright (C) 2006-2009 Google Inc. | 7 * Copyright (C) 2006-2009 Google Inc. |
8 * | 8 * |
9 * Redistribution and use in source and binary forms, with or without | 9 * Redistribution and use in source and binary forms, with or without |
10 * modification, are permitted provided that the following conditions | 10 * modification, are permitted provided that the following conditions |
(...skipping 484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 | 495 |
496 void SetWebEventLocationFromEventInView(blink::WebMouseEvent* result, | 496 void SetWebEventLocationFromEventInView(blink::WebMouseEvent* result, |
497 NSEvent* event, | 497 NSEvent* event, |
498 NSView* view) { | 498 NSView* view) { |
499 NSPoint window_local = [event locationInWindow]; | 499 NSPoint window_local = [event locationInWindow]; |
500 | 500 |
501 NSPoint screen_local = [[view window] convertBaseToScreen:window_local]; | 501 NSPoint screen_local = [[view window] convertBaseToScreen:window_local]; |
502 result->globalX = screen_local.x; | 502 result->globalX = screen_local.x; |
503 // Flip y. | 503 // Flip y. |
504 NSScreen* primary_screen = ([[NSScreen screens] count] > 0) | 504 NSScreen* primary_screen = ([[NSScreen screens] count] > 0) |
505 ? [[NSScreen screens] objectAtIndex:0] | 505 ? [[NSScreen screens] firstObject] |
506 : nil; | 506 : nil; |
507 if (primary_screen) | 507 if (primary_screen) |
508 result->globalY = [primary_screen frame].size.height - screen_local.y; | 508 result->globalY = [primary_screen frame].size.height - screen_local.y; |
509 else | 509 else |
510 result->globalY = screen_local.y; | 510 result->globalY = screen_local.y; |
511 | 511 |
512 NSPoint content_local = [view convertPoint:window_local fromView:nil]; | 512 NSPoint content_local = [view convertPoint:window_local fromView:nil]; |
513 result->x = content_local.x; | 513 result->x = content_local.x; |
514 result->y = [view frame].size.height - content_local.y; // Flip y. | 514 result->y = [view frame].size.height - content_local.y; // Flip y. |
515 | 515 |
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
918 break; | 918 break; |
919 default: | 919 default: |
920 NOTIMPLEMENTED(); | 920 NOTIMPLEMENTED(); |
921 result.type = blink::WebInputEvent::Undefined; | 921 result.type = blink::WebInputEvent::Undefined; |
922 } | 922 } |
923 | 923 |
924 return result; | 924 return result; |
925 } | 925 } |
926 | 926 |
927 } // namespace content | 927 } // namespace content |
OLD | NEW |