| 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 22 matching lines...) Expand all Loading... |
| 33 #import <ApplicationServices/ApplicationServices.h> | 33 #import <ApplicationServices/ApplicationServices.h> |
| 34 #import <Cocoa/Cocoa.h> | 34 #import <Cocoa/Cocoa.h> |
| 35 | 35 |
| 36 #include <stdint.h> | 36 #include <stdint.h> |
| 37 | 37 |
| 38 #include "base/mac/sdk_forward_declarations.h" | 38 #include "base/mac/sdk_forward_declarations.h" |
| 39 #include "base/strings/string_util.h" | 39 #include "base/strings/string_util.h" |
| 40 #include "content/browser/renderer_host/input/web_input_event_util.h" | 40 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 41 #include "third_party/WebKit/public/web/WebInputEvent.h" | 41 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| 42 #include "ui/base/cocoa/cocoa_base_utils.h" | 42 #include "ui/base/cocoa/cocoa_base_utils.h" |
| 43 #import "ui/events/cocoa/cocoa_event_utils.h" |
| 43 #include "ui/events/keycodes/keyboard_code_conversion.h" | 44 #include "ui/events/keycodes/keyboard_code_conversion.h" |
| 44 #include "ui/events/keycodes/keyboard_code_conversion_mac.h" | 45 #include "ui/events/keycodes/keyboard_code_conversion_mac.h" |
| 45 | 46 |
| 46 namespace content { | 47 namespace content { |
| 47 | 48 |
| 48 namespace { | 49 namespace { |
| 49 | 50 |
| 50 // Return true if the target modifier key is up. OS X has an "official" flag | 51 // Return true if the target modifier key is up. OS X has an "official" flag |
| 51 // to test whether either left or right versions of a modifier key are held, | 52 // to test whether either left or right versions of a modifier key are held, |
| 52 // and "unofficial" flags for the left and right versions independently. This | 53 // and "unofficial" flags for the left and right versions independently. This |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 540 DCHECK(cg_event); | 541 DCHECK(cg_event); |
| 541 | 542 |
| 542 // Wheel ticks are supposed to be raw, unaccelerated values, one per physical | 543 // Wheel ticks are supposed to be raw, unaccelerated values, one per physical |
| 543 // mouse wheel notch. The delta event is perfect for this (being a good | 544 // mouse wheel notch. The delta event is perfect for this (being a good |
| 544 // "specific edge case" as mentioned above). Trackpads, unfortunately, do | 545 // "specific edge case" as mentioned above). Trackpads, unfortunately, do |
| 545 // event chunking, and sending mousewheel events with 0 ticks causes some | 546 // event chunking, and sending mousewheel events with 0 ticks causes some |
| 546 // websites to malfunction. Therefore, for all continuous input devices we use | 547 // websites to malfunction. Therefore, for all continuous input devices we use |
| 547 // the point delta data instead, since we cannot distinguish trackpad data | 548 // the point delta data instead, since we cannot distinguish trackpad data |
| 548 // from data from any other continuous device. | 549 // from data from any other continuous device. |
| 549 | 550 |
| 550 // Conversion between wheel delta amounts and number of pixels to scroll. | |
| 551 static const double kScrollbarPixelsPerCocoaTick = 40.0; | |
| 552 | |
| 553 if (CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventIsContinuous)) { | 551 if (CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventIsContinuous)) { |
| 554 result.deltaX = CGEventGetIntegerValueField( | 552 result.deltaX = CGEventGetIntegerValueField( |
| 555 cg_event, kCGScrollWheelEventPointDeltaAxis2); | 553 cg_event, kCGScrollWheelEventPointDeltaAxis2); |
| 556 result.deltaY = CGEventGetIntegerValueField( | 554 result.deltaY = CGEventGetIntegerValueField( |
| 557 cg_event, kCGScrollWheelEventPointDeltaAxis1); | 555 cg_event, kCGScrollWheelEventPointDeltaAxis1); |
| 558 result.wheelTicksX = result.deltaX / kScrollbarPixelsPerCocoaTick; | 556 result.wheelTicksX = result.deltaX / ui::kScrollbarPixelsPerCocoaTick; |
| 559 result.wheelTicksY = result.deltaY / kScrollbarPixelsPerCocoaTick; | 557 result.wheelTicksY = result.deltaY / ui::kScrollbarPixelsPerCocoaTick; |
| 560 result.hasPreciseScrollingDeltas = true; | 558 result.hasPreciseScrollingDeltas = true; |
| 561 } else { | 559 } else { |
| 562 result.deltaX = [event deltaX] * kScrollbarPixelsPerCocoaTick; | 560 result.deltaX = [event deltaX] * ui::kScrollbarPixelsPerCocoaTick; |
| 563 result.deltaY = [event deltaY] * kScrollbarPixelsPerCocoaTick; | 561 result.deltaY = [event deltaY] * ui::kScrollbarPixelsPerCocoaTick; |
| 564 result.wheelTicksY = | 562 result.wheelTicksY = |
| 565 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis1); | 563 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis1); |
| 566 result.wheelTicksX = | 564 result.wheelTicksX = |
| 567 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis2); | 565 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis2); |
| 568 } | 566 } |
| 569 | 567 |
| 570 result.timeStampSeconds = [event timestamp]; | 568 result.timeStampSeconds = [event timestamp]; |
| 571 | 569 |
| 572 result.phase = PhaseForEvent(event); | 570 result.phase = PhaseForEvent(event); |
| 573 result.momentumPhase = MomentumPhaseForEvent(event); | 571 result.momentumPhase = MomentumPhaseForEvent(event); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 break; | 612 break; |
| 615 default: | 613 default: |
| 616 NOTIMPLEMENTED(); | 614 NOTIMPLEMENTED(); |
| 617 result.type = blink::WebInputEvent::Undefined; | 615 result.type = blink::WebInputEvent::Undefined; |
| 618 } | 616 } |
| 619 | 617 |
| 620 return result; | 618 return result; |
| 621 } | 619 } |
| 622 | 620 |
| 623 } // namespace content | 621 } // namespace content |
| OLD | NEW |