2010-11-03 Antonio Gomes <tonikitoo@webkit.org>, Andre Pedralho <andre.pedralho...
[webkit:qtwebkit.git] / WebKit / qt / Api / qwebpage_p.h
1 /*
2     Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies)
3     Copyright (C) 2008 Holger Hans Peter Freyther
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Library General Public
7     License as published by the Free Software Foundation; either
8     version 2 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13     Library General Public License for more details.
14
15     You should have received a copy of the GNU Library General Public License
16     along with this library; see the file COPYING.LIB.  If not, write to
17     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18     Boston, MA 02110-1301, USA.
19 */
20
21 #ifndef QWEBPAGE_P_H
22 #define QWEBPAGE_P_H
23
24 #include <qbasictimer.h>
25 #include <qnetworkproxy.h>
26 #include <qpointer.h>
27 #include <qevent.h>
28 #include <qgraphicssceneevent.h>
29
30 #include "qwebpage.h"
31 #include "qwebhistory.h"
32 #include "qwebframe.h"
33
34 #include "IntPoint.h"
35 #include "KURL.h"
36 #include "PlatformString.h"
37
38 #include <wtf/RefPtr.h>
39
40 #include "ViewportArguments.h"
41
42 namespace WebCore {
43     class ChromeClientQt;
44     class ContextMenuClientQt;
45     class ContextMenuItem;
46     class ContextMenu;
47     class Document;
48     class EditorClientQt;
49     class Element;
50     class InspectorController;
51     class IntRect;
52     class Node;
53     class NodeList;
54     class Page;
55     class Frame;
56 }
57
58 QT_BEGIN_NAMESPACE
59 class QUndoStack;
60 class QMenu;
61 class QBitArray;
62 QT_END_NAMESPACE
63
64 class QWebInspector;
65 class QWebPageClient;
66
67 class QtViewportAttributesPrivate : public QSharedData {
68 public:
69     QtViewportAttributesPrivate(QWebPage::ViewportAttributes* qq)
70         : q(qq)
71     { }
72
73     QWebPage::ViewportAttributes* q;
74 };
75
76 class QWebPagePrivate {
77 public:
78     QWebPagePrivate(QWebPage*);
79     ~QWebPagePrivate();
80
81     static WebCore::Page* core(QWebPage*);
82     static QWebPagePrivate* priv(QWebPage*);
83
84     void createMainFrame();
85 #ifndef QT_NO_CONTEXTMENU
86     QMenu* createContextMenu(const WebCore::ContextMenu* webcoreMenu, const QList<WebCore::ContextMenuItem>* items, QBitArray* visitedWebActions);
87 #endif
88     void _q_onLoadProgressChanged(int);
89     void _q_webActionTriggered(bool checked);
90     void _q_cleanupLeakMessages();
91     void updateAction(QWebPage::WebAction action);
92     void updateNavigationActions();
93     void updateEditorActions();
94
95     void timerEvent(QTimerEvent*);
96
97     void mouseMoveEvent(QMouseEvent*);
98     void mouseMoveEvent(QGraphicsSceneMouseEvent*);
99     void mousePressEvent(QMouseEvent*);
100     void mousePressEvent(QGraphicsSceneMouseEvent*);
101     void mouseDoubleClickEvent(QMouseEvent*);
102     void mouseDoubleClickEvent(QGraphicsSceneMouseEvent*);
103     void mouseTripleClickEvent(QMouseEvent*);
104     void mouseTripleClickEvent(QGraphicsSceneMouseEvent*);
105     void mouseReleaseEvent(QMouseEvent*);
106     void mouseReleaseEvent(QGraphicsSceneMouseEvent*);
107 #ifndef QT_NO_CONTEXTMENU
108     void contextMenuEvent(const QPoint& globalPos);
109 #endif
110 #ifndef QT_NO_WHEELEVENT
111     void wheelEvent(QWheelEvent*);
112     void wheelEvent(QGraphicsSceneWheelEvent*);
113 #endif
114     void keyPressEvent(QKeyEvent*);
115     void keyReleaseEvent(QKeyEvent*);
116     void focusInEvent(QFocusEvent*);
117     void focusOutEvent(QFocusEvent*);
118
119     void dragEnterEvent(QDragEnterEvent*);
120     void dragEnterEvent(QGraphicsSceneDragDropEvent*);
121     void dragLeaveEvent(QDragLeaveEvent*);
122     void dragLeaveEvent(QGraphicsSceneDragDropEvent*);
123     void dragMoveEvent(QDragMoveEvent*);
124     void dragMoveEvent(QGraphicsSceneDragDropEvent*);
125     void dropEvent(QDropEvent*);
126     void dropEvent(QGraphicsSceneDragDropEvent*);
127
128     void inputMethodEvent(QInputMethodEvent*);
129
130 #ifndef QT_NO_PROPERTIES
131     void dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent*);
132 #endif
133
134     void shortcutOverrideEvent(QKeyEvent*);
135     void leaveEvent(QEvent*);
136     void handleClipboard(QEvent*, Qt::MouseButton);
137     void handleSoftwareInputPanel(Qt::MouseButton);
138     bool handleScrolling(QKeyEvent*, WebCore::Frame*);
139
140 #if QT_VERSION >= QT_VERSION_CHECK(4, 6, 0)
141     // Returns whether the default action was cancelled in the JS event handler
142     bool touchEvent(QTouchEvent*);
143 #endif
144
145     class TouchAdjuster {
146     public:
147         TouchAdjuster(unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
148
149         WebCore::IntPoint findCandidatePointForTouch(const WebCore::IntPoint&, WebCore::Document*) const;
150
151     private:
152         unsigned m_topPadding;
153         unsigned m_rightPadding;
154         unsigned m_bottomPadding;
155         unsigned m_leftPadding;
156     };
157
158     void adjustPointForClicking(QMouseEvent*);
159     void adjustPointForClicking(QGraphicsSceneMouseEvent*);
160
161     void setInspector(QWebInspector*);
162     QWebInspector* getOrCreateInspector();
163     WebCore::InspectorController* inspectorController();
164
165     WebCore::ViewportArguments viewportArguments();
166
167 #ifndef QT_NO_SHORTCUT
168     static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
169 #endif
170     static const char* editorCommandForWebActions(QWebPage::WebAction action);
171
172     WebCore::ChromeClientQt *chromeClient;
173     WebCore::ContextMenuClientQt *contextMenuClient;
174     WebCore::EditorClientQt *editorClient;
175     WebCore::Page *page;
176
177     QPointer<QWebFrame> mainFrame;
178
179     QWebPage *q;
180     QWebPageClient* client;
181 #ifndef QT_NO_UNDOSTACK
182     QUndoStack *undoStack;
183 #endif
184
185 #if QT_VERSION >= 0x040600
186     QWeakPointer<QWidget> view;
187 #else
188     QWidget* view;
189 #endif
190
191     bool insideOpenCall;
192     quint64 m_totalBytes;
193     quint64 m_bytesReceived;
194
195     QPoint tripleClick;
196     QBasicTimer tripleClickTimer;
197
198     bool clickCausedFocus;
199
200     bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
201     QNetworkAccessManager *networkManager;
202
203     bool forwardUnsupportedContent;
204     bool smartInsertDeleteEnabled;
205     bool selectTrailingWhitespaceEnabled;
206     QWebPage::LinkDelegationPolicy linkPolicy;
207
208     QSize viewportSize;
209     QSize fixedLayoutSize;
210     QWebHistory history;
211     QWebHitTestResult hitTestResult;
212 #ifndef QT_NO_CONTEXTMENU
213     QPointer<QMenu> currentContextMenu;
214 #endif
215     QWebSettings *settings;
216     QPalette palette;
217     bool editable;
218     bool useFixedLayout;
219
220     QAction *actions[QWebPage::WebActionCount];
221
222     QWebPluginFactory *pluginFactory;
223
224     QWidget* inspectorFrontend;
225     QWebInspector* inspector;
226     bool inspectorIsInternalOnly; // True if created through the Inspect context menu action
227     Qt::DropAction m_lastDropAction;
228
229     static bool drtRun;
230 };
231
232 #endif