Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(276)

Side by Side Diff: content/browser/renderer_host/input/web_input_event_builders_mac.mm

Issue 2461323002: Mac: Support Sierra's broken MouseWheel events. (Closed)
Patch Set: Horizontal is a trap - stay clear Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | ui/events/cocoa/events_mac.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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. However, kCGScrollWheelEventPointDeltaAxisXY has a "nasty bug"
572 // when holding Shift (see "Of Mice and Men", above). So only check vertical
573 // scrolls. Also, to be consistent with the values when truncation does NOT
574 // scroll, it needs to be multiplied by some factor. The documentation for
575 // CGEventSourceGetPixelsPerLine() says "By default, the scale is about ten
576 // pixels per line." However, the actual relationship is fuzzy because of
577 // acceleration. Using a constant of 10 for small values seems to "feel
578 // right" when this bug is encountered. See http://crbug.com/660773.
579 const float kPixelsPerLine = 10.0;
580 if (result.deltaY == 0 && pointDeltaY != 0)
581 result.deltaY = pointDeltaY * kPixelsPerLine;
582
565 result.wheelTicksY = 583 result.wheelTicksY =
566 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis1); 584 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis1);
567 result.wheelTicksX = 585 result.wheelTicksX =
568 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis2); 586 CGEventGetIntegerValueField(cg_event, kCGScrollWheelEventDeltaAxis2);
569 } 587 }
570 588
571 result.timeStampSeconds = [event timestamp]; 589 result.timeStampSeconds = [event timestamp];
572 590
573 result.phase = PhaseForEvent(event); 591 result.phase = PhaseForEvent(event);
574 result.momentumPhase = MomentumPhaseForEvent(event); 592 result.momentumPhase = MomentumPhaseForEvent(event);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
615 break; 633 break;
616 default: 634 default:
617 NOTIMPLEMENTED(); 635 NOTIMPLEMENTED();
618 result.type = blink::WebInputEvent::Undefined; 636 result.type = blink::WebInputEvent::Undefined;
619 } 637 }
620 638
621 return result; 639 return result;
622 } 640 }
623 641
624 } // namespace content 642 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | ui/events/cocoa/events_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698