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