| 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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 } else | 245 } else |
| 246 NOTIMPLEMENTED(); | 246 NOTIMPLEMENTED(); |
| 247 | 247 |
| 248 result.isSystemKey = IsSystemKeyEvent(result); | 248 result.isSystemKey = IsSystemKeyEvent(result); |
| 249 | 249 |
| 250 return result; | 250 return result; |
| 251 } | 251 } |
| 252 | 252 |
| 253 // WebMouseEvent -------------------------------------------------------------- | 253 // WebMouseEvent -------------------------------------------------------------- |
| 254 | 254 |
| 255 blink::WebMouseEvent WebMouseEventBuilder::Build(NSEvent* event, NSView* view) { | 255 blink::WebMouseEvent WebMouseEventBuilder::Build( |
| 256 NSEvent* event, |
| 257 NSView* view, |
| 258 blink::WebPointerProperties::PointerType pointerType) { |
| 256 blink::WebInputEvent::Type event_type = blink::WebInputEvent::Type::Undefined; | 259 blink::WebInputEvent::Type event_type = blink::WebInputEvent::Type::Undefined; |
| 257 int click_count = 0; | 260 int click_count = 0; |
| 258 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::NoButton; | 261 blink::WebMouseEvent::Button button = blink::WebMouseEvent::Button::NoButton; |
| 259 | 262 |
| 260 NSEventType type = [event type]; | 263 NSEventType type = [event type]; |
| 261 switch (type) { | 264 switch (type) { |
| 262 case NSMouseExited: | 265 case NSMouseExited: |
| 263 event_type = blink::WebInputEvent::MouseLeave; | 266 event_type = blink::WebInputEvent::MouseLeave; |
| 264 break; | 267 break; |
| 265 case NSLeftMouseDown: | 268 case NSLeftMouseDown: |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 default: | 314 default: |
| 312 NOTIMPLEMENTED(); | 315 NOTIMPLEMENTED(); |
| 313 } | 316 } |
| 314 | 317 |
| 315 blink::WebMouseEvent result(event_type, ModifiersFromEvent(event), | 318 blink::WebMouseEvent result(event_type, ModifiersFromEvent(event), |
| 316 [event timestamp]); | 319 [event timestamp]); |
| 317 result.clickCount = click_count; | 320 result.clickCount = click_count; |
| 318 result.button = button; | 321 result.button = button; |
| 319 SetWebEventLocationFromEventInView(&result, event, view); | 322 SetWebEventLocationFromEventInView(&result, event, view); |
| 320 | 323 |
| 321 // For NSMouseExited and NSMouseEntered, they do not have a subtype. Styluses | 324 // For NSMouseExited and NSMouseEntered events, they do not have a subtype. |
| 322 // and mouses share the same cursor, so we will set their pointerType as | 325 // We decide their pointer types by checking if we recevied a |
| 323 // Unknown for now. | 326 // NSTabletProximity event. |
| 324 if (type == NSMouseExited || type == NSMouseEntered) { | 327 if (type == NSMouseExited || type == NSMouseEntered) { |
| 325 result.pointerType = blink::WebPointerProperties::PointerType::Unknown; | 328 result.pointerType = pointerType; |
| 326 return result; | 329 return result; |
| 327 } | 330 } |
| 328 | 331 |
| 329 // For other mouse events and touchpad events, the pointer type is mouse. | 332 // For other mouse events and touchpad events, the pointer type is mouse. |
| 330 // For all other tablet events, the pointer type will be just pen. | 333 // For all other tablet events, the pointer type will be just pen. |
| 331 NSEventSubtype subtype = [event subtype]; | 334 NSEventSubtype subtype = [event subtype]; |
| 332 if (subtype != NSTabletPointEventSubtype && | 335 if (subtype != NSTabletPointEventSubtype && |
| 333 subtype != NSTabletProximityEventSubtype) { | 336 subtype != NSTabletProximityEventSubtype) { |
| 334 result.pointerType = blink::WebPointerProperties::PointerType::Mouse; | 337 result.pointerType = blink::WebPointerProperties::PointerType::Mouse; |
| 335 return result; | 338 return result; |
| 336 } | 339 } |
| 337 | 340 |
| 338 // Set stylus properties for events with a subtype of | 341 // Set stylus properties for events with a subtype of |
| 339 // NSTabletPointEventSubtype. | 342 // NSTabletPointEventSubtype. |
| 340 result.pointerType = blink::WebPointerProperties::PointerType::Pen; | 343 result.pointerType = blink::WebPointerProperties::PointerType::Pen; |
| 341 result.id = [event deviceID]; | 344 result.id = [event deviceID]; |
| 342 if (subtype == NSTabletPointEventSubtype) { | 345 if (subtype == NSTabletPointEventSubtype) { |
| 343 result.force = [event pressure]; | 346 result.force = [event pressure]; |
| 344 NSPoint tilt = [event tilt]; | 347 NSPoint tilt = [event tilt]; |
| 345 result.tiltX = lround(tilt.x * 90); | 348 result.tiltX = lround(tilt.x * 90); |
| 346 result.tiltY = lround(tilt.y * 90); | 349 result.tiltY = lround(tilt.y * 90); |
| 347 result.tangentialPressure = [event tangentialPressure]; | 350 result.tangentialPressure = [event tangentialPressure]; |
| 348 // NSEvent spec doesn't specify the range of rotation, we make sure that | 351 // NSEvent spec doesn't specify the range of rotation, we make sure that |
| 349 // this value is in the range of [0,359]. | 352 // this value is in the range of [0,359]. |
| 350 int twist = (int)[event rotation]; | 353 int twist = (int)[event rotation]; |
| 351 twist = twist % 360; | 354 twist = twist % 360; |
| 352 if (twist < 0) | 355 if (twist < 0) |
| 353 twist += 360; | 356 twist += 360; |
| 354 result.twist = twist; | 357 result.twist = twist; |
| 358 } else { |
| 359 event_type = [event isEnteringProximity] |
| 360 ? blink::WebInputEvent::MouseMove |
| 361 : blink::WebInputEvent::MouseLeave; |
| 362 result.setType(event_type); |
| 355 } | 363 } |
| 356 return result; | 364 return result; |
| 357 } | 365 } |
| 358 | 366 |
| 359 // WebMouseWheelEvent --------------------------------------------------------- | 367 // WebMouseWheelEvent --------------------------------------------------------- |
| 360 | 368 |
| 361 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build( | 369 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build( |
| 362 NSEvent* event, | 370 NSEvent* event, |
| 363 NSView* view) { | 371 NSView* view) { |
| 364 blink::WebMouseWheelEvent result(blink::WebInputEvent::MouseWheel, | 372 blink::WebMouseWheelEvent result(blink::WebInputEvent::MouseWheel, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 541 // to specify them when the gesture is differentiated. | 549 // to specify them when the gesture is differentiated. |
| 542 break; | 550 break; |
| 543 default: | 551 default: |
| 544 NOTIMPLEMENTED(); | 552 NOTIMPLEMENTED(); |
| 545 } | 553 } |
| 546 | 554 |
| 547 return result; | 555 return result; |
| 548 } | 556 } |
| 549 | 557 |
| 550 } // namespace content | 558 } // namespace content |
| OLD | NEW |