Diff
Modified: trunk/Source/WebKit2/ChangeLog (101178 => 101179)
--- trunk/Source/WebKit2/ChangeLog 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/ChangeLog 2011-11-25 19:57:28 UTC (rev 101179)
@@ -1,3 +1,35 @@
+2011-11-25 Jesus Sanchez-Palencia <jesus.palen...@openbossa.org>
+
+ [Qt][WK2] Refactor GestureRecognizers to use QtWebPageEventHandler
+ https://bugs.webkit.org/show_bug.cgi?id=73096
+
+ Reviewed by Kenneth Rohde Christiansen.
+
+ Move all the interaction engine usage to QtWebPageEventHandler,
+ making all GestureRecognizers (Tap, Pinch and Pan) use it directly.
+
+ * UIProcess/qt/QtGestureRecognizer.cpp:
+ (WebKit::QtGestureRecognizer::QtGestureRecognizer):
+ * UIProcess/qt/QtGestureRecognizer.h:
+ * UIProcess/qt/QtPanGestureRecognizer.cpp:
+ (WebKit::QtPanGestureRecognizer::QtPanGestureRecognizer):
+ (WebKit::QtPanGestureRecognizer::recognize):
+ * UIProcess/qt/QtPanGestureRecognizer.h:
+ * UIProcess/qt/QtPinchGestureRecognizer.cpp:
+ (WebKit::QtPinchGestureRecognizer::QtPinchGestureRecognizer):
+ (WebKit::QtPinchGestureRecognizer::recognize):
+ * UIProcess/qt/QtPinchGestureRecognizer.h:
+ * UIProcess/qt/QtTapGestureRecognizer.cpp:
+ (WebKit::QtTapGestureRecognizer::QtTapGestureRecognizer):
+ (WebKit::QtTapGestureRecognizer::recognize):
+ (WebKit::QtTapGestureRecognizer::tapTimeout):
+ * UIProcess/qt/QtTapGestureRecognizer.h:
+ * UIProcess/qt/QtWebPageEventHandler.cpp:
+ (QtWebPageEventHandler::QtWebPageEventHandler):
+ (QtWebPageEventHandler::setViewportInteractionEngine):
+ * UIProcess/qt/QtWebPageEventHandler.h:
+ (QtWebPageEventHandler::interactionEngine):
+
2011-11-25 Caio Marcelo de Oliveira Filho <caio.olive...@openbossa.org>
[Qt] Remove unneeded declaration from QQuickWebPagePrivate
Modified: trunk/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.cpp 2011-11-25 19:57:28 UTC (rev 101179)
@@ -26,10 +26,12 @@
#include "config.h"
#include "QtGestureRecognizer.h"
+#include "QtWebPageEventHandler.h"
+
namespace WebKit {
-QtGestureRecognizer::QtGestureRecognizer(QtViewportInteractionEngine* viewportInteractionEngine)
- : m_viewportInteractionEngine(viewportInteractionEngine)
+QtGestureRecognizer::QtGestureRecognizer(QtWebPageEventHandler* eventHandler)
+ : m_eventHandler(eventHandler)
, m_state(NoGesture)
{
}
@@ -39,9 +41,9 @@
m_state = NoGesture;
}
-void QtGestureRecognizer::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
+QtViewportInteractionEngine* QtGestureRecognizer::interactionEngine()
{
- m_viewportInteractionEngine = engine;
+ return m_eventHandler->interactionEngine();
}
}
Modified: trunk/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtGestureRecognizer.h 2011-11-25 19:57:28 UTC (rev 101179)
@@ -26,6 +26,8 @@
#ifndef QtGestureRecognizer_h
#define QtGestureRecognizer_h
+class QtWebPageEventHandler;
+
namespace WebKit {
class QtViewportInteractionEngine;
@@ -35,16 +37,17 @@
bool isRecognized() const { return m_state == GestureRecognized; }
protected:
- QtGestureRecognizer(QtViewportInteractionEngine*);
- void setViewportInteractionEngine(QtViewportInteractionEngine*);
+ QtGestureRecognizer(QtWebPageEventHandler*);
void reset();
- QtViewportInteractionEngine* m_viewportInteractionEngine;
+ QtWebPageEventHandler* m_eventHandler;
enum State {
NoGesture,
GestureRecognitionStarted,
GestureRecognized
} m_state;
+
+ QtViewportInteractionEngine* interactionEngine();
};
}
Modified: trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.cpp 2011-11-25 19:57:28 UTC (rev 101179)
@@ -26,26 +26,20 @@
#include "QtPanGestureRecognizer.h"
-#include "QtViewportInteractionEngine.h"
+#include "QtWebPageEventHandler.h"
#include <QTouchEvent>
namespace WebKit {
-QtPanGestureRecognizer::QtPanGestureRecognizer(QtViewportInteractionEngine* interactionEngine)
- : QtGestureRecognizer(interactionEngine)
+QtPanGestureRecognizer::QtPanGestureRecognizer(QtWebPageEventHandler* eventHandler)
+ : QtGestureRecognizer(eventHandler)
{
reset();
}
-void QtPanGestureRecognizer::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
-{
- QtGestureRecognizer::setViewportInteractionEngine(engine);
- reset();
-}
-
bool QtPanGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTimestampMillis)
{
- if (!m_viewportInteractionEngine)
+ if (interactionEngine())
return false;
// Pan gesture always starts on TouchBegin unless the engine is suspended, or
@@ -56,7 +50,7 @@
// Having multiple touch points cancel the panning gesture.
if (event->touchPoints().size() > 1) {
if (m_state == GestureRecognized)
- m_viewportInteractionEngine->panGestureCancelled();
+ interactionEngine()->panGestureCancelled();
reset();
return false;
}
@@ -79,16 +73,16 @@
return false;
m_state = GestureRecognized;
- m_viewportInteractionEngine->panGestureStarted(touchPoint.pos(), eventTimestampMillis);
+ interactionEngine()->panGestureStarted(touchPoint.pos(), eventTimestampMillis);
}
ASSERT(m_state == GestureRecognized);
- m_viewportInteractionEngine->panGestureRequestUpdate(touchPoint.pos(), eventTimestampMillis);
+ interactionEngine()->panGestureRequestUpdate(touchPoint.pos(), eventTimestampMillis);
return true;
}
case QEvent::TouchEnd:
if (m_state == GestureRecognized) {
- m_viewportInteractionEngine->panGestureEnded(touchPoint.pos(), eventTimestampMillis);
+ interactionEngine()->panGestureEnded(touchPoint.pos(), eventTimestampMillis);
reset();
return true;
}
Modified: trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPanGestureRecognizer.h 2011-11-25 19:57:28 UTC (rev 101179)
@@ -41,8 +41,7 @@
class QtPanGestureRecognizer : public QtGestureRecognizer {
public:
- QtPanGestureRecognizer(QtViewportInteractionEngine*);
- void setViewportInteractionEngine(QtViewportInteractionEngine*);
+ QtPanGestureRecognizer(QtWebPageEventHandler*);
bool recognize(const QTouchEvent*, qint64 eventTimestampMillis);
void reset();
Modified: trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.cpp 2011-11-25 19:57:28 UTC (rev 101179)
@@ -26,7 +26,7 @@
#include "config.h"
#include "QtPinchGestureRecognizer.h"
-#include "QtViewportInteractionEngine.h"
+#include "QtWebPageEventHandler.h"
#include <QtCore/QLineF>
namespace WebKit {
@@ -49,21 +49,21 @@
return (point1.pos() + point2.pos()) / 2.0f;
}
-QtPinchGestureRecognizer::QtPinchGestureRecognizer(QtViewportInteractionEngine* interactionEngine)
- : QtGestureRecognizer(interactionEngine)
+QtPinchGestureRecognizer::QtPinchGestureRecognizer(QtWebPageEventHandler* eventHandler)
+ : QtGestureRecognizer(eventHandler)
{
reset();
}
bool QtPinchGestureRecognizer::recognize(const QTouchEvent* event)
{
- if (!m_viewportInteractionEngine)
+ if (!interactionEngine())
return false;
const QList<QTouchEvent::TouchPoint>& touchPoints = event->touchPoints();
if (touchPoints.size() < 2) {
if (m_state == GestureRecognized)
- m_viewportInteractionEngine->pinchGestureEnded();
+ interactionEngine()->pinchGestureEnded();
reset();
return false;
}
@@ -99,7 +99,7 @@
if (pinchDistance < pinchInitialTriggerDistanceThreshold)
return false;
m_state = GestureRecognized;
- m_viewportInteractionEngine->pinchGestureStarted(computePinchCenter(point1, point2));
+ interactionEngine()->pinchGestureStarted(computePinchCenter(point1, point2));
// We reset the initial position to the previous position in order to avoid the jump caused
// by skipping all the events between the beginning and when the threshold is hit.
@@ -113,14 +113,14 @@
const qreal initialSpanDistance = QLineF(m_point1.initialScreenPosition, m_point2.initialScreenPosition).length();
const qreal totalScaleFactor = currentSpanDistance / initialSpanDistance;
const QPointF touchCenterInPageViewCoordinates = computePinchCenter(point1, point2);
- m_viewportInteractionEngine->pinchGestureRequestUpdate(touchCenterInPageViewCoordinates, totalScaleFactor);
+ interactionEngine()->pinchGestureRequestUpdate(touchCenterInPageViewCoordinates, totalScaleFactor);
return true;
break;
}
break;
case QEvent::TouchEnd:
if (m_state == GestureRecognized) {
- m_viewportInteractionEngine->pinchGestureEnded();
+ interactionEngine()->pinchGestureEnded();
reset();
return true;
}
@@ -133,12 +133,6 @@
return false;
}
-void QtPinchGestureRecognizer::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
-{
- QtGestureRecognizer::setViewportInteractionEngine(engine);
- reset();
-}
-
void QtPinchGestureRecognizer::reset()
{
QtGestureRecognizer::reset();
Modified: trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtPinchGestureRecognizer.h 2011-11-25 19:57:28 UTC (rev 101179)
@@ -50,8 +50,7 @@
QPointF initialPosition;
};
- QtPinchGestureRecognizer(QtViewportInteractionEngine*);
- void setViewportInteractionEngine(QtViewportInteractionEngine*);
+ QtPinchGestureRecognizer(QtWebPageEventHandler*);
bool recognize(const QTouchEvent*);
void reset();
Modified: trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.cpp 2011-11-25 19:57:28 UTC (rev 101179)
@@ -26,26 +26,18 @@
#include "QtTapGestureRecognizer.h"
#include "QtWebPageEventHandler.h"
-#include "QtViewportInteractionEngine.h"
#include <QLineF>
#include <QTouchEvent>
namespace WebKit {
-QtTapGestureRecognizer::QtTapGestureRecognizer(QtViewportInteractionEngine* interactionEngine, QtWebPageEventHandler* eventHandler)
- : QtGestureRecognizer(interactionEngine)
- , m_eventHandler(eventHandler)
+QtTapGestureRecognizer::QtTapGestureRecognizer(QtWebPageEventHandler* eventHandler)
+ : QtGestureRecognizer(eventHandler)
, m_tapState(NoTap)
{
reset();
}
-void QtTapGestureRecognizer::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
-{
- QtGestureRecognizer::setViewportInteractionEngine(engine);
- reset();
-}
-
bool QtTapGestureRecognizer::recognize(const QTouchEvent* event, qint64 eventTimestampMillis)
{
if (event->touchPoints().size() != 1) {
Modified: trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtTapGestureRecognizer.h 2011-11-25 19:57:28 UTC (rev 101179)
@@ -49,8 +49,7 @@
class QtTapGestureRecognizer : public QObject, private QtGestureRecognizer {
public:
- QtTapGestureRecognizer(QtViewportInteractionEngine*, QtWebPageEventHandler*);
- void setViewportInteractionEngine(QtViewportInteractionEngine*);
+ QtTapGestureRecognizer(QtWebPageEventHandler*);
bool recognize(const QTouchEvent*, qint64 eventTimestampMillis);
void reset();
@@ -60,7 +59,6 @@
void tapAndHoldTimeout();
private:
- QtWebPageEventHandler* m_eventHandler;
QBasicTimer m_doubleTapTimer;
QBasicTimer m_tapAndHoldTimer;
OwnPtr<QTouchEvent> m_touchBeginEventForTap;
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.cpp 2011-11-25 19:57:28 UTC (rev 101179)
@@ -80,9 +80,9 @@
QtWebPageEventHandler::QtWebPageEventHandler(WKPageRef pageRef, WebKit::QtViewportInteractionEngine* viewportInteractionEngine)
: m_webPageProxy(toImpl(pageRef))
, m_interactionEngine(viewportInteractionEngine)
- , m_panGestureRecognizer(viewportInteractionEngine)
- , m_pinchGestureRecognizer(viewportInteractionEngine)
- , m_tapGestureRecognizer(viewportInteractionEngine, this)
+ , m_panGestureRecognizer(this)
+ , m_pinchGestureRecognizer(this)
+ , m_tapGestureRecognizer(this)
{
}
@@ -303,9 +303,6 @@
void QtWebPageEventHandler::setViewportInteractionEngine(QtViewportInteractionEngine* engine)
{
m_interactionEngine = engine;
- m_panGestureRecognizer.setViewportInteractionEngine(engine);
- m_pinchGestureRecognizer.setViewportInteractionEngine(engine);
- m_tapGestureRecognizer.setViewportInteractionEngine(engine);
}
void QtWebPageEventHandler::touchEvent(QTouchEvent* event)
Modified: trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h (101178 => 101179)
--- trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h 2011-11-25 19:26:21 UTC (rev 101178)
+++ trunk/Source/WebKit2/UIProcess/qt/QtWebPageEventHandler.h 2011-11-25 19:57:28 UTC (rev 101179)
@@ -24,6 +24,7 @@
#include "QtPanGestureRecognizer.h"
#include "QtPinchGestureRecognizer.h"
#include "QtTapGestureRecognizer.h"
+#include "QtViewportInteractionEngine.h"
#include "WebPageProxy.h"
#include <QBasicTimer>
#include <QKeyEvent>
@@ -54,6 +55,8 @@
void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
void resetGestureRecognizers();
+ QtViewportInteractionEngine* interactionEngine() { return m_interactionEngine; }
+
protected:
WebPageProxy* m_webPageProxy;
QtViewportInteractionEngine* m_interactionEngine;