-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathqultralightframe.h
252 lines (199 loc) · 7.49 KB
/
qultralightframe.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
/*
Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
Copyright (C) 2008 Holger Hans Peter Freyther
Copyright (C) 2009 Girish Ramakrishnan <[email protected]>
Copyright (C) 2021 Jerzy Głowacki
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef QULTRALIGHTFRAME_H
#define QULTRALIGHTFRAME_H
#include <QtCore/qobject.h>
#include <QtCore/qurl.h>
#include <QtCore/qvariant.h>
#include <QtGui/qicon.h>
#include <QtNetwork/qnetworkaccessmanager.h>
#include <AppCore/AppCore.h>
QT_BEGIN_NAMESPACE
class QRect;
class QPoint;
class QPainter;
class QPixmap;
class QMouseEvent;
class QWheelEvent;
class QNetworkRequest;
class QRegion;
class QPrinter;
QT_END_NAMESPACE
class QWebNetworkRequest;
class QUltralightPage;
class QUltralightView;
//class QUltralightHitTestResult;
class QWebHistoryItem;
class QWebSecurityOrigin;
class QWebElement;
class QWebElementCollection;
class QWebScriptWorld;
class DumpRenderTreeSupportQt;
namespace WebCore {
class WidgetPrivate;
class FrameLoaderClientQt;
class ChromeClientQt;
class TextureMapperLayerClientQt;
}
namespace WebKit {
class InspectorClientWebPage;
}
class QUltralightFrameData;
//class QUltralightHitTestResultPrivate;
class QUltralightFrame;
class QUltralightHitTestResult {
public:
QUltralightHitTestResult();
QUltralightHitTestResult(const QUltralightHitTestResult &other);
QUltralightHitTestResult &operator=(const QUltralightHitTestResult &other);
~QUltralightHitTestResult();
bool isNull() const;
QPoint pos() const;
QRect boundingRect() const;
//QWebElement enclosingBlockElement() const;
QString title() const;
QString linkText() const;
QUrl linkUrl() const;
#if QT_DEPRECATED_SINCE(5,5)
QT_DEPRECATED QUrl linkTitle() const;
#endif // QT_DEPRECATED_SINCE(5,5)
QString linkTitleString() const;
QUltralightFrame *linkTargetFrame() const;
//QWebElement linkElement() const;
QString alternateText() const; // for img, area, input and applet
QUrl imageUrl() const;
QPixmap pixmap() const;
QUrl mediaUrl() const;
bool isContentEditable() const;
bool isContentSelected() const;
//QWebElement element() const;
QUltralightFrame *frame() const;
private:
friend class QUltralightFrame;
friend class QUltralightPage;
QPoint _pos;
QRect _boundingRect;
};
class QUltralightFrame : public QObject {
Q_OBJECT
Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
Q_PROPERTY(QString title READ title)
Q_PROPERTY(QUrl url READ url WRITE setUrl)
Q_PROPERTY(QUrl requestedUrl READ requestedUrl)
Q_PROPERTY(QUrl baseUrl READ baseUrl)
Q_PROPERTY(QIcon icon READ icon)
Q_PROPERTY(QSize contentsSize READ contentsSize)
Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition)
Q_PROPERTY(bool focus READ hasFocus)
private:
QUltralightFrame(QUltralightPage *parentPage);
QUltralightFrame(QUltralightFrame* parent, QUltralightFrameData* frameData);
~QUltralightFrame();
public:
enum ValueOwnership {
QtOwnership,
ScriptOwnership,
AutoOwnership
};
QUltralightPage *page() const;
void load(const QUrl &url);
void load(const QNetworkRequest &request, QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation, const QByteArray &body = QByteArray());
void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
void addToJavaScriptWindowObject(const QString &name, QObject *object, ValueOwnership ownership = QtOwnership);
QString toHtml() const;
QString toPlainText() const;
QString title() const;
void setUrl(const QUrl &url);
QUrl url() const;
QUrl requestedUrl() const;
QUrl baseUrl() const;
QIcon icon() const;
QMultiMap<QString, QString> metaData() const;
QString frameName() const;
QUltralightFrame *parentFrame() const;
QList<QUltralightFrame*> childFrames() const;
Qt::ScrollBarPolicy scrollBarPolicy(Qt::Orientation orientation) const;
void setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPolicy policy);
void setScrollBarValue(Qt::Orientation orientation, int value);
int scrollBarValue(Qt::Orientation orientation) const;
int scrollBarMinimum(Qt::Orientation orientation) const;
int scrollBarMaximum(Qt::Orientation orientation) const;
QRect scrollBarGeometry(Qt::Orientation orientation) const;
void scroll(int, int);
QPoint scrollPosition() const;
void setScrollPosition(const QPoint &pos);
void scrollToAnchor(const QString& anchor);
enum RenderLayer {
ContentsLayer = 0x10,
ScrollBarLayer = 0x20,
PanIconLayer = 0x40,
AllLayers = 0xff
};
Q_DECLARE_FLAGS(RenderLayers, RenderLayer)
void render(QPainter*, const QRegion& clip = QRegion());
void render(QPainter*, RenderLayers layer, const QRegion& clip = QRegion());
void setTextSizeMultiplier(qreal factor);
qreal textSizeMultiplier() const;
qreal zoomFactor() const;
void setZoomFactor(qreal factor);
bool hasFocus() const;
void setFocus();
QPoint pos() const;
QRect geometry() const;
QSize contentsSize() const;
QWebElement documentElement() const;
QWebElement ownerElement() const;
QWebElementCollection findAllElements(const QString &selectorQuery) const;
QWebElement findFirstElement(const QString &selectorQuery) const;
QUltralightHitTestResult hitTestContent(const QPoint &pos) const;
bool event(QEvent *) Q_DECL_OVERRIDE;
//QWebSecurityOrigin securityOrigin() const;
public Q_SLOTS:
QVariant evaluateJavaScript(const QString& scriptSource);
#ifndef QT_NO_PRINTER
void print(QPrinter *printer) const;
#endif
Q_SIGNALS:
void javaScriptWindowObjectCleared();
void provisionalLoad();
void titleChanged(const QString &title);
void urlChanged(const QUrl &url);
void initialLayoutCompleted();
void iconChanged();
void contentsSizeChanged(const QSize &size);
void loadStarted();
void loadFinished(bool ok);
void pageChanged();
private:
//friend class QGraphicsWebView;
friend class QUltralightPage;
friend class DumpRenderTreeSupportQt;
friend class WebCore::WidgetPrivate;
friend class WebCore::FrameLoaderClientQt;
friend class WebCore::ChromeClientQt;
friend class WebCore::TextureMapperLayerClientQt;
friend class WebKit::InspectorClientWebPage;
QUltralightPage *_page;
QUltralightView *_view;
QUrl ensureAbsoluteUrl(const QUrl&);
};
Q_DECLARE_OPERATORS_FOR_FLAGS(QUltralightFrame::RenderLayers)
#endif // QULTRALIGHTFRAME_H