1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 package org.chromium.content_public.browser;
6 
7 /**
8  * An interface that is notified of events and state changes related to gesture processing
9  * from content layer.
10  */
11 public interface GestureStateListener {
12     /**
13      * Called when the pinch gesture starts.
14      */
onPinchStarted()15     public default void onPinchStarted() {}
16 
17     /**
18      * Called when the pinch gesture ends.
19      */
onPinchEnded()20     public default void onPinchEnded() {}
21 
22     /**
23      * Called when a fling starts.
24      */
onFlingStartGesture(int scrollOffsetY, int scrollExtentY)25     public default void onFlingStartGesture(int scrollOffsetY, int scrollExtentY) {}
26 
27     /**
28      * Called when a fling has ended.
29      */
onFlingEndGesture(int scrollOffsetY, int scrollExtentY)30     public default void onFlingEndGesture(int scrollOffsetY, int scrollExtentY) {}
31 
32     /**
33      * Called to indicate that a scroll update gesture had been consumed by the page.
34      * This callback is called whenever any layer is scrolled (like a frame or div). It is
35      * not called when a JS touch handler consumes the event (preventDefault), it is not called
36      * for JS-initiated scrolling.
37      */
onScrollUpdateGestureConsumed()38     public default void onScrollUpdateGestureConsumed() {}
39 
40     /**
41      * Called when a scroll gesture has started.
42      */
onScrollStarted(int scrollOffsetY, int scrollExtentY)43     public default void onScrollStarted(int scrollOffsetY, int scrollExtentY) {}
44 
45     /**
46      * Called when a scroll gesture has stopped.
47      */
onScrollEnded(int scrollOffsetY, int scrollExtentY)48     public default void onScrollEnded(int scrollOffsetY, int scrollExtentY) {}
49 
50     /**
51      * Called when the min or max scale factor may have been changed.
52      */
onScaleLimitsChanged(float minPageScaleFactor, float maxPageScaleFactor)53     public default void onScaleLimitsChanged(float minPageScaleFactor, float maxPageScaleFactor) {}
54 
55     /**
56      * Called at the beginning of any kind of touch event when the user's finger first touches down
57      * onto the screen.  The resulting gesture may be a single tap, long-press, or scroll.
58      */
onTouchDown()59     public default void onTouchDown() {}
60 
61     /**
62      * Called after a single-tap gesture event was dispatched to the renderer,
63      * indicating whether or not the gesture was consumed.
64      */
onSingleTap(boolean consumed)65     public default void onSingleTap(boolean consumed) {}
66 
67     /**
68      * Called after a single-tap gesture event was processed by the renderer,
69      * but was not handled.
70      */
onShowUnhandledTapUIIfNeeded(int x, int y)71     public default void onShowUnhandledTapUIIfNeeded(int x, int y) {}
72 
73     /**
74      * Called when the gesture source loses window focus.
75      */
onWindowFocusChanged(boolean hasWindowFocus)76     public default void onWindowFocusChanged(boolean hasWindowFocus) {}
77 
78     /**
79      * Called when a long press gesture event was processed by the rendereer.
80      */
onLongPress()81     public default void onLongPress() {}
82 
83     /**
84      * Called when the gesture source is being destroyed.
85      */
onDestroyed()86     public default void onDestroyed() {}
87 }
88