diff options
author | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2013-08-05 14:56:59 +0200 |
---|---|---|
committer | Jocelyn Turcotte <jocelyn.turcotte@digia.com> | 2013-08-20 17:42:53 +0200 |
commit | f4c5a81cc1050bc267359d1b2173e36392fe08a1 (patch) | |
tree | a3b42f13ed36302842c35d97d156e2ac5f6fa073 /lib/widgets | |
parent | 9a3641f43572ce9e77dd6770f0029e82bd92d70c (diff) |
Import QtWebKit public headers.
This is the first step toward re-implementing part of the QWebView
API on top of QtWebEngine. The plan is to import the complete headers
to facilitate diffs and progress tracking.
Changes squashed in this commit:
- Use the QWebEngine prefix for class names
- Strip out non-public members and directives
- Allow building using those headers by disabling the Q_PROPERTY
macros and by adding a dummy implementation for virtual methods
directly in the header
- Update the widgetsnanobrowser example to comply with the slight
changes from the previous API
Change-Id: Ia7efa5430f775d09b493544430a04856cc7928f6
Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Reviewed-by: Andras Becsi <andras.becsi@digia.com>
Diffstat (limited to 'lib/widgets')
-rw-r--r-- | lib/widgets/Api/qwebengineframe.h | 214 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginehistory.cpp | 75 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginehistory.h | 100 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginehistory_p.h | 58 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginehistoryinterface.h | 42 | ||||
-rw-r--r-- | lib/widgets/Api/qwebengineinspector.h | 39 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginepage.cpp | 88 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginepage.h | 407 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginepage_p.h | 66 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginesecurityorigin.h | 49 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginesettings.h | 166 | ||||
-rw-r--r-- | lib/widgets/Api/qwebengineview.cpp | 47 | ||||
-rw-r--r-- | lib/widgets/Api/qwebengineview.h | 156 | ||||
-rw-r--r-- | lib/widgets/Api/qwebengineview_p.h | 14 | ||||
-rw-r--r-- | lib/widgets/widgets.pro | 4 |
15 files changed, 1462 insertions, 63 deletions
diff --git a/lib/widgets/Api/qwebengineframe.h b/lib/widgets/Api/qwebengineframe.h new file mode 100644 index 000000000..833837d0f --- /dev/null +++ b/lib/widgets/Api/qwebengineframe.h @@ -0,0 +1,214 @@ +/* + Copyright (C) 2008,2009 Nokia Corporation and/or its subsidiary(-ies) + Copyright (C) 2007 Staikos Computing Services Inc. + + 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 QWEBENGINEFRAME_H +#define QWEBENGINEFRAME_H + +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QtCore/qvariant.h> +#include <QtGui/qicon.h> +#include <QtNetwork/qnetworkaccessmanager.h> +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> + +QT_BEGIN_NAMESPACE +class QRect; +class QPoint; +class QPainter; +class QPixmap; +class QNetworkRequest; +class QRegion; +class QPrinter; +QT_END_NAMESPACE + +class QWebEngineFramePrivate; +class QWebEnginePage; +class QWebEngineSecurityOrigin; +class QWebEngineElement; +class QWebEngineElementCollection; + +class QWebEngineFrameData; +class QWebEngineHitTestResultPrivate; +class QWebEngineFrame; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineHitTestResult { +public: + QWebEngineHitTestResult(); + QWebEngineHitTestResult(const QWebEngineHitTestResult &other); + QWebEngineHitTestResult &operator=(const QWebEngineHitTestResult &other); + ~QWebEngineHitTestResult(); + + bool isNull() const; + + QPoint pos() const; + QRect boundingRect() const; + QWebEngineElement enclosingBlockElement() const; + QString title() const; + + QString linkText() const; + QUrl linkUrl() const; + QUrl linkTitle() const; + QWebEngineFrame *linkTargetFrame() const; + QWebEngineElement linkElement() const; + + QString alternateText() const; // for img, area, input and applet + + QUrl imageUrl() const; + QPixmap pixmap() const; + + bool isContentEditable() const; + bool isContentSelected() const; + + QWebEngineElement element() const; + + QWebEngineFrame *frame() const; + +private: + QWebEngineHitTestResult(QWebEngineHitTestResultPrivate *priv); + QWebEngineHitTestResultPrivate *d; +}; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineFrame : 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: + QWebEngineFrame(QWebEnginePage *parentPage); + QWebEngineFrame(QWebEngineFrame* parent, QWebEngineFrameData*); + ~QWebEngineFrame(); + +public: + enum ValueOwnership { + QtOwnership, + ScriptOwnership, + AutoOwnership + }; + + QWebEnginePage *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; + + QWebEngineFrame *parentFrame() const; + QList<QWebEngineFrame*> 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; + + QWebEngineElement documentElement() const; + QWebEngineElementCollection findAllElements(const QString &selectorQuery) const; + QWebEngineElement findFirstElement(const QString &selectorQuery) const; + + QWebEngineHitTestResult hitTestContent(const QPoint &pos) const; + + QWebEngineSecurityOrigin 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: + QWebEngineFramePrivate *d; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEngineFrame::RenderLayers) + +#endif diff --git a/lib/widgets/Api/qwebenginehistory.cpp b/lib/widgets/Api/qwebenginehistory.cpp new file mode 100644 index 000000000..929d12b3f --- /dev/null +++ b/lib/widgets/Api/qwebenginehistory.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebenginehistory.h" +#include "qwebenginehistory_p.h" + +#include "qwebenginepage_p.h" +#include "qwebengineview.h" +#include "qwebengineview_p.h" +#include "web_contents_adapter.h" + +QWebEngineHistoryPrivate::QWebEngineHistoryPrivate() + : pagePrivate(0) +{ +} + +QWebEngineHistory::QWebEngineHistory() + : d_ptr(new QWebEngineHistoryPrivate) +{ + d_ptr->q_ptr=this; +} + +QWebEngineHistory::~QWebEngineHistory() +{ +} + +bool QWebEngineHistory::canGoBack() const +{ + Q_D(const QWebEngineHistory); + return d->pagePrivate->view->d_func()->adapter->canGoBack(); +} + +bool QWebEngineHistory::canGoForward() const +{ + Q_D(const QWebEngineHistory); + return d->pagePrivate->view->d_func()->adapter->canGoForward(); +} diff --git a/lib/widgets/Api/qwebenginehistory.h b/lib/widgets/Api/qwebenginehistory.h new file mode 100644 index 000000000..8a7f9a7c6 --- /dev/null +++ b/lib/widgets/Api/qwebenginehistory.h @@ -0,0 +1,100 @@ +/* + Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + 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 QWEBENGINEHISTORY_H +#define QWEBENGINEHISTORY_H + +#include <QtCore/qurl.h> +#include <QtCore/qstring.h> +#include <QtCore/qdatetime.h> +#include <QtCore/qshareddata.h> +#include <QtGui/qicon.h> +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> + +class QWebEnginePage; +class QWebEnginePagePrivate; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineHistoryItem { +public: + QWebEngineHistoryItem(const QWebEngineHistoryItem &other); + QWebEngineHistoryItem &operator=(const QWebEngineHistoryItem &other); + ~QWebEngineHistoryItem(); + + QUrl originalUrl() const; + QUrl url() const; + + QString title() const; + QDateTime lastVisited() const; + + QIcon icon() const; + + QVariant userData() const; + void setUserData(const QVariant& userData); + + bool isValid() const; +}; + + +class QWebEngineHistoryPrivate; +class QWEBENGINEWIDGETS_EXPORT QWebEngineHistory { +public: + void clear(); + + QList<QWebEngineHistoryItem> items() const; + QList<QWebEngineHistoryItem> backItems(int maxItems) const; + QList<QWebEngineHistoryItem> forwardItems(int maxItems) const; + + bool canGoBack() const; + bool canGoForward() const; + + void back(); + void forward(); + void goToItem(const QWebEngineHistoryItem &item); + + QWebEngineHistoryItem backItem() const; + QWebEngineHistoryItem currentItem() const; + QWebEngineHistoryItem forwardItem() const; + QWebEngineHistoryItem itemAt(int i) const; + + int currentItemIndex() const; + + int count() const; + + int maximumItemCount() const; + void setMaximumItemCount(int count); + +private: + QWebEngineHistory(); + ~QWebEngineHistory(); + + Q_DISABLE_COPY(QWebEngineHistory) + Q_DECLARE_PRIVATE(QWebEngineHistory); + QScopedPointer<QWebEngineHistoryPrivate> d_ptr; + + friend QWEBENGINEWIDGETS_EXPORT QDataStream& operator>>(QDataStream&, QWebEngineHistory&); + friend QWEBENGINEWIDGETS_EXPORT QDataStream& operator<<(QDataStream&, const QWebEngineHistory&); + friend class QWebEnginePage; + friend class QWebEnginePagePrivate; +}; + +QWEBENGINEWIDGETS_EXPORT QDataStream& operator<<(QDataStream& stream, const QWebEngineHistory& history); +QWEBENGINEWIDGETS_EXPORT QDataStream& operator>>(QDataStream& stream, QWebEngineHistory& history); + +#endif // QWEBENGINEHISTORY_H diff --git a/lib/widgets/Api/qwebenginehistory_p.h b/lib/widgets/Api/qwebenginehistory_p.h new file mode 100644 index 000000000..7f94cf659 --- /dev/null +++ b/lib/widgets/Api/qwebenginehistory_p.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINEHISTORY_P_H +#define QWEBENGINEHISTORY_P_H + +class QWebEngineHistoryPrivate; +class QWebEnginePagePrivate; + +class QWebEngineHistoryPrivate +{ + QWebEngineHistory *q_ptr; +public: + Q_DECLARE_PUBLIC(QWebEngineHistory) + + QWebEngineHistoryPrivate(); + QWebEnginePagePrivate *pagePrivate; +}; + +#endif // QWEBENGINEHISTORY_P_H diff --git a/lib/widgets/Api/qwebenginehistoryinterface.h b/lib/widgets/Api/qwebenginehistoryinterface.h new file mode 100644 index 000000000..73b3f5630 --- /dev/null +++ b/lib/widgets/Api/qwebenginehistoryinterface.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Copyright (C) 2007 Staikos Computing Services, Inc. <info@staikos.net> + + 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. + + This class provides all functionality needed for tracking global history. +*/ + +#ifndef QWEBENGINEHISTORYINTERFACE_H +#define QWEBENGINEHISTORYINTERFACE_H + +#include <QtCore/qobject.h> +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> + +class QWEBENGINEWIDGETS_EXPORT QWebEngineHistoryInterface : public QObject { + Q_OBJECT +public: + QWebEngineHistoryInterface(QObject *parent = 0); + ~QWebEngineHistoryInterface(); + + static void setDefaultInterface(QWebEngineHistoryInterface *defaultInterface); + static QWebEngineHistoryInterface *defaultInterface(); + + virtual bool historyContains(const QString &url) const = 0; + virtual void addHistoryEntry(const QString &url) = 0; +}; + +#endif // QWEBENGINEHISTORYINTERFACE_H diff --git a/lib/widgets/Api/qwebengineinspector.h b/lib/widgets/Api/qwebengineinspector.h new file mode 100644 index 000000000..b5b652181 --- /dev/null +++ b/lib/widgets/Api/qwebengineinspector.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies) + + 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 QWEBENGINEINSPECTOR_H +#define QWEBENGINEINSPECTOR_H + +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> + +class QWebEnginePage; +class QWebEngineInspectorPrivate; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineInspector : public QWidget { + Q_OBJECT +public: + QWebEngineInspector(QWidget* parent = 0); + ~QWebEngineInspector(); + + void setPage(QWebEnginePage* page); + QWebEnginePage* page() const; +}; + +#endif // QWEBENGINEINSPECTOR_H diff --git a/lib/widgets/Api/qwebenginepage.cpp b/lib/widgets/Api/qwebenginepage.cpp new file mode 100644 index 000000000..082305e7b --- /dev/null +++ b/lib/widgets/Api/qwebenginepage.cpp @@ -0,0 +1,88 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qwebenginepage.h" +#include "qwebenginepage_p.h" + +#include "qwebenginehistory.h" +#include "qwebenginehistory_p.h" +#include "qwebengineview.h" +#include "qwebengineview_p.h" + +QWebEnginePagePrivate::QWebEnginePagePrivate() + : QObjectPrivate(QObjectPrivateVersion) + , history(new QWebEngineHistory) +{ + history->d_func()->pagePrivate = this; +} + +QWebEnginePagePrivate::~QWebEnginePagePrivate() +{ + delete history; +} + +QWebEnginePage::QWebEnginePage(QObject* parent) + : QObject(*new QWebEnginePagePrivate, parent) +{ +} + +QWebEnginePage::~QWebEnginePage() +{ +} + +QWebEngineHistory *QWebEnginePage::history() const +{ + Q_D(const QWebEnginePage); + return d->history; +} + +void QWebEnginePage::setView(QWidget *view) +{ + QWebEngineViewPrivate::bind(qobject_cast<QWebEngineView*>(view), this); +} + +QWidget *QWebEnginePage::view() const +{ + Q_D(const QWebEnginePage); + return d->view; +} + +#include "moc_qwebenginepage.cpp" diff --git a/lib/widgets/Api/qwebenginepage.h b/lib/widgets/Api/qwebenginepage.h new file mode 100644 index 000000000..5d94abb27 --- /dev/null +++ b/lib/widgets/Api/qwebenginepage.h @@ -0,0 +1,407 @@ +/* + Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + Copyright (C) 2007 Staikos Computing Services Inc. + + 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 QWEBENGINEPAGE_H +#define QWEBENGINEPAGE_H + +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> +#include <QtWebEngineWidgets/qwebenginesettings.h> + +#include <QtCore/qobject.h> +#include <QtCore/qurl.h> +#include <QtWidgets/qwidget.h> + +QT_BEGIN_NAMESPACE +class QUndoStack; +class QMenu; +class QNetworkRequest; +class QNetworkReply; +class QNetworkAccessManager; +QT_END_NAMESPACE + +class QWebEngineFrame; +class QWebEngineHistory; + +class QWebEngineHistoryItem; +class QWebEnginePagePrivate; +class QWebEnginePluginFactory; +class QWebEngineSecurityOrigin; +class QtViewportAttributesPrivate; + +class QWEBENGINEWIDGETS_EXPORT QWebEnginePage : public QObject { + Q_OBJECT +// Hack to avoid undefined symbols with properties until we have them implemented. +#ifndef Q_MOC_RUN + Q_PROPERTY(bool modified READ isModified) + Q_PROPERTY(QString selectedText READ selectedText) + Q_PROPERTY(QString selectedHtml READ selectedHtml) + Q_PROPERTY(bool hasSelection READ hasSelection) + Q_PROPERTY(QSize viewportSize READ viewportSize WRITE setViewportSize) + Q_PROPERTY(QSize preferredContentsSize READ preferredContentsSize WRITE setPreferredContentsSize) + Q_PROPERTY(bool forwardUnsupportedContent READ forwardUnsupportedContent WRITE setForwardUnsupportedContent) + Q_PROPERTY(LinkDelegationPolicy linkDelegationPolicy READ linkDelegationPolicy WRITE setLinkDelegationPolicy) + Q_PROPERTY(QPalette palette READ palette WRITE setPalette) + Q_PROPERTY(bool contentEditable READ isContentEditable WRITE setContentEditable) + Q_ENUMS(LinkDelegationPolicy NavigationType WebAction) +#endif + +public: + enum NavigationType { + NavigationTypeLinkClicked, + NavigationTypeFormSubmitted, + NavigationTypeBackOrForward, + NavigationTypeReload, + NavigationTypeFormResubmitted, + NavigationTypeOther + }; + + enum WebAction { + NoWebAction = - 1, + + OpenLink, + + OpenLinkInNewWindow, + OpenFrameInNewWindow, + + DownloadLinkToDisk, + CopyLinkToClipboard, + + OpenImageInNewWindow, + DownloadImageToDisk, + CopyImageToClipboard, + + Back, + Forward, + Stop, + Reload, + + Cut, + Copy, + Paste, + + Undo, + Redo, + MoveToNextChar, + MoveToPreviousChar, + MoveToNextWord, + MoveToPreviousWord, + MoveToNextLine, + MoveToPreviousLine, + MoveToStartOfLine, + MoveToEndOfLine, + MoveToStartOfBlock, + MoveToEndOfBlock, + MoveToStartOfDocument, + MoveToEndOfDocument, + SelectNextChar, + SelectPreviousChar, + SelectNextWord, + SelectPreviousWord, + SelectNextLine, + SelectPreviousLine, + SelectStartOfLine, + SelectEndOfLine, + SelectStartOfBlock, + SelectEndOfBlock, + SelectStartOfDocument, + SelectEndOfDocument, + DeleteStartOfWord, + DeleteEndOfWord, + + SetTextDirectionDefault, + SetTextDirectionLeftToRight, + SetTextDirectionRightToLeft, + + ToggleBold, + ToggleItalic, + ToggleUnderline, + + InspectElement, + + InsertParagraphSeparator, + InsertLineSeparator, + + SelectAll, + ReloadAndBypassCache, + + PasteAndMatchStyle, + RemoveFormat, + + ToggleStrikethrough, + ToggleSubscript, + ToggleSuperscript, + InsertUnorderedList, + InsertOrderedList, + Indent, + Outdent, + + AlignCenter, + AlignJustified, + AlignLeft, + AlignRight, + + StopScheduledPageRefresh, + + CopyImageUrlToClipboard, + + OpenLinkInThisWindow, + + WebActionCount + }; + + enum FindFlag { + FindBackward = 1, + FindCaseSensitively = 2, + FindWrapsAroundDocument = 4, + HighlightAllOccurrences = 8 + }; + Q_DECLARE_FLAGS(FindFlags, FindFlag) + + enum LinkDelegationPolicy { + DontDelegateLinks, + DelegateExternalLinks, + DelegateAllLinks + }; + + enum WebWindowType { + WebBrowserWindow, + WebModalDialog + }; + + enum PermissionPolicy { + PermissionUnknown, + PermissionGrantedByUser, + PermissionDeniedByUser + }; + + enum Feature { + Notifications, + Geolocation + }; + + class QWEBENGINEWIDGETS_EXPORT ViewportAttributes { + public: + ViewportAttributes(); + ViewportAttributes(const QWebEnginePage::ViewportAttributes& other); + + ~ViewportAttributes(); + + QWebEnginePage::ViewportAttributes& operator=(const QWebEnginePage::ViewportAttributes& other); + + inline qreal initialScaleFactor() const { return m_initialScaleFactor; } + inline qreal minimumScaleFactor() const { return m_minimumScaleFactor; } + inline qreal maximumScaleFactor() const { return m_maximumScaleFactor; } + inline qreal devicePixelRatio() const { return m_devicePixelRatio; } + inline bool isUserScalable() const { return m_isUserScalable; } + inline bool isValid() const { return m_isValid; } + inline QSizeF size() const { return m_size; } + + private: + QSharedDataPointer<QtViewportAttributesPrivate> d; + qreal m_initialScaleFactor; + qreal m_minimumScaleFactor; + qreal m_maximumScaleFactor; + qreal m_devicePixelRatio; + bool m_isUserScalable; + bool m_isValid; + QSizeF m_size; + + friend class QWebEnginePage; + }; + + + explicit QWebEnginePage(QObject *parent = 0); + ~QWebEnginePage(); + + QWebEngineFrame *mainFrame() const; + QWebEngineFrame *currentFrame() const; + QWebEngineFrame* frameAt(const QPoint& pos) const; + + QWebEngineHistory *history() const; + QWebEngineSettings *settings() const; + + void setView(QWidget *view); + QWidget *view() const; + + bool isModified() const; +#ifndef QT_NO_UNDOSTACK + QUndoStack *undoStack() const; +#endif + + void setNetworkAccessManager(QNetworkAccessManager *manager); + QNetworkAccessManager *networkAccessManager() const; + + void setPluginFactory(QWebEnginePluginFactory *factory); + QWebEnginePluginFactory *pluginFactory() const; + + quint64 totalBytes() const; + quint64 bytesReceived() const; + + bool hasSelection() const; + QString selectedText() const; + QString selectedHtml() const; + +#ifndef QT_NO_ACTION + QAction *action(WebAction action) const; +#endif + virtual void triggerAction(WebAction action, bool checked = false) { Q_UNUSED(action); Q_UNUSED(checked); Q_UNREACHABLE(); } + + QSize viewportSize() const; + void setViewportSize(const QSize &size) const; + ViewportAttributes viewportAttributesForSize(const QSize& availableSize) const; + + QSize preferredContentsSize() const; + void setPreferredContentsSize(const QSize &size) const; + void setActualVisibleContentRect(const QRect& rect) const; + + bool focusNextPrevChild(bool next); + + QVariant inputMethodQuery(Qt::InputMethodQuery property) const; + + bool findText(const QString &subString, FindFlags options = 0); + + void setForwardUnsupportedContent(bool forward); + bool forwardUnsupportedContent() const; + + void setLinkDelegationPolicy(LinkDelegationPolicy policy); + LinkDelegationPolicy linkDelegationPolicy() const; + + void setPalette(const QPalette &palette); + QPalette palette() const; + + void setContentEditable(bool editable); + bool isContentEditable() const; + +#ifndef QT_NO_CONTEXTMENU + bool swallowContextMenuEvent(QContextMenuEvent *event); +#endif + void updatePositionDependentActions(const QPoint &pos); + + QMenu *createStandardContextMenu(); + + void setFeaturePermission(QWebEngineFrame* frame, Feature feature, PermissionPolicy policy); + + QStringList supportedContentTypes() const; + bool supportsContentType(const QString& mimeType) const; + + enum Extension { + ChooseMultipleFilesExtension, + ErrorPageExtension + }; + class ExtensionOption + {}; + class ExtensionReturn + {}; + + class ChooseMultipleFilesExtensionOption : public ExtensionOption { + public: + QWebEngineFrame *parentFrame; + QStringList suggestedFileNames; + }; + + class ChooseMultipleFilesExtensionReturn : public ExtensionReturn { + public: + QStringList fileNames; + }; + + enum ErrorDomain { QtNetwork, Http, WebKit }; + class ErrorPageExtensionOption : public ExtensionOption { + public: + QUrl url; + QWebEngineFrame* frame; + ErrorDomain domain; + int error; + QString errorString; + }; + + class ErrorPageExtensionReturn : public ExtensionReturn { + public: + ErrorPageExtensionReturn() : contentType(QLatin1String("text/html")), encoding(QLatin1String("utf-8")) {}; + QString contentType; + QString encoding; + QUrl baseUrl; + QByteArray content; + }; + + + virtual bool extension(Extension extension, const ExtensionOption *option = 0, ExtensionReturn *output = 0) { Q_UNUSED(extension); Q_UNUSED(option); Q_UNUSED(output); Q_UNREACHABLE(); return false; } + virtual bool supportsExtension(Extension extension) const { Q_UNUSED(extension); Q_UNREACHABLE(); return false; } + + virtual bool shouldInterruptJavaScript() { Q_UNREACHABLE(); return false; } + +Q_SIGNALS: + void loadStarted(); + void loadProgress(int progress); + void loadFinished(bool ok); + + void linkHovered(const QString &link, const QString &title, const QString &textContent); + void statusBarMessage(const QString& text); + void selectionChanged(); + void frameCreated(QWebEngineFrame *frame); + void geometryChangeRequested(const QRect& geom); + void repaintRequested(const QRect& dirtyRect); + void scrollRequested(int dx, int dy, const QRect& scrollViewRect); + void windowCloseRequested(); + void printRequested(QWebEngineFrame *frame); + void linkClicked(const QUrl &url); + + void toolBarVisibilityChangeRequested(bool visible); + void statusBarVisibilityChangeRequested(bool visible); + void menuBarVisibilityChangeRequested(bool visible); + + void unsupportedContent(QNetworkReply *reply); + void downloadRequested(const QNetworkRequest &request); + + void microFocusChanged(); + void contentsChanged(); + void databaseQuotaExceeded(QWebEngineFrame* frame, QString databaseName); + void applicationCacheQuotaExceeded(QWebEngineSecurityOrigin* origin, quint64 defaultOriginQuota, quint64 totalSpaceNeeded); + + void saveFrameStateRequested(QWebEngineFrame* frame, QWebEngineHistoryItem* item); + void restoreFrameStateRequested(QWebEngineFrame* frame); + + void viewportChangeRequested(); + + void featurePermissionRequested(QWebEngineFrame* frame, QWebEnginePage::Feature feature); + void featurePermissionRequestCanceled(QWebEngineFrame* frame, QWebEnginePage::Feature feature); + +protected: + virtual QWebEnginePage *createWindow(WebWindowType type) { Q_UNUSED(type); Q_UNREACHABLE(); return 0; }; + virtual QObject *createPlugin(const QString &classid, const QUrl &url, const QStringList ¶mNames, const QStringList ¶mValues) { Q_UNUSED(classid); Q_UNUSED(url); Q_UNUSED(paramNames); Q_UNUSED(paramValues); Q_UNREACHABLE(); return 0; } + + virtual bool acceptNavigationRequest(QWebEngineFrame *frame, const QNetworkRequest &request, NavigationType type) { Q_UNUSED(frame); Q_UNUSED(request); Q_UNUSED(type); Q_UNREACHABLE(); return false; } + virtual QString chooseFile(QWebEngineFrame *originatingFrame, const QString& oldFile) { Q_UNUSED(originatingFrame); Q_UNUSED(oldFile); Q_UNREACHABLE(); return QString(); } + virtual void javaScriptAlert(QWebEngineFrame *originatingFrame, const QString& msg) { Q_UNUSED(originatingFrame); Q_UNUSED(msg); Q_UNREACHABLE(); } + virtual bool javaScriptConfirm(QWebEngineFrame *originatingFrame, const QString& msg) { Q_UNUSED(originatingFrame); Q_UNUSED(msg); Q_UNREACHABLE(); return false; } + virtual bool javaScriptPrompt(QWebEngineFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result) { Q_UNUSED(originatingFrame); Q_UNUSED(msg); Q_UNUSED(defaultValue); Q_UNUSED(result); Q_UNREACHABLE(); return false; } + virtual void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) { Q_UNUSED(message); Q_UNUSED(lineNumber); Q_UNUSED(sourceID); Q_UNREACHABLE(); } + + virtual QString userAgentForUrl(const QUrl& url) const { Q_UNUSED(url); Q_UNREACHABLE(); return QString(); } + +private: + Q_DECLARE_PRIVATE(QWebEnginePage); + friend class QWebEngineView; + friend class QWebEngineViewPrivate; +}; + +Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEnginePage::FindFlags) + +#endif // QWEBENGINEPAGE_H diff --git a/lib/widgets/Api/qwebenginepage_p.h b/lib/widgets/Api/qwebenginepage_p.h new file mode 100644 index 000000000..ed9ad22a8 --- /dev/null +++ b/lib/widgets/Api/qwebenginepage_p.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtWebEngine module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QWEBENGINEPAGE_P_H +#define QWEBENGINEPAGE_P_H + +#include "qwebenginepage.h" + +#include <QtCore/private/qobject_p.h> + +class QWebEngineHistory; +class QWebEnginePage; +class QWebEngineView; + +class QWebEnginePagePrivate : public QObjectPrivate +{ +public: + Q_DECLARE_PUBLIC(QWebEnginePage) + + QWebEnginePagePrivate(); + ~QWebEnginePagePrivate(); + + QWebEngineHistory *history; + QWebEngineView *view; + bool m_isLoading; +}; + +#endif // QWEBENGINEPAGE_P_H diff --git a/lib/widgets/Api/qwebenginesecurityorigin.h b/lib/widgets/Api/qwebenginesecurityorigin.h new file mode 100644 index 000000000..66ccfebd4 --- /dev/null +++ b/lib/widgets/Api/qwebenginesecurityorigin.h @@ -0,0 +1,49 @@ +/* + Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + 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 QWEBENGINESECURITYORIGIN_H_ +#define QWEBENGINESECURITYORIGIN_H_ + +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> + +class QWebEngineDatabase; +class QWebEngineSecurityOriginPrivate; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineSecurityOrigin { +public: + static QList<QWebEngineSecurityOrigin> allOrigins(); + static void addLocalScheme(const QString& scheme); + static void removeLocalScheme(const QString& scheme); + static QStringList localSchemes(); + + ~QWebEngineSecurityOrigin(); + + QString scheme() const; + QString host() const; + int port() const; + + qint64 databaseUsage() const; + qint64 databaseQuota() const; + void setDatabaseQuota(qint64 quota); + void setApplicationCacheQuota(qint64 quota); + QList<QWebEngineDatabase> databases() const; +}; + +#endif // QWEBENGINESECURITYORIGIN_H_ diff --git a/lib/widgets/Api/qwebenginesettings.h b/lib/widgets/Api/qwebenginesettings.h new file mode 100644 index 000000000..b6c8b6a19 --- /dev/null +++ b/lib/widgets/Api/qwebenginesettings.h @@ -0,0 +1,166 @@ +/* + Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + + 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 QWEBENGINESETTINGS_H +#define QWEBENGINESETTINGS_H + +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> +#include <QtCore/qstring.h> + +class QIcon; +class QPixmap; +class QUrl; +class QWebEngineSettingsPrivate; + +class QWEBENGINEWIDGETS_EXPORT QWebEngineSettings { +public: + enum FontFamily { + StandardFont, + FixedFont, + SerifFont, + SansSerifFont, + CursiveFont, + FantasyFont + }; + enum WebAttribute { + AutoLoadImages, + JavascriptEnabled, + JavaEnabled, + PluginsEnabled, + PrivateBrowsingEnabled, + JavascriptCanOpenWindows, + JavascriptCanAccessClipboard, + DeveloperExtrasEnabled, + LinksIncludedInFocusChain, + ZoomTextOnly, + PrintElementBackgrounds, + OfflineStorageDatabaseEnabled, + OfflineWebApplicationCacheEnabled, + LocalStorageEnabled, +#if defined(QT_DEPRECATED) || defined(qdoc) + LocalStorageDatabaseEnabled = LocalStorageEnabled, +#endif + LocalContentCanAccessRemoteUrls, + DnsPrefetchEnabled, + XSSAuditingEnabled, + AcceleratedCompositingEnabled, + SpatialNavigationEnabled, + LocalContentCanAccessFileUrls, + TiledBackingStoreEnabled, + FrameFlatteningEnabled, + SiteSpecificQuirksEnabled, + JavascriptCanCloseWindows, + WebGLEnabled, + CSSRegionsEnabled, + HyperlinkAuditingEnabled, + CSSGridLayoutEnabled, + ScrollAnimatorEnabled, + CaretBrowsingEnabled, + NotificationsEnabled + }; + enum WebGraphic { + MissingImageGraphic, + MissingPluginGraphic, + DefaultFrameIconGraphic, + TextAreaSizeGripCornerGraphic, + DeleteButtonGraphic, + InputSpeechButtonGraphic, + SearchCancelButtonGraphic, + SearchCancelButtonPressedGraphic + }; + enum FontSize { + MinimumFontSize, + MinimumLogicalFontSize, + DefaultFontSize, + DefaultFixedFontSize + }; + enum ThirdPartyCookiePolicy { + AlwaysAllowThirdPartyCookies, + AlwaysBlockThirdPartyCookies, + AllowThirdPartyWithExistingCookies + }; + + static QWebEngineSettings *globalSettings(); + + void setFontFamily(FontFamily which, const QString &family); + QString fontFamily(FontFamily which) const; + void resetFontFamily(FontFamily which); + + void setFontSize(FontSize type, int size); + int fontSize(FontSize type) const; + void resetFontSize(FontSize type); + + void setAttribute(WebAttribute attr, bool on); + bool testAttribute(WebAttribute attr) const; + void resetAttribute(WebAttribute attr); + + void setUserStyleSheetUrl(const QUrl &location); + QUrl userStyleSheetUrl() const; + + void setDefaultTextEncoding(const QString &encoding); + QString defaultTextEncoding() const; + + static void setIconDatabasePath(const QString &location); + static QString iconDatabasePath(); + static void clearIconDatabase(); + static QIcon iconForUrl(const QUrl &url); + + //static QWebEnginePluginDatabase *pluginDatabase(); + + static void setWebGraphic(WebGraphic type, const QPixmap &graphic); + static QPixmap webGraphic(WebGraphic type); + + static void setMaximumPagesInCache(int pages); + static int maximumPagesInCache(); + static void setObjectCacheCapacities(int cacheMinDeadCapacity, int cacheMaxDead, int totalCapacity); + + static void setOfflineStoragePath(const QString& path); + static QString offlineStoragePath(); + static void setOfflineStorageDefaultQuota(qint64 maximumSize); + static qint64 offlineStorageDefaultQuota(); + + static void setOfflineWebApplicationCachePath(const QString& path); + static QString offlineWebApplicationCachePath(); + static void setOfflineWebApplicationCacheQuota(qint64 maximumSize); + static qint64 offlineWebApplicationCacheQuota(); + + void setLocalStoragePath(const QString& path); + QString localStoragePath() const; + + static void clearMemoryCaches(); + + static void enablePersistentStorage(const QString& path = QString()); + + void setThirdPartyCookiePolicy(ThirdPartyCookiePolicy); + QWebEngineSettings::ThirdPartyCookiePolicy thirdPartyCookiePolicy() const; + + void setCSSMediaType(const QString&); + QString cssMediaType() const; + +private: + Q_DISABLE_COPY(QWebEngineSettings) + + QWebEngineSettings(); + ~QWebEngineSettings(); + + QWebEngineSettingsPrivate *d; +}; + +#endif // QWEBENGINESETTINGS_H diff --git a/lib/widgets/Api/qwebengineview.cpp b/lib/widgets/Api/qwebengineview.cpp index 369aa6efa..aea228cc1 100644 --- a/lib/widgets/Api/qwebengineview.cpp +++ b/lib/widgets/Api/qwebengineview.cpp @@ -42,16 +42,42 @@ #include "qwebengineview.h" #include "qwebengineview_p.h" +#include "qwebenginepage_p.h" #include "render_widget_host_view_qt_delegate_widget.h" #include "web_contents_adapter.h" #include <QStackedLayout> #include <QUrl> +void QWebEngineViewPrivate::bind(QWebEngineView *view, QWebEnginePage *page) +{ + if (view && page == view->d_func()->page) + return; + + if (page) { + // Un-bind page from its current view. + if (QWebEngineView *oldView = page->d_func()->view) { + page->disconnect(oldView); + oldView->d_func()->page = 0; + } + page->d_func()->view = view; + } + + if (view) { + // Un-bind view from its current page. + if (QWebEnginePage *oldPage = view->d_func()->page) { + oldPage->disconnect(view); + oldPage->d_func()->view = 0; + } + view->d_func()->page = page; + } +} + QWebEngineViewPrivate::QWebEngineViewPrivate() : QWidgetPrivate(QObjectPrivateVersion) , m_isLoading(false) , adapter(new WebContentsAdapter(this)) + , page(0) { } @@ -113,22 +139,25 @@ QWebEngineView::~QWebEngineView() { } -void QWebEngineView::load(const QUrl& url) +QWebEnginePage* QWebEngineView::page() const { - Q_D(QWebEngineView); - d->adapter->load(url); + Q_D(const QWebEngineView); + if (!d->page) { + QWebEngineView *that = const_cast<QWebEngineView*>(this); + that->setPage(new QWebEnginePage(that)); + } + return d->page; } -bool QWebEngineView::canGoBack() const +void QWebEngineView::setPage(QWebEnginePage* page) { - Q_D(const QWebEngineView); - return d->adapter->canGoBack(); + QWebEngineViewPrivate::bind(this, page); } -bool QWebEngineView::canGoForward() const +void QWebEngineView::load(const QUrl& url) { - Q_D(const QWebEngineView); - return d->adapter->canGoForward(); + Q_D(QWebEngineView); + d->adapter->load(url); } void QWebEngineView::back() diff --git a/lib/widgets/Api/qwebengineview.h b/lib/widgets/Api/qwebengineview.h index b75f62369..afd7920bc 100644 --- a/lib/widgets/Api/qwebengineview.h +++ b/lib/widgets/Api/qwebengineview.h @@ -1,77 +1,135 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtWebEngine module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3.0 as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU General Public License version 3.0 requirements will be -** met: http://www.gnu.org/copyleft/gpl.html. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +/* + Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). + Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) + Copyright (C) 2007 Staikos Computing Services Inc. + + 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 QWEBENGINEVIEW_H #define QWEBENGINEVIEW_H -#include <qtwebenginewidgetsglobal.h> +#include <QtGui/qpainter.h> +#include <QtNetwork/qnetworkaccessmanager.h> +#include <QtWidgets/qwidget.h> -#include <QWidget> +#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> +#include <QtWebEngineWidgets/qwebenginepage.h> +class QIcon; +class QNetworkRequest; +class QPrinter; +class QUrl; +class QWebEnginePage; class QWebEngineViewPrivate; +class QWebEngineNetworkRequest; class QWEBENGINEWIDGETS_EXPORT QWebEngineView : public QWidget { Q_OBJECT +// Hack to avoid undefined symbols with properties until we have them implemented. +#ifndef Q_MOC_RUN + Q_PROPERTY(QString title READ title) + Q_PROPERTY(QUrl url READ url WRITE setUrl) + Q_PROPERTY(QIcon icon READ icon) + Q_PROPERTY(QString selectedText READ selectedText) + Q_PROPERTY(QString selectedHtml READ selectedHtml) + Q_PROPERTY(bool hasSelection READ hasSelection) + Q_PROPERTY(bool modified READ isModified) + //Q_PROPERTY(Qt::TextInteractionFlags textInteractionFlags READ textInteractionFlags WRITE setTextInteractionFlags) + Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false) + Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) + + Q_PROPERTY(QPainter::RenderHints renderHints READ renderHints WRITE setRenderHints) + Q_FLAGS(QPainter::RenderHints) +#endif + public: - QWebEngineView(QWidget *parent = 0); - ~QWebEngineView(); + explicit QWebEngineView(QWidget* parent = 0); + virtual ~QWebEngineView(); + + QWebEnginePage* page() const; + void setPage(QWebEnginePage* page); void load(const QUrl& url); - bool canGoBack() const; - bool canGoForward() const; + 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()); + + QWebEngineHistory* history() const; + QWebEngineSettings* settings() const; + + QString title() const; + void setUrl(const QUrl &url); + QUrl url() const; + QIcon icon() const; + + bool hasSelection() const; + QString selectedText() const; + QString selectedHtml() const; + +#ifndef QT_NO_ACTION + QAction* pageAction(QWebEnginePage::WebAction action) const; +#endif + void triggerPageAction(QWebEnginePage::WebAction action, bool checked = false); + + bool isModified() const; + + /* + Qt::TextInteractionFlags textInteractionFlags() const; + void setTextInteractionFlags(Qt::TextInteractionFlags flags); + void setTextInteractionFlag(Qt::TextInteractionFlag flag); + */ + + qreal zoomFactor() const; + void setZoomFactor(qreal factor); + + void setTextSizeMultiplier(qreal factor); + qreal textSizeMultiplier() const; + + QPainter::RenderHints renderHints() const; + void setRenderHints(QPainter::RenderHints hints); + void setRenderHint(QPainter::RenderHint hint, bool enabled = true); + + bool findText(const QString& subString, QWebEnginePage::FindFlags options = 0); public Q_SLOTS: + void stop(); void back(); void forward(); void reload(); - void stop(); + + void print(QPrinter*) const { } Q_SIGNALS: - void loadFinished(bool ok); void loadStarted(); + void loadProgress(int progress); + void loadFinished(bool); void titleChanged(const QString& title); - void urlChanged(const QUrl& url); + void statusBarMessage(const QString& text); + void linkClicked(const QUrl&); + void selectionChanged(); + void iconChanged(); + void urlChanged(const QUrl&); + +protected: + virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type) { Q_UNUSED(type); return 0; } private: Q_DECLARE_PRIVATE(QWebEngineView); + friend class QWebEngineHistory; }; #endif // QWEBENGINEVIEW_H diff --git a/lib/widgets/Api/qwebengineview_p.h b/lib/widgets/Api/qwebengineview_p.h index 9ac5e57e8..d5c803c34 100644 --- a/lib/widgets/Api/qwebengineview_p.h +++ b/lib/widgets/Api/qwebengineview_p.h @@ -39,13 +39,14 @@ ** ****************************************************************************/ -#ifndef QWEBENGINEVIEWPRIVATE_H -#define QWEBENGINEVIEWPRIVATE_H +#ifndef QWEBENGINEVIEW_P_H +#define QWEBENGINEVIEW_P_H #include "web_contents_adapter_client.h" #include <QScopedPointer> #include <QtWidgets/private/qwidget_p.h> +#include <QtWebEngineWidgets/qwebengineview.h> class QWebEngineView; class RenderWidgetHostViewQtDelegate; @@ -53,8 +54,11 @@ class WebContentsAdapter; class QWebEngineViewPrivate : public QWidgetPrivate, public WebContentsAdapterClient { - Q_DECLARE_PUBLIC(QWebEngineView) public: + Q_DECLARE_PUBLIC(QWebEngineView) + + static void bind(QWebEngineView *view, QWebEnginePage *page); + QWebEngineViewPrivate(); virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate() Q_DECL_OVERRIDE; @@ -67,7 +71,7 @@ public: bool m_isLoading; QScopedPointer<WebContentsAdapter> adapter; - friend class RenderWidgetHostViewQtDelegateWidget; + QWebEnginePage *page; }; -#endif +#endif // QWEBENGINEVIEW_P_H diff --git a/lib/widgets/widgets.pro b/lib/widgets/widgets.pro index 45b71284e..272e3568e 100644 --- a/lib/widgets/widgets.pro +++ b/lib/widgets/widgets.pro @@ -23,11 +23,15 @@ DESTDIR = $$LIBPATH INCLUDEPATH += Api ../ SOURCES = \ + Api/qwebenginehistory.cpp \ + Api/qwebenginepage.cpp \ Api/qwebengineview.cpp\ render_widget_host_view_qt_delegate_widget.cpp HEADERS = \ Api/qtwebenginewidgetsglobal.h \ + Api/qwebenginehistory.h \ + Api/qwebenginepage.h \ Api/qwebengineview.h \ Api/qwebengineview_p.h \ render_widget_host_view_qt_delegate_widget.h |