[Qt][WK2] Move startDrag implementation to QtWebPageEventHandler
[WebKit.git] / Source / WebKit2 / UIProcess / qt / QtWebPageEventHandler.h
1 /*
2  * Copyright (C) 2010, 2011 Nokia Corporation and/or its subsidiary(-ies)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this program; see the file COPYING.LIB.  If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  *
19  */
20
21 #ifndef QtWebPageEventHandler_h
22 #define QtWebPageEventHandler_h
23
24 #include "QtPanGestureRecognizer.h"
25 #include "QtPinchGestureRecognizer.h"
26 #include "QtTapGestureRecognizer.h"
27 #include "QtViewportInteractionEngine.h"
28 #include "WebPageProxy.h"
29 #include <QBasicTimer>
30 #include <QKeyEvent>
31 #include <QTouchEvent>
32 #include <WKPage.h>
33
34 class QQuickWebView;
35
36 using namespace WebKit;
37
38 class QtWebPageEventHandler : public QObject {
39     Q_OBJECT
40
41 public:
42     QtWebPageEventHandler(WKPageRef, QQuickWebView*, WebKit::QtViewportInteractionEngine* = 0);
43     ~QtWebPageEventHandler();
44
45     bool handleEvent(QEvent*);
46
47     void setViewportInteractionEngine(QtViewportInteractionEngine*);
48
49     void handleSingleTapEvent(const QTouchEvent::TouchPoint&);
50     void handleDoubleTapEvent(const QTouchEvent::TouchPoint&);
51
52     void didFindZoomableArea(const WebCore::IntPoint& target, const WebCore::IntRect& area);
53     void focusEditableArea(const WebCore::IntRect& caret, const WebCore::IntRect& area);
54     void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
55     void resetGestureRecognizers();
56
57     QtViewportInteractionEngine* interactionEngine() { return m_interactionEngine; }
58
59     void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
60
61 protected:
62     WebPageProxy* m_webPageProxy;
63     QtViewportInteractionEngine* m_interactionEngine;
64     QtPanGestureRecognizer m_panGestureRecognizer;
65     QtPinchGestureRecognizer m_pinchGestureRecognizer;
66     QtTapGestureRecognizer m_tapGestureRecognizer;
67     QQuickWebView* m_webView;
68
69 private:
70     bool handleKeyPressEvent(QKeyEvent*);
71     bool handleKeyReleaseEvent(QKeyEvent*);
72     bool handleFocusInEvent(QFocusEvent*);
73     bool handleFocusOutEvent(QFocusEvent*);
74     bool handleMouseMoveEvent(QMouseEvent*);
75     bool handleMousePressEvent(QMouseEvent*);
76     bool handleMouseReleaseEvent(QMouseEvent*);
77     bool handleWheelEvent(QWheelEvent*);
78     bool handleHoverLeaveEvent(QHoverEvent*);
79     bool handleHoverMoveEvent(QHoverEvent*);
80     bool handleDragEnterEvent(QDragEnterEvent*);
81     bool handleDragLeaveEvent(QDragLeaveEvent*);
82     bool handleDragMoveEvent(QDragMoveEvent*);
83     bool handleDropEvent(QDropEvent*);
84
85     void timerEvent(QTimerEvent*);
86
87     void touchEvent(QTouchEvent*);
88
89     QPoint m_lastClick;
90     QBasicTimer m_clickTimer;
91     Qt::MouseButton m_previousClickButton;
92     int m_clickCount;
93 };
94
95 #endif /* QtWebPageEventHandler_h */