2 Copyright (C) 2008, 2009 Nokia Corporation and/or its subsidiary(-ies)
3 Copyright (C) 2008 Holger Hans Peter Freyther
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.
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.
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.
24 #include <qbasictimer.h>
25 #include <qnetworkproxy.h>
28 #include <qgraphicssceneevent.h>
31 #include "qwebhistory.h"
32 #include "qwebframe.h"
36 #include "PlatformString.h"
38 #include <wtf/RefPtr.h>
40 #include "ViewportArguments.h"
44 class ContextMenuClientQt;
45 class ContextMenuItem;
50 class InspectorController;
67 class QtViewportAttributesPrivate : public QSharedData {
69 QtViewportAttributesPrivate(QWebPage::ViewportAttributes* qq)
73 QWebPage::ViewportAttributes* q;
76 class QWebPagePrivate {
78 QWebPagePrivate(QWebPage*);
81 static WebCore::Page* core(const QWebPage*);
82 static QWebPagePrivate* priv(QWebPage*);
84 void createMainFrame();
85 #ifndef QT_NO_CONTEXTMENU
86 QMenu* createContextMenu(const WebCore::ContextMenu* webcoreMenu, const QList<WebCore::ContextMenuItem>* items, QBitArray* visitedWebActions);
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();
95 void timerEvent(QTimerEvent*);
97 template<class T> void mouseMoveEvent(T*);
98 template<class T> void mousePressEvent(T*);
99 template<class T> void mouseDoubleClickEvent(T*);
100 template<class T> void mouseTripleClickEvent(T*);
101 template<class T> void mouseReleaseEvent(T*);
102 #ifndef QT_NO_CONTEXTMENU
103 void contextMenuEvent(const QPoint& globalPos);
105 #ifndef QT_NO_WHEELEVENT
106 template<class T> void wheelEvent(T*);
108 void keyPressEvent(QKeyEvent*);
109 void keyReleaseEvent(QKeyEvent*);
110 void focusInEvent(QFocusEvent*);
111 void focusOutEvent(QFocusEvent*);
113 template<class T> void dragEnterEvent(T*);
114 template<class T> void dragLeaveEvent(T*);
115 template<class T> void dragMoveEvent(T*);
116 template<class T> void dropEvent(T*);
118 void inputMethodEvent(QInputMethodEvent*);
120 #ifndef QT_NO_PROPERTIES
121 void dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent*);
124 void shortcutOverrideEvent(QKeyEvent*);
125 void leaveEvent(QEvent*);
126 void handleClipboard(QEvent*, Qt::MouseButton);
127 void handleSoftwareInputPanel(Qt::MouseButton);
128 bool handleScrolling(QKeyEvent*, WebCore::Frame*);
130 // Returns whether the default action was cancelled in the JS event handler
131 bool touchEvent(QTouchEvent*);
133 class TouchAdjuster {
135 TouchAdjuster(unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
137 WebCore::IntPoint findCandidatePointForTouch(const WebCore::IntPoint&, WebCore::Document*) const;
140 unsigned m_topPadding;
141 unsigned m_rightPadding;
142 unsigned m_bottomPadding;
143 unsigned m_leftPadding;
146 void adjustPointForClicking(QMouseEvent*);
147 void adjustPointForClicking(QGraphicsSceneMouseEvent*);
149 void setInspector(QWebInspector*);
150 QWebInspector* getOrCreateInspector();
151 WebCore::InspectorController* inspectorController();
152 quint16 inspectorServerPort();
154 WebCore::ViewportArguments viewportArguments();
156 #ifndef QT_NO_SHORTCUT
157 static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
159 static const char* editorCommandForWebActions(QWebPage::WebAction action);
163 QWebPageClient* client;
164 QPointer<QWebFrame> mainFrame;
166 #ifndef QT_NO_UNDOSTACK
167 QUndoStack *undoStack;
170 QWeakPointer<QWidget> view;
173 quint64 m_totalBytes;
174 quint64 m_bytesReceived;
177 QBasicTimer tripleClickTimer;
179 bool clickCausedFocus;
181 bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
182 QNetworkAccessManager *networkManager;
184 bool forwardUnsupportedContent;
185 bool smartInsertDeleteEnabled;
186 bool selectTrailingWhitespaceEnabled;
187 QWebPage::LinkDelegationPolicy linkPolicy;
190 QSize fixedLayoutSize;
192 QWebHitTestResult hitTestResult;
193 #ifndef QT_NO_CONTEXTMENU
194 QPointer<QMenu> currentContextMenu;
196 QWebSettings *settings;
201 QAction *actions[QWebPage::WebActionCount];
203 QWebPluginFactory *pluginFactory;
205 QWidget* inspectorFrontend;
206 QWebInspector* inspector;
207 bool inspectorIsInternalOnly; // True if created through the Inspect context menu action
208 Qt::DropAction m_lastDropAction;