the Chromium logo

The Chromium Projects

Gesture Recognizer

Gesture Recognizer Overview

This document describes the process by which Touch Events received by a WindowEventDispatcher are transformed into Gesture Events.

Touch Events

Gesture Events

Gesture Events contain type specific data in their GestureEventDetails object. See here for a summary of the typical event sequences.

Terminology

Finding a Target

Possible ways of establishing a target

  1. If a touch is already locked to a target, keep it.
  2. If a window is capturing touches, target that window.
  3. If it's outside the root window, target the root window.
  4. If it's near another touch, use the other touch's target.
  5. Otherwise, use whichever window the touch is above.

In the following images, a filled in circle represents a touch down, and the outline of a circle represents a position the touch has moved to. The dotted green line indicates the window that a touch is targeted at. The rounded rectangle represents a window, and the outer rectangle represents the root window.

1. If a touch is already locked to a target, keep it. image 2. If a window is capturing touches, target that window. image
3. If it's outside the root window, target the root window. image 4. If it's near another touch, use the other touch's target. image
5. Otherwise, use whichever window the touch is above. image

Complications

preventDefault’ed Release

When Javascript calls preventDefault on a touch release, we need to make sure that no gesture events are created, but we also need to ensure that the GestureRecognizer knows that the associated finger isn’t down any more. To accomplish this, we turn the touch release into a touch cancel event.

Touch Capture

When a touch capture occurs, all touches on windows other than the window gaining capture need to be ignored until they are released. To do this, we fire a touch cancel for each of these touches.

Generating Gesture Events

Each touch-id has an associated window (See GestureRecognizerImpl::touch_id_target_), and each window has an associated GestureProviderAura.

GestureProviderAura contains a FilteredGestureProvider, which is responsible for performing gesture detection on both Android and Aura.

Where To Start

GestureRecognizerImpl

GestureDetector, ScaleGestureDetector

GestureProvider