Skip to content

Commit

Permalink
[Android] Cancel a fling if necessary before programmatic scrolls
Browse files Browse the repository at this point in the history
The compositor expects a fling cancellation event if the active fling is
interrupted by a new scroll sequence. For programmatic scrolls via
ContentViewCore.scrollTo, this cancellation event is never sent,
potentially confusing the compositor if a fling is active. Send the
cancellation event if a fling is potentially active.

Review URL: https://codereview.chromium.org/727963003

Cr-Commit-Position: refs/heads/master@{#304724}
  • Loading branch information
jdduke authored and Commit bot committed Nov 19, 2014
1 parent c2a475e commit afd8a4a
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,10 @@ public void scrollTo(int xPix, int yPix) {
final float dyPix = yPix - yCurrentPix;
if (dxPix != 0 || dyPix != 0) {
long time = SystemClock.uptimeMillis();
// It's a very real (and valid) possibility that a fling may still
// be active when programatically scrolling. Cancelling the fling in
// such cases ensures a consistent gesture event stream.
if (mPotentiallyActiveFlingCount > 0) nativeFlingCancel(mNativeContentViewCore, time);
nativeScrollBegin(mNativeContentViewCore, time,
xCurrentPix, yCurrentPix, -dxPix, -dyPix);
nativeScrollBy(mNativeContentViewCore,
Expand Down

0 comments on commit afd8a4a

Please sign in to comment.