Skip to content

Instantly share code, notes, and snippets.

@kenchris
Created March 22, 2012 09:25
Show Gist options
  • Save kenchris/2157308 to your computer and use it in GitHub Desktop.
Save kenchris/2157308 to your computer and use it in GitHub Desktop.
diff --git a/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp
index 431f8d8..eaa6ed9 100644
--- a/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp
@@ -75,6 +75,7 @@ bool QtPanGestureRecognizer::recognize(const QTouchEvent* event)
return false;
m_state = GestureRecognized;
+ interactionEngine()->cancelScrollAnimation();
ASSERT(m_touchBegin);
interactionEngine()->panGestureStarted(m_touchBegin.data());
}
diff --git a/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp
index 7699ad3..36c63de 100644
--- a/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp
@@ -99,6 +99,7 @@ bool QtPinchGestureRecognizer::recognize(const QTouchEvent* event)
if (pinchDistance < pinchInitialTriggerDistanceThreshold)
return false;
m_state = GestureRecognized;
+ interactionEngine()->cancelScrollAnimation();
interactionEngine()->pinchGestureStarted(computePinchCenter(point1, point2));
// We reset the initial position to the previous position in order to avoid the jump caused
diff --git a/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp b/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp
index 7032220..d431bd3 100644
--- a/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp
@@ -52,7 +52,7 @@ bool QtTapGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTim
m_tapAndHoldTimer.start(tapAndHoldTime, this);
if (m_doubleTapTimer.isActive()) {
- // Might be double tap.
+ // Double tap candidate.
ASSERT(m_touchBeginEventForTap);
m_doubleTapTimer.stop();
QPointF lastPosition = m_touchBeginEventForTap->touchPoints().first().screenPos();
@@ -61,11 +61,12 @@ bool QtTapGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTim
m_tapState = DoubleTapCandidate;
else {
// Received a new tap, that is unrelated to the previous one.
- tapTimeout();
+ m_eventHandler->handlePotentialSingleTapEvent(QTouchEvent::TouchPoint());
m_tapState = SingleTapStarted;
}
} else
m_tapState = SingleTapStarted;
+
m_touchBeginEventForTap = adoptPtr(new QTouchEvent(*event));
if (m_tapState == SingleTapStarted) {
diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp
index 2ffafd7..6430dda 100644
--- a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.cpp
@@ -218,6 +218,11 @@ void QtViewportInteractionEngine::flickableMoveEnded()
disconnect(m_flickProvider, SIGNAL(contentYChanged()), this, SLOT(flickableMovingPositionUpdate()));
}
+bool QtViewportInteractionEngine::flickableMoveActive()
+{
+ return m_flickProvider->isMoving();
+}
+
void QtViewportInteractionEngine::flickableMovingPositionUpdate()
{
QPointF newPosition = m_flickProvider->contentPos();
diff --git a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
index b66defd..52acb5a 100644
--- a/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
+++ b/Source/WebKit2/UIProcess/qt/QtViewportInteractionEngine.h
@@ -100,6 +100,8 @@ public:
const Constraints& constraints() const { return m_constraints; }
qreal currentCSSScale();
+ bool flickableMoveActive();
+
Q_SIGNALS:
void contentSuspendRequested();
void contentResumeRequested();
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp
index 280b99c..407f61d 100644
--- a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp
@@ -97,6 +97,7 @@ QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, QQuickWebPage* q
, m_previousClickButton(Qt::NoButton)
, m_clickCount(0)
, m_postponeTextInputStateChanged(false)
+ , m_hasNoPotentialActivationHighlight(true)
{
connect(qApp->inputPanel(), SIGNAL(visibleChanged()), this, SLOT(inputPanelVisibleChanged()));
}
@@ -232,11 +233,17 @@ void QtWebPageEventHandler::handleDropEvent(QDropEvent* ev)
void QtWebPageEventHandler::handlePotentialSingleTapEvent(const QTouchEvent::TouchPoint& point)
{
#if ENABLE(TOUCH_EVENTS)
- if (point.pos() == QPointF()) {
- // An empty point deactivates the highlighting.
+ // An empty point deactivates the highlighting.
+ bool shouldCancel = point.pos() == QPointF();
+
+ if (shouldCancel && !m_hasNoPotentialActivationHighlight)
m_webPageProxy->handlePotentialActivation(IntPoint(), IntSize());
- } else {
+
+ m_hasNoPotentialActivationHighlight = shouldCancel;
+
+ if (!shouldCancel) {
QTransform fromItemTransform = m_webPage->transformFromItem();
+ m_hasNoPotentialActivationHighlight = false;
m_webPageProxy->handlePotentialActivation(IntPoint(fromItemTransform.map(point.pos()).toPoint()), IntSize(point.rect().size().toSize()));
}
#else
@@ -466,19 +473,27 @@ void QtWebPageEventHandler::doneWithTouchEvent(const NativeWebTouchEvent& event,
// If the scale animation is active we don't pass the event to the recognizers. In the future
// we would want to queue the event here and repost then when the animation ends.
- if (m_interactionEngine->scaleAnimationActive())
+ if (m_interactionEngine->scaleAnimationActive()) {
+ resetGestureRecognizers();
return;
+ }
- m_panGestureRecognizer.recognize(ev);
- m_pinchGestureRecognizer.recognize(ev);
+ // Upon recognition the following recognizers cancels any kinetic scrolling.
+ bool wasRecognized = false;
+ wasRecognized |= m_pinchGestureRecognizer.recognize(ev);
+ wasRecognized |= m_panGestureRecognizer.recognize(ev);
- if (m_panGestureRecognizer.isRecognized() || m_pinchGestureRecognizer.isRecognized())
+ if (wasRecognized || m_interactionEngine->flickableMoveActive()) {
+ // We need to reset the tap recognizer if something else was recognized to ignore
+ // queued single taps and future double taps.
m_tapGestureRecognizer.reset();
- else {
- // Convert the event timestamp from second to millisecond.
- qint64 eventTimestampMillis = static_cast<qint64>(event.timestamp() * 1000);
- m_tapGestureRecognizer.recognize(ev, eventTimestampMillis);
+ return;
}
+
+ // Convert the event timestamp from second to millisecond.
+ qint64 eventTimestampMillis = static_cast<qint64>(event.timestamp() * 1000);
+
+ m_tapGestureRecognizer.recognize(ev, eventTimestampMillis);
}
#endif
diff --git a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h
index 2040d28..346132c 100644
--- a/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h
+++ b/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h
@@ -98,6 +98,7 @@ private:
Qt::MouseButton m_previousClickButton;
int m_clickCount;
bool m_postponeTextInputStateChanged;
+ bool m_hasNoPotentialActivationHighlight;
};
#endif /* QtWebPageEventHandler_h */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment