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

Issue 250923004: Synthesize ctrl-wheel events on touchpad pinch (Closed)

Created:
6 years, 8 months ago by Rick Byers
Modified:
6 years, 7 months ago
Reviewers:
jdduke (slow), sadrul
CC:
chromium-reviews, jam, jdduke+watch_chromium.org, darin-cc_chromium.org
Visibility:
Public.

Description

Synthesize 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 #

Unified diffs Side-by-side diffs Delta from patch set Stats (+457 lines, -133 lines) Patch
M content/browser/renderer_host/input/gesture_event_queue_unittest.cc View 1 1 chunk +2 lines, -5 lines 0 comments Download
M content/browser/renderer_host/input/input_router_impl.h View 1 2 3 4 5 6 7 8 3 chunks +22 lines, -2 lines 0 comments Download
M content/browser/renderer_host/input/input_router_impl.cc View 1 2 3 4 5 6 7 8 9 10 11 12 9 chunks +100 lines, -42 lines 0 comments Download
M content/browser/renderer_host/input/input_router_impl_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 7 chunks +268 lines, -60 lines 0 comments Download
M content/browser/renderer_host/input/mock_input_ack_handler.h View 1 2 chunks +5 lines, -1 line 0 comments Download
M content/browser/renderer_host/input/mock_input_ack_handler.cc View 1 2 3 4 5 6 7 8 6 chunks +13 lines, -9 lines 0 comments Download
M content/browser/renderer_host/input/touch_action_filter_unittest.cc View 1 1 chunk +2 lines, -1 line 0 comments Download
M content/browser/renderer_host/render_widget_host_unittest.cc View 1 2 3 4 5 6 7 8 9 10 1 chunk +2 lines, -5 lines 0 comments Download
M content/common/input/synthetic_web_input_event_builders.h View 1 2 3 4 5 6 7 8 1 chunk +7 lines, -5 lines 0 comments Download
M content/common/input/synthetic_web_input_event_builders.cc View 1 2 3 4 5 6 7 8 1 chunk +6 lines, -3 lines 0 comments Download
M content/common/input/web_input_event_traits.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +8 lines, -0 lines 0 comments Download
M content/common/input/web_input_event_traits_unittest.cc View 1 2 3 4 5 6 7 8 9 10 11 12 3 chunks +22 lines, -0 lines 0 comments Download

Messages

Total messages: 24 (0 generated)
Rick Byers
Jared, PTAL.
6 years, 7 months ago (2014-05-01 14:24:01 UTC) #1
jdduke (slow)
I think my only worry is completely removing the wheel flush. Surely the original clearing ...
6 years, 7 months ago (2014-05-01 15:44:47 UTC) #2
jdduke (slow)
https://codereview.chromium.org/250923004/diff/1/content/browser/renderer_host/input/input_router_impl.cc File content/browser/renderer_host/input/input_router_impl.cc (right): https://codereview.chromium.org/250923004/diff/1/content/browser/renderer_host/input/input_router_impl.cc#newcode213 content/browser/renderer_host/input/input_router_impl.cc:213: // it in with other wheel events as that ...
6 years, 7 months ago (2014-05-01 16:26:01 UTC) #3
Rick Byers
On 2014/05/01 15:44:47, jdduke wrote: > I think my only worry is completely removing the ...
6 years, 7 months ago (2014-05-01 16:54:34 UTC) #4
jdduke (slow)
On 2014/05/01 16:54:34, Rick Byers wrote: > On 2014/05/01 15:44:47, jdduke wrote: > > I ...
6 years, 7 months ago (2014-05-01 17:02:13 UTC) #5
Rick Byers
On 2014/05/01 17:02:13, jdduke wrote: > On 2014/05/01 16:54:34, Rick Byers wrote: > > On ...
6 years, 7 months ago (2014-05-01 17:32:03 UTC) #6
Rick Byers
Thanks. https://codereview.chromium.org/250923004/diff/1/content/browser/renderer_host/input/input_router_impl.cc File content/browser/renderer_host/input/input_router_impl.cc (right): https://codereview.chromium.org/250923004/diff/1/content/browser/renderer_host/input/input_router_impl.cc#newcode213 content/browser/renderer_host/input/input_router_impl.cc:213: // it in with other wheel events as ...
6 years, 7 months ago (2014-05-01 17:34:56 UTC) #7
jdduke (slow)
This lgtm with a couple nits and assuming it works as originally desired with Google ...
6 years, 7 months ago (2014-05-01 17:53:26 UTC) #8
Rick Byers
> This lgtm with a couple nits and assuming it works as originally desired with ...
6 years, 7 months ago (2014-05-01 18:11:43 UTC) #9
jdduke (slow)
https://codereview.chromium.org/250923004/diff/150001/content/browser/renderer_host/input/input_router_impl.cc File content/browser/renderer_host/input/input_router_impl.cc (right): https://codereview.chromium.org/250923004/diff/150001/content/browser/renderer_host/input/input_router_impl.cc#newcode540 content/browser/renderer_host/input/input_router_impl.cc:540: DCHECK(pinch_event.event.data.pinchUpdate.scale >= 0); On 2014/05/01 18:11:44, Rick Byers wrote: ...
6 years, 7 months ago (2014-05-01 18:51:19 UTC) #10
Rick Byers
On 2014/05/01 18:51:19, jdduke wrote: > https://codereview.chromium.org/250923004/diff/150001/content/browser/renderer_host/input/input_router_impl.cc > File content/browser/renderer_host/input/input_router_impl.cc (right): > > https://codereview.chromium.org/250923004/diff/150001/content/browser/renderer_host/input/input_router_impl.cc#newcode540 > ...
6 years, 7 months ago (2014-05-01 19:54:36 UTC) #11
jdduke (slow)
epsilon check lgtm, thanks.
6 years, 7 months ago (2014-05-01 19:58:13 UTC) #12
sadrul
lgtm
6 years, 7 months ago (2014-05-02 01:46:12 UTC) #13
jdduke (slow)
So I was reading through the referenced bug where you describe generating a synthetic wheel ...
6 years, 7 months ago (2014-05-02 01:57:47 UTC) #14
jdduke (slow)
On 2014/05/02 01:57:47, jdduke wrote: > So I was reading through the referenced bug where ...
6 years, 7 months ago (2014-05-02 02:09:47 UTC) #15
jdduke (slow)
On 2014/05/02 02:09:47, jdduke wrote: > On 2014/05/02 01:57:47, jdduke wrote: > > So I ...
6 years, 7 months ago (2014-05-02 03:04:08 UTC) #16
Rick Byers
On 2014/05/02 02:09:47, jdduke wrote: > On 2014/05/02 01:57:47, jdduke wrote: > > So I ...
6 years, 7 months ago (2014-05-02 03:15:22 UTC) #17
Rick Byers
The CQ bit was checked by rbyers@chromium.org
6 years, 7 months ago (2014-05-02 03:30:20 UTC) #18
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rbyers@chromium.org/250923004/220001
6 years, 7 months ago (2014-05-02 03:30:50 UTC) #19
commit-bot: I haz the power
The CQ bit was unchecked by commit-bot@chromium.org
6 years, 7 months ago (2014-05-02 03:53:52 UTC) #20
commit-bot: I haz the power
Try jobs failed on following builders: linux_chromium_chromeos_rel on tryserver.chromium
6 years, 7 months ago (2014-05-02 03:53:53 UTC) #21
Rick Byers
The CQ bit was checked by rbyers@chromium.org
6 years, 7 months ago (2014-05-02 11:30:18 UTC) #22
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-status.appspot.com/cq/rbyers@chromium.org/250923004/220001
6 years, 7 months ago (2014-05-02 11:30:36 UTC) #23
commit-bot: I haz the power
6 years, 7 months ago (2014-05-02 17:00:03 UTC) #24
Message was sent while issue was closed.
Change committed as 267822

Powered by Google App Engine
This is Rietveld 408576698