| 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 | class QWebElementCollection;
|
|---|
| 54 |
|
|---|
| 55 | namespace WebCore {
|
|---|
| 56 | class WidgetPrivate;
|
|---|
| 57 | class FrameLoaderClientQt;
|
|---|
| 58 | class ChromeClientQt;
|
|---|
| 59 | }
|
|---|
| 60 | class QWebFrameData;
|
|---|
| 61 | class QWebHitTestResultPrivate;
|
|---|
| 62 | class QWebFrame;
|
|---|
| 63 |
|
|---|
| 64 | class QWEBKIT_EXPORT QWebHitTestResult {
|
|---|
| 65 | public:
|
|---|
| 66 | QWebHitTestResult();
|
|---|
| 67 | QWebHitTestResult(const QWebHitTestResult &other);
|
|---|
| 68 | QWebHitTestResult &operator=(const QWebHitTestResult &other);
|
|---|
| 69 | ~QWebHitTestResult();
|
|---|
| 70 |
|
|---|
| 71 | bool isNull() const;
|
|---|
| 72 |
|
|---|
| 73 | QPoint pos() const;
|
|---|
| 74 | QRect boundingRect() const;
|
|---|
| 75 | QWebElement enclosingBlockElement() const;
|
|---|
| 76 | QString title() const;
|
|---|
| 77 |
|
|---|
| 78 | QString linkText() const;
|
|---|
| 79 | QUrl linkUrl() const;
|
|---|
| 80 | QUrl linkTitle() const;
|
|---|
| 81 | QWebFrame *linkTargetFrame() const;
|
|---|
| 82 | QWebElement linkElement() const;
|
|---|
| 83 |
|
|---|
| 84 | QString alternateText() const; // for img, area, input and applet
|
|---|
| 85 |
|
|---|
| 86 | QUrl imageUrl() const;
|
|---|
| 87 | QPixmap pixmap() const;
|
|---|
| 88 |
|
|---|
| 89 | bool isContentEditable() const;
|
|---|
| 90 | bool isContentSelected() const;
|
|---|
| 91 |
|
|---|
| 92 | QWebElement element() const;
|
|---|
| 93 |
|
|---|
| 94 | QWebFrame *frame() const;
|
|---|
| 95 |
|
|---|
| 96 | private:
|
|---|
| 97 | QWebHitTestResult(QWebHitTestResultPrivate *priv);
|
|---|
| 98 | QWebHitTestResultPrivate *d;
|
|---|
| 99 |
|
|---|
| 100 | friend class QWebFrame;
|
|---|
| 101 | friend class QWebPagePrivate;
|
|---|
| 102 | friend class QWebPage;
|
|---|
| 103 | };
|
|---|
| 104 |
|
|---|
| 105 | class QWEBKIT_EXPORT QWebFrame : public QObject {
|
|---|
| 106 | Q_OBJECT
|
|---|
| 107 | Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
|
|---|
| 108 | Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
|
|---|
| 109 | Q_PROPERTY(QString title READ title)
|
|---|
| 110 | Q_PROPERTY(QUrl url READ url WRITE setUrl)
|
|---|
| 111 | Q_PROPERTY(QUrl requestedUrl READ requestedUrl)
|
|---|
| 112 | Q_PROPERTY(QUrl baseUrl READ baseUrl)
|
|---|
| 113 | Q_PROPERTY(QIcon icon READ icon)
|
|---|
| 114 | Q_PROPERTY(QSize contentsSize READ contentsSize)
|
|---|
| 115 | Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition)
|
|---|
| 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 | enum RenderLayer {
|
|---|
| 169 | ContentsLayer = 0x10,
|
|---|
| 170 | ScrollBarLayer = 0x20,
|
|---|
| 171 | PanIconLayer = 0x40,
|
|---|
| 172 |
|
|---|
| 173 | AllLayers = 0xff
|
|---|
| 174 | };
|
|---|
| 175 |
|
|---|
| 176 | void render(QPainter*);
|
|---|
| 177 | void render(QPainter*, const QRegion& clip);
|
|---|
| 178 | void render(QPainter*, RenderLayer layer, const QRegion& clip = QRegion());
|
|---|
| 179 |
|
|---|
| 180 | void setTextSizeMultiplier(qreal factor);
|
|---|
| 181 | qreal textSizeMultiplier() const;
|
|---|
| 182 |
|
|---|
| 183 | qreal zoomFactor() const;
|
|---|
| 184 | void setZoomFactor(qreal factor);
|
|---|
| 185 |
|
|---|
| 186 | bool hasFocus() const;
|
|---|
| 187 | void setFocus();
|
|---|
| 188 |
|
|---|
| 189 | QPoint pos() const;
|
|---|
| 190 | QRect geometry() const;
|
|---|
| 191 | QSize contentsSize() const;
|
|---|
| 192 |
|
|---|
| 193 | QWebElement documentElement() const;
|
|---|
| 194 | QWebElementCollection findAllElements(const QString &selectorQuery) const;
|
|---|
| 195 | QWebElement findFirstElement(const QString &selectorQuery) const;
|
|---|
| 196 |
|
|---|
| 197 | QWebHitTestResult hitTestContent(const QPoint &pos) const;
|
|---|
| 198 |
|
|---|
| 199 | virtual bool event(QEvent *);
|
|---|
| 200 |
|
|---|
| 201 | QWebSecurityOrigin securityOrigin() const;
|
|---|
| 202 |
|
|---|
| 203 | public Q_SLOTS:
|
|---|
| 204 | QVariant evaluateJavaScript(const QString& scriptSource);
|
|---|
| 205 | #ifndef QT_NO_PRINTER
|
|---|
| 206 | void print(QPrinter *printer) const;
|
|---|
| 207 | #endif
|
|---|
| 208 |
|
|---|
| 209 | Q_SIGNALS:
|
|---|
| 210 | void javaScriptWindowObjectCleared();
|
|---|
| 211 |
|
|---|
| 212 | void provisionalLoad();
|
|---|
| 213 | void titleChanged(const QString &title);
|
|---|
| 214 | void urlChanged(const QUrl &url);
|
|---|
| 215 |
|
|---|
| 216 | void initialLayoutCompleted();
|
|---|
| 217 |
|
|---|
| 218 | void iconChanged();
|
|---|
| 219 |
|
|---|
| 220 | void contentsSizeChanged(const QSize &size);
|
|---|
| 221 |
|
|---|
| 222 | void loadStarted();
|
|---|
| 223 | void loadFinished(bool ok);
|
|---|
| 224 |
|
|---|
| 225 | private:
|
|---|
| 226 | friend class QWebPage;
|
|---|
| 227 | friend class QWebPagePrivate;
|
|---|
| 228 | friend class QWebFramePrivate;
|
|---|
| 229 | friend class WebCore::WidgetPrivate;
|
|---|
| 230 | friend class WebCore::FrameLoaderClientQt;
|
|---|
| 231 | friend class WebCore::ChromeClientQt;
|
|---|
| 232 | QWebFramePrivate *d;
|
|---|
| 233 | };
|
|---|
| 234 |
|
|---|
| 235 | #endif
|
|---|