| 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; |  | 
| 119   // Flip y. |  | 
| 120   NSScreen* primary_screen = ([[NSScreen screens] count] > 0) | 118   NSScreen* primary_screen = ([[NSScreen screens] count] > 0) | 
| 121                                  ? [[NSScreen screens] firstObject] | 119                                  ? [[NSScreen screens] firstObject] | 
| 122                                  : nil; | 120                                  : nil; | 
| 123   if (primary_screen) | 121   // Flip y conditionally. | 
| 124     result->globalY = [primary_screen frame].size.height - screen_local.y; | 122   result->setPositionInScreen( | 
| 125   else | 123       screen_local.x, primary_screen | 
| 126     result->globalY = screen_local.y; | 124                           ? [primary_screen frame].size.height - screen_local.y | 
|  | 125                           : screen_local.y); | 
| 127 | 126 | 
| 128   NSPoint content_local = | 127   NSPoint content_local = | 
| 129       [view convertPoint:[event locationInWindow] fromView:nil]; | 128       [view convertPoint:[event locationInWindow] fromView:nil]; | 
| 130   result->x = content_local.x; | 129   // Flip y. | 
| 131   result->y = [view frame].size.height - content_local.y;  // Flip y. | 130   result->setPositionInWidget(content_local.x, | 
|  | 131                               [view frame].size.height - content_local.y); | 
| 132 | 132 | 
| 133   result->movementX = [event deltaX]; | 133   result->movementX = [event deltaX]; | 
| 134   result->movementY = [event deltaY]; | 134   result->movementY = [event deltaY]; | 
| 135 } | 135 } | 
| 136 | 136 | 
| 137 bool IsSystemKeyEvent(const blink::WebKeyboardEvent& event) { | 137 bool IsSystemKeyEvent(const blink::WebKeyboardEvent& event) { | 
| 138   // Windows and Linux set |isSystemKey| if alt is down. Blink looks at this | 138   // 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 | 139   // 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 | 140   // 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 | 141   // 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 } | 500 } | 
| 501 | 501 | 
| 502 blink::WebGestureEvent WebGestureEventBuilder::Build(NSEvent* event, | 502 blink::WebGestureEvent WebGestureEventBuilder::Build(NSEvent* event, | 
| 503                                                      NSView* view) { | 503                                                      NSView* view) { | 
| 504   blink::WebGestureEvent result; | 504   blink::WebGestureEvent result; | 
| 505 | 505 | 
| 506   // Use a temporary WebMouseEvent to get the location. | 506   // Use a temporary WebMouseEvent to get the location. | 
| 507   blink::WebMouseEvent temp; | 507   blink::WebMouseEvent temp; | 
| 508 | 508 | 
| 509   SetWebEventLocationFromEventInView(&temp, event, view); | 509   SetWebEventLocationFromEventInView(&temp, event, view); | 
| 510   result.x = temp.x; | 510   result.x = temp.positionInWidget().x; | 
| 511   result.y = temp.y; | 511   result.y = temp.positionInWidget().y; | 
| 512   result.globalX = temp.globalX; | 512   result.globalX = temp.positionInScreen().x; | 
| 513   result.globalY = temp.globalY; | 513   result.globalY = temp.positionInScreen().y; | 
| 514 | 514 | 
| 515   result.setModifiers(ModifiersFromEvent(event)); | 515   result.setModifiers(ModifiersFromEvent(event)); | 
| 516   result.setTimeStampSeconds([event timestamp]); | 516   result.setTimeStampSeconds([event timestamp]); | 
| 517 | 517 | 
| 518   result.sourceDevice = blink::WebGestureDeviceTouchpad; | 518   result.sourceDevice = blink::WebGestureDeviceTouchpad; | 
| 519   switch ([event type]) { | 519   switch ([event type]) { | 
| 520     case NSEventTypeMagnify: | 520     case NSEventTypeMagnify: | 
| 521       result.setType(blink::WebInputEvent::GesturePinchUpdate); | 521       result.setType(blink::WebInputEvent::GesturePinchUpdate); | 
| 522       result.data.pinchUpdate.scale = [event magnification] + 1.0; | 522       result.data.pinchUpdate.scale = [event magnification] + 1.0; | 
| 523       break; | 523       break; | 
| (...skipping 12 matching lines...) Expand all  Loading... | 
| 536       // to specify them when the gesture is differentiated. | 536       // to specify them when the gesture is differentiated. | 
| 537       break; | 537       break; | 
| 538     default: | 538     default: | 
| 539       NOTIMPLEMENTED(); | 539       NOTIMPLEMENTED(); | 
| 540   } | 540   } | 
| 541 | 541 | 
| 542   return result; | 542   return result; | 
| 543 } | 543 } | 
| 544 | 544 | 
| 545 }  // namespace content | 545 }  // namespace content | 
| OLD | NEW | 
|---|