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 <QWeakPointer>
26 #include <qbasictimer.h>
27 #include <qnetworkproxy.h>
29 #include <qgraphicssceneevent.h>
32 #include "qwebhistory.h"
33 #include "qwebframe.h"
37 #include "PlatformString.h"
39 #include <wtf/OwnPtr.h>
40 #include <wtf/RefPtr.h>
42 #include "ViewportArguments.h"
46 class ContextMenuClientQt;
47 class ContextMenuItem;
52 class InspectorController;
69 class QtViewportAttributesPrivate : public QSharedData {
71 QtViewportAttributesPrivate(QWebPage::ViewportAttributes* qq)
75 QWebPage::ViewportAttributes* q;
78 class QWebPagePrivate {
80 QWebPagePrivate(QWebPage*);
83 static WebCore::Page* core(const QWebPage*);
84 static QWebPagePrivate* priv(QWebPage*);
86 void createMainFrame();
87 #ifndef QT_NO_CONTEXTMENU
88 QMenu* createContextMenu(const WebCore::ContextMenu* webcoreMenu, const QList<WebCore::ContextMenuItem>* items, QBitArray* visitedWebActions);
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();
97 void timerEvent(QTimerEvent*);
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);
107 #ifndef QT_NO_WHEELEVENT
108 template<class T> void wheelEvent(T*);
110 void keyPressEvent(QKeyEvent*);
111 void keyReleaseEvent(QKeyEvent*);
112 void focusInEvent(QFocusEvent*);
113 void focusOutEvent(QFocusEvent*);
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*);
120 void inputMethodEvent(QInputMethodEvent*);
122 #ifndef QT_NO_PROPERTIES
123 void dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent*);
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*);
132 // Returns whether the default action was cancelled in the JS event handler
133 bool touchEvent(QTouchEvent*);
135 class TouchAdjuster {
137 TouchAdjuster(unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
139 WebCore::IntPoint findCandidatePointForTouch(const WebCore::IntPoint&, WebCore::Document*) const;
142 unsigned m_topPadding;
143 unsigned m_rightPadding;
144 unsigned m_bottomPadding;
145 unsigned m_leftPadding;
148 void adjustPointForClicking(QMouseEvent*);
149 #if !defined(QT_NO_GRAPHICSVIEW)
150 void adjustPointForClicking(QGraphicsSceneMouseEvent*);
153 void setInspector(QWebInspector*);
154 QWebInspector* getOrCreateInspector();
155 WebCore::InspectorController* inspectorController();
156 quint16 inspectorServerPort();
158 WebCore::ViewportArguments viewportArguments();
160 #ifndef QT_NO_SHORTCUT
161 static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
163 static const char* editorCommandForWebActions(QWebPage::WebAction action);
167 OwnPtr<QWebPageClient> client;
168 QWeakPointer<QWebFrame> mainFrame;
170 #ifndef QT_NO_UNDOSTACK
171 QUndoStack *undoStack;
174 QWeakPointer<QWidget> view;
177 quint64 m_totalBytes;
178 quint64 m_bytesReceived;
181 QBasicTimer tripleClickTimer;
183 bool clickCausedFocus;
185 bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
186 QNetworkAccessManager *networkManager;
188 bool forwardUnsupportedContent;
189 bool smartInsertDeleteEnabled;
190 bool selectTrailingWhitespaceEnabled;
191 QWebPage::LinkDelegationPolicy linkPolicy;
194 QSize fixedLayoutSize;
197 QWebHitTestResult hitTestResult;
198 #ifndef QT_NO_CONTEXTMENU
199 QWeakPointer<QMenu> currentContextMenu;
201 QWebSettings *settings;
205 QAction *actions[QWebPage::WebActionCount];
207 QWebPluginFactory *pluginFactory;
209 QWidget* inspectorFrontend;
210 QWebInspector* inspector;
211 bool inspectorIsInternalOnly; // True if created through the Inspect context menu action
212 Qt::DropAction m_lastDropAction;