WebKit/qt/Api/qwebframe.h
changeset 0 4f2f89ce4247
equal deleted inserted replaced
-1:000000000000 0:4f2f89ce4247
       
     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 class QWebScriptWorld;
       
    53 
       
    54 class DumpRenderTreeSupportQt;
       
    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     void load(const QNetworkRequest &request,
       
   127               QNetworkAccessManager::Operation operation = QNetworkAccessManager::GetOperation,
       
   128               const QByteArray &body = QByteArray());
       
   129     void setHtml(const QString &html, const QUrl &baseUrl = QUrl());
       
   130     void setContent(const QByteArray &data, const QString &mimeType = QString(), const QUrl &baseUrl = QUrl());
       
   131 
       
   132     void addToJavaScriptWindowObject(const QString &name, QObject *object);
       
   133     void addToJavaScriptWindowObject(const QString &name, QObject *object, QScriptEngine::ValueOwnership ownership);
       
   134     QString toHtml() const;
       
   135     QString toPlainText() const;
       
   136     QString renderTreeDump() const;
       
   137 
       
   138     QString title() const;
       
   139     void setUrl(const QUrl &url);
       
   140     QUrl url() const;
       
   141     QUrl requestedUrl() const;
       
   142     QUrl baseUrl() const;
       
   143     QIcon icon() const;
       
   144     QMultiMap<QString, QString> metaData() const;
       
   145 
       
   146     QString frameName() const;
       
   147 
       
   148     QWebFrame *parentFrame() const;
       
   149     QList<QWebFrame*> childFrames() const;
       
   150 
       
   151     Qt::ScrollBarPolicy scrollBarPolicy(Qt::Orientation orientation) const;
       
   152     void setScrollBarPolicy(Qt::Orientation orientation, Qt::ScrollBarPolicy policy);
       
   153 
       
   154     void setScrollBarValue(Qt::Orientation orientation, int value);
       
   155     int scrollBarValue(Qt::Orientation orientation) const;
       
   156     int scrollBarMinimum(Qt::Orientation orientation) const;
       
   157     int scrollBarMaximum(Qt::Orientation orientation) const;
       
   158     QRect scrollBarGeometry(Qt::Orientation orientation) const;
       
   159 
       
   160     void scroll(int, int);
       
   161     QPoint scrollPosition() const;
       
   162     void setScrollPosition(const QPoint &pos);
       
   163 
       
   164     void scrollToAnchor(const QString& anchor);
       
   165 
       
   166     enum RenderLayer {
       
   167         ContentsLayer = 0x10,
       
   168         ScrollBarLayer = 0x20,
       
   169         PanIconLayer = 0x40,
       
   170 
       
   171         AllLayers = 0xff
       
   172     };
       
   173 
       
   174     void render(QPainter*);
       
   175     void render(QPainter*, const QRegion& clip);
       
   176     void render(QPainter*, RenderLayer layer, const QRegion& clip = QRegion());
       
   177 
       
   178     void setTextSizeMultiplier(qreal factor);
       
   179     qreal textSizeMultiplier() const;
       
   180 
       
   181     qreal zoomFactor() const;
       
   182     void setZoomFactor(qreal factor);
       
   183 
       
   184     bool hasFocus() const;
       
   185     void setFocus();
       
   186 
       
   187     QPoint pos() const;
       
   188     QRect geometry() const;
       
   189     QSize contentsSize() const;
       
   190 
       
   191     QWebElement documentElement() const;
       
   192     QWebElementCollection findAllElements(const QString &selectorQuery) const;
       
   193     QWebElement findFirstElement(const QString &selectorQuery) const;
       
   194 
       
   195     QWebHitTestResult hitTestContent(const QPoint &pos) const;
       
   196 
       
   197     virtual bool event(QEvent *);
       
   198 
       
   199     QWebSecurityOrigin securityOrigin() const;
       
   200 
       
   201 public Q_SLOTS:
       
   202     QVariant evaluateJavaScript(const QString& scriptSource);
       
   203 #ifndef QT_NO_PRINTER
       
   204     void print(QPrinter *printer) const;
       
   205 #endif
       
   206 
       
   207 Q_SIGNALS:
       
   208     void javaScriptWindowObjectCleared();
       
   209 
       
   210     void provisionalLoad();
       
   211     void titleChanged(const QString &title);
       
   212     void urlChanged(const QUrl &url);
       
   213 
       
   214     void initialLayoutCompleted();
       
   215 
       
   216     void iconChanged();
       
   217 
       
   218     void contentsSizeChanged(const QSize &size);
       
   219 
       
   220     void loadStarted();
       
   221     void loadFinished(bool ok);
       
   222 
       
   223     void pageChanged();
       
   224 
       
   225 private:
       
   226     friend class QGraphicsWebView;
       
   227     friend class QWebPage;
       
   228     friend class QWebPagePrivate;
       
   229     friend class QWebFramePrivate;
       
   230     friend class DumpRenderTreeSupportQt;
       
   231     friend class WebCore::WidgetPrivate;
       
   232     friend class WebCore::FrameLoaderClientQt;
       
   233     friend class WebCore::ChromeClientQt;
       
   234     QWebFramePrivate *d;
       
   235 };
       
   236 
       
   237 #endif