qwebframe.h

Go to the documentation of this file.
00001 /*
00002     Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies)
00003     Copyright (C) 2007 Staikos Computing Services Inc.
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018     Boston, MA 02110-1301, USA.
00019 */
00020 
00021 #ifndef QWEBFRAME_H
00022 #define QWEBFRAME_H
00023 
00024 #include <QtCore/qobject.h>
00025 #include <QtCore/qurl.h>
00026 #include <QtCore/qvariant.h>
00027 #include <QtGui/qicon.h>
00028 #include <QtScript/qscriptengine.h>
00029 #include <QtNetwork/qnetworkaccessmanager.h>
00030 #include "qwebkitglobal.h"
00031 
00032 QT_BEGIN_NAMESPACE
00033 class QRect;
00034 class QPoint;
00035 class QPainter;
00036 class QPixmap;
00037 class QMouseEvent;
00038 class QWheelEvent;
00039 class QNetworkRequest;
00040 class QRegion;
00041 class QPrinter;
00042 QT_END_NAMESPACE
00043 
00044 class QWebNetworkRequest;
00045 class QWebFramePrivate;
00046 class QWebPage;
00047 class QWebHitTestResult;
00048 class QWebHistoryItem;
00049 class QWebSecurityOrigin;
00050 class QWebElement;
00051 class QWebElementCollection;
00052 
00053 namespace WebCore {
00054     class WidgetPrivate;
00055     class FrameLoaderClientQt;
00056     class ChromeClientQt;
00057 }
00058 class QWebFrameData;
00059 class QWebHitTestResultPrivate;
00060 class QWebFrame;
00061 
00062 class QWEBKIT_EXPORT QWebHitTestResult {
00063 public:
00064     QWebHitTestResult();
00065     QWebHitTestResult(const QWebHitTestResult &other);
00066     QWebHitTestResult &operator=(const QWebHitTestResult &other);
00067     ~QWebHitTestResult();
00068 
00069     bool isNull() const;
00070 
00071     QPoint pos() const;
00072     QRect boundingRect() const;
00073     QWebElement enclosingBlockElement() const;
00074     QString title() const;
00075 
00076     QString linkText() const;
00077     QUrl linkUrl() const;
00078     QUrl linkTitle() const;
00079     QWebFrame *linkTargetFrame() const;
00080     QWebElement linkElement() const;
00081 
00082     QString alternateText() const; // for img, area, input and applet
00083 
00084     QUrl imageUrl() const;
00085     QPixmap pixmap() const;
00086 
00087     bool isContentEditable() const;
00088     bool isContentSelected() const;
00089 
00090     QWebElement element() const;
00091 
00092     QWebFrame *frame() const;
00093 
00094 private:
00095     QWebHitTestResult(QWebHitTestResultPrivate *priv);
00096     QWebHitTestResultPrivate *d;
00097 
00098     friend class QWebFrame;
00099     friend class QWebPagePrivate;
00100     friend class QWebPage;
00101 };
00102 
00103 class QWEBKIT_EXPORT QWebFrame : public QObject {
00104     Q_OBJECT
00105     Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false)
00106     Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor)
00107     Q_PROPERTY(QString title READ title)
00108     Q_PROPERTY(QUrl url READ url WRITE setUrl)
00109     Q_PROPERTY(QUrl requestedUrl READ requestedUrl)
00110     Q_PROPERTY(QUrl baseUrl READ baseUrl)
00111     Q_PROPERTY(QIcon icon READ icon)
00112     Q_PROPERTY(QSize contentsSize READ contentsSize)
00113     Q_PROPERTY(QPoint scrollPosition READ scrollPosition WRITE setScrollPosition)
00114     Q_PROPERTY(bool focus READ hasFocus)
00115 private:
00116     QWebFrame(QWebPage *parent, QWebFrameData *frameData);
00117     QWebFrame(QWebFrame *parent, QWebFrameData *frameData);
00118     ~QWebFrame();
00119 
00120 public:
00121     QWebPage *page() const;
00122 
00123     void load(const QUrl &url);
00124     void load(const QNetworkRequest &request,
00125               QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
00126               const QByteArray &body = QByteArray());
00127     void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
00128     void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
00129 
00130     void addToJavaScriptWindowObject(const QString &name, QObject *object);
00131     void addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership);
00132     QString toHtml() const;
00133     QString toPlainText() const;
00134     QString renderTreeDump() const;
00135 
00136     QString title() const;
00137     void setUrl(const QUrl &url);
00138     QUrl url() const;
00139     QUrl requestedUrl() const;
00140     QUrl baseUrl() const;
00141     QIcon icon() const;
00142     QMultiMap<QString, QString> metaData() const;
00143 
00144     QString frameName() const;
00145 
00146     QWebFrame *parentFrame() const;
00147     QList<QWebFrame*> childFrames() const;
00148 
00149     Qt::ScrollBarPolicy scrollBarPolicy(Qt::Orientation orientation) const;
00150     void setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPolicy policy);
00151 
00152     void setScrollBarValue(Qt::Orientation orientation, int value);
00153     int scrollBarValue(Qt::Orientation orientation) const;
00154     int scrollBarMinimum(Qt::Orientation orientation) const;
00155     int scrollBarMaximum(Qt::Orientation orientation) const;
00156     QRect scrollBarGeometry(Qt::Orientation orientation) const;
00157 
00158     void scroll(int, int);
00159     QPoint scrollPosition() const;
00160     void setScrollPosition(const QPoint &pos);
00161 
00162     void scrollToAnchor(const QString& anchor);
00163 
00164     enum RenderLayer {
00165         ContentsLayer = 0x10,
00166         ScrollBarLayer = 0x20,
00167         PanIconLayer = 0x40,
00168 
00169         AllLayers = 0xff
00170     };
00171 
00172     void render(QPainter*);
00173     void render(QPainter*, const QRegion& clip);
00174     void render(QPainter*, RenderLayer layer, const QRegion& clip = QRegion());
00175 
00176     void setTextSizeMultiplier(qreal factor);
00177     qreal textSizeMultiplier() const;
00178 
00179     qreal zoomFactor() const;
00180     void setZoomFactor(qreal factor);
00181 
00182     bool hasFocus() const;
00183     void setFocus();
00184 
00185     QPoint pos() const;
00186     QRect geometry() const;
00187     QSize contentsSize() const;
00188 
00189     QWebElement documentElement() const;
00190     QWebElementCollection findAllElements(const QString &selectorQuery) const;
00191     QWebElement findFirstElement(const QString &selectorQuery) const;
00192 
00193     QWebHitTestResult hitTestContent(const QPoint &pos) const;
00194 
00195     virtual bool event(QEvent *);
00196 
00197     QWebSecurityOrigin securityOrigin() const;
00198 
00199 public Q_SLOTS:
00200     QVariant evaluateJavaScript(const QString& scriptSource);
00201 #ifndef QT_NO_PRINTER
00202     void print(QPrinter *printer) const;
00203 #endif
00204 
00205 Q_SIGNALS:
00206     void javaScriptWindowObjectCleared();
00207 
00208     void provisionalLoad();
00209     void titleChanged(const QString &title);
00210     void urlChanged(const QUrl &url);
00211 
00212     void initialLayoutCompleted();
00213 
00214     void iconChanged();
00215 
00216     void contentsSizeChanged(const QSize &size);
00217 
00218     void loadStarted();
00219     void loadFinished(bool ok);
00220 
00221     void pageChanged();
00222 
00223 private:
00224     friend class QGraphicsWebView;
00225     friend class QWebPage;
00226     friend class QWebPagePrivate;
00227     friend class QWebFramePrivate;
00228     friend class WebCore::WidgetPrivate;
00229     friend class WebCore::FrameLoaderClientQt;
00230     friend class WebCore::ChromeClientQt;
00231     QWebFramePrivate *d;
00232 };
00233 
00234 #endif