initial import
[vuplus_webkit] / 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 <QWeakPointer>
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 #include "PlatformString.h"
38
39 #include <wtf/OwnPtr.h>
40 #include <wtf/RefPtr.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     void timerEvent(QTimerEvent*);
98
99     template<class T> void mouseMoveEvent(T*);
100     template<class T> void mousePressEvent(T*);
101     template<class T> void mouseDoubleClickEvent(T*);
102     template<class T> void mouseTripleClickEvent(T*);
103     template<class T> void mouseReleaseEvent(T*);
104 #ifndef QT_NO_CONTEXTMENU
105     void contextMenuEvent(const QPoint& globalPos);
106 #endif
107 #ifndef QT_NO_WHEELEVENT
108     template<class T> void wheelEvent(T*);
109 #endif
110     void keyPressEvent(QKeyEvent*);
111     void keyReleaseEvent(QKeyEvent*);
112     void focusInEvent(QFocusEvent*);
113     void focusOutEvent(QFocusEvent*);
114
115     template<class T> void dragEnterEvent(T*);
116     template<class T> void dragLeaveEvent(T*);
117     template<class T> void dragMoveEvent(T*);
118     template<class T> void dropEvent(T*);
119
120     void inputMethodEvent(QInputMethodEvent*);
121
122 #ifndef QT_NO_PROPERTIES
123     void dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent*);
124 #endif
125
126     void shortcutOverrideEvent(QKeyEvent*);
127     void leaveEvent(QEvent*);
128     void handleClipboard(QEvent*, Qt::MouseButton);
129     void handleSoftwareInputPanel(Qt::MouseButton, const QPoint&);
130     bool handleScrolling(QKeyEvent*, WebCore::Frame*);
131
132     // Returns whether the default action was cancelled in the JS event handler
133     bool touchEvent(QTouchEvent*);
134
135     class TouchAdjuster {
136     public:
137         TouchAdjuster(unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
138
139         WebCore::IntPoint findCandidatePointForTouch(const WebCore::IntPoint&, WebCore::Document*) const;
140
141     private:
142         unsigned m_topPadding;
143         unsigned m_rightPadding;
144         unsigned m_bottomPadding;
145         unsigned m_leftPadding;
146     };
147
148     void adjustPointForClicking(QMouseEvent*);
149 #if !defined(QT_NO_GRAPHICSVIEW)
150     void adjustPointForClicking(QGraphicsSceneMouseEvent*);
151 #endif
152
153     void setInspector(QWebInspector*);
154     QWebInspector* getOrCreateInspector();
155     WebCore::InspectorController* inspectorController();
156     quint16 inspectorServerPort();
157
158     WebCore::ViewportArguments viewportArguments();
159
160 #ifndef QT_NO_SHORTCUT
161     static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
162 #endif
163     static const char* editorCommandForWebActions(QWebPage::WebAction action);
164
165     QWebPage *q;
166     WebCore::Page *page;
167     OwnPtr<QWebPageClient> client;
168     QWeakPointer<QWebFrame> mainFrame;
169
170 #ifndef QT_NO_UNDOSTACK
171     QUndoStack *undoStack;
172 #endif
173
174     QWeakPointer<QWidget> view;
175
176     bool insideOpenCall;
177     quint64 m_totalBytes;
178     quint64 m_bytesReceived;
179
180     QPoint tripleClick;
181     QBasicTimer tripleClickTimer;
182
183     bool clickCausedFocus;
184
185     bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
186     QNetworkAccessManager *networkManager;
187
188     bool forwardUnsupportedContent;
189     bool smartInsertDeleteEnabled;
190     bool selectTrailingWhitespaceEnabled;
191     QWebPage::LinkDelegationPolicy linkPolicy;
192
193     QSize viewportSize;
194     QSize fixedLayoutSize;
195
196     QWebHistory history;
197     QWebHitTestResult hitTestResult;
198 #ifndef QT_NO_CONTEXTMENU
199     QWeakPointer<QMenu> currentContextMenu;
200 #endif
201     QWebSettings *settings;
202     QPalette palette;
203     bool useFixedLayout;
204
205     QAction *actions[QWebPage::WebActionCount];
206
207     QWebPluginFactory *pluginFactory;
208
209     QWidget* inspectorFrontend;
210     QWebInspector* inspector;
211     bool inspectorIsInternalOnly; // True if created through the Inspect context menu action
212     Qt::DropAction m_lastDropAction;
213
214     static bool drtRun;
215 };
216
217 #endif