OSDN Git Service

Merge WebKit at r71558: Initial merge by git.
[android-x86/external-webkit.git] / 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 <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/RefPtr.h>
39
40 #include "ViewportArguments.h"
41
42 namespace WebCore {
43     class ChromeClientQt;
44     class ContextMenuClientQt;
45     class ContextMenuItem;
46     class ContextMenu;
47     class Document;
48     class EditorClientQt;
49     class Element;
50     class InspectorController;
51     class IntRect;
52     class Node;
53     class NodeList;
54     class Page;
55     class Frame;
56 }
57
58 QT_BEGIN_NAMESPACE
59 class QUndoStack;
60 class QMenu;
61 class QBitArray;
62 QT_END_NAMESPACE
63
64 class QWebInspector;
65 class QWebPageClient;
66
67 class QtViewportAttributesPrivate : public QSharedData {
68 public:
69     QtViewportAttributesPrivate(QWebPage::ViewportAttributes* qq)
70         : q(qq)
71     { }
72
73     QWebPage::ViewportAttributes* q;
74 };
75
76 class QWebPagePrivate {
77 public:
78     QWebPagePrivate(QWebPage*);
79     ~QWebPagePrivate();
80
81     static WebCore::Page* core(const QWebPage*);
82     static QWebPagePrivate* priv(QWebPage*);
83
84     void createMainFrame();
85 #ifndef QT_NO_CONTEXTMENU
86     QMenu* createContextMenu(const WebCore::ContextMenu* webcoreMenu, const QList<WebCore::ContextMenuItem>* items, QBitArray* visitedWebActions);
87 #endif
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();
94
95     void timerEvent(QTimerEvent*);
96
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);
104 #endif
105 #ifndef QT_NO_WHEELEVENT
106     template<class T> void wheelEvent(T*);
107 #endif
108     void keyPressEvent(QKeyEvent*);
109     void keyReleaseEvent(QKeyEvent*);
110     void focusInEvent(QFocusEvent*);
111     void focusOutEvent(QFocusEvent*);
112
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*);
117
118     void inputMethodEvent(QInputMethodEvent*);
119
120 #ifndef QT_NO_PROPERTIES
121     void dynamicPropertyChangeEvent(QDynamicPropertyChangeEvent*);
122 #endif
123
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*);
129
130     // Returns whether the default action was cancelled in the JS event handler
131     bool touchEvent(QTouchEvent*);
132
133     class TouchAdjuster {
134     public:
135         TouchAdjuster(unsigned topPadding, unsigned rightPadding, unsigned bottomPadding, unsigned leftPadding);
136
137         WebCore::IntPoint findCandidatePointForTouch(const WebCore::IntPoint&, WebCore::Document*) const;
138
139     private:
140         unsigned m_topPadding;
141         unsigned m_rightPadding;
142         unsigned m_bottomPadding;
143         unsigned m_leftPadding;
144     };
145
146     void adjustPointForClicking(QMouseEvent*);
147     void adjustPointForClicking(QGraphicsSceneMouseEvent*);
148
149     void setInspector(QWebInspector*);
150     QWebInspector* getOrCreateInspector();
151     WebCore::InspectorController* inspectorController();
152     quint16 inspectorServerPort();
153
154     WebCore::ViewportArguments viewportArguments();
155
156 #ifndef QT_NO_SHORTCUT
157     static QWebPage::WebAction editorActionForKeyEvent(QKeyEvent* event);
158 #endif
159     static const char* editorCommandForWebActions(QWebPage::WebAction action);
160
161     QWebPage *q;
162     WebCore::Page *page;
163     QWebPageClient* client;
164     QPointer<QWebFrame> mainFrame;
165
166 #ifndef QT_NO_UNDOSTACK
167     QUndoStack *undoStack;
168 #endif
169
170     QWeakPointer<QWidget> view;
171
172     bool insideOpenCall;
173     quint64 m_totalBytes;
174     quint64 m_bytesReceived;
175
176     QPoint tripleClick;
177     QBasicTimer tripleClickTimer;
178
179     bool clickCausedFocus;
180
181     bool acceptNavigationRequest(QWebFrame *frame, const QNetworkRequest &request, QWebPage::NavigationType type);
182     QNetworkAccessManager *networkManager;
183
184     bool forwardUnsupportedContent;
185     bool smartInsertDeleteEnabled;
186     bool selectTrailingWhitespaceEnabled;
187     QWebPage::LinkDelegationPolicy linkPolicy;
188
189     QSize viewportSize;
190     QSize fixedLayoutSize;
191     QWebHistory history;
192     QWebHitTestResult hitTestResult;
193 #ifndef QT_NO_CONTEXTMENU
194     QPointer<QMenu> currentContextMenu;
195 #endif
196     QWebSettings *settings;
197     QPalette palette;
198     bool editable;
199     bool useFixedLayout;
200
201     QAction *actions[QWebPage::WebActionCount];
202
203     QWebPluginFactory *pluginFactory;
204
205     QWidget* inspectorFrontend;
206     QWebInspector* inspector;
207     bool inspectorIsInternalOnly; // True if created through the Inspect context menu action
208     Qt::DropAction m_lastDropAction;
209
210     static bool drtRun;
211 };
212
213 #endif