ImmediateInterpreter: Reset tap state machine during scroll

This patch is a workaround for a subtle, complicated issue. Currently,
the tap state machine and the scroll engine independently check motion
against a threshold.

The tap state machine checks motion to determine whether or not to cancel
a tap.

The scroll engine checks distances twice; once to determine whether or
not to scroll, and again a second time to determine in which direction
to scroll, and by how much.

A recent change added a WARP flag check to the tap motion determination
(if WARP is set, then ignore that axis when computing total motion).
The final scroll "which direction and how much" check also uses the WARP
flags.

However, the "should we scroll, move or do nothing" check, does NOT use
WARP. Thus, a big, but WARP'ed move may cause a scroll to be generated
even though that (WARP'ed) component of the scroll will actually be
surpressed. In other words, a large WARP'ed horizontal scroll with a
tiny vertical component will result in a small vertical scroll - even if
that vertical component, by itself, should not have been a scroll in the
first place. Also, if this happened as part of a very short scroll, the
tap state machine would not see this as motion, and might generate a
Tap! This leads to a bizarre sequence of three getures: a small veritcal
scroll, its fling, and then a two-finger tap.

This scenario is actually relatively easy to generate using the Cr48
semi-mt trackpad with the current SemiMt filter by doing a large quick
horizontal scroll since, when the upper finger crosses the original
position of the lower finger, the SemiMt filter does a "finger pattern
swap", and sets the X warp flag for the hwstate with large horizontal
motion.

The workaround in this patch uses the fact that such a gesture will
still be a scroll (albeit a small scroll in the wrong axis), and makes
sure that it doesn't also generate a two finger tap.

BUG=chromium-os:32026
TEST=unittest

Reviewed-on: https://gerrit.chromium.org/gerrit/25822
Commit-Ready: Chung-yih Wang <cywang@chromium.org>
Reviewed-by: Chung-yih Wang <cywang@chromium.org>
Tested-by: Chung-yih Wang <cywang@chromium.org>
(cherry picked from commit cbcd3695c371ba0ea41c9807d35801d26dab603f)

Change-Id: I53288ee07c4fb644fbadf1c9ae94770da2166287
Reviewed-on: https://gerrit.chromium.org/gerrit/26196
Reviewed-by: Chung-yih Wang <cywang@chromium.org>
Reviewed-by: Andrew de los Reyes <adlr@chromium.org>
Reviewed-by: Daniel Kurtz <djkurtz@chromium.org>
Tested-by: Daniel Kurtz <djkurtz@chromium.org>
3 files changed