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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 544 DCHECK(cg_event); | 544 DCHECK(cg_event); |
| 545 | 545 |
| 546 // Wheel ticks are supposed to be raw, unaccelerated values, one per physical | 546 // Wheel ticks are supposed to be raw, unaccelerated values, one per physical |
| 547 // mouse wheel notch. The delta event is perfect for this (being a good | 547 // mouse wheel notch. The delta event is perfect for this (being a good |
| 548 // "specific edge case" as mentioned above). Trackpads, unfortunately, do | 548 // "specific edge case" as mentioned above). Trackpads, unfortunately, do |
| 549 // event chunking, and sending mousewheel events with 0 ticks causes some | 549 // event chunking, and sending mousewheel events with 0 ticks causes some |
| 550 // websites to malfunction. Therefore, for all continuous input devices we use | 550 // websites to malfunction. Therefore, for all continuous input devices we use |
| 551 // the point delta data instead, since we cannot distinguish trackpad data | 551 // the point delta data instead, since we cannot distinguish trackpad data |
| 552 // from data from any other continuous device. | 552 // from data from any other continuous device. |
| 553 | 553 |
| 554 int64_t pointDeltaX = CGEventGetIntegerValueField( | |
| 555 cg_event, kCGScrollWheelEventPointDeltaAxis2); | |
| 556 int64_t pointDeltaY = CGEventGetIntegerValueField( | |
| 557 cg_event, kCGScrollWheelEventPointDeltaAxis1); | |
| 558 | |
| 554 if (CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventIsContinuous)) { | 559 if (CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventIsContinuous)) { |
| 555 result.deltaX = CGEventGetIntegerValueField( | 560 result.deltaX = pointDeltaX; |
| 556 cg_event, kCGScrollWheelEventPointDeltaAxis2); | 561 result.deltaY = pointDeltaY; |
| 557 result.deltaY = CGEventGetIntegerValueField( | 562 result.wheelTicksX = pointDeltaX / ui::kScrollbarPixelsPerCocoaTick; |
| 558 cg_event, kCGScrollWheelEventPointDeltaAxis1); | 563 result.wheelTicksY = pointDeltaY / ui::kScrollbarPixelsPerCocoaTick; |
| 559 result.wheelTicksX = result.deltaX / ui::kScrollbarPixelsPerCocoaTick; | |
| 560 result.wheelTicksY = result.deltaY / ui::kScrollbarPixelsPerCocoaTick; | |
| 561 result.hasPreciseScrollingDeltas = true; | 564 result.hasPreciseScrollingDeltas = true; |
| 562 } else { | 565 } else { |
| 563 result.deltaX = [event deltaX] * ui::kScrollbarPixelsPerCocoaTick; | 566 result.deltaX = [event deltaX] * ui::kScrollbarPixelsPerCocoaTick; |
| 564 result.deltaY = [event deltaY] * ui::kScrollbarPixelsPerCocoaTick; | 567 result.deltaY = [event deltaY] * ui::kScrollbarPixelsPerCocoaTick; |
| 568 | |
| 569 // A rounding bug on Sierra means that single-tick wheel scrolls may be | |
| 570 // truncated to zero. Prefer kCGScrollWheelEventPointDeltaAxisXY in those | |
| 571 // cases. First assume the CGEventSource has the default value of 10, rather | |
|
Avi (use Gerrit)
2016/10/31 13:32:59
"First" assume? I'm not sure what you mean by that
tapted
2016/11/01 02:29:46
Ah, there were more steps earlier :). Should be mo
| |
| 572 // than querying CGEventSourceGetPixelsPerLine() each time. | |
| 573 const float kPixelsPerLine = 10.0; | |
| 574 if (result.deltaX == 0 && pointDeltaX != 0) | |
| 575 result.deltaX = pointDeltaX * kPixelsPerLine; | |
| 576 if (result.deltaY == 0 && pointDeltaY != 0) | |
| 577 result.deltaY = pointDeltaY * kPixelsPerLine; | |
| 578 | |
| 565 result.wheelTicksY = | 579 result.wheelTicksY = |
| 566 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis1); | 580 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis1); |
| 567 result.wheelTicksX = | 581 result.wheelTicksX = |
| 568 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis2); | 582 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis2); |
| 569 } | 583 } |
| 570 | 584 |
| 571 result.timeStampSeconds = [event timestamp]; | 585 result.timeStampSeconds = [event timestamp]; |
| 572 | 586 |
| 573 result.phase = PhaseForEvent(event); | 587 result.phase = PhaseForEvent(event); |
| 574 result.momentumPhase = MomentumPhaseForEvent(event); | 588 result.momentumPhase = MomentumPhaseForEvent(event); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 615 break; | 629 break; |
| 616 default: | 630 default: |
| 617 NOTIMPLEMENTED(); | 631 NOTIMPLEMENTED(); |
| 618 result.type = blink::WebInputEvent::Undefined; | 632 result.type = blink::WebInputEvent::Undefined; |
| 619 } | 633 } |
| 620 | 634 |
| 621 return result; | 635 return result; |
| 622 } | 636 } |
| 623 | 637 |
| 624 } // namespace content | 638 } // namespace content |
| OLD | NEW |