• David Bokan's avatar
    Make synthetic pinch zooms accurate · 67a4a779
    David Bokan authored
    This patch makes synthetic pinch zoom gestures zoom to the correct
    scale. We do this by fixing two bugs in the scale gesture detector.
    
    The first is error due to touch slop. Slop is the amount that the touch
    points must move before the zoom gesture is activated. Unfortunately,
    the gesture recognizer drops the entire event that crosses the slop
    threshold.
    
    The second issue is similar but has to do with the minimum scaling
    span. The "span" is the distance between the two fingers in the pinch
    gesture. The minimum scaling span is the span at which point making
    the span smaller doesn't change the zoom level. Similarly to slop,
    the event that crosses this threshold is entirely dropped. At high
    speeds this resulted in losing a significant amount of delta.
    
    This CL fixes these issues by modifying the prev_span_ field on the
    first event that initiates a scale to be at the threshold, thus
    contributing the delta beyond it.
    
    I moved the reset and end that happens when a zoom out crosses
    the min span threshold to happen after we send an update, which allows
    us to send the final delta, clamped to the min span, before ending the
    gesture. I also start a pinch-zoom if the initial span is large enough
    but the first update causes us to cross this threshold. This means a
    single update can cuase a PinchBegin, PinchUpdate, PinchEnd.
    
    It also fixes existing tests that didn't expect that the first touch
    move that initiates a pinch zoom would also include a gesture pinch
    update.
    
    Bug: 610021
    Change-Id: I22e2ff8d4b89f5da67ab102658175dbb5f2b2cec
    Reviewed-on: https://chromium-review.googlesource.com/784213
    Commit-Queue: David Bokan <bokan@chromium.org>
    Reviewed-by: default avatarTimothy Dresser <tdresser@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#525348}
    67a4a779
gesture_provider.cc 34.5 KB