diff options
Diffstat (limited to 'lib/widgets')
-rw-r--r-- | lib/widgets/Api/qtwebenginewidgetsglobal.h | 60 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginehistory.cpp | 288 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginehistory.h | 112 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginehistory_p.h | 73 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginehistoryinterface.h | 46 | ||||
-rw-r--r-- | lib/widgets/Api/qwebengineinspector.h | 43 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginepage.cpp | 494 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginepage.h | 592 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginepage_p.h | 95 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginesecurityorigin.h | 52 | ||||
-rw-r--r-- | lib/widgets/Api/qwebenginesettings.h | 170 | ||||
-rw-r--r-- | lib/widgets/Api/qwebengineview.cpp | 211 | ||||
-rw-r--r-- | lib/widgets/Api/qwebengineview.h | 145 | ||||
-rw-r--r-- | lib/widgets/Api/qwebengineview_p.h | 67 | ||||
-rw-r--r-- | lib/widgets/render_widget_host_view_qt_delegate_widget.cpp | 170 | ||||
-rw-r--r-- | lib/widgets/render_widget_host_view_qt_delegate_widget.h | 87 | ||||
-rw-r--r-- | lib/widgets/widgets.pro | 47 |
17 files changed, 0 insertions, 2752 deletions
diff --git a/lib/widgets/Api/qtwebenginewidgetsglobal.h b/lib/widgets/Api/qtwebenginewidgetsglobal.h deleted file mode 100644 index d875c1cbe..000000000 --- a/lib/widgets/Api/qtwebenginewidgetsglobal.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** 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 QTWEBENGINEWIDGETSGLOBAL_H -#define QTWEBENGINEWIDGETSGLOBAL_H - -#include <QtCore/qglobal.h> - -QT_BEGIN_NAMESPACE - -#ifndef QT_STATIC -# if defined(QT_BUILD_WEBENGINEWIDGETS_LIB) -# define QWEBENGINEWIDGETS_EXPORT Q_DECL_EXPORT -# else -# define QWEBENGINEWIDGETS_EXPORT Q_DECL_IMPORT -# endif -#else -# define QWEBENGINEWIDGETS_EXPORT -#endif - -QT_END_NAMESPACE - -#endif // QTWEBENGINEWIDGETSGLOBAL_H diff --git a/lib/widgets/Api/qwebenginehistory.cpp b/lib/widgets/Api/qwebenginehistory.cpp deleted file mode 100644 index 2dd69dcff..000000000 --- a/lib/widgets/Api/qwebenginehistory.cpp +++ /dev/null @@ -1,288 +0,0 @@ -/**************************************************************************** -** -** 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 "web_contents_adapter.h" - -QT_BEGIN_NAMESPACE - -QWebEngineHistoryItemPrivate::QWebEngineHistoryItemPrivate(WebContentsAdapter *adapter, int index) - : adapter(adapter) - , index(index) -{ -} - -QWebEngineHistoryItem::QWebEngineHistoryItem(QWebEngineHistoryItemPrivate *d) - : d(d) -{ -} - -QWebEngineHistoryItem::QWebEngineHistoryItem(const QWebEngineHistoryItem &other) - : d(other.d) -{ -} - -QWebEngineHistoryItem &QWebEngineHistoryItem::operator=(const QWebEngineHistoryItem &other) -{ - d = other.d; - return *this; -} - -QWebEngineHistoryItem::~QWebEngineHistoryItem() -{ -} - -QUrl QWebEngineHistoryItem::originalUrl() const -{ - Q_D(const QWebEngineHistoryItem); - return d->adapter ? d->adapter->getNavigationEntryOriginalUrl(d->index) : QUrl(); -} - -QUrl QWebEngineHistoryItem::url() const -{ - Q_D(const QWebEngineHistoryItem); - return d->adapter ? d->adapter->getNavigationEntryUrl(d->index) : QUrl(); -} - -QString QWebEngineHistoryItem::title() const -{ - Q_D(const QWebEngineHistoryItem); - return d->adapter ? d->adapter->getNavigationEntryTitle(d->index) : QString(); -} - -QDateTime QWebEngineHistoryItem::lastVisited() const -{ - qWarning("Not implemented: %s", __func__); - return QDateTime(); -} - -QIcon QWebEngineHistoryItem::icon() const -{ - qWarning("Not implemented: %s", __func__); - return QIcon(); -} - -QVariant QWebEngineHistoryItem::userData() const -{ - return QVariant(); -} - -void QWebEngineHistoryItem::setUserData(const QVariant& userData) -{ - qWarning("Not implemented: %s", __func__); -} - -bool QWebEngineHistoryItem::isValid() const -{ - Q_D(const QWebEngineHistoryItem); - if (!d->adapter) - return false; - return d->index >= 0 && d->index < d->adapter->navigationEntryCount(); -} - -QWebEngineHistoryPrivate::QWebEngineHistoryPrivate(WebContentsAdapter *adapter) - : adapter(adapter) -{ -} - -QWebEngineHistoryPrivate::~QWebEngineHistoryPrivate() -{ - // Invalidate shared item references possibly still out there. - QList<QWebEngineHistoryItem>::iterator it, end; - for (it = items.begin(), end = items.end(); it != end; ++it) - it->d->adapter = 0; -} - -void QWebEngineHistoryPrivate::updateItems() const -{ - // Keep track of items we return to be able to invalidate them - // and avoid dangling references to our adapter. - int entryCount = adapter->navigationEntryCount(); - while (items.size() > entryCount) { - items.last().d->adapter = 0; - items.removeLast(); - } - while (items.size() < entryCount) { - int nextIndex = items.size(); - items.append(QWebEngineHistoryItem(new QWebEngineHistoryItemPrivate(adapter, nextIndex))); - } -} - -QWebEngineHistory::QWebEngineHistory(QWebEngineHistoryPrivate *d) - : d_ptr(d) -{ -} - -QWebEngineHistory::~QWebEngineHistory() -{ -} - -void QWebEngineHistory::clear() -{ - Q_D(const QWebEngineHistory); - d->adapter->clearNavigationHistory(); -} - -QList<QWebEngineHistoryItem> QWebEngineHistory::items() const -{ - Q_D(const QWebEngineHistory); - d->updateItems(); - return d->items; -} - -QList<QWebEngineHistoryItem> QWebEngineHistory::backItems(int maxItems) const -{ - Q_D(const QWebEngineHistory); - d->updateItems(); - const int end = currentItemIndex(); - const int start = std::max(0, end - maxItems); - return d->items.mid(start, end - start); -} - -QList<QWebEngineHistoryItem> QWebEngineHistory::forwardItems(int maxItems) const -{ - Q_D(const QWebEngineHistory); - d->updateItems(); - const int start = currentItemIndex() + 1; - const int end = std::min(count(), start + maxItems); - return d->items.mid(start, end - start); -} - -bool QWebEngineHistory::canGoBack() const -{ - Q_D(const QWebEngineHistory); - return d->adapter->canGoBack(); -} - -bool QWebEngineHistory::canGoForward() const -{ - Q_D(const QWebEngineHistory); - return d->adapter->canGoForward(); -} - -void QWebEngineHistory::back() -{ - Q_D(const QWebEngineHistory); - d->adapter->navigateToOffset(-1); -} - -void QWebEngineHistory::forward() -{ - Q_D(const QWebEngineHistory); - d->adapter->navigateToOffset(1); -} - -void QWebEngineHistory::goToItem(const QWebEngineHistoryItem &item) -{ - Q_D(const QWebEngineHistory); - Q_ASSERT(item.d->adapter == d->adapter); - d->adapter->navigateToIndex(item.d->index); -} - -QWebEngineHistoryItem QWebEngineHistory::backItem() const -{ - return itemAt(currentItemIndex() - 1); -} - -QWebEngineHistoryItem QWebEngineHistory::currentItem() const -{ - Q_D(const QWebEngineHistory); - d->updateItems(); - return d->items[currentItemIndex()]; -} - -QWebEngineHistoryItem QWebEngineHistory::forwardItem() const -{ - return itemAt(currentItemIndex() + 1); -} - -QWebEngineHistoryItem QWebEngineHistory::itemAt(int i) const -{ - Q_D(const QWebEngineHistory); - if (i >= 0 && i < count()) { - d->updateItems(); - return d->items[i]; - } else { - // Return an invalid item right away. - QWebEngineHistoryItem item(new QWebEngineHistoryItemPrivate(0, i)); - Q_ASSERT(!item.isValid()); - return item; - } -} - -int QWebEngineHistory::currentItemIndex() const -{ - Q_D(const QWebEngineHistory); - return d->adapter->currentNavigationEntryIndex(); -} - -int QWebEngineHistory::count() const -{ - Q_D(const QWebEngineHistory); - return d->adapter->navigationEntryCount(); -} - -int QWebEngineHistory::maximumItemCount() const -{ - return 100; -} - -void QWebEngineHistory::setMaximumItemCount(int count) -{ - qWarning("Not implemented: %s", __func__); -} - -QDataStream& operator<<(QDataStream& stream, const QWebEngineHistory& history) -{ - qWarning("Not implemented: %s", __func__); - return stream; -} - -QDataStream& operator>>(QDataStream& stream, QWebEngineHistory& history) -{ - qWarning("Not implemented: %s", __func__); - return stream; -} - -QT_END_NAMESPACE diff --git a/lib/widgets/Api/qwebenginehistory.h b/lib/widgets/Api/qwebenginehistory.h deleted file mode 100644 index b8ea6b863..000000000 --- a/lib/widgets/Api/qwebenginehistory.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - 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> - -QT_BEGIN_NAMESPACE - -class QWebEngineHistory; -class QWebEngineHistoryItemPrivate; -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; -private: - QWebEngineHistoryItem(QWebEngineHistoryItemPrivate *priv); - Q_DECLARE_PRIVATE_D(d.data(), QWebEngineHistoryItem); - QExplicitlySharedDataPointer<QWebEngineHistoryItemPrivate> d; - friend class QWebEngineHistory; - friend class QWebEngineHistoryPrivate; -}; - - -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(QWebEngineHistoryPrivate *d); - ~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); - -QT_END_NAMESPACE - -#endif // QWEBENGINEHISTORY_H diff --git a/lib/widgets/Api/qwebenginehistory_p.h b/lib/widgets/Api/qwebenginehistory_p.h deleted file mode 100644 index 42f3ff73c..000000000 --- a/lib/widgets/Api/qwebenginehistory_p.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** 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 - -#include <QtCore/qshareddata.h> - -class WebContentsAdapter; - -QT_BEGIN_NAMESPACE - -class QWebEngineHistoryItemPrivate : public QSharedData -{ -public: - QWebEngineHistoryItemPrivate(WebContentsAdapter *adapter = 0, int index = 0); - - WebContentsAdapter *adapter; - int index; -}; - -class QWebEngineHistoryPrivate -{ -public: - QWebEngineHistoryPrivate(WebContentsAdapter *adapter); - ~QWebEngineHistoryPrivate(); - void updateItems() const; - - WebContentsAdapter *adapter; - mutable QList<QWebEngineHistoryItem> items; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINEHISTORY_P_H diff --git a/lib/widgets/Api/qwebenginehistoryinterface.h b/lib/widgets/Api/qwebenginehistoryinterface.h deleted file mode 100644 index b8108c516..000000000 --- a/lib/widgets/Api/qwebenginehistoryinterface.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - 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> - -QT_BEGIN_NAMESPACE - -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; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINEHISTORYINTERFACE_H diff --git a/lib/widgets/Api/qwebengineinspector.h b/lib/widgets/Api/qwebengineinspector.h deleted file mode 100644 index 9427b4e5c..000000000 --- a/lib/widgets/Api/qwebengineinspector.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - 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> - -QT_BEGIN_NAMESPACE - -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; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINEINSPECTOR_H diff --git a/lib/widgets/Api/qwebenginepage.cpp b/lib/widgets/Api/qwebenginepage.cpp deleted file mode 100644 index 106e46949..000000000 --- a/lib/widgets/Api/qwebenginepage.cpp +++ /dev/null @@ -1,494 +0,0 @@ -/* - Copyright (C) 2012, 2013 Digia Plc and/or its subsidiary(-ies). - Copyright (C) 2008, 2009, 2012 Nokia Corporation and/or its subsidiary(-ies) - Copyright (C) 2007 Staikos Computing Services Inc. - Copyright (C) 2007 Apple 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. -*/ - -#include "qwebenginepage.h" -#include "qwebenginepage_p.h" - -#include "qwebenginehistory.h" -#include "qwebenginehistory_p.h" -#include "qwebengineview.h" -#include "qwebengineview_p.h" -#include "render_widget_host_view_qt_delegate_widget.h" -#include "web_contents_adapter.h" - -#include <QAction> -#include <QApplication> -#include <QClipboard> -#include <QIcon> -#include <QInputDialog> -#include <QLayout> -#include <QMenu> -#include <QMessageBox> -#include <QUrl> - -QT_BEGIN_NAMESPACE - -QWebEnginePagePrivate::QWebEnginePagePrivate() - : QObjectPrivate(QObjectPrivateVersion) - , adapter(new WebContentsAdapter(SoftwareRenderingMode)) - , history(new QWebEngineHistory(new QWebEngineHistoryPrivate(adapter.data()))) - , view(0) - , m_isLoading(false) -{ - adapter->initialize(this); - memset(actions, 0, sizeof(actions)); -} - -QWebEnginePagePrivate::~QWebEnginePagePrivate() -{ - delete history; -} - -RenderWidgetHostViewQtDelegate *QWebEnginePagePrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client, RenderingMode mode) -{ - Q_UNUSED(mode); - return new RenderWidgetHostViewQtDelegateWidget(client); -} - -void QWebEnginePagePrivate::titleChanged(const QString &title) -{ - Q_Q(QWebEnginePage); - Q_EMIT q->titleChanged(title); -} - -void QWebEnginePagePrivate::urlChanged(const QUrl &url) -{ - Q_Q(QWebEnginePage); - Q_EMIT q->urlChanged(url); -} - -void QWebEnginePagePrivate::iconChanged(const QUrl &url) -{ - Q_UNUSED(url) -} - -void QWebEnginePagePrivate::loadingStateChanged() -{ - Q_Q(QWebEnginePage); - const bool wasLoading = m_isLoading; - m_isLoading = adapter->isLoading(); - if (m_isLoading != wasLoading) { - if (m_isLoading) - Q_EMIT q->loadStarted(); - } - updateNavigationActions(); -} - -void QWebEnginePagePrivate::loadProgressChanged(int progress) -{ - Q_Q(QWebEnginePage); - Q_EMIT q->loadProgress(progress); -} - -QRectF QWebEnginePagePrivate::viewportRect() const -{ - return view ? view->geometry() : QRectF(); -} - -void QWebEnginePagePrivate::loadFinished(bool success) -{ - Q_Q(QWebEnginePage); - m_isLoading = adapter->isLoading(); - Q_EMIT q->loadFinished(success); -} - -void QWebEnginePagePrivate::focusContainer() -{ - if (view) - view->setFocus(); -} - -void QWebEnginePagePrivate::adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect &initialGeometry) -{ - Q_Q(QWebEnginePage); - QWebEnginePage *newPage = q->createWindow(disposition == WebContentsAdapterClient::NewPopupDisposition ? QWebEnginePage::WebModalDialog : QWebEnginePage::WebBrowserWindow); - // Overwrite the new page's WebContents with ours. - if (newPage) { - newPage->d_func()->adapter = newWebContents; - newWebContents->initialize(newPage->d_func()); - if (!initialGeometry.isEmpty()) - emit newPage->geometryChangeRequested(initialGeometry); - } -} - -void QWebEnginePagePrivate::close() -{ - Q_Q(QWebEnginePage); - Q_EMIT q->windowCloseRequested(); -} - -void QWebEnginePagePrivate::updateAction(QWebEnginePage::WebAction action) const -{ -#ifdef QT_NO_ACTION - Q_UNUSED(action) -#else - QAction *a = actions[action]; - if (!a) - return; - - bool enabled = false; - - switch (action) { - case QWebEnginePage::Back: - enabled = adapter->canGoBack(); - break; - case QWebEnginePage::Forward: - enabled = adapter->canGoForward(); - break; - case QWebEnginePage::Stop: - enabled = adapter->isLoading(); - break; - case QWebEnginePage::Reload: - case QWebEnginePage::ReloadAndBypassCache: - enabled = !adapter->isLoading(); - break; - default: - break; - } - - a->setEnabled(enabled); -#endif // QT_NO_ACTION -} - -void QWebEnginePagePrivate::updateNavigationActions() -{ - updateAction(QWebEnginePage::Back); - updateAction(QWebEnginePage::Forward); - updateAction(QWebEnginePage::Stop); - updateAction(QWebEnginePage::Reload); - updateAction(QWebEnginePage::ReloadAndBypassCache); -} - -#ifndef QT_NO_ACTION -void QWebEnginePagePrivate::_q_webActionTriggered(bool checked) -{ - Q_Q(QWebEnginePage); - QAction *a = qobject_cast<QAction *>(q->sender()); - if (!a) - return; - QWebEnginePage::WebAction action = static_cast<QWebEnginePage::WebAction>(a->data().toInt()); - q->triggerAction(action, checked); -} -#endif // QT_NO_ACTION - -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; -} - -#ifndef QT_NO_ACTION -QAction *QWebEnginePage::action(WebAction action) const -{ - Q_D(const QWebEnginePage); - if (action == QWebEnginePage::NoWebAction) - return 0; - if (d->actions[action]) - return d->actions[action]; - - QString text; - QIcon icon; - QStyle *style = d->view ? d->view->style() : qApp->style(); - - switch (action) { - case Back: - text = tr("Back"); - icon = style->standardIcon(QStyle::SP_ArrowBack); - break; - case Forward: - text = tr("Forward"); - icon = style->standardIcon(QStyle::SP_ArrowForward); - break; - case Stop: - text = tr("Stop"); - icon = style->standardIcon(QStyle::SP_BrowserStop); - break; - case Reload: - text = tr("Reload"); - icon = style->standardIcon(QStyle::SP_BrowserReload); - break; - default: - break; - } - - QAction *a = new QAction(const_cast<QWebEnginePage*>(this)); - a->setText(text); - a->setData(action); - a->setIcon(icon); - - connect(a, SIGNAL(triggered(bool)), this, SLOT(_q_webActionTriggered(bool))); - - d->actions[action] = a; - d->updateAction(action); - return a; -} -#endif // QT_NO_ACTION - -void QWebEnginePage::triggerAction(WebAction action, bool) -{ - Q_D(QWebEnginePage); - switch (action) { - case Back: - d->adapter->navigateToOffset(-1); - break; - case Forward: - d->adapter->navigateToOffset(1); - break; - case Stop: - d->adapter->stop(); - break; - case Reload: - d->adapter->reload(); - break; - default: - Q_UNREACHABLE(); - } -} - -bool QWebEnginePagePrivate::contextMenuRequested(const WebEngineContextMenuData &data) -{ - if (!view) - return false; - - QContextMenuEvent event(QContextMenuEvent::Mouse, data.pos, view->mapToGlobal(data.pos)); - switch (view->contextMenuPolicy()) { - case Qt::PreventContextMenu: - return false; - case Qt::DefaultContextMenu: - m_menuData = data; - view->contextMenuEvent(&event); - break; - case Qt::CustomContextMenu: - Q_EMIT view->customContextMenuRequested(data.pos); - break; - case Qt::ActionsContextMenu: - if (view->actions().count()) { - QMenu::exec(view->actions(), event.globalPos(), 0, view); - break; - } - // fall through - default: - event.ignore(); - return false; - break; - } - Q_ASSERT(view->d_func()->m_pendingContextMenuEvent); - view->d_func()->m_pendingContextMenuEvent = false; - m_menuData = WebEngineContextMenuData(); - return true; -} - -bool QWebEnginePagePrivate::javascriptDialog(JavascriptDialogType type, const QString &message, const QString &defaultValue, QString *result) -{ - Q_Q(QWebEnginePage); - switch (type) { - case AlertDialog: - q->javaScriptAlert(0, message); - return true; - case ConfirmDialog: - return q->javaScriptConfirm(0, message); - case PromptDialog: - return q->javaScriptPrompt(0, message, defaultValue, result); - } - Q_UNREACHABLE(); - return false; -} - -namespace { -class SaveToClipboardFunctor -{ - QString m_text; -public: - SaveToClipboardFunctor(const QString &text) - : m_text(text) - {} - void operator()() const - { - qApp->clipboard()->setText(m_text); - } -}; - -class LoadUrlFunctor -{ - QWebEnginePage *m_page; - QUrl m_url; -public: - LoadUrlFunctor(QWebEnginePage *page, const QUrl &url) - : m_page(page) - , m_url(url) - {} - void operator()() const - { - m_page->load(m_url); - } -}; -} - -QMenu *QWebEnginePage::createStandardContextMenu() -{ - Q_D(QWebEnginePage); - QMenu *menu = new QMenu(d->view); - QAction *action = 0; - WebEngineContextMenuData contextMenuData(d->m_menuData); - if (contextMenuData.selectedText.isEmpty()) { - action = new QAction(QIcon::fromTheme(QStringLiteral("go-previous")), tr("&Back"), menu); - connect(action, &QAction::triggered, d->view, &QWebEngineView::back); - action->setEnabled(d->adapter->canGoBack()); - menu->addAction(action); - - action = new QAction(QIcon::fromTheme(QStringLiteral("go-next")), tr("&Forward"), menu); - connect(action, &QAction::triggered, d->view, &QWebEngineView::forward); - action->setEnabled(d->adapter->canGoForward()); - menu->addAction(action); - - action = new QAction(QIcon::fromTheme(QStringLiteral("view-refresh")), tr("&Reload"), menu); - connect(action, &QAction::triggered, d->view, &QWebEngineView::reload); - menu->addAction(action); - } else { - action = new QAction(tr("Copy..."), menu); - connect(action, &QAction::triggered, SaveToClipboardFunctor(contextMenuData.selectedText)); - menu->addAction(action); - } - - if (!contextMenuData.linkText.isEmpty() && contextMenuData.linkUrl.isValid()) { - menu->addSeparator(); - action = new QAction(tr("Navigate to..."), menu); - connect(action, &QAction::triggered, LoadUrlFunctor(this, contextMenuData.linkUrl)); - menu->addAction(action); - action = new QAction(tr("Copy link address"), menu); - connect(action, &QAction::triggered, SaveToClipboardFunctor(contextMenuData.linkUrl.toString())); - menu->addAction(action); - } - return menu; -} - -void QWebEnginePage::load(const QUrl& url) -{ - Q_D(QWebEnginePage); - d->adapter->load(url); -} - -QString QWebEnginePage::title() const -{ - Q_D(const QWebEnginePage); - return d->adapter->pageTitle(); -} - -void QWebEnginePage::setUrl(const QUrl &url) -{ - load(url); -} - -QUrl QWebEnginePage::url() const -{ - Q_D(const QWebEnginePage); - return d->adapter->activeUrl(); -} - -qreal QWebEnginePage::zoomFactor() const -{ - Q_D(const QWebEnginePage); - return d->adapter->currentZoomFactor(); -} - -void QWebEnginePage::setZoomFactor(qreal factor) -{ - Q_D(QWebEnginePage); - d->adapter->setZoomFactor(factor); -} - -void QWebEnginePage::runJavaScript(const QString &scriptSource, const QString &xPath) -{ - Q_D(QWebEnginePage); - d->adapter->runJavaScript(scriptSource, xPath); -} - -namespace { -struct JSCallbackFunctor : public JSCallbackBase { - JSCallbackFunctor(QtWebEnginePrivate::FunctorBase *functor) : m_func(functor) { } - ~JSCallbackFunctor() { delete m_func; } - void call(const QVariant &value) { (*m_func)(value); } -private: - QtWebEnginePrivate::FunctorBase *m_func; -}; -} - -void QWebEnginePage::runJavaScriptHelper(const QString &source, QtWebEnginePrivate::FunctorBase *functor, const QString &xPath) -{ - Q_D(QWebEnginePage); - d->adapter->runJavaScript(source, xPath, new JSCallbackFunctor(functor)); -} - -QWebEnginePage *QWebEnginePage::createWindow(WebWindowType type) -{ - Q_D(QWebEnginePage); - if (d->view) { - QWebEngineView *newView = d->view->createWindow(type); - if (newView) - return newView->page(); - } - return 0; -} - -void QWebEnginePage::javaScriptAlert(QWebEngineFrame *originatingFrame, const QString &msg) -{ - Q_UNUSED(originatingFrame); - QMessageBox::information(view(), QStringLiteral("Javascript Alert - %1").arg(url().toString()), msg); -} - -bool QWebEnginePage::javaScriptConfirm(QWebEngineFrame *originatingFrame, const QString &msg) -{ - Q_UNUSED(originatingFrame); - return (QMessageBox::information(view(), QStringLiteral("Javascript Confirm - %1").arg(url().toString()), msg, QMessageBox::Ok, QMessageBox::Cancel) == QMessageBox::Ok); -} - -bool QWebEnginePage::javaScriptPrompt(QWebEngineFrame *originatingFrame, const QString &msg, const QString &defaultValue, QString *result) -{ - Q_UNUSED(originatingFrame); - bool ret = false; - if (result) - *result = QInputDialog::getText(view(), QStringLiteral("Javascript Prompt - %1").arg(url().toString()), msg, QLineEdit::Normal, defaultValue, &ret); - return ret; -} -QT_END_NAMESPACE - -#include "moc_qwebenginepage.cpp" diff --git a/lib/widgets/Api/qwebenginepage.h b/lib/widgets/Api/qwebenginepage.h deleted file mode 100644 index a613f4a27..000000000 --- a/lib/widgets/Api/qwebenginepage.h +++ /dev/null @@ -1,592 +0,0 @@ -/* - 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 <QtCore/qvariant.h> -#include <QtNetwork/qnetworkaccessmanager.h> -#include <QtWidgets/qwidget.h> - -QT_BEGIN_NAMESPACE -class QUndoStack; -class QMenu; -class QPrinter; - -// FIXME: Just forward-declare the to-be-removed frame and element classes for now. -// Referencing calls should be ported to be page-friendly or removed individually. -class QWebEngineFrame; -class QWebEngineElement; -class QWebEngineElementCollection; - -class QWebEngineHistory; -class QWebEngineHistoryItem; -class QWebEnginePagePrivate; -class QWebEnginePluginFactory; -class QWebEngineSecurityOrigin; -class QtViewportAttributesPrivate; -class QWebEngineHitTestResultPrivate; - -namespace QtWebEnginePrivate { - -struct FunctorBase { - virtual ~FunctorBase() {} - virtual void operator()(const QVariant &) = 0; -}; - -template <typename F> -struct FunctorCallback : public FunctorBase { - FunctorCallback(F callback) : m_callback(callback) {} - virtual void operator()(const QVariant &value) Q_DECL_OVERRIDE { m_callback(value); } -private: - F m_callback; -}; -} - -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; -}; - -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) - - // Ex-QWebFrame properties - Q_PROPERTY(qreal textSizeMultiplier READ textSizeMultiplier WRITE setTextSizeMultiplier DESIGNABLE false) - 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) -#endif - Q_PROPERTY(qreal zoomFactor READ zoomFactor WRITE setZoomFactor) - Q_PROPERTY(QString title READ title) - Q_PROPERTY(QUrl url READ url WRITE setUrl) - -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 - }; - - // Ex-QWebFrame enum - enum ValueOwnership { - QtOwnership, - ScriptOwnership, - AutoOwnership - }; - - 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); - - 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; } - - // Ex-QWebFrame methods - 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; - - void runJavaScript(const QString& scriptSource, const QString &xPath = QString()); - - template <typename F> - void runJavaScript(const QString& scriptSource, F func, const QString &xPath = QString()); - -public Q_SLOTS: - // Ex-QWebFrame slot -#ifndef QT_NO_PRINTER - void print(QPrinter *printer) const { Q_UNUSED(printer); Q_UNREACHABLE(); } -#endif - - -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); - - // Ex-QWebFrame 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 pageChanged(); - -protected: - virtual QWebEnginePage *createWindow(WebWindowType type); - 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); - virtual bool javaScriptConfirm(QWebEngineFrame *originatingFrame, const QString& msg); - virtual bool javaScriptPrompt(QWebEngineFrame *originatingFrame, const QString& msg, const QString& defaultValue, QString* result); - 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); -#ifndef QT_NO_ACTION - Q_PRIVATE_SLOT(d_func(), void _q_webActionTriggered(bool checked)) -#endif - void runJavaScriptHelper(const QString &source, QtWebEnginePrivate::FunctorBase *, const QString &xPath); - - friend class QWebEngineView; - friend class QWebEngineViewPrivate; -}; - -Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEnginePage::FindFlags); -Q_DECLARE_OPERATORS_FOR_FLAGS(QWebEnginePage::RenderLayers); - - -template <typename F> -inline void QWebEnginePage::runJavaScript(const QString &scriptSource, F func, const QString &xPath) -{ - runJavaScriptHelper(scriptSource, new QtWebEnginePrivate::FunctorCallback<F>(func), xPath); -} - -QT_END_NAMESPACE - -#endif // QWEBENGINEPAGE_H diff --git a/lib/widgets/Api/qwebenginepage_p.h b/lib/widgets/Api/qwebenginepage_p.h deleted file mode 100644 index 0e654e6c9..000000000 --- a/lib/widgets/Api/qwebenginepage_p.h +++ /dev/null @@ -1,95 +0,0 @@ -/**************************************************************************** -** -** 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 "web_contents_adapter_client.h" -#include <QtCore/private/qobject_p.h> -#include <QSharedData> - -class RenderWidgetHostViewQtDelegate; -class WebContentsAdapter; - -QT_BEGIN_NAMESPACE -class QWebEngineHistory; -class QWebEnginePage; -class QWebEngineView; - -class QWebEnginePagePrivate : public QObjectPrivate, public WebContentsAdapterClient -{ -public: - Q_DECLARE_PUBLIC(QWebEnginePage) - - QWebEnginePagePrivate(); - ~QWebEnginePagePrivate(); - - virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client, RenderingMode mode) Q_DECL_OVERRIDE; - virtual void titleChanged(const QString&) Q_DECL_OVERRIDE; - virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE; - virtual void loadingStateChanged() Q_DECL_OVERRIDE; - virtual void loadProgressChanged(int progress) Q_DECL_OVERRIDE; - virtual QRectF viewportRect() const Q_DECL_OVERRIDE; - virtual void loadFinished(bool success) Q_DECL_OVERRIDE; - virtual void focusContainer() Q_DECL_OVERRIDE; - virtual void adoptNewWindow(WebContentsAdapter *newWebContents, WindowOpenDisposition disposition, const QRect &initialGeometry) Q_DECL_OVERRIDE; - virtual void close() Q_DECL_OVERRIDE; - virtual bool contextMenuRequested(const WebEngineContextMenuData &data) Q_DECL_OVERRIDE; - virtual bool javascriptDialog(JavascriptDialogType type, const QString &message, const QString &defaultValue = QString(), QString *result = 0) Q_DECL_OVERRIDE; - - void updateAction(QWebEnginePage::WebAction) const; - void updateNavigationActions(); - void _q_webActionTriggered(bool checked); - - QExplicitlySharedDataPointer<WebContentsAdapter> adapter; - QWebEngineHistory *history; - QWebEngineView *view; - mutable QAction *actions[QWebEnginePage::WebActionCount]; - bool m_isLoading; - WebEngineContextMenuData m_menuData; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINEPAGE_P_H diff --git a/lib/widgets/Api/qwebenginesecurityorigin.h b/lib/widgets/Api/qwebenginesecurityorigin.h deleted file mode 100644 index c943bec84..000000000 --- a/lib/widgets/Api/qwebenginesecurityorigin.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - 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> - -QT_BEGIN_NAMESPACE -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; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINESECURITYORIGIN_H_ diff --git a/lib/widgets/Api/qwebenginesettings.h b/lib/widgets/Api/qwebenginesettings.h deleted file mode 100644 index 177a975fd..000000000 --- a/lib/widgets/Api/qwebenginesettings.h +++ /dev/null @@ -1,170 +0,0 @@ -/* - 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> - -QT_BEGIN_NAMESPACE - -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; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINESETTINGS_H diff --git a/lib/widgets/Api/qwebengineview.cpp b/lib/widgets/Api/qwebengineview.cpp deleted file mode 100644 index 4dea036b1..000000000 --- a/lib/widgets/Api/qwebengineview.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/**************************************************************************** -** -** 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 "qwebengineview.h" -#include "qwebengineview_p.h" - -#include "qwebenginepage_p.h" - -#include <QAction> -#include <QMenu> -#include <QContextMenuEvent> -#include <QStackedLayout> - -QT_BEGIN_NAMESPACE - -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; - } - - if (view && page) { - QObject::connect(page, &QWebEnginePage::titleChanged, view, &QWebEngineView::titleChanged); - QObject::connect(page, &QWebEnginePage::urlChanged, view, &QWebEngineView::urlChanged); - QObject::connect(page, &QWebEnginePage::loadStarted, view, &QWebEngineView::loadStarted); - QObject::connect(page, &QWebEnginePage::loadProgress, view, &QWebEngineView::loadProgress); - QObject::connect(page, &QWebEnginePage::loadFinished, view, &QWebEngineView::loadFinished); - } -} - -QWebEngineViewPrivate::QWebEngineViewPrivate() - : QWidgetPrivate(QObjectPrivateVersion) - , page(0) -{ -} - -QWebEngineView::QWebEngineView(QWidget *parent) - : QWidget(*(new QWebEngineViewPrivate), parent, 0) -{ - // This causes the child RenderWidgetHostViewQtDelegateWidgets to fill this widget. - setLayout(new QStackedLayout); -} - -QWebEngineView::~QWebEngineView() -{ -} - -QWebEnginePage* QWebEngineView::page() const -{ - Q_D(const QWebEngineView); - if (!d->page) { - QWebEngineView *that = const_cast<QWebEngineView*>(this); - that->setPage(new QWebEnginePage(that)); - } - return d->page; -} - -void QWebEngineView::setPage(QWebEnginePage* page) -{ - QWebEngineViewPrivate::bind(this, page); -} - -void QWebEngineView::load(const QUrl& url) -{ - page()->load(url); -} - -QWebEngineHistory* QWebEngineView::history() const -{ - return page()->history(); -} - -QString QWebEngineView::title() const -{ - return page()->title(); -} - -void QWebEngineView::setUrl(const QUrl &url) -{ - page()->setUrl(url); -} - -QUrl QWebEngineView::url() const -{ - return page()->url(); -} - -#ifndef QT_NO_ACTION -QAction* QWebEngineView::pageAction(QWebEnginePage::WebAction action) const -{ - return page()->action(action); -} -#endif - -void QWebEngineView::triggerPageAction(QWebEnginePage::WebAction action, bool checked) -{ - page()->triggerAction(action, checked); -} - -void QWebEngineView::stop() -{ - page()->triggerAction(QWebEnginePage::Stop); -} - -void QWebEngineView::back() -{ - page()->triggerAction(QWebEnginePage::Back); -} - -void QWebEngineView::forward() -{ - page()->triggerAction(QWebEnginePage::Forward); -} - -void QWebEngineView::reload() -{ - page()->triggerAction(QWebEnginePage::Reload); -} - -QWebEngineView *QWebEngineView::createWindow(QWebEnginePage::WebWindowType type) -{ - Q_UNUSED(type) - return 0; -} - - -qreal QWebEngineView::zoomFactor() const -{ - return page()->zoomFactor(); -} - -void QWebEngineView::setZoomFactor(qreal factor) -{ - page()->setZoomFactor(factor); -} - -bool QWebEngineView::event(QEvent *ev) -{ - // We swallow spontaneous contextMenu events and synthethize those back later on when we get the - // HandleContextMenu callback from chromium - if (ev->type() == QEvent::ContextMenu) { - ev->accept(); - return true; - } - return QWidget::event(ev); -} - -void QWebEngineView::contextMenuEvent(QContextMenuEvent *event) -{ - QMenu *menu = page()->createStandardContextMenu(); - menu->popup(event->globalPos()); -} - -QT_END_NAMESPACE - -#include "moc_qwebengineview.cpp" diff --git a/lib/widgets/Api/qwebengineview.h b/lib/widgets/Api/qwebengineview.h deleted file mode 100644 index 2c649d46f..000000000 --- a/lib/widgets/Api/qwebengineview.h +++ /dev/null @@ -1,145 +0,0 @@ -/* - 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 <QtGui/qpainter.h> -#include <QtNetwork/qnetworkaccessmanager.h> -#include <QtWidgets/qwidget.h> - -#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h> -#include <QtWebEngineWidgets/qwebenginepage.h> - -QT_BEGIN_NAMESPACE -class QContextMenuEvent; -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: - explicit QWebEngineView(QWidget* parent = 0); - virtual ~QWebEngineView(); - - QWebEnginePage* page() const; - void setPage(QWebEnginePage* page); - - 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()); - - 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); - - virtual QSize sizeHint() const { return QSize(800, 600); } - -public Q_SLOTS: - void stop(); - void back(); - void forward(); - void reload(); - - void print(QPrinter*) const { } - -Q_SIGNALS: - void loadStarted(); - void loadProgress(int progress); - void loadFinished(bool); - void titleChanged(const QString& title); - void statusBarMessage(const QString& text); - void linkClicked(const QUrl&); - void selectionChanged(); - void iconChanged(); - void urlChanged(const QUrl&); - -protected: - virtual QWebEngineView *createWindow(QWebEnginePage::WebWindowType type); - virtual void contextMenuEvent(QContextMenuEvent*) Q_DECL_OVERRIDE; - virtual bool event(QEvent*) Q_DECL_OVERRIDE; - -private: - Q_DECLARE_PRIVATE(QWebEngineView); - - friend class QWebEnginePage; - friend class QWebEnginePagePrivate; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINEVIEW_H diff --git a/lib/widgets/Api/qwebengineview_p.h b/lib/widgets/Api/qwebengineview_p.h deleted file mode 100644 index 774386a21..000000000 --- a/lib/widgets/Api/qwebengineview_p.h +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** 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 QWEBENGINEVIEW_P_H -#define QWEBENGINEVIEW_P_H - -#include <QtWidgets/private/qwidget_p.h> -#include <QtWebEngineWidgets/qwebengineview.h> - -QT_BEGIN_NAMESPACE - -class QWebEngineView; - -class QWebEngineViewPrivate : public QWidgetPrivate -{ -public: - Q_DECLARE_PUBLIC(QWebEngineView) - - static void bind(QWebEngineView *view, QWebEnginePage *page); - - QWebEngineViewPrivate(); - - QWebEnginePage *page; - bool m_pendingContextMenuEvent; -}; - -QT_END_NAMESPACE - -#endif // QWEBENGINEVIEW_P_H diff --git a/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp deleted file mode 100644 index 0d84a0f46..000000000 --- a/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************************** -** -** 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 "render_widget_host_view_qt_delegate_widget.h" - -#include "qwebengineview.h" -#include "qwebenginepage_p.h" -#include <QtGlobal> -#include <QLayout> -#include <QResizeEvent> -#include <QPainter> -#include <QPaintEvent> -#include <QWindow> -#include <QtWidgets/QApplication> - -RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent) - : QWidget(parent) - , m_client(client) -{ - setFocusPolicy(Qt::ClickFocus); - setMouseTracking(true); - setAttribute(Qt::WA_AcceptTouchEvents); - setAttribute(Qt::WA_OpaquePaintEvent); -} - -void RenderWidgetHostViewQtDelegateWidget::initAsChild(WebContentsAdapterClient* container) -{ - QWebEnginePagePrivate *pagePrivate = static_cast<QWebEnginePagePrivate *>(container); - // FIXME: What is going to trigger this if the page is attached later to the view? - if (pagePrivate->view) - pagePrivate->view->layout()->addWidget(this); -} - -void RenderWidgetHostViewQtDelegateWidget::initAsPopup(const QRect& rect) -{ - QPoint pos = QWidget::mapToGlobal(rect.topLeft()); - QRect qrect = QRect(pos, rect.size()); - setGeometry(qrect); - show(); -} - -QRectF RenderWidgetHostViewQtDelegateWidget::screenRect() const -{ - return QRectF(x(), y(), width(), height()); -} - -void RenderWidgetHostViewQtDelegateWidget::setKeyboardFocus() -{ - setFocus(); -} - -bool RenderWidgetHostViewQtDelegateWidget::hasKeyboardFocus() -{ - return hasFocus(); -} - -void RenderWidgetHostViewQtDelegateWidget::show() -{ - QWidget::show(); -} - -void RenderWidgetHostViewQtDelegateWidget::hide() -{ - QWidget::hide(); -} - -bool RenderWidgetHostViewQtDelegateWidget::isVisible() const -{ - return QWidget::isVisible(); -} - -WId RenderWidgetHostViewQtDelegateWidget::nativeWindowIdForCompositor() const -{ - // The QtWidgets API doesn't support hardware acceleration. - return 0; -} - -QWindow* RenderWidgetHostViewQtDelegateWidget::window() const -{ - const QWidget* root = QWidget::window(); - return root ? root->windowHandle() : 0; -} - -void RenderWidgetHostViewQtDelegateWidget::update(const QRect& rect) -{ - QWidget::update(rect); -} - -void RenderWidgetHostViewQtDelegateWidget::updateCursor(const QCursor &cursor) -{ - QWidget::setCursor(cursor); -} - -void RenderWidgetHostViewQtDelegateWidget::resize(int width, int height) -{ - QWidget::resize(width, height); -} - -void RenderWidgetHostViewQtDelegateWidget::inputMethodStateChanged(bool editorVisible) -{ - if (qApp->inputMethod()->isVisible() == editorVisible) - return; - - QWidget::setAttribute(Qt::WA_InputMethodEnabled, editorVisible); - qApp->inputMethod()->update(Qt::ImQueryInput | Qt::ImEnabled | Qt::ImHints); - qApp->inputMethod()->setVisible(editorVisible); -} - -QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQuery query) const -{ - return m_client->inputMethodQuery(query); -} - -void RenderWidgetHostViewQtDelegateWidget::paintEvent(QPaintEvent * event) -{ - QPainter painter(this); - m_client->fetchBackingStore(); - m_client->paint(&painter, event->rect()); -} - -void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent) -{ - Q_UNUSED(resizeEvent); - m_client->notifyResize(); -} - -bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event) -{ - if (!m_client->forwardEvent(event)) - return QWidget::event(event); - return true; -} diff --git a/lib/widgets/render_widget_host_view_qt_delegate_widget.h b/lib/widgets/render_widget_host_view_qt_delegate_widget.h deleted file mode 100644 index 7ec91931f..000000000 --- a/lib/widgets/render_widget_host_view_qt_delegate_widget.h +++ /dev/null @@ -1,87 +0,0 @@ -/**************************************************************************** -** -** 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 RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_WIDGET_H -#define RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_WIDGET_H - -#include "render_widget_host_view_qt_delegate.h" -#include "web_contents_adapter_client.h" - -#include <QWidget> - -class BackingStoreQt; - -QT_BEGIN_NAMESPACE -class QWindow; -QT_END_NAMESPACE - -class RenderWidgetHostViewQtDelegateWidget : public QWidget, public RenderWidgetHostViewQtDelegate -{ -public: - RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = 0); - - virtual void initAsChild(WebContentsAdapterClient* container) Q_DECL_OVERRIDE; - virtual void initAsPopup(const QRect&) Q_DECL_OVERRIDE; - virtual QRectF screenRect() const Q_DECL_OVERRIDE; - virtual void setKeyboardFocus() Q_DECL_OVERRIDE; - virtual bool hasKeyboardFocus() Q_DECL_OVERRIDE; - virtual void show() Q_DECL_OVERRIDE; - virtual void hide() Q_DECL_OVERRIDE; - virtual bool isVisible() const Q_DECL_OVERRIDE; - virtual WId nativeWindowIdForCompositor() const Q_DECL_OVERRIDE; - virtual QWindow* window() const Q_DECL_OVERRIDE; - virtual void update(const QRect& rect = QRect()) Q_DECL_OVERRIDE; - virtual void updateCursor(const QCursor &) Q_DECL_OVERRIDE; - virtual void resize(int width, int height) Q_DECL_OVERRIDE; - virtual void inputMethodStateChanged(bool editorVisible) Q_DECL_OVERRIDE; - -protected: - void paintEvent(QPaintEvent * event); - bool event(QEvent *event); - void resizeEvent(QResizeEvent *resizeEvent); - - QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - -private: - RenderWidgetHostViewQtDelegateClient *m_client; -}; - -#endif diff --git a/lib/widgets/widgets.pro b/lib/widgets/widgets.pro deleted file mode 100644 index 3338e0cf7..000000000 --- a/lib/widgets/widgets.pro +++ /dev/null @@ -1,47 +0,0 @@ -# Use Qt5 module system -load(qt_build_config) - -TEMPLATE = lib -TARGET = QtWebEngineWidgets - -MODULE = webenginewidgets - -# For our export macros -DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB - -QT += widgets -QT_PRIVATE += widgets-private gui-private core-private - -# FIXME: all this should eventually be turned into QT += webenginecore -macx:LIBPATH = $$getOutDir()/$$getConfigDir() -else:LIBPATH = $$getOutDir()/$$getConfigDir()/lib -LIBS_PRIVATE += -lQt5WebEngineCore -L$$LIBPATH -QMAKE_RPATHDIR += $$LIBPATH - -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 - -load(qt_module) - -# QNX ld only supports staging-relative rpath values and can't use the rpath specified above. -# Instead, append an appropriate rpath-link to lib_qt_webenginewidgets.pri. -qnx:!build_pass { - local_build_rpath_link = "QMAKE_RPATHLINKDIR += $$LIBPATH" - # MODULE_PRI is defined in qt_module_pris.prf - write_file($$MODULE_PRI, local_build_rpath_link, append) -} |