* Move the various event methods to QWebPagePrivate. This is similar to
[WebKit-https.git] / WebKit / qt / Api / qwebpage_p.h
1 /*
2     Copyright (C) 2007 Trolltech ASA
3
4     This library is free software; you can redistribute it and/or
5     modify it under the terms of the GNU Library General Public
6     License as published by the Free Software Foundation; either
7     version 2 of the License, or (at your option) any later version.
8
9     This library is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12     Library General Public License for more details.
13
14     You should have received a copy of the GNU Library General Public License
15     along with this library; see the file COPYING.LIB.  If not, write to
16     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17     Boston, MA 02110-1301, USA.
18
19     This class provides all functionality needed for loading images, style sheets and html
20     pages from the web. It has a memory cache for these objects.
21 */
22 #ifndef QWEBPAGE_P_H
23 #define QWEBPAGE_P_H
24
25 #include <qnetworkproxy.h>
26 #include <qpointer.h>
27
28 #include "qwebpage.h"
29 #include "qwebframe.h"
30
31 #include <wtf/RefPtr.h>
32
33 namespace WebCore
34 {
35     class ChromeClientQt;
36     class ContextMenuClientQt;
37     class ContextMenuItem;
38     class ContextMenu;
39     class EditorClientQt;
40     class Node;
41     class Page;
42 }
43
44 class QUndoStack;
45 class QMenu;
46
47 class QWebPageContextPrivate
48 {
49 public:
50     QPoint pos;
51     QString text;
52     QUrl linkUrl;
53     QUrl imageUrl;
54     QPixmap image;
55     QPointer<QWebFrame> targetFrame;
56     RefPtr<WebCore::Node> innerNonSharedNode;
57 };
58
59 class QWebPageContext
60 {
61 public:
62     QWebPageContext();
63     QWebPageContext(const QWebPageContext &other);
64     QWebPageContext &operator=(const QWebPageContext &other);
65     ~QWebPageContext();
66
67     QPoint pos() const;
68     QString text() const;
69     QUrl linkUrl() const;
70     QUrl imageUrl() const;
71     // ### we have a pixmap internally, should this be called pixmap() instead?
72     QPixmap image() const;
73
74     QWebFrame *targetFrame() const;
75
76 private:
77     QWebPageContext(const WebCore::HitTestResult &hitTest);
78     QWebPageContextPrivate *d;
79
80     friend class QWebPage;
81     friend class QWebPagePrivate;
82 };
83
84 class QWebPagePrivate
85 {
86 public:
87     QWebPagePrivate(QWebPage *);
88     ~QWebPagePrivate();
89     void createMainFrame();
90     QMenu *createContextMenu(const WebCore::ContextMenu *webcoreMenu, const QList<WebCore::ContextMenuItem> *items);
91
92     QWebFrame *frameAt(const QPoint &pos) const;
93
94     void _q_onLoadProgressChanged(int);
95     void _q_webActionTriggered(bool checked);
96     void updateAction(QWebPage::WebAction action);
97     void updateNavigationActions();
98     void updateEditorActions();
99
100     void mouseMoveEvent(QMouseEvent*);
101     void mousePressEvent(QMouseEvent*);
102     void mouseDoubleClickEvent(QMouseEvent*);
103     void mouseReleaseEvent(QMouseEvent*);
104     void contextMenuEvent(QContextMenuEvent*);
105     void wheelEvent(QWheelEvent*);
106     void keyPressEvent(QKeyEvent*);
107     void keyReleaseEvent(QKeyEvent*);
108     void focusInEvent(QFocusEvent*);
109     void focusOutEvent(QFocusEvent*);
110
111     void dragEnterEvent(QDragEnterEvent *);
112     void dragLeaveEvent(QDragLeaveEvent *);
113     void dragMoveEvent(QDragMoveEvent *);
114     void dropEvent(QDropEvent *);
115
116
117     WebCore::ChromeClientQt *chromeClient;
118     WebCore::ContextMenuClientQt *contextMenuClient;
119     WebCore::EditorClientQt *editorClient;
120     WebCore::Page *page;
121
122     QPointer<QWebFrame> mainFrame;
123     QPointer<QWebFrame> frameUnderMouse;
124
125     inline QWebFrame *currentFrame(const QPoint &pos) const
126     { return frameUnderMouse ? static_cast<QWebFrame *>(frameUnderMouse) : frameAt(pos); }
127
128     QWebPage *q;
129     QUndoStack *undoStack;
130     QWidget *view;
131
132     QWebNetworkInterface *networkInterface;
133
134     bool modified;
135
136     bool insideOpenCall;
137     quint64 m_totalBytes;
138     quint64 m_bytesReceived;
139
140     QWebPage::NavigationRequestResponse navigationRequested(QWebFrame *frame, const QWebNetworkRequest &request, QWebPage::NavigationType type);
141 #ifndef QT_NO_NETWORKPROXY
142     QNetworkProxy networkProxy;
143 #endif
144
145     QWebPageHistory history;
146     QWebPageContext currentContext;
147     QWebSettings *settings;
148
149     QAction *actions[QWebPage::WebActionCount];
150 };
151
152 #endif