| 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 | QPoint scrollPosition() const;
|
|---|
| 160 | void setScrollPosition(const QPoint &pos);
|
|---|
| 161 |
|
|---|
| 162 | void scrollToAnchor(const QString& anchor);
|
|---|
| 163 |
|
|---|
| 164 | enum RenderLayer {
|
|---|
| 165 | ContentsLayer = 0x10,
|
|---|
| 166 | ScrollBarLayer = 0x20,
|
|---|
| 167 | PanIconLayer = 0x40,
|
|---|
| 168 |
|
|---|
| 169 | AllLayers = 0xff
|
|---|
| 170 | };
|
|---|
| 171 |
|
|---|
| 172 | void render(QPainter*);
|
|---|
| 173 | void render(QPainter*, const QRegion& clip);
|
|---|
| 174 | void render(QPainter*, RenderLayer layer, const QRegion& clip = QRegion());
|
|---|
| 175 |
|
|---|
| 176 | void setTextSizeMultiplier(qreal factor);
|
|---|
| 177 | qreal textSizeMultiplier() const;
|
|---|
| 178 |
|
|---|
| 179 | qreal zoomFactor() const;
|
|---|
| 180 | void setZoomFactor(qreal factor);
|
|---|
| 181 |
|
|---|
| 182 | bool hasFocus() const;
|
|---|
| 183 | void setFocus();
|
|---|
| 184 |
|
|---|
| 185 | QPoint pos() const;
|
|---|
| 186 | QRect geometry() const;
|
|---|
| 187 | QSize contentsSize() const;
|
|---|
| 188 |
|
|---|
| 189 | QWebElement documentElement() const;
|
|---|
| 190 | QWebElementCollection findAllElements(const QString &selectorQuery) const;
|
|---|
| 191 | QWebElement findFirstElement(const QString &selectorQuery) const;
|
|---|
| 192 |
|
|---|
| 193 | QWebHitTestResult hitTestContent(const QPoint &pos) const;
|
|---|
| 194 |
|
|---|
| 195 | virtual bool event(QEvent *);
|
|---|
| 196 |
|
|---|
| 197 | QWebSecurityOrigin securityOrigin() const;
|
|---|
| 198 |
|
|---|
| 199 | public Q_SLOTS:
|
|---|
| 200 | QVariant evaluateJavaScript(const QString& scriptSource);
|
|---|
| 201 | #ifndef QT_NO_PRINTER
|
|---|
| 202 | void print(QPrinter *printer) const;
|
|---|
| 203 | #endif
|
|---|
| 204 |
|
|---|
| 205 | Q_SIGNALS:
|
|---|
| 206 | void javaScriptWindowObjectCleared();
|
|---|
| 207 |
|
|---|
| 208 | void provisionalLoad();
|
|---|
| 209 | void titleChanged(const QString &title);
|
|---|
| 210 | void urlChanged(const QUrl &url);
|
|---|
| 211 |
|
|---|
| 212 | void initialLayoutCompleted();
|
|---|
| 213 |
|
|---|
| 214 | void iconChanged();
|
|---|
| 215 |
|
|---|
| 216 | void contentsSizeChanged(const QSize &size);
|
|---|
| 217 |
|
|---|
| 218 | void loadStarted();
|
|---|
| 219 | void loadFinished(bool ok);
|
|---|
| 220 |
|
|---|
| 221 | void pageChanged();
|
|---|
| 222 |
|
|---|
| 223 | private:
|
|---|
| 224 | friend class QGraphicsWebView;
|
|---|
| 225 | friend class QWebPage;
|
|---|
| 226 | friend class QWebPagePrivate;
|
|---|
| 227 | friend class QWebFramePrivate;
|
|---|
| 228 | friend class WebCore::WidgetPrivate;
|
|---|
| 229 | friend class WebCore::FrameLoaderClientQt;
|
|---|
| 230 | friend class WebCore::ChromeClientQt;
|
|---|
| 231 | QWebFramePrivate *d;
|
|---|
| 232 | };
|
|---|
| 233 |
|
|---|
| 234 | #endif
|
|---|