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