Part 2 of removing PlatformString.h, remove PlatformString.h
[WebKit-https.git] / Source / 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 <QPointer>
25
26 #include <qbasictimer.h>
27 #include <qnetworkproxy.h>
28 #include <qevent.h>
29 #include <qgraphicssceneevent.h>
30
31 #include "qwebpage.h"
32 #include "qwebhistory.h"
33 #include "qwebframe.h"
34
35 #include "IntPoint.h"
36 #include "KURL.h"
37
38 #include <wtf/OwnPtr.h>
39 #include <wtf/RefPtr.h>
40 #include <wtf/text/WTFString.h>
41
42 #include "ViewportArguments.h"
43
44 namespace WebCore {
45     class ChromeClientQt;
46     class ContextMenuClientQt;
47     class ContextMenuItem;
48     class ContextMenu;
49     class Document;
50     class EditorClientQt;
51     class Element;
52     class InspectorController;
53     class IntRect;
54     class Node;
55     class NodeList;
56     class Page;
57     class Frame;
58 }
59
60 QT_BEGIN_NAMESPACE
61 class QUndoStack;
62 class QMenu;
63 class QBitArray;
64 QT_END_NAMESPACE
65
66 class QWebInspector;
67 class QWebPageClient;
68
69 class QtViewportAttributesPrivate : public QSharedData {
70 public:
71     QtViewportAttributesPrivate(QWebPage::ViewportAttributes* qq)
72         : q(qq)
73     { }
74
75     QWebPage::ViewportAttributes* q;
76 };
77
78 class QWebPagePrivate {
79 public:
80     QWebPagePrivate(QWebPage*);
81     ~QWebPagePrivate();
82
83     static WebCore::Page* core(const QWebPage*);
84     static QWebPagePrivate* priv(QWebPage*);
85
86     void createMainFrame();
87 #ifndef QT_NO_CONTEXTMENU
88     QMenu* createContextMenu(const WebCore::ContextMenu* webcoreMenu, const QList<WebCore::ContextMenuItem>* items, QBitArray* visitedWebActions);
89 #endif
90     void _q_onLoadProgressChanged(int);
91     void _q_webActionTriggered(bool checked);
92     void _q_cleanupLeakMessages();
93     void updateAction(QWebPage::WebAction action);
94     void updateNavigationActions();
95     void updateEditorActions();
96
97     QColor colorSelectionRequested(const QColor& selectedColor);
98
99     void timerEvent(QTimerEvent*);
100
101     template<class T> void mouseMoveEvent(T*);
102     template<class T> void mousePressEvent(T*);
103     template<class T> void mouseDoubleClickEvent(T*);
104     template<class T> void mouseTripleClickEvent(T*);
105     template<class T> void mouseReleaseEvent(T*);
106 #ifndef QT_NO_CONTEXTMENU
107     void contextMenuEvent(const QPoint& globalPos);
108 #endif
109 #ifndef QT_NO_WHEELEVENT
110     template<class T> void wheelEvent(T*);
111 #endif
112     void keyPressEvent(QKeyEvent*);
113     void keyReleaseEvent(QKeyEvent*);
114     void focusInEvent(QFocusEvent*);
115     void focusOutEvent(QFocusEvent*);
116
117     template<class T> void dragEnterEvent(T*);
118     template<class T> void dragLeaveEvent(T*);
119     template<class T> void dragMoveEvent(T*);
120     template<class T> void dropEvent(T*);
121
122     void inputMethodEvent(QInputMethodEvent*);
123
124 #ifndef QT_NO_PROPERTIES
125     void dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent*);
126 #endif
127
128     void shortcutOverrideEvent(QKeyEvent*);
129     void leaveEvent(QEvent*);
130     void handleClipboard(QEvent*, Qt::MouseButton);
131     void handleSoftwareInputPanel(Qt::MouseButton, const QPoint&);
132     bool handleScrolling(QKeyEvent*, WebCore::Frame*);
133
134     // Returns whether the default action was cancelled in the JS event handler
135     bool touchEvent(QTouchEvent*);
136
137     class TouchAdjuster {
138     public:
139         TouchAdjuster(unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
140
141         WebCore::IntPoint findCandidatePointForTouch(const WebCore::IntPoint&, WebCore::Document*) const;
142
143     private:
144         unsigned m_topPadding;
145         unsigned m_rightPadding;
146         unsigned m_bottomPadding;
147         unsigned m_leftPadding;
148     };
149
150     void adjustPointForClicking(QMouseEvent*);
151 #if !defined(QT_NO_GRAPHICSVIEW)
152     void adjustPointForClicking(QGraphicsSceneMouseEvent*);
153 #endif
154
155     void setInspector(QWebInspector*);
156     QWebInspector* getOrCreateInspector();
157     WebCore::InspectorController* inspectorController();
158     quint16 inspectorServerPort();
159
160     WebCore::ViewportArguments viewportArguments();
161
162 #ifndef QT_NO_SHORTCUT
163     static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
164 #endif
165     static const char* editorCommandForWebActions(QWebPage::WebAction action);
166
167     QWebPage *q;
168     WebCore::Page *page;
169     OwnPtr<QWebPageClient> client;
170     QPointer<QWebFrame> mainFrame;
171
172 #ifndef QT_NO_UNDOSTACK
173     QUndoStack *undoStack;
174 #endif
175
176     QPointer<QWidget> view;
177
178     bool insideOpenCall;
179     quint64 m_totalBytes;
180     quint64 m_bytesReceived;
181
182     QPoint tripleClick;
183     QBasicTimer tripleClickTimer;
184
185     bool clickCausedFocus;
186
187     bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
188     QNetworkAccessManager *networkManager;
189
190     bool forwardUnsupportedContent;
191     bool smartInsertDeleteEnabled;
192     bool selectTrailingWhitespaceEnabled;
193     QWebPage::LinkDelegationPolicy linkPolicy;
194
195     QSize viewportSize;
196     QSize fixedLayoutSize;
197
198     QWebHistory history;
199     QWebHitTestResult hitTestResult;
200 #ifndef QT_NO_CONTEXTMENU
201     QPointer<QMenu> currentContextMenu;
202 #endif
203     QWebSettings *settings;
204     QPalette palette;
205     bool useFixedLayout;
206
207     QAction *actions[QWebPage::WebActionCount];
208
209     QWebPluginFactory *pluginFactory;
210
211     QWidget* inspectorFrontend;
212     QWebInspector* inspector;
213     bool inspectorIsInternalOnly; // True if created through the Inspect context menu action
214     Qt::DropAction m_lastDropAction;
215
216     static bool drtRun;
217 };
218
219 #endif