2 * Copyright (c) 2011, Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 #ifndef GestureRecognizerChromium_h
32 #define GestureRecognizerChromium_h
34 #include "PlatformGestureRecognizer.h"
36 #include "PlatformTouchEvent.h"
37 #include "PlatformTouchPoint.h"
38 #include <wtf/HashMap.h>
40 class InspectableGestureRecognizerChromium;
44 class PlatformGestureEvent;
46 class GestureRecognizerChromium : public PlatformGestureRecognizer {
50 PendingSyntheticClick,
56 typedef Vector<PlatformGestureEvent>* Gestures;
57 typedef bool (GestureRecognizerChromium::*GestureTransitionFunction)(const PlatformTouchPoint&, Gestures);
59 GestureRecognizerChromium();
60 ~GestureRecognizerChromium();
63 virtual PlatformGestureRecognizer::PassGestures processTouchEventForGestures(const PlatformTouchEvent&, bool defaultPrevented);
64 State state() { return m_state; }
67 friend class ::InspectableGestureRecognizerChromium;
69 static unsigned int signature(State, unsigned, PlatformTouchPoint::State, bool);
70 void addEdgeFunction(State, unsigned finger, PlatformTouchPoint::State, bool touchHandledByJavaScript, GestureTransitionFunction);
71 void appendTapDownGestureEvent(const PlatformTouchPoint&, Gestures);
72 void appendClickGestureEvent(const PlatformTouchPoint&, Gestures);
73 void appendDoubleClickGestureEvent(const PlatformTouchPoint&, Gestures);
74 void appendScrollGestureBegin(const PlatformTouchPoint&, Gestures);
75 void appendScrollGestureEnd(const PlatformTouchPoint&, Gestures);
76 void appendScrollGestureUpdate(const PlatformTouchPoint&, Gestures);
77 bool isInClickTimeWindow();
78 bool isInSecondClickTimeWindow();
79 bool isInsideManhattanSquare(const PlatformTouchPoint&);
80 void setState(State value) { m_state = value; }
81 void updateValues(double touchTime, const PlatformTouchPoint&);
83 bool click(const PlatformTouchPoint&, Gestures);
84 bool isClickOrScroll(const PlatformTouchPoint&, Gestures);
85 bool inScroll(const PlatformTouchPoint&, Gestures);
86 bool noGesture(const PlatformTouchPoint&, Gestures);
87 bool touchDown(const PlatformTouchPoint&, Gestures);
88 bool scrollEnd(const PlatformTouchPoint&, Gestures);
90 bool doubleClick(const PlatformTouchPoint&, Gestures);
91 bool maybeDoubleClick(const PlatformTouchPoint&, Gestures);
93 WTF::HashMap<int, GestureTransitionFunction> m_edgeFunctions;
94 IntPoint m_firstTouchPosition;
95 IntPoint m_firstTouchScreenPosition;
96 double m_firstTouchTime;
98 double m_lastTouchTime;
99 double m_lastClickTime;
107 } // namespace WebCore
109 #endif // GestureRecognizerChromium_h