Commit 12a1ad20 authored by Liviu Tinta's avatar Liviu Tinta Committed by Commit Bot

Pointer Events tiltY is reversed on Mac

On Mac, tiltY is positive when the pen is tilted away from
the user. Based on Pointer Event spec, tiltY should be positive when
the pen is tilted towards the user.

On Mac, by default Y increases going up, while in Chromium Y increases
going down. NSView has isFlipped property which controls if Y increases
going up (false) or going down (true).

In order to fix the bug, we check NSView's isFlipped flag and if it is
false we reverse the sign of tiltY to accommodate the difference in the
direction of Y.

Bug: 1111347
Change-Id: I108ba496adc6f951277e1c9ddb7eaf6483e522f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348544Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: Liviu Tinta <liviutinta@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796963}
parent a8c99c83
...@@ -423,7 +423,15 @@ blink::WebMouseEvent WebMouseEventBuilder::Build( ...@@ -423,7 +423,15 @@ blink::WebMouseEvent WebMouseEventBuilder::Build(
result.force = [event pressure]; result.force = [event pressure];
NSPoint tilt = [event tilt]; NSPoint tilt = [event tilt];
result.tilt_x = lround(tilt.x * 90); result.tilt_x = lround(tilt.x * 90);
result.tilt_y = lround(tilt.y * 90); // Pointer Events specification states that tiltY is positive when the
// pen is tilted towards the user.
// By default, in MacOS, the Y coordinate increases going up,
// while in Chromium the Y coordinate increases going down.
// https://developer.apple.com/library/archive/documentation/General/Conceptual/Devpedia-CocoaApp/CoordinateSystem.html
// In this case (if the coordinate system is not flipped) tiltY needs to
// be reversed to match Chromium's expectation that tiltY is positive
// towards the user
result.tilt_y = ([view isFlipped] ? 1 : (-1)) * lround(tilt.y * 90);
result.tangential_pressure = [event tangentialPressure]; result.tangential_pressure = [event tangentialPressure];
// NSEvent spec doesn't specify the range of rotation, we make sure that // NSEvent spec doesn't specify the range of rotation, we make sure that
// this value is in the range of [0,359]. // this value is in the range of [0,359].
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment