• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2     Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies)
3     Copyright (C) 2007 Staikos Computing Services Inc.
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 QWEBFRAME_H
22 #define QWEBFRAME_H
23 
24 #include <QtCore/qobject.h>
25 #include <QtCore/qurl.h>
26 #include <QtCore/qvariant.h>
27 #include <QtGui/qicon.h>
28 #include <QtScript/qscriptengine.h>
29 #if QT_VERSION >= 0x040400
30 #include <QtNetwork/qnetworkaccessmanager.h>
31 #endif
32 #include "qwebkitglobal.h"
33 
34 QT_BEGIN_NAMESPACE
35 class QRect;
36 class QPoint;
37 class QPainter;
38 class QPixmap;
39 class QMouseEvent;
40 class QWheelEvent;
41 class QNetworkRequest;
42 class QRegion;
43 class QPrinter;
44 QT_END_NAMESPACE
45 
46 class QWebNetworkRequest;
47 class QWebFramePrivate;
48 class QWebPage;
49 class QWebHitTestResult;
50 class QWebHistoryItem;
51 class QWebSecurityOrigin;
52 class QWebElement;
53 
54 namespace WebCore {
55     class WidgetPrivate;
56     class FrameLoaderClientQt;
57     class ChromeClientQt;
58 }
59 class QWebFrameData;
60 class QWebHitTestResultPrivate;
61 class QWebFrame;
62 
63 class QWEBKIT_EXPORT QWebHitTestResult {
64 public:
65     QWebHitTestResult();
66     QWebHitTestResult(const QWebHitTestResult &other);
67     QWebHitTestResult &operator=(const QWebHitTestResult &other);
68     ~QWebHitTestResult();
69 
70     bool isNull() const;
71 
72     QPoint pos() const;
73     QRect boundingRect() const;
74     QWebElement enclosingBlockElement() const;
75     QString title() const;
76 
77     QString linkText() const;
78     QUrl linkUrl() const;
79     QUrl linkTitle() const;
80     QWebFrame *linkTargetFrame() const;
81     QWebElement linkElement() const;
82 
83     QString alternateText() const; // for img, area, input and applet
84 
85     QUrl imageUrl() const;
86     QPixmap pixmap() const;
87 
88     bool isContentEditable() const;
89     bool isContentSelected() const;
90 
91     QWebElement element() const;
92 
93     QWebFrame *frame() const;
94 
95 private:
96     QWebHitTestResult(QWebHitTestResultPrivate *priv);
97     QWebHitTestResultPrivate *d;
98 
99     friend class QWebFrame;
100     friend class QWebPagePrivate;
101     friend class QWebPage;
102 };
103 
104 class QWEBKIT_EXPORT QWebFrame : public QObject {
105     Q_OBJECT
106     Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
107     Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
108     Q_PROPERTY(QString title READ title)
109     Q_PROPERTY(QUrl url READ url WRITE setUrl)
110     Q_PROPERTY(QUrl requestedUrl READ requestedUrl)
111     Q_PROPERTY(QUrl baseUrl READ baseUrl)
112     Q_PROPERTY(QIcon icon READ icon)
113     Q_PROPERTY(QSize contentsSize READ contentsSize)
114     Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition)
115     Q_PROPERTY(bool clipRenderToViewport READ clipRenderToViewport WRITE setClipRenderToViewport)
116     Q_PROPERTY(bool focus READ hasFocus)
117 private:
118     QWebFrame(QWebPage *parent, QWebFrameData *frameData);
119     QWebFrame(QWebFrame *parent, QWebFrameData *frameData);
120     ~QWebFrame();
121 
122 public:
123     QWebPage *page() const;
124 
125     void load(const QUrl &url);
126 #if QT_VERSION < 0x040400
127     void load(const QWebNetworkRequest &request);
128 #else
129     void load(const QNetworkRequest &request,
130               QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
131               const QByteArray &body = QByteArray());
132 #endif
133     void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
134     void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
135 
136     void addToJavaScriptWindowObject(const QString &name, QObject *object);
137     void addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership);
138     QString toHtml() const;
139     QString toPlainText() const;
140     QString renderTreeDump() const;
141 
142     QString title() const;
143     void setUrl(const QUrl &url);
144     QUrl url() const;
145     QUrl requestedUrl() const;
146     QUrl baseUrl() const;
147     QIcon icon() const;
148     QMultiMap<QString, QString> metaData() const;
149 
150     QString frameName() const;
151 
152     QWebFrame *parentFrame() const;
153     QList<QWebFrame*> childFrames() const;
154 
155     Qt::ScrollBarPolicy scrollBarPolicy(Qt::Orientation orientation) const;
156     void setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPolicy policy);
157 
158     void setScrollBarValue(Qt::Orientation orientation, int value);
159     int scrollBarValue(Qt::Orientation orientation) const;
160     int scrollBarMinimum(Qt::Orientation orientation) const;
161     int scrollBarMaximum(Qt::Orientation orientation) const;
162     QRect scrollBarGeometry(Qt::Orientation orientation) const;
163 
164     void scroll(int, int);
165     QPoint scrollPosition() const;
166     void setScrollPosition(const QPoint &pos);
167 
168     void render(QPainter *painter, const QRegion &clip);
169     void render(QPainter *painter);
170     bool clipRenderToViewport() const;
171     void setClipRenderToViewport(bool clipRenderToViewport);
172 
173     void setTextSizeMultiplier(qreal factor);
174     qreal textSizeMultiplier() const;
175 
176     qreal zoomFactor() const;
177     void setZoomFactor(qreal factor);
178 
179     bool hasFocus() const;
180     void setFocus();
181 
182     QPoint pos() const;
183     QRect geometry() const;
184     QSize contentsSize() const;
185 
186     QWebElement documentElement() const;
187     QList<QWebElement> findAllElements(const QString &selectorQuery) const;
188     QWebElement findFirstElement(const QString &selectorQuery) const;
189 
190     QWebHitTestResult hitTestContent(const QPoint &pos) const;
191 
192     virtual bool event(QEvent *);
193 
194     QWebSecurityOrigin securityOrigin() const;
195 
196 public Q_SLOTS:
197     QVariant evaluateJavaScript(const QString& scriptSource);
198 #ifndef QT_NO_PRINTER
199     void print(QPrinter *printer) const;
200 #endif
201 
202 Q_SIGNALS:
203     void javaScriptWindowObjectCleared();
204 
205     void provisionalLoad();
206     void titleChanged(const QString &title);
207     void urlChanged(const QUrl &url);
208 
209     void initialLayoutCompleted();
210 
211     void iconChanged();
212 
213     void contentsSizeChanged(const QSize &size);
214 
215     void loadStarted();
216     void loadFinished(bool ok);
217 
218 private:
219     friend class QWebPage;
220     friend class QWebPagePrivate;
221     friend class QWebFramePrivate;
222     friend class WebCore::WidgetPrivate;
223     friend class WebCore::FrameLoaderClientQt;
224     friend class WebCore::ChromeClientQt;
225     QWebFramePrivate *d;
226 };
227 
228 #endif
229