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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 modifiers |= blink::WebInputEvent::MiddleButtonDown; | 108 modifiers |= blink::WebInputEvent::MiddleButtonDown; |
109 | 109 |
110 return modifiers; | 110 return modifiers; |
111 } | 111 } |
112 | 112 |
113 void SetWebEventLocationFromEventInView(blink::WebMouseEvent* result, | 113 void SetWebEventLocationFromEventInView(blink::WebMouseEvent* result, |
114 NSEvent* event, | 114 NSEvent* event, |
115 NSView* view) { | 115 NSView* view) { |
116 NSPoint screen_local = ui::ConvertPointFromWindowToScreen( | 116 NSPoint screen_local = ui::ConvertPointFromWindowToScreen( |
117 [view window], [event locationInWindow]); | 117 [view window], [event locationInWindow]); |
118 result->globalX = screen_local.x; | 118 result->screenPosition.x = screen_local.x; |
119 // Flip y. | 119 // Flip y. |
120 NSScreen* primary_screen = ([[NSScreen screens] count] > 0) | 120 NSScreen* primary_screen = ([[NSScreen screens] count] > 0) |
121 ? [[NSScreen screens] firstObject] | 121 ? [[NSScreen screens] firstObject] |
122 : nil; | 122 : nil; |
123 if (primary_screen) | 123 if (primary_screen) |
124 result->globalY = [primary_screen frame].size.height - screen_local.y; | 124 result->screenPosition.y = |
| 125 [primary_screen frame].size.height - screen_local.y; |
125 else | 126 else |
126 result->globalY = screen_local.y; | 127 result->screenPosition.y = screen_local.y; |
127 | 128 |
128 NSPoint content_local = | 129 NSPoint content_local = |
129 [view convertPoint:[event locationInWindow] fromView:nil]; | 130 [view convertPoint:[event locationInWindow] fromView:nil]; |
130 result->x = content_local.x; | 131 result->position.x = content_local.x; |
131 result->y = [view frame].size.height - content_local.y; // Flip y. | 132 result->position.y = [view frame].size.height - content_local.y; // Flip y. |
132 | 133 |
133 result->movementX = [event deltaX]; | 134 result->movementX = [event deltaX]; |
134 result->movementY = [event deltaY]; | 135 result->movementY = [event deltaY]; |
135 } | 136 } |
136 | 137 |
137 bool IsSystemKeyEvent(const blink::WebKeyboardEvent& event) { | 138 bool IsSystemKeyEvent(const blink::WebKeyboardEvent& event) { |
138 // Windows and Linux set |isSystemKey| if alt is down. Blink looks at this | 139 // Windows and Linux set |isSystemKey| if alt is down. Blink looks at this |
139 // flag to decide if it should handle a key or not. E.g. alt-left/right | 140 // flag to decide if it should handle a key or not. E.g. alt-left/right |
140 // shouldn't be used by Blink to scroll the current page, because we want | 141 // shouldn't be used by Blink to scroll the current page, because we want |
141 // to get that key back for it to do history navigation. Hence, the | 142 // to get that key back for it to do history navigation. Hence, the |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 } | 501 } |
501 | 502 |
502 blink::WebGestureEvent WebGestureEventBuilder::Build(NSEvent* event, | 503 blink::WebGestureEvent WebGestureEventBuilder::Build(NSEvent* event, |
503 NSView* view) { | 504 NSView* view) { |
504 blink::WebGestureEvent result; | 505 blink::WebGestureEvent result; |
505 | 506 |
506 // Use a temporary WebMouseEvent to get the location. | 507 // Use a temporary WebMouseEvent to get the location. |
507 blink::WebMouseEvent temp; | 508 blink::WebMouseEvent temp; |
508 | 509 |
509 SetWebEventLocationFromEventInView(&temp, event, view); | 510 SetWebEventLocationFromEventInView(&temp, event, view); |
510 result.x = temp.x; | 511 result.x = temp.position.x; |
511 result.y = temp.y; | 512 result.y = temp.position.y; |
512 result.globalX = temp.globalX; | 513 result.globalX = temp.screenPosition.x; |
513 result.globalY = temp.globalY; | 514 result.globalY = temp.screenPosition.y; |
514 | 515 |
515 result.setModifiers(ModifiersFromEvent(event)); | 516 result.setModifiers(ModifiersFromEvent(event)); |
516 result.setTimeStampSeconds([event timestamp]); | 517 result.setTimeStampSeconds([event timestamp]); |
517 | 518 |
518 result.sourceDevice = blink::WebGestureDeviceTouchpad; | 519 result.sourceDevice = blink::WebGestureDeviceTouchpad; |
519 switch ([event type]) { | 520 switch ([event type]) { |
520 case NSEventTypeMagnify: | 521 case NSEventTypeMagnify: |
521 result.setType(blink::WebInputEvent::GesturePinchUpdate); | 522 result.setType(blink::WebInputEvent::GesturePinchUpdate); |
522 result.data.pinchUpdate.scale = [event magnification] + 1.0; | 523 result.data.pinchUpdate.scale = [event magnification] + 1.0; |
523 break; | 524 break; |
(...skipping 12 matching lines...) Expand all Loading... |
536 // to specify them when the gesture is differentiated. | 537 // to specify them when the gesture is differentiated. |
537 break; | 538 break; |
538 default: | 539 default: |
539 NOTIMPLEMENTED(); | 540 NOTIMPLEMENTED(); |
540 } | 541 } |
541 | 542 |
542 return result; | 543 return result; |
543 } | 544 } |
544 | 545 |
545 } // namespace content | 546 } // namespace content |
OLD | NEW |