DescriptionSynthesize ctrl-wheel events on touchpad pinch
On Windows, pinch gestures on a touchpad typically sends wheel events
with the ctrlKey modifier set. This CL makes Chrome on Mac do the same
thing so that pages that are 'naturally zoomable' (eg. maps) get a
chance to override the pinch behavior before we use it to do browser
zoom. Getting browser zoom on pinch is a long standing source of
confusion for users of Google Maps. See http://goo.gl/84CTaJ for
discussion.
To be compatible with existing uses of wheel events, the deltaY value
in the wheel event is computed as -100*log(scale). So zooming in 2x is
about -70 and zooming out 2x is 70. To compute a scale factor from this
value in JavaScript use 'Math.exp(-deltaY / 100)'. See demo at
http://jsbin.com/qiyaseza/.
We expect to eventually want this change on ChromeOS as well (once
ChromeOS wires pinch up to pinch-zoom), and so this transformation
belongs in InputRouter.
The trickiest part of this change is handling the WheelEvent ACK
messages properly. If the wheel was synthesized from a
GesturePinchUpdate, we need to convert the ACK back to the right type.
To do this I attach a 'synthesized_from_pinch' bit to each
WebWheelEvent in InputRouter's coalesced_mouse_wheel_events_ and to the
current_wheel_event_. Then when I get a wheel ACK I use this bit on
current_wheel_event_ to decide how it should be handled.
This removes some old code which flushed any pending wheel events
whenever we got a non-wheel event. Doing that causes us to ignore (or
possibly misattribute) the ACKs we'll eventually get back from the
renderer for these events. This was probably already responsible for
some bugs with the Overscroll controller (which relies on
current_wheel_event representing THE event that we received an ACK for)
and would be very problematic for the pinch-derived wheels where
(since the GestureEventQueue expects to reliably get an ack per event).
I tracked this code back to http://crbug.com/154740 where it was added
to cope with the fact that we were discarding pending wheel events. I
think a better fix for that is to just continue to queue and send wheel
events, even when there are other events happening (as we do for
interleaving touch and gesture events with other events).
BUG=289887
Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=267822
Patch Set 1 #
Total comments: 5
Patch Set 2 : Fixes and basic testing #Patch Set 3 : More tests and fixes #Patch Set 4 : Fix scaling #Patch Set 5 : Refactor after discussion with jdduke #Patch Set 6 : Finished version #Patch Set 7 : Fix windows build and tweaks #
Total comments: 24
Patch Set 8 : Update conversion function #
Total comments: 2
Patch Set 9 : tweaks for jdduke CR #
Total comments: 4
Patch Set 10 : tweaks for jdduke cr #Patch Set 11 : Merge with trunk #Patch Set 12 : windows warning fixes #Patch Set 13 : Ensure scales never coalesce to 0 or Infinity #Messages
Total messages: 24 (0 generated)
|