[Qt][WK2] Commit the preedit string in the input method when focus is about to be...
[WebKit-https.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 <QBasicTimer>
28 #include <QTouchEvent>
29 #include <WKPage.h>
30 #include <wtf/PassRefPtr.h>
31
32 QT_BEGIN_NAMESPACE
33 class QInputMethodEvent;
34 class QKeyEvent;
35 QT_END_NAMESPACE
36
37 class QQuickWebPage;
38 class QQuickWebView;
39
40 namespace WebCore {
41 class DragData;
42 class IntPoint;
43 class IntRect;
44 }
45
46 namespace WebKit {
47
48 class NativeWebTouchEvent;
49 class PageViewportControllerClientQt;
50 class ShareableBitmap;
51 class WebGestureEvent;
52 class WebPageProxy;
53
54 class QtWebPageEventHandler : public QObject {
55     Q_OBJECT
56
57 public:
58     QtWebPageEventHandler(WKPageRef, QQuickWebPage*, QQuickWebView*);
59     ~QtWebPageEventHandler();
60
61     void handleKeyPressEvent(QKeyEvent*);
62     void handleKeyReleaseEvent(QKeyEvent*);
63     void handleFocusInEvent(QFocusEvent*);
64     void handleFocusLost();
65     void handleMouseMoveEvent(QMouseEvent*);
66     void handleMousePressEvent(QMouseEvent*);
67     void handleMouseReleaseEvent(QMouseEvent*);
68     void handleWheelEvent(QWheelEvent*);
69     void handleHoverLeaveEvent(QHoverEvent*);
70     void handleHoverMoveEvent(QHoverEvent*);
71     void handleDragEnterEvent(QDragEnterEvent*);
72     void handleDragLeaveEvent(QDragLeaveEvent*);
73     void handleDragMoveEvent(QDragMoveEvent*);
74     void handleDropEvent(QDropEvent*);
75     void handleInputMethodEvent(QInputMethodEvent*);
76     void handleTouchEvent(QTouchEvent*);
77
78     void setViewportController(PageViewportControllerClientQt*);
79
80     void activateTapHighlight(const QTouchEvent::TouchPoint&);
81     void deactivateTapHighlight();
82     void handleSingleTapEvent(const QTouchEvent::TouchPoint&);
83     void handleDoubleTapEvent(const QTouchEvent::TouchPoint&);
84
85     void didFindZoomableArea(const WebCore::IntPoint& target, const WebCore::IntRect& area);
86     void updateTextInputState();
87     void doneWithGestureEvent(const WebGestureEvent& event, bool wasEventHandled);
88 #if ENABLE(TOUCH_EVENTS)
89     void doneWithTouchEvent(const NativeWebTouchEvent&, bool wasEventHandled);
90 #endif
91     void handleInputEvent(const QInputEvent*);
92     void handleWillSetInputMethodState();
93     void resetGestureRecognizers();
94
95     PageViewportControllerClientQt* viewportController() { return m_viewportController; }
96
97     void startDrag(const WebCore::DragData&, PassRefPtr<ShareableBitmap> dragImage);
98
99 protected:
100     WebPageProxy* m_webPageProxy;
101     PageViewportControllerClientQt* m_viewportController;
102     QtPanGestureRecognizer m_panGestureRecognizer;
103     QtPinchGestureRecognizer m_pinchGestureRecognizer;
104     QtTapGestureRecognizer m_tapGestureRecognizer;
105     QQuickWebPage* m_webPage;
106     QQuickWebView* m_webView;
107
108 private Q_SLOTS:
109     void inputPanelVisibleChanged();
110
111 private:
112     void timerEvent(QTimerEvent*);
113
114     QPointF m_lastClick;
115     QBasicTimer m_clickTimer;
116     Qt::MouseButton m_previousClickButton;
117     int m_clickCount;
118     bool m_postponeTextInputStateChanged;
119     bool m_isTapHighlightActive;
120     bool m_isMouseButtonPressed;
121 };
122
123 } // namespace WebKit
124
125 #endif /* QtWebPageEventHandler_h */