Title: [113175] trunk/Source/WebKit2
- Revision
- 113175
- Author
- kenn...@webkit.org
- Date
- 2012-04-04 05:32:53 -0700 (Wed, 04 Apr 2012)
Log Message
[Qt] Further improvements of the tap gesture recognizer
https://bugs.webkit.org/show_bug.cgi?id=83149
Reviewed by Zoltan Herczeg.
Ignore single tap while finger is still pressed.
Some renaming to make the states more clear.
A pan further than the maxPanDistance can now invalidate
double-taps as well.
* UIProcess/qt/QtTapGestureRecognizer.cpp:
(WebKit::QtTapGestureRecognizer::QtTapGestureRecognizer):
(WebKit::QtTapGestureRecognizer::recognize):
(WebKit::QtTapGestureRecognizer::singleTapTimeout):
(WebKit::QtTapGestureRecognizer::tapAndHoldTimeout):
(WebKit::QtTapGestureRecognizer::reset):
* UIProcess/qt/QtTapGestureRecognizer.h:
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (113174 => 113175)
--- trunk/Source/WebKit2/ChangeLog 2012-04-04 12:31:28 UTC (rev 113174)
+++ trunk/Source/WebKit2/ChangeLog 2012-04-04 12:32:53 UTC (rev 113175)
@@ -1,3 +1,23 @@
+2012-04-04 Kenneth Rohde Christiansen <kenn...@webkit.org>
+
+ [Qt] Further improvements of the tap gesture recognizer
+ https://bugs.webkit.org/show_bug.cgi?id=83149
+
+ Reviewed by Zoltan Herczeg.
+
+ Ignore single tap while finger is still pressed.
+ Some renaming to make the states more clear.
+ A pan further than the maxPanDistance can now invalidate
+ double-taps as well.
+
+ * UIProcess/qt/QtTapGestureRecognizer.cpp:
+ (WebKit::QtTapGestureRecognizer::QtTapGestureRecognizer):
+ (WebKit::QtTapGestureRecognizer::recognize):
+ (WebKit::QtTapGestureRecognizer::singleTapTimeout):
+ (WebKit::QtTapGestureRecognizer::tapAndHoldTimeout):
+ (WebKit::QtTapGestureRecognizer::reset):
+ * UIProcess/qt/QtTapGestureRecognizer.h:
+
2012-04-04 Andras Becsi <andras.be...@nokia.com>
[Qt][WK2] Make the WebView a subclass of Flickable
Modified: trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp (113174 => 113175)
--- trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp 2012-04-04 12:31:28 UTC (rev 113174)
+++ trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp 2012-04-04 12:32:53 UTC (rev 113175)
@@ -33,7 +33,7 @@
QtTapGestureRecognizer::QtTapGestureRecognizer(QtWebPageEventHandler* eventHandler)
: QtGestureRecognizer(eventHandler)
- , m_tapState(NoTap)
+ , m_candidate(Invalid)
{
}
@@ -55,16 +55,15 @@
switch (event->type()) {
case QEvent::TouchBegin:
- ASSERT(m_tapState == NoTap);
m_doubleTapTimer.stop(); // Cancel other pending single tap event.
ASSERT(!m_tapAndHoldTimer.isActive());
m_tapAndHoldTimer.start(tapAndHoldTime, this);
if (m_lastTouchEvent && withinDistance(touchPoint, maxDoubleTapDistance))
- m_tapState = DoubleTapCandidate;
+ m_candidate = DoubleTapCandidate;
else {
- m_tapState = SingleTapStarted;
+ m_candidate = SingleTapCandidate;
// The below in facts resets any previous single tap event.
m_eventHandler->handlePotentialSingleTapEvent(touchPoint);
m_lastTouchEvent = adoptPtr(new QTouchEvent(*event));
@@ -74,20 +73,21 @@
case QEvent::TouchUpdate:
// If the touch point moves further than the threshold, we cancel the tap gesture.
- if (m_tapState == SingleTapStarted && !withinDistance(touchPoint, maxPanDistance))
+ if (m_candidate != Invalid && !withinDistance(touchPoint, maxPanDistance))
reset();
break;
case QEvent::TouchEnd:
m_tapAndHoldTimer.stop();
- if (m_tapState == DoubleTapCandidate && withinDistance(touchPoint, maxDoubleTapDistance))
- m_eventHandler->handleDoubleTapEvent(touchPoint);
+ if (m_candidate == Invalid)
+ break;
- if (m_tapState != NoTap)
+ if (m_candidate == DoubleTapCandidate) {
m_eventHandler->handlePotentialSingleTapEvent(QTouchEvent::TouchPoint());
+ m_eventHandler->handleDoubleTapEvent(touchPoint);
+ }
- m_tapState = NoTap;
break;
default:
@@ -99,33 +99,38 @@
void QtTapGestureRecognizer::singleTapTimeout()
{
+ // Finger is still pressed, ignore.
+ if (m_tapAndHoldTimer.isActive())
+ return;
+
ASSERT(m_lastTouchEvent);
+ const QTouchEvent::TouchPoint& touchPoint = m_lastTouchEvent->touchPoints().first();
- m_eventHandler->handlePotentialSingleTapEvent(QTouchEvent::TouchPoint());
- m_eventHandler->handleSingleTapEvent(m_lastTouchEvent->touchPoints().first());
+ if (m_candidate == SingleTapCandidate) {
+ m_eventHandler->handlePotentialSingleTapEvent(QTouchEvent::TouchPoint());
+ m_eventHandler->handleSingleTapEvent(touchPoint);
+ }
reset();
}
void QtTapGestureRecognizer::tapAndHoldTimeout()
{
ASSERT(m_lastTouchEvent);
+#if 0 // No support for synthetic context menus in WK2 yet.
+ const QTouchEvent::TouchPoint& touchPoint = m_lastTouchEvent->touchPoints().first();
m_eventHandler->handlePotentialSingleTapEvent(QTouchEvent::TouchPoint());
+ m_eventHandler->handleTapAndHoldEvent(touchPoint);
+#endif
reset();
-
-#if 0 // No support for synthetic context menus in WK2 yet.
- const QTouchEvent::TouchPoint& touchPoint = m_lastTouchEvent->touchPoints().first();
- WebGestureEvent event(WebEvent::GestureTapAndHold, touchPoint.pos().toPoint(), touchPoint.screenPos().toPoint(), WebEvent::Modifiers(0), 0);
- m_eventHandler->handleGestureEvent(event);
-#endif
}
void QtTapGestureRecognizer::reset()
{
- if (m_tapState != NoTap)
+ if (m_candidate != Invalid)
m_eventHandler->handlePotentialSingleTapEvent(QTouchEvent::TouchPoint());
- m_tapState = NoTap;
+ m_candidate = Invalid;
m_tapAndHoldTimer.stop();
m_doubleTapTimer.stop();
m_lastTouchEvent.clear();
Modified: trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h (113174 => 113175)
--- trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h 2012-04-04 12:31:28 UTC (rev 113174)
+++ trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h 2012-04-04 12:32:53 UTC (rev 113175)
@@ -63,11 +63,10 @@
OwnPtr<QTouchEvent> m_lastTouchEvent;
enum {
- NoTap,
- SingleTapStarted,
+ Invalid,
+ SingleTapCandidate,
DoubleTapCandidate,
- TapAndHold
- } m_tapState;
+ } m_candidate;
};
} // namespace WebKit
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes