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