Chromium Code Reviews| 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 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 398 // and mouses share the same cursor, so we will set their pointerType as | 398 // and mouses share the same cursor, so we will set their pointerType as |
| 399 // Unknown for now. | 399 // Unknown for now. |
| 400 if (type == NSMouseExited || type == NSMouseEntered) { | 400 if (type == NSMouseExited || type == NSMouseEntered) { |
| 401 result.pointerType = blink::WebPointerProperties::PointerType::Unknown; | 401 result.pointerType = blink::WebPointerProperties::PointerType::Unknown; |
| 402 return result; | 402 return result; |
| 403 } | 403 } |
| 404 | 404 |
| 405 // For other mouse events and touchpad events, the pointer type is mouse. | 405 // For other mouse events and touchpad events, the pointer type is mouse. |
| 406 // For all other tablet events, the pointer type will be just pen. | 406 // For all other tablet events, the pointer type will be just pen. |
| 407 NSEventSubtype subtype = [event subtype]; | 407 NSEventSubtype subtype = [event subtype]; |
| 408 if (subtype == NSTabletPointEventSubtype || | 408 if (subtype != NSTabletPointEventSubtype && |
| 409 subtype == NSTabletProximityEventSubtype) { | 409 subtype != NSTabletProximityEventSubtype) { |
| 410 result.pointerType = blink::WebPointerProperties::PointerType::Pen; | |
| 411 } else { | |
| 412 result.pointerType = blink::WebPointerProperties::PointerType::Mouse; | 410 result.pointerType = blink::WebPointerProperties::PointerType::Mouse; |
| 411 return result; | |
|
mustaq
2016/09/21 19:39:36
- Could you please confirm that uninitialized resu
lanwei
2016/09/21 20:13:42
Yes, default values of force is NaN, tiltx, y are
| |
| 413 } | 412 } |
| 413 | |
| 414 // Set stylus properties for events with a subtype of | |
| 415 // NSTabletPointEventSubtype. | |
| 416 result.pointerType = blink::WebPointerProperties::PointerType::Pen; | |
| 414 result.id = [event deviceID]; | 417 result.id = [event deviceID]; |
| 415 result.force = [event pressure]; | 418 if (subtype == NSTabletPointEventSubtype) { |
| 416 NSPoint tilt = [event tilt]; | 419 result.force = [event pressure]; |
| 417 result.tiltX = lround(tilt.x * 90); | 420 NSPoint tilt = [event tilt]; |
| 418 result.tiltY = lround(tilt.y * 90); | 421 result.tiltX = lround(tilt.x * 90); |
| 422 result.tiltY = lround(tilt.y * 90); | |
| 423 } | |
| 419 return result; | 424 return result; |
| 420 } | 425 } |
| 421 | 426 |
| 422 // WebMouseWheelEvent --------------------------------------------------------- | 427 // WebMouseWheelEvent --------------------------------------------------------- |
| 423 | 428 |
| 424 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build( | 429 blink::WebMouseWheelEvent WebMouseWheelEventBuilder::Build( |
| 425 NSEvent* event, | 430 NSEvent* event, |
| 426 NSView* view) { | 431 NSView* view) { |
| 427 blink::WebMouseWheelEvent result; | 432 blink::WebMouseWheelEvent result; |
| 428 | 433 |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 610 break; | 615 break; |
| 611 default: | 616 default: |
| 612 NOTIMPLEMENTED(); | 617 NOTIMPLEMENTED(); |
| 613 result.type = blink::WebInputEvent::Undefined; | 618 result.type = blink::WebInputEvent::Undefined; |
| 614 } | 619 } |
| 615 | 620 |
| 616 return result; | 621 return result; |
| 617 } | 622 } |
| 618 | 623 |
| 619 } // namespace content | 624 } // namespace content |
| OLD | NEW |