summaryrefslogtreecommitdiffstats
path: root/src/webenginewidgets
diff options
context:
space:
mode:
Diffstat (limited to 'src/webenginewidgets')
-rw-r--r--src/webenginewidgets/CMakeLists.txt14
-rw-r--r--src/webenginewidgets/api/qtwebenginewidgetsglobal.h40
-rw-r--r--src/webenginewidgets/api/qwebenginenotificationpresenter.cpp48
-rw-r--r--src/webenginewidgets/api/qwebenginenotificationpresenter_p.h40
-rw-r--r--src/webenginewidgets/api/qwebengineview.cpp742
-rw-r--r--src/webenginewidgets/api/qwebengineview.h51
-rw-r--r--src/webenginewidgets/api/qwebengineview_p.h97
-rw-r--r--src/webenginewidgets/configure.json28
-rw-r--r--src/webenginewidgets/doc/snippets/push-notifications/commands19
-rw-r--r--src/webenginewidgets/doc/snippets/qtwebengine_qwebengineview_snippet.cpp28
-rw-r--r--src/webenginewidgets/doc/snippets/qtwebenginewidgets_build_snippet.qdoc37
-rw-r--r--src/webenginewidgets/doc/snippets/simple/main.cpp62
-rw-r--r--src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc29
-rw-r--r--src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc37
-rw-r--r--src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc40
-rw-r--r--src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc28
-rw-r--r--src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc36
-rw-r--r--src/webenginewidgets/plugins/qwebengineview/CMakeLists.txt3
-rw-r--r--src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.cpp41
-rw-r--r--src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.h40
-rw-r--r--src/webenginewidgets/qwebengine_accessible.cpp102
-rw-r--r--src/webenginewidgets/qwebengine_accessible_p.h60
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp519
-rw-r--r--src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h137
-rw-r--r--src/webenginewidgets/ui/autofillpopupwidget.cpp201
-rw-r--r--src/webenginewidgets/ui/autofillpopupwidget_p.h58
-rw-r--r--src/webenginewidgets/ui/touchhandlewidget.cpp59
-rw-r--r--src/webenginewidgets/ui/touchhandlewidget_p.h50
-rw-r--r--src/webenginewidgets/ui/touchselectionmenuwidget.cpp117
-rw-r--r--src/webenginewidgets/ui/touchselectionmenuwidget_p.h52
-rw-r--r--src/webenginewidgets/webenginewidgets.pro26
31 files changed, 1412 insertions, 1429 deletions
diff --git a/src/webenginewidgets/CMakeLists.txt b/src/webenginewidgets/CMakeLists.txt
index 6a25e7297..ff043b45a 100644
--- a/src/webenginewidgets/CMakeLists.txt
+++ b/src/webenginewidgets/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
if(TARGET Qt::Designer)
add_subdirectory(plugins/qwebengineview)
else()
@@ -8,12 +11,15 @@ qt_internal_add_module(WebEngineWidgets
api/qtwebenginewidgetsglobal.h
api/qwebenginenotificationpresenter.cpp api/qwebenginenotificationpresenter_p.h
api/qwebengineview.cpp api/qwebengineview.h api/qwebengineview_p.h
- render_widget_host_view_qt_delegate_widget.cpp render_widget_host_view_qt_delegate_widget.h
+ ui/autofillpopupwidget.cpp ui/autofillpopupwidget_p.h
+ ui/touchhandlewidget.cpp ui/touchhandlewidget_p.h
+ ui/touchselectionmenuwidget.cpp ui/touchselectionmenuwidget_p.h
DEFINES
QT_BUILD_WEBENGINEWIDGETS_LIB
INCLUDE_DIRECTORIES
../core
api
+ ui
LIBRARIES
Qt::CorePrivate
Qt::GuiPrivate
@@ -26,6 +32,12 @@ qt_internal_add_module(WebEngineWidgets
Qt::Gui
Qt::Widgets
Qt::WebEngineCore
+ NO_GENERATE_CPP_EXPORTS
+)
+
+qt_internal_extend_target(WebEngineWidgets CONDITION QT_FEATURE_accessibility
+ SOURCES
+ qwebengine_accessible.cpp qwebengine_accessible_p.h
)
qt_internal_extend_target(WebEngineWidgets CONDITION QT_FEATURE_webengine_printing_and_pdf
diff --git a/src/webenginewidgets/api/qtwebenginewidgetsglobal.h b/src/webenginewidgets/api/qtwebenginewidgetsglobal.h
index 128704578..58b9c7a2b 100644
--- a/src/webenginewidgets/api/qtwebenginewidgetsglobal.h
+++ b/src/webenginewidgets/api/qtwebenginewidgetsglobal.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QTWEBENGINEWIDGETSGLOBAL_H
#define QTWEBENGINEWIDGETSGLOBAL_H
diff --git a/src/webenginewidgets/api/qwebenginenotificationpresenter.cpp b/src/webenginewidgets/api/qwebenginenotificationpresenter.cpp
index 667605c37..83814fe4a 100644
--- a/src/webenginewidgets/api/qwebenginenotificationpresenter.cpp
+++ b/src/webenginewidgets/api/qwebenginenotificationpresenter.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qwebenginenotificationpresenter_p.h"
@@ -46,7 +10,7 @@ QT_BEGIN_NAMESPACE
DefaultNotificationPresenter::DefaultNotificationPresenter(QObject *parent) : QObject(parent)
{
-#ifndef QT_NO_SYSTEMTRAYICON
+#if QT_CONFIG(systemtrayicon)
m_systemTrayIcon = new QSystemTrayIcon(this);
connect(m_systemTrayIcon, &QSystemTrayIcon::messageClicked, this, &DefaultNotificationPresenter::messageClicked);
#endif
@@ -66,7 +30,7 @@ void DefaultNotificationPresenter::show(std::unique_ptr<QWebEngineNotification>
m_activeNotification = std::move(notification);
-#ifndef QT_NO_SYSTEMTRAYICON
+#if QT_CONFIG(systemtrayicon)
if (m_activeNotification && m_systemTrayIcon) {
m_systemTrayIcon->setIcon(qApp->windowIcon());
m_systemTrayIcon->show();
@@ -90,7 +54,7 @@ void DefaultNotificationPresenter::messageClicked()
void DefaultNotificationPresenter::closeNotification()
{
-#ifndef QT_NO_SYSTEMTRAYICON
+#if QT_CONFIG(systemtrayicon)
const QWebEngineNotification *canceled = static_cast<const QWebEngineNotification *>(QObject::sender());
if (m_systemTrayIcon && canceled->matches(m_activeNotification.get()))
m_systemTrayIcon->hide();
@@ -107,3 +71,5 @@ void defaultNotificationPresenter(std::unique_ptr<QWebEngineNotification> notifi
QT_END_NAMESPACE
+
+#include "moc_qwebenginenotificationpresenter_p.cpp"
diff --git a/src/webenginewidgets/api/qwebenginenotificationpresenter_p.h b/src/webenginewidgets/api/qwebenginenotificationpresenter_p.h
index 33b6a6782..61e7f9e45 100644
--- a/src/webenginewidgets/api/qwebenginenotificationpresenter_p.h
+++ b/src/webenginewidgets/api/qwebenginenotificationpresenter_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWEBENGINENOTIFICATIONPRESENTER_P_H
#define QWEBENGINENOTIFICATIONPRESENTER_P_H
diff --git a/src/webenginewidgets/api/qwebengineview.cpp b/src/webenginewidgets/api/qwebengineview.cpp
index 635bb10ea..5b47d67bf 100644
--- a/src/webenginewidgets/api/qwebengineview.cpp
+++ b/src/webenginewidgets/api/qwebengineview.cpp
@@ -1,53 +1,25 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+#include "qapplication.h"
#include "qwebenginenotificationpresenter_p.h"
#include "qwebengineview.h"
#include "qwebengineview_p.h"
-#include "render_widget_host_view_qt_delegate_widget.h"
+#include "render_widget_host_view_qt_delegate_client.h"
+#include "render_widget_host_view_qt_delegate_item.h"
+#include "ui/autofillpopupwidget_p.h"
+#include "touchhandlewidget_p.h"
+#include "touchselectionmenuwidget_p.h"
#include <QtWebEngineCore/private/qwebenginepage_p.h>
#include <QtWebEngineCore/qwebenginecontextmenurequest.h>
#include <QtWebEngineCore/qwebenginehistory.h>
#include <QtWebEngineCore/qwebenginehttprequest.h>
#include <QtWebEngineCore/qwebengineprofile.h>
+
+#include "autofill_popup_controller.h"
#include "color_chooser_controller.h"
+#include "touch_selection_menu_controller.h"
#include "web_contents_adapter.h"
#include <QContextMenuEvent>
@@ -57,6 +29,11 @@
#include <QIcon>
#include <QStyle>
#include <QGuiApplication>
+#include <QQuickWidget>
+
+#if QT_CONFIG(accessibility)
+#include "qwebengine_accessible_p.h"
+#endif
#if QT_CONFIG(action)
#include <QAction>
@@ -87,11 +64,311 @@
#if QT_CONFIG(webengine_printing_and_pdf)
#include "printing/printer_worker.h"
+#include <QPrintEngine>
#include <QPrinter>
#include <QThread>
#endif
QT_BEGIN_NAMESPACE
+class QSpontaneKeyEvent
+{
+public:
+ static inline void makeSpontaneous(QEvent *ev) { ev->setSpontaneous(); }
+};
+QT_END_NAMESPACE
+
+namespace QtWebEngineCore {
+class WebEngineQuickWidget : public QQuickWidget, public WidgetDelegate
+{
+public:
+ WebEngineQuickWidget(RenderWidgetHostViewQtDelegateItem *widget, QWidget *parent)
+ : QQuickWidget(parent)
+ , m_contentItem(widget)
+ {
+ setFocusPolicy(Qt::StrongFocus);
+ setMouseTracking(true);
+ setAttribute(Qt::WA_AcceptTouchEvents);
+ setAttribute(Qt::WA_OpaquePaintEvent);
+ setAttribute(Qt::WA_AlwaysShowToolTips);
+
+ QQuickItem *root = new QQuickItem(); // Indirection so we don't delete m_contentItem
+ setContent(QUrl(), nullptr, root);
+ root->setFlags(QQuickItem::ItemHasContents);
+ root->setVisible(true);
+ m_contentItem->setParentItem(root);
+
+ connectRemoveParentBeforeParentDelete();
+ }
+ ~WebEngineQuickWidget() override
+ {
+ if (m_contentItem) {
+ m_contentItem->setWidgetDelegate(nullptr);
+ m_contentItem->setParentItem(nullptr);
+ }
+ }
+
+ void InitAsPopup(const QRect &screenRect) override
+ {
+ setAttribute(Qt::WA_ShowWithoutActivating);
+ setFocusPolicy(Qt::NoFocus);
+ setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
+
+ setGeometry(screenRect);
+ raise();
+ m_contentItem->show();
+ show();
+ }
+
+ void Bind(WebContentsAdapterClient *client) override
+ {
+ QWebEnginePagePrivate *page = static_cast<QWebEnginePagePrivate *>(client);
+ if (m_pageDestroyedConnection)
+ QObject::disconnect(m_pageDestroyedConnection);
+ QWebEngineViewPrivate::bindPageAndWidget(page, this);
+ m_pageDestroyedConnection = QObject::connect(page->q_ptr, &QObject::destroyed, this, &WebEngineQuickWidget::Unbind);
+ }
+
+ void Unbind() override
+ {
+ if (m_pageDestroyedConnection) {
+ QObject::disconnect(m_pageDestroyedConnection);
+ m_pageDestroyedConnection = {};
+ }
+ QWebEngineViewPrivate::bindPageAndWidget(nullptr, this);
+ }
+
+ void Destroy() override
+ {
+ deleteLater();
+ }
+
+ bool ActiveFocusOnPress() override
+ {
+ return true;
+ }
+
+ void SetInputMethodEnabled(bool enabled) override
+ {
+ QQuickWidget::setAttribute(Qt::WA_InputMethodEnabled, enabled);
+ }
+ void SetInputMethodHints(Qt::InputMethodHints hints) override
+ {
+ QQuickWidget::setInputMethodHints(hints);
+ }
+ void SetClearColor(const QColor &color) override
+ {
+ setUpdatesEnabled(false);
+ QQuickWidget::setClearColor(color);
+ // QQuickWidget is usually blended by punching holes into widgets
+ // above it to simulate the visual stacking order. If we want it to be
+ // transparent we have to throw away the proper stacking order and always
+ // blend the complete normal widgets backing store under it.
+ bool isTranslucent = color.alpha() < 255;
+ setAttribute(Qt::WA_AlwaysStackOnTop, isTranslucent);
+ setAttribute(Qt::WA_OpaquePaintEvent, !isTranslucent);
+ setUpdatesEnabled(true);
+ window()->update();
+ }
+ void MoveWindow(const QPoint &screenPos) override
+ {
+ QQuickWidget::move(screenPos);
+ }
+ void Resize(int width, int height) override
+ {
+ QQuickWidget::resize(width, height);
+ }
+ QWindow *Window() override
+ {
+ if (const QWidget *root = QQuickWidget::window())
+ return root->windowHandle();
+ return nullptr;
+ }
+ void unhandledWheelEvent(QWheelEvent *ev) override
+ {
+ auto parentWidget = QQuickWidget::parentWidget();
+ if (parentWidget) {
+ QSpontaneKeyEvent::makeSpontaneous(ev);
+ qApp->notify(parentWidget, ev);
+ }
+ }
+
+protected:
+ void closeEvent(QCloseEvent *event) override
+ {
+ QQuickWidget::closeEvent(event);
+
+ // If a close event was received from the window manager (e.g. when moving the parent window,
+ // clicking outside the popup area)
+ // make sure to notify the Chromium WebUI popup and its underlying
+ // RenderWidgetHostViewQtDelegate instance to be closed.
+ if (m_contentItem && m_contentItem->m_isPopup)
+ m_contentItem->m_client->closePopup();
+ }
+ void showEvent(QShowEvent *event) override
+ {
+ QQuickWidget::showEvent(event);
+ // We don't have a way to catch a top-level window change with QWidget
+ // but a widget will most likely be shown again if it changes, so do
+ // the reconnection at this point.
+ for (const QMetaObject::Connection &c : std::as_const(m_windowConnections))
+ disconnect(c);
+ m_windowConnections.clear();
+ if (QWindow *w = Window()) {
+ m_windowConnections.append(connect(w, SIGNAL(xChanged(int)), m_contentItem, SLOT(onWindowPosChanged())));
+ m_windowConnections.append(connect(w, SIGNAL(yChanged(int)), m_contentItem, SLOT(onWindowPosChanged())));
+ }
+ }
+ void resizeEvent(QResizeEvent *event) override
+ {
+ QQuickWidget::resizeEvent(event);
+ if (m_contentItem) { // FIXME: Not sure why we need to set m_contentItem size manually
+ m_contentItem->setSize(event->size());
+ m_contentItem->onWindowPosChanged();
+ }
+ }
+ QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
+ {
+ if (m_contentItem)
+ return m_contentItem->inputMethodQuery(query);
+ return QVariant();
+ }
+ bool event(QEvent *event) override;
+
+ void connectRemoveParentBeforeParentDelete();
+ void removeParentBeforeParentDelete();
+
+private:
+ friend QWebEngineViewPrivate;
+ QPointer<RenderWidgetHostViewQtDelegateItem> m_contentItem; // deleted by core
+ QMetaObject::Connection m_parentDestroyedConnection;
+ QMetaObject::Connection m_pageDestroyedConnection;
+ QList<QMetaObject::Connection> m_windowConnections;
+};
+
+void WebEngineQuickWidget::connectRemoveParentBeforeParentDelete()
+{
+ disconnect(m_parentDestroyedConnection);
+
+ if (QWidget *parent = parentWidget()) {
+ m_parentDestroyedConnection = connect(parent, &QObject::destroyed,
+ this,
+ &WebEngineQuickWidget::removeParentBeforeParentDelete);
+ } else {
+ m_parentDestroyedConnection = QMetaObject::Connection();
+ }
+}
+
+void WebEngineQuickWidget::removeParentBeforeParentDelete()
+{
+ // Unset the parent, because parent is being destroyed, but the owner of this
+ // WebEngineQuickWidget is actually a RenderWidgetHostViewQt instance.
+ setParent(nullptr);
+
+ // If this widget represents a popup window, make sure to close it, so that if the popup was the
+ // last visible top level window, the application event loop can quit if it deems it necessarry.
+ if (m_contentItem && m_contentItem->m_isPopup)
+ close();
+}
+
+bool WebEngineQuickWidget::event(QEvent *event)
+{
+ bool handled = false;
+
+ // Track parent to make sure we don't get deleted.
+ if (event->type() == QEvent::ParentChange)
+ connectRemoveParentBeforeParentDelete();
+
+ if (!m_contentItem)
+ return QQuickWidget::event(event);
+
+ // Mimic QWidget::event() by ignoring mouse, keyboard, touch and tablet events if the widget is
+ // disabled.
+ if (!isEnabled()) {
+ switch (event->type()) {
+ case QEvent::TabletPress:
+ case QEvent::TabletRelease:
+ case QEvent::TabletMove:
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseMove:
+ case QEvent::TouchBegin:
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ case QEvent::TouchCancel:
+ case QEvent::ContextMenu:
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+#if QT_CONFIG(wheelevent)
+ case QEvent::Wheel:
+#endif
+ return false;
+ default:
+ break;
+ }
+ }
+
+ switch (event->type()) {
+ case QEvent::FocusIn:
+ case QEvent::FocusOut:
+ // We forward focus events later, once they have made it to the content item.
+ return QQuickWidget::event(event);
+ case QEvent::DragEnter:
+ case QEvent::DragLeave:
+ case QEvent::DragMove:
+ case QEvent::Drop:
+ case QEvent::HoverEnter:
+ case QEvent::HoverLeave:
+ case QEvent::HoverMove:
+ // Let the parent handle these events.
+ return false;
+ default:
+ break;
+ }
+
+ switch (event->type()) {
+ case QEvent::MouseButtonPress:
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseMove:
+ // Don't forward mouse events synthesized by the system, which are caused by genuine touch
+ // events. Chromium would then process for e.g. a mouse click handler twice, once due to the
+ // system synthesized mouse event, and another time due to a touch-to-gesture-to-mouse
+ // transformation done by Chromium.
+ // Only allow them for popup type, since QWidgetWindow will ignore them for Qt::Popup flag,
+ // which is expected to get input through synthesized mouse events (either by system or Qt)
+ if (!m_contentItem->m_isPopup &&
+ static_cast<QMouseEvent *>(event)->source() == Qt::MouseEventSynthesizedBySystem) {
+ Q_ASSERT(!windowFlags().testFlag(Qt::Popup));
+ return true;
+ }
+ break;
+ default:
+ break;
+ }
+
+ if (event->type() == QEvent::MouseButtonDblClick) {
+ // QWidget keeps the Qt4 behavior where the DblClick event would replace the Press event.
+ // QtQuick is different by sending both the Press and DblClick events for the second press
+ // where we can simply ignore the DblClick event.
+ QMouseEvent *dblClick = static_cast<QMouseEvent *>(event);
+ QMouseEvent press(QEvent::MouseButtonPress, dblClick->position(), dblClick->scenePosition(),
+ dblClick->globalPosition(), dblClick->button(), dblClick->buttons(),
+ dblClick->modifiers(), dblClick->source());
+ press.setTimestamp(dblClick->timestamp());
+ handled = m_contentItem->m_client->forwardEvent(&press);
+ } else
+ handled = m_contentItem->m_client->forwardEvent(event);
+
+ if (!handled)
+ return QQuickWidget::event(event);
+ event->accept();
+ return true;
+}
+
+} // namespace QtWebEngineCore
+
+QT_BEGIN_NAMESPACE
void QWebEngineViewPrivate::pageChanged(QWebEnginePage *oldPage, QWebEnginePage *newPage)
{
@@ -144,8 +421,8 @@ void QWebEngineViewPrivate::pageChanged(QWebEnginePage *oldPage, QWebEnginePage
Q_EMIT q->selectionChanged();
}
-void QWebEngineViewPrivate::widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *oldWidget,
- QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *newWidget)
+void QWebEngineViewPrivate::widgetChanged(QtWebEngineCore::WebEngineQuickWidget *oldWidget,
+ QtWebEngineCore::WebEngineQuickWidget *newWidget)
{
Q_Q(QWebEngineView);
@@ -153,19 +430,22 @@ void QWebEngineViewPrivate::widgetChanged(QtWebEngineCore::RenderWidgetHostViewQ
q->layout()->removeWidget(oldWidget);
oldWidget->hide();
#if QT_CONFIG(accessibility)
- QAccessible::deleteAccessibleInterface(QAccessible::uniqueId(QAccessible::queryAccessibleInterface(oldWidget)));
+ if (!QtWebEngineCore::closingDown())
+ QAccessible::deleteAccessibleInterface(
+ QAccessible::uniqueId(QAccessible::queryAccessibleInterface(oldWidget)));
#endif
}
if (newWidget) {
+ Q_ASSERT(!QtWebEngineCore::closingDown());
#if QT_CONFIG(accessibility)
- // An earlier QAccessible::queryAccessibleInterface() call may have already registered a default
- // QAccessibleInterface for newWidget: remove it first to avoid assert in QAccessibleCache::insert().
QAccessible::deleteAccessibleInterface(QAccessible::uniqueId(QAccessible::queryAccessibleInterface(newWidget)));
QAccessible::registerAccessibleInterface(new QtWebEngineCore::RenderWidgetHostViewQtDelegateWidgetAccessible(newWidget, q));
#endif
q->layout()->addWidget(newWidget);
q->setFocusProxy(newWidget);
+ if (oldWidget && oldWidget == QApplication::focusWidget())
+ newWidget->setFocus();
newWidget->show();
}
}
@@ -185,7 +465,7 @@ void QWebEngineViewPrivate::contextMenuRequested(QWebEngineContextMenuRequest *r
Q_EMIT q_ptr->customContextMenuRequested(request->position());
return;
case Qt::ActionsContextMenu:
- if (q_ptr->actions().count()) {
+ if (q_ptr->actions().size()) {
QContextMenuEvent event(QContextMenuEvent::Mouse, request->position(),
q_ptr->mapToGlobal(request->position()));
QMenu::exec(q_ptr->actions(), event.globalPos(), 0, q_ptr);
@@ -264,6 +544,10 @@ void QWebEngineViewPrivate::showColorDialog(
QColorDialog::connect(dialog, SIGNAL(colorSelected(QColor)), dialog, SLOT(deleteLater()));
QColorDialog::connect(dialog, SIGNAL(rejected()), dialog, SLOT(deleteLater()));
+#if defined(Q_OS_MACOS)
+ dialog->setOption(QColorDialog::DontUseNativeDialog);
+#endif
+
dialog->open();
#else
Q_UNUSED(controller);
@@ -274,8 +558,10 @@ bool QWebEngineViewPrivate::showAuthorizationDialog(const QString &title, const
{
#if QT_CONFIG(messagebox)
Q_Q(QWebEngineView);
- return QMessageBox::question(q, title, message, QMessageBox::Yes, QMessageBox::No)
- == QMessageBox::Yes;
+ QMessageBox msgBox(QMessageBox::Question, title, message, QMessageBox::Yes | QMessageBox::No,
+ q, Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
+ msgBox.setTextFormat(Qt::PlainText);
+ return msgBox.exec() == QMessageBox::Yes;
#else
return false;
#endif // QT_CONFIG(messagebox)
@@ -285,8 +571,12 @@ void QWebEngineViewPrivate::javaScriptAlert(const QUrl &url, const QString &msg)
{
#if QT_CONFIG(messagebox)
Q_Q(QWebEngineView);
- QMessageBox::information(q, QStringLiteral("Javascript Alert - %1").arg(url.toString()),
- msg.toHtmlEscaped());
+ QMessageBox msgBox(QMessageBox::Information,
+ QStringLiteral("Javascript Alert - %1").arg(url.toString()),
+ msg, QMessageBox::Ok, q,
+ Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
+ msgBox.setTextFormat(Qt::PlainText);
+ msgBox.exec();
#else
Q_UNUSED(msg);
#endif // QT_CONFIG(messagebox)
@@ -296,10 +586,12 @@ bool QWebEngineViewPrivate::javaScriptConfirm(const QUrl &url, const QString &ms
{
#if QT_CONFIG(messagebox)
Q_Q(QWebEngineView);
- return (QMessageBox::information(q,
- QStringLiteral("Javascript Confirm - %1").arg(url.toString()),
- msg.toHtmlEscaped(), QMessageBox::Ok, QMessageBox::Cancel)
- == QMessageBox::Ok);
+ QMessageBox msgBox(QMessageBox::Information,
+ QStringLiteral("Javascript Confirm - %1").arg(url.toString()),
+ msg, QMessageBox::Ok | QMessageBox::Cancel, q,
+ Qt::Dialog | Qt::MSWindowsFixedSizeDialogHint);
+ msgBox.setTextFormat(Qt::PlainText);
+ return msgBox.exec() == QMessageBox::Ok;
#else
Q_UNUSED(msg);
return false;
@@ -312,10 +604,16 @@ bool QWebEngineViewPrivate::javaScriptPrompt(const QUrl &url, const QString &msg
#if QT_CONFIG(inputdialog)
Q_Q(QWebEngineView);
bool ret = false;
+
+ // Workaround: Do not interpret text as Qt::RichText
+ // QInputDialog uses Qt::AutoText that interprets the text string as
+ // Qt::RichText if Qt::mightBeRichText() returns true, otherwise as Qt::PlainText.
+ const QString message = Qt::mightBeRichText(msg) ? msg.toHtmlEscaped() : msg;
+
if (result)
*result = QInputDialog::getText(
q, QStringLiteral("Javascript Prompt - %1").arg(url.toString()),
- msg.toHtmlEscaped(), QLineEdit::Normal, defaultValue.toHtmlEscaped(), &ret);
+ message, QLineEdit::Normal, defaultValue, &ret);
return ret;
#else
Q_UNUSED(msg);
@@ -345,28 +643,29 @@ bool QWebEngineViewPrivate::passOnFocus(bool reverse)
return q->focusNextPrevChild(!reverse);
}
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
static QAccessibleInterface *webAccessibleFactory(const QString &, QObject *object)
{
if (QWebEngineView *v = qobject_cast<QWebEngineView*>(object))
return new QWebEngineViewAccessible(v);
return nullptr;
}
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
QWebEngineViewPrivate::QWebEngineViewPrivate()
- : page(0)
+ : page(nullptr)
, m_dragEntered(false)
, m_ownsPage(false)
, m_contextRequest(nullptr)
{
-#ifndef QT_NO_ACCESSIBILITY
+#if QT_CONFIG(accessibility)
QAccessible::installFactory(&webAccessibleFactory);
-#endif // QT_NO_ACCESSIBILITY
+#endif // QT_CONFIG(accessibility)
}
QWebEngineViewPrivate::~QWebEngineViewPrivate() = default;
+// static
void QWebEngineViewPrivate::bindPageAndView(QWebEnginePage *page, QWebEngineView *view)
{
QWebEngineViewPrivate *v =
@@ -400,20 +699,28 @@ void QWebEngineViewPrivate::bindPageAndView(QWebEnginePage *page, QWebEngineView
// Then notify.
- auto widget = page ? page->d_func()->widget : nullptr;
- auto oldWidget = (oldPage && oldPage->d_func()) ? oldPage->d_func()->widget : nullptr;
+ auto item = page ? page->d_func()->delegateItem : nullptr;
+ auto oldItem = (oldPage && oldPage->d_func()) ? oldPage->d_func()->delegateItem : nullptr;
+ auto widget = item ? static_cast<QtWebEngineCore::WebEngineQuickWidget *>(item->m_widgetDelegate) : nullptr;
+ auto oldWidget = oldItem ? static_cast<QtWebEngineCore::WebEngineQuickWidget *>(oldItem->m_widgetDelegate) : nullptr;
+ // New page/widget moving away from oldView
if (page && oldView != view && oldView) {
oldView->d_func()->pageChanged(page, nullptr);
if (widget)
oldView->d_func()->widgetChanged(widget, nullptr);
}
+ // New page/widget moving into new view
if (view && oldPage != page) {
if (oldPage && oldPage->d_func())
view->d_func()->pageChanged(oldPage, page);
else
view->d_func()->pageChanged(nullptr, page);
+ if (!widget && item) {
+ widget = new QtWebEngineCore::WebEngineQuickWidget(item, nullptr);
+ item->setWidgetDelegate(widget);
+ }
if (oldWidget != widget)
view->d_func()->widgetChanged(oldWidget, widget);
}
@@ -421,42 +728,47 @@ void QWebEngineViewPrivate::bindPageAndView(QWebEnginePage *page, QWebEngineView
delete oldPage;
}
-void QWebEngineViewPrivate::bindPageAndWidget(
- QWebEnginePage *page, QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget)
+// static
+void QWebEngineViewPrivate::bindPageAndWidget(QWebEnginePagePrivate *pagePrivate,
+ QtWebEngineCore::WebEngineQuickWidget *widget)
{
- auto oldPage = widget ? widget->m_page : nullptr;
- auto oldWidget = page ? page->d_func()->widget : nullptr;
+ auto *oldAdapterClient = (widget && widget->m_contentItem) ? widget->m_contentItem->m_adapterClient : nullptr;
+ auto *oldPagePrivate = static_cast<QWebEnginePagePrivate *>(oldAdapterClient);
+ auto *oldItem = pagePrivate ? pagePrivate->delegateItem : nullptr;
+ auto *oldWidget = oldItem ? static_cast<QtWebEngineCore::WebEngineQuickWidget *>(oldItem->m_widgetDelegate) : nullptr;
// Change pointers first.
- if (widget && oldPage != page) {
- if (oldPage && oldPage->d_func())
- oldPage->d_func()->widget = nullptr;
- widget->m_page = page;
+ if (widget && oldPagePrivate != pagePrivate) {
+ if (oldPagePrivate)
+ oldPagePrivate->delegateItem = nullptr;
+ if (widget->m_contentItem)
+ widget->m_contentItem->m_adapterClient = pagePrivate;
}
- if (page && oldWidget != widget) {
- if (oldWidget)
- oldWidget->m_page = nullptr;
- page->d_func()->widget = widget;
+ if (pagePrivate && oldWidget != widget) {
+ if (oldWidget && oldWidget->m_contentItem)
+ oldWidget->m_contentItem->m_adapterClient = nullptr;
+ if (widget)
+ pagePrivate->delegateItem = widget->m_contentItem;
}
// Then notify.
- if (widget && oldPage != page && oldPage && oldPage->d_func()) {
- if (auto oldView = oldPage->d_func()->view)
+ if (oldPagePrivate && oldPagePrivate != pagePrivate) {
+ if (auto oldView = oldPagePrivate->view)
static_cast<QWebEngineViewPrivate *>(oldView)->widgetChanged(widget, nullptr);
}
- if (page && oldWidget != widget) {
- if (auto view = page->d_func()->view)
+ if (pagePrivate && oldWidget != widget) {
+ if (auto view = pagePrivate->view)
static_cast<QWebEngineViewPrivate *>(view)->widgetChanged(oldWidget, widget);
}
}
-QIcon QWebEngineViewPrivate::webActionIcon(QWebEnginePage::WebAction action)
+QIcon QWebEngineViewPrivate::webActionIcon(QWebEnginePage::WebAction action) const
{
- Q_Q(QWebEngineView);
+ Q_Q(const QWebEngineView);
QIcon icon;
QStyle *style = q->style();
@@ -494,7 +806,18 @@ QWebEnginePage *QWebEngineViewPrivate::createPageForWindow(QWebEnginePage::WebWi
void QWebEngineViewPrivate::setToolTip(const QString &toolTipText)
{
Q_Q(QWebEngineView);
- q->setToolTip(toolTipText);
+ if (toolTipText.isEmpty()) {
+ // Avoid duplicate events.
+ if (!q->toolTip().isEmpty())
+ q->setToolTip(QString());
+ // Force to hide tooltip because QWidget's default handler
+ // doesn't hide on empty text.
+ if (!QToolTip::text().isEmpty())
+ QToolTip::hideText();
+ } else if (toolTipText != q->toolTip()) {
+ q->setToolTip(toolTipText);
+ }
+
}
bool QWebEngineViewPrivate::isEnabled() const
@@ -526,7 +849,11 @@ void QWebEngineViewPrivate::didPrintPage(QPrinter *&currentPrinter, QSharedPoint
printerWorker->m_documentCopies = currentPrinter->copyCount();
printerWorker->m_collateCopies = currentPrinter->collateCopies();
- QObject::connect(printerWorker, &QtWebEngineCore::PrinterWorker::resultReady, q, [q, &currentPrinter](bool success) {
+ int oldCopyCount = currentPrinter->copyCount();
+ currentPrinter->printEngine()->setProperty(QPrintEngine::PPK_CopyCount, 1);
+
+ QObject::connect(printerWorker, &QtWebEngineCore::PrinterWorker::resultReady, q, [q, &currentPrinter, oldCopyCount](bool success) {
+ currentPrinter->printEngine()->setProperty(QPrintEngine::PPK_CopyCount, oldCopyCount);
currentPrinter = nullptr;
Q_EMIT q->printFinished(success);
});
@@ -571,14 +898,55 @@ QtWebEngineCore::RenderWidgetHostViewQtDelegate *
QWebEngineViewPrivate::CreateRenderWidgetHostViewQtDelegate(
QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client)
{
+ auto *item = new QtWebEngineCore::RenderWidgetHostViewQtDelegateItem(client, false);
+ auto *widget = new QtWebEngineCore::WebEngineQuickWidget(item, nullptr);
+ item->setWidgetDelegate(widget);
+ return item;
+}
+
+QtWebEngineCore::RenderWidgetHostViewQtDelegate *
+QWebEngineViewPrivate::CreateRenderWidgetHostViewQtDelegateForPopup(
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client)
+{
Q_Q(QWebEngineView);
- return new QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget(client, q);
+ auto *item = new QtWebEngineCore::RenderWidgetHostViewQtDelegateItem(client, true);
+ auto *widget = new QtWebEngineCore::WebEngineQuickWidget(item, q);
+ item->setWidgetDelegate(widget);
+ return item;
}
QWebEngineContextMenuRequest *QWebEngineViewPrivate::lastContextMenuRequest() const
{
return m_contextRequest;
}
+
+void QWebEngineViewPrivate::showAutofillPopup(QtWebEngineCore::AutofillPopupController *controller,
+ const QRect &bounds, bool autoselectFirstSuggestion)
+{
+ Q_Q(QWebEngineView);
+ if (!m_autofillPopupWidget)
+ m_autofillPopupWidget.reset(new QtWebEngineWidgetUI::AutofillPopupWidget(controller, q));
+ m_autofillPopupWidget->showPopup(q->mapToGlobal(bounds.bottomLeft()), bounds.width() + 2,
+ autoselectFirstSuggestion);
+ controller->notifyPopupShown();
+}
+
+void QWebEngineViewPrivate::hideAutofillPopup()
+{
+ if (!m_autofillPopupWidget)
+ return;
+
+ Q_Q(QWebEngineView);
+ QTimer::singleShot(0, q, [this] {
+ if (m_autofillPopupWidget) {
+ QtWebEngineCore::AutofillPopupController *controller =
+ m_autofillPopupWidget->m_controller;
+ m_autofillPopupWidget.reset();
+ controller->notifyPopupHidden();
+ }
+ });
+}
+
/*!
\fn QWebEngineView::renderProcessTerminated(QWebEnginePage::RenderProcessTerminationStatus terminationStatus, int exitCode)
\since 5.6
@@ -611,6 +979,40 @@ QWebEngineView::QWebEngineView(QWidget *parent)
setLayout(layout);
}
+/*!
+ \since 6.4
+
+ Constructs an empty web view using \a profile with the parent \a parent.
+
+ \note The \a profile object ownership is not taken and it should outlive the view.
+
+ \sa load()
+*/
+
+QWebEngineView::QWebEngineView(QWebEngineProfile *profile, QWidget *parent)
+ : QWebEngineView(parent)
+{
+ Q_D(QWebEngineView);
+ setPage(new QWebEnginePage(profile, this));
+ d->m_ownsPage = true;
+}
+
+/*!
+ \since 6.4
+
+ Constructs a web view containing \a page with the parent \a parent.
+
+ \note Ownership of \a page is not taken, and it is up to the caller to ensure it is deleted.
+
+ \sa load(), setPage()
+*/
+
+QWebEngineView::QWebEngineView(QWebEnginePage *page, QWidget *parent)
+ : QWebEngineView(parent)
+{
+ setPage(page);
+}
+
QWebEngineView::~QWebEngineView()
{
blockSignals(true);
@@ -644,9 +1046,17 @@ QWebEnginePage* QWebEngineView::page() const
void QWebEngineView::setPage(QWebEnginePage *newPage)
{
+ Q_D(QWebEngineView);
+ if (d->page) {
+ disconnect(d->m_pageConnection);
+ d->m_pageConnection = {};
+ }
+
QWebEngineViewPrivate::bindPageAndView(newPage, this);
- connect(newPage, &QWebEnginePage::_q_aboutToDelete, this,
- [newPage]() { QWebEngineViewPrivate::bindPageAndView(newPage, nullptr); });
+ if (!newPage)
+ return;
+ d->m_pageConnection = connect(newPage, &QWebEnginePage::_q_aboutToDelete, this,
+ [newPage]() { QWebEngineViewPrivate::bindPageAndView(newPage, nullptr); });
auto profile = newPage->profile();
if (!profile->notificationPresenter())
profile->setNotificationPresenter(&defaultNotificationPresenter);
@@ -727,10 +1137,19 @@ QString QWebEngineView::selectedText() const
return page()->selectedText();
}
-#ifndef QT_NO_ACTION
+#if QT_CONFIG(action)
QAction* QWebEngineView::pageAction(QWebEnginePage::WebAction action) const
{
- return page()->action(action);
+ Q_D(const QWebEngineView);
+ QAction *pageAction = page()->action(action);
+
+ if (pageAction->icon().isNull()) {
+ auto icon = d->webActionIcon(action);
+ if (!icon.isNull())
+ pageAction->setIcon(icon);
+ }
+
+ return pageAction;
}
#endif
@@ -812,17 +1231,6 @@ bool QWebEngineView::event(QEvent *ev)
return true;
}
- // Override QWidget's default ToolTip handler since it doesn't hide tooltip on empty text.
- if (ev->type() == QEvent::ToolTip) {
- if (!toolTip().isEmpty())
- QToolTip::showText(static_cast<QHelpEvent *>(ev)->globalPos(), toolTip(), this, QRect(), toolTipDuration());
- else
- QToolTip::hideText();
-
- ev->accept();
- return true;
- }
-
return QWidget::event(ev);
}
@@ -1015,7 +1423,8 @@ void QWebEngineView::printToPdf(const std::function<void(const QByteArray&)> &re
\fn void QWebEngineView::printRequested()
\since 6.2
- This signal is emitted when the JavaScript \c{window.print()} method is called.
+ This signal is emitted when the JavaScript \c{window.print()} method is called or the user pressed the print
+ button of PDF viewer plugin.
Typically, the signal handler can simply call print().
\sa print()
@@ -1044,6 +1453,9 @@ void QWebEngineView::printToPdf(const std::function<void(const QByteArray&)> &re
\note Printing runs on the browser process, which is by default not sandboxed.
+ \note The data generation step of printing can be interrupted for a short period of time using
+ the \l QWebEnginePage::Stop web action.
+
\note This function rasterizes the result when rendering onto \a printer. Please consider raising
the default resolution of \a printer to at least 300 DPI or using printToPdf() to produce
PDF file output more effectively.
@@ -1070,45 +1482,6 @@ void QWebEngineView::print(QPrinter *printer)
#endif
}
-#ifndef QT_NO_ACCESSIBILITY
-bool QWebEngineViewAccessible::isValid() const
-{
- if (!QAccessibleWidget::isValid())
- return false;
-
- if (!view() || !view()->d_func() || !view()->d_func()->page || !view()->d_func()->page->d_func())
- return false;
-
- return true;
-}
-
-QAccessibleInterface *QWebEngineViewAccessible::focusChild() const
-{
- if (child(0) && child(0)->focusChild())
- return child(0)->focusChild();
- return const_cast<QWebEngineViewAccessible *>(this);
-}
-
-int QWebEngineViewAccessible::childCount() const
-{
- return child(0) ? 1 : 0;
-}
-
-QAccessibleInterface *QWebEngineViewAccessible::child(int index) const
-{
- if (index == 0 && isValid())
- return view()->page()->d_func()->adapter->browserAccessible();
- return nullptr;
-}
-
-int QWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const
-{
- if (child(0) && c == child(0))
- return 0;
- return -1;
-}
-#endif // QT_NO_ACCESSIBILITY
-
#if QT_CONFIG(action)
QContextMenuBuilder::QContextMenuBuilder(QWebEngineContextMenuRequest *request,
QWebEngineView *view, QMenu *menu)
@@ -1134,82 +1507,82 @@ void QContextMenuBuilder::addMenuItem(ContextMenuItem menuItem)
switch (menuItem) {
case ContextMenuItem::Back:
- action = thisRef->action(QWebEnginePage::Back);
+ action = m_view->pageAction(QWebEnginePage::Back);
break;
case ContextMenuItem::Forward:
- action = thisRef->action(QWebEnginePage::Forward);
+ action = m_view->pageAction(QWebEnginePage::Forward);
break;
case ContextMenuItem::Reload:
- action = thisRef->action(QWebEnginePage::Reload);
+ action = m_view->pageAction(QWebEnginePage::Reload);
break;
case ContextMenuItem::Cut:
- action = thisRef->action(QWebEnginePage::Cut);
+ action = m_view->pageAction(QWebEnginePage::Cut);
break;
case ContextMenuItem::Copy:
- action = thisRef->action(QWebEnginePage::Copy);
+ action = m_view->pageAction(QWebEnginePage::Copy);
break;
case ContextMenuItem::Paste:
- action = thisRef->action(QWebEnginePage::Paste);
+ action = m_view->pageAction(QWebEnginePage::Paste);
break;
case ContextMenuItem::Undo:
- action = thisRef->action(QWebEnginePage::Undo);
+ action = m_view->pageAction(QWebEnginePage::Undo);
break;
case ContextMenuItem::Redo:
- action = thisRef->action(QWebEnginePage::Redo);
+ action = m_view->pageAction(QWebEnginePage::Redo);
break;
case ContextMenuItem::SelectAll:
- action = thisRef->action(QWebEnginePage::SelectAll);
+ action = m_view->pageAction(QWebEnginePage::SelectAll);
break;
case ContextMenuItem::PasteAndMatchStyle:
- action = thisRef->action(QWebEnginePage::PasteAndMatchStyle);
+ action = m_view->pageAction(QWebEnginePage::PasteAndMatchStyle);
break;
case ContextMenuItem::OpenLinkInNewWindow:
- action = thisRef->action(QWebEnginePage::OpenLinkInNewWindow);
+ action = m_view->pageAction(QWebEnginePage::OpenLinkInNewWindow);
break;
case ContextMenuItem::OpenLinkInNewTab:
- action = thisRef->action(QWebEnginePage::OpenLinkInNewTab);
+ action = m_view->pageAction(QWebEnginePage::OpenLinkInNewTab);
break;
case ContextMenuItem::CopyLinkToClipboard:
- action = thisRef->action(QWebEnginePage::CopyLinkToClipboard);
+ action = m_view->pageAction(QWebEnginePage::CopyLinkToClipboard);
break;
case ContextMenuItem::DownloadLinkToDisk:
- action = thisRef->action(QWebEnginePage::DownloadLinkToDisk);
+ action = m_view->pageAction(QWebEnginePage::DownloadLinkToDisk);
break;
case ContextMenuItem::CopyImageToClipboard:
- action = thisRef->action(QWebEnginePage::CopyImageToClipboard);
+ action = m_view->pageAction(QWebEnginePage::CopyImageToClipboard);
break;
case ContextMenuItem::CopyImageUrlToClipboard:
- action = thisRef->action(QWebEnginePage::CopyImageUrlToClipboard);
+ action = m_view->pageAction(QWebEnginePage::CopyImageUrlToClipboard);
break;
case ContextMenuItem::DownloadImageToDisk:
- action = thisRef->action(QWebEnginePage::DownloadImageToDisk);
+ action = m_view->pageAction(QWebEnginePage::DownloadImageToDisk);
break;
case ContextMenuItem::CopyMediaUrlToClipboard:
- action = thisRef->action(QWebEnginePage::CopyMediaUrlToClipboard);
+ action = m_view->pageAction(QWebEnginePage::CopyMediaUrlToClipboard);
break;
case ContextMenuItem::ToggleMediaControls:
- action = thisRef->action(QWebEnginePage::ToggleMediaControls);
+ action = m_view->pageAction(QWebEnginePage::ToggleMediaControls);
break;
case ContextMenuItem::ToggleMediaLoop:
- action = thisRef->action(QWebEnginePage::ToggleMediaLoop);
+ action = m_view->pageAction(QWebEnginePage::ToggleMediaLoop);
break;
case ContextMenuItem::DownloadMediaToDisk:
- action = thisRef->action(QWebEnginePage::DownloadMediaToDisk);
+ action = m_view->pageAction(QWebEnginePage::DownloadMediaToDisk);
break;
case ContextMenuItem::InspectElement:
- action = thisRef->action(QWebEnginePage::InspectElement);
+ action = m_view->pageAction(QWebEnginePage::InspectElement);
break;
case ContextMenuItem::ExitFullScreen:
- action = thisRef->action(QWebEnginePage::ExitFullScreen);
+ action = m_view->pageAction(QWebEnginePage::ExitFullScreen);
break;
case ContextMenuItem::SavePage:
- action = thisRef->action(QWebEnginePage::SavePage);
+ action = m_view->pageAction(QWebEnginePage::SavePage);
break;
case ContextMenuItem::ViewSource:
- action = thisRef->action(QWebEnginePage::ViewSource);
+ action = m_view->pageAction(QWebEnginePage::ViewSource);
break;
case ContextMenuItem::SpellingSuggestions:
- for (int i = 0; i < m_contextData->spellCheckerSuggestions().count() && i < 4; i++) {
+ for (int i = 0; i < m_contextData->spellCheckerSuggestions().size() && i < 4; i++) {
action = new QAction(m_menu);
QString replacement = m_contextData->spellCheckerSuggestions().at(i);
QObject::connect(action, &QAction::triggered, [thisRef, replacement] {
@@ -1277,6 +1650,49 @@ bool QContextMenuBuilder::isMenuItemEnabled(ContextMenuItem menuItem)
}
#endif // QT_CONFIG(action)
+QtWebEngineCore::TouchHandleDrawableDelegate *
+QWebEngineViewPrivate::createTouchHandleDelegate(const QMap<int, QImage> &images)
+{
+ Q_Q(QWebEngineView);
+ return new QtWebEngineWidgetUI::TouchHandleWidget(q, images);
+}
+
+void QWebEngineViewPrivate::hideTouchSelectionMenu()
+{
+ if (m_touchSelectionMenu)
+ m_touchSelectionMenu->close();
+}
+
+void QWebEngineViewPrivate::showTouchSelectionMenu(
+ QtWebEngineCore::TouchSelectionMenuController *controller, const QRect &selectionBounds)
+{
+ Q_ASSERT(m_touchSelectionMenu == nullptr);
+ Q_Q(QWebEngineView);
+
+ // Do not show outside of view
+ QSize parentSize = q->nativeParentWidget() ? q->nativeParentWidget()->size() : q->size();
+ if (selectionBounds.x() < 0 || selectionBounds.x() > parentSize.width()
+ || selectionBounds.y() < 0 || selectionBounds.y() > parentSize.height())
+ return;
+
+ m_touchSelectionMenu = new QtWebEngineWidgetUI::TouchSelectionMenuWidget(q, controller);
+
+ const int kSpacingBetweenButtons = 2;
+ const int kMenuButtonMinWidth = 80;
+ const int kMenuButtonMinHeight = 40;
+
+ int buttonCount = controller->buttonCount();
+ int width = (kSpacingBetweenButtons * (buttonCount + 1)) + (kMenuButtonMinWidth * buttonCount);
+ int height = kMenuButtonMinHeight + kSpacingBetweenButtons;
+ int x = (selectionBounds.x() + selectionBounds.x() + selectionBounds.width() - width) / 2;
+ int y = selectionBounds.y() - height - 2;
+
+ QPoint pos = q->mapToGlobal(QPoint(x, y));
+
+ m_touchSelectionMenu->setGeometry(pos.x(), pos.y(), width, height);
+ m_touchSelectionMenu->show();
+}
+
QT_END_NAMESPACE
#include "moc_qwebengineview.cpp"
diff --git a/src/webenginewidgets/api/qwebengineview.h b/src/webenginewidgets/api/qwebengineview.h
index b222de0df..f93d61b12 100644
--- a/src/webenginewidgets/api/qwebengineview.h
+++ b/src/webenginewidgets/api/qwebengineview.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWEBENGINEVIEW_H
#define QWEBENGINEVIEW_H
@@ -47,6 +11,10 @@
#include <QtWebEngineWidgets/qtwebenginewidgetsglobal.h>
#include <QtWebEngineCore/qwebenginepage.h>
+namespace QtWebEngineWidgetUI {
+class AutofillPopupWidget;
+}
+
QT_BEGIN_NAMESPACE
class QContextMenuEvent;
@@ -72,6 +40,8 @@ class QWEBENGINEWIDGETS_EXPORT QWebEngineView : public QWidget
public:
explicit QWebEngineView(QWidget *parent = nullptr);
+ explicit QWebEngineView(QWebEngineProfile *profile, QWidget *parent = nullptr);
+ explicit QWebEngineView(QWebEnginePage *page, QWidget *parent = nullptr);
virtual ~QWebEngineView();
static QWebEngineView *forPage(const QWebEnginePage *page);
@@ -96,7 +66,7 @@ public:
bool hasSelection() const;
QString selectedText() const;
-#ifndef QT_NO_ACTION
+#if QT_CONFIG(action)
QAction *pageAction(QWebEnginePage::WebAction action) const;
#endif
void triggerPageAction(QWebEnginePage::WebAction action, bool checked = false);
@@ -167,8 +137,7 @@ private:
Q_DECLARE_PRIVATE(QWebEngineView)
QScopedPointer<QWebEngineViewPrivate> d_ptr;
- friend class QWebEnginePage;
- friend class QWebEnginePagePrivate;
+ friend class QtWebEngineWidgetUI::AutofillPopupWidget;
#if QT_CONFIG(accessibility)
friend class QWebEngineViewAccessible;
#endif
diff --git a/src/webenginewidgets/api/qwebengineview_p.h b/src/webenginewidgets/api/qwebengineview_p.h
index c34aec09a..aa330ac23 100644
--- a/src/webenginewidgets/api/qwebengineview_p.h
+++ b/src/webenginewidgets/api/qwebengineview_p.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2021 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2021 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWEBENGINEVIEW_P_H
#define QWEBENGINEVIEW_P_H
@@ -52,14 +16,24 @@
//
#include <QtWebEngineCore/private/qwebenginepage_p.h> // PageView
-#include <QtWidgets/qaccessiblewidget.h>
#include "render_view_context_menu_qt.h"
+#include <QtCore/qpointer.h>
+
namespace QtWebEngineCore {
+class AutofillPopupController;
class QWebEngineContextMenuRequest;
-class RenderWidgetHostViewQtDelegateWidget;
+class WebEngineQuickWidget;
class RenderWidgetHostViewQtDelegate;
+class RenderWidgetHostViewQtDelegateClient;
+class TouchSelectionMenuController;
+}
+
+namespace QtWebEngineWidgetUI {
+class AutofillPopupWidget;
+class TouchHandleDrawableDelegate;
+class TouchSelectionMenuWidget;
}
QT_BEGIN_NAMESPACE
@@ -75,8 +49,8 @@ public:
QWebEngineView *q_ptr;
void pageChanged(QWebEnginePage *oldPage, QWebEnginePage *newPage);
- void widgetChanged(QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *oldWidget,
- QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *newWidget);
+ void widgetChanged(QtWebEngineCore::WebEngineQuickWidget *oldWidget,
+ QtWebEngineCore::WebEngineQuickWidget *newWidget);
void contextMenuRequested(QWebEngineContextMenuRequest *request) override;
QStringList chooseFiles(QWebEnginePage::FileSelectionMode mode, const QStringList &oldFiles,
@@ -91,19 +65,29 @@ public:
void setToolTip(const QString &toolTipText) override;
QtWebEngineCore::RenderWidgetHostViewQtDelegate *CreateRenderWidgetHostViewQtDelegate(
QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
+ QtWebEngineCore::RenderWidgetHostViewQtDelegate *CreateRenderWidgetHostViewQtDelegateForPopup(
+ QtWebEngineCore::RenderWidgetHostViewQtDelegateClient *client) override;
QWebEngineContextMenuRequest *lastContextMenuRequest() const override;
QWebEnginePage *createPageForWindow(QWebEnginePage::WebWindowType type) override;
QObject *accessibilityParentObject() override;
void didPrintPage(QPrinter *&printer, QSharedPointer<QByteArray> result) override;
void didPrintPageToPdf(const QString &filePath, bool success) override;
void printRequested() override;
-
+ void showAutofillPopup(QtWebEngineCore::AutofillPopupController *controller,
+ const QRect &bounds, bool autoselectFirstSuggestion) override;
+ void hideAutofillPopup() override;
+ QtWebEngineCore::TouchHandleDrawableDelegate *
+ createTouchHandleDelegate(const QMap<int, QImage> &images) override;
+
+ void showTouchSelectionMenu(QtWebEngineCore::TouchSelectionMenuController *,
+ const QRect &) override;
+ void hideTouchSelectionMenu() override;
QWebEngineViewPrivate();
virtual ~QWebEngineViewPrivate();
static void bindPageAndView(QWebEnginePage *page, QWebEngineView *view);
- static void bindPageAndWidget(QWebEnginePage *page,
- QtWebEngineCore::RenderWidgetHostViewQtDelegateWidget *widget);
- QIcon webActionIcon(QWebEnginePage::WebAction action);
+ static void bindPageAndWidget(QWebEnginePagePrivate *pagePrivate,
+ QtWebEngineCore::WebEngineQuickWidget *widget);
+ QIcon webActionIcon(QWebEnginePage::WebAction action) const;
void unhandledKeyEvent(QKeyEvent *event) override;
void focusContainer() override;
bool passOnFocus(bool reverse) override;
@@ -111,29 +95,14 @@ public:
bool isVisible() const override;
QRect viewportRect() const override;
QWebEnginePage *page;
+ QMetaObject::Connection m_pageConnection;
bool m_dragEntered;
mutable bool m_ownsPage;
QWebEngineContextMenuRequest *m_contextRequest;
+ QScopedPointer<QtWebEngineWidgetUI::AutofillPopupWidget> m_autofillPopupWidget;
+ QPointer<QtWebEngineWidgetUI::TouchSelectionMenuWidget> m_touchSelectionMenu;
};
-#ifndef QT_NO_ACCESSIBILITY
-class QWebEngineViewAccessible : public QAccessibleWidget
-{
-public:
- QWebEngineViewAccessible(QWebEngineView *o) : QAccessibleWidget(o)
- {}
-
- bool isValid() const override;
- QAccessibleInterface *focusChild() const override;
- int childCount() const override;
- QAccessibleInterface *child(int index) const override;
- int indexOfChild(const QAccessibleInterface *child) const override;
-
-private:
- QWebEngineView *view() const { return static_cast<QWebEngineView *>(object()); }
-};
-#endif // QT_NO_ACCESSIBILITY
-
class QContextMenuBuilder : public QtWebEngineCore::RenderViewContextMenuQt
{
public:
diff --git a/src/webenginewidgets/configure.json b/src/webenginewidgets/configure.json
deleted file mode 100644
index a27faf78d..000000000
--- a/src/webenginewidgets/configure.json
+++ /dev/null
@@ -1,28 +0,0 @@
-{
- "module": "webenginewidgets",
- "condition": "module.webenginecore && features.webengine-widgets",
- "depends": [
- "webenginecore-private"
- ],
- "commandline": {
- "options": {
- "webengine-widgets": "boolean"
- }
- },
- "features": {
- "webengine-widgets": {
- "label": "Support Qt WebEngine Widgets",
- "purpose": "Provides WebEngine Widgets support.",
- "condition": "module.widgets",
- "output": [ "privateFeature" ]
- }
- },
- "summary": [
- {
- "section": "Qt WebEngineWidgets",
- "entries": [
- "webengine-widgets"
- ]
- }
- ]
-}
diff --git a/src/webenginewidgets/doc/snippets/push-notifications/commands b/src/webenginewidgets/doc/snippets/push-notifications/commands
new file mode 100644
index 000000000..aee9761c1
--- /dev/null
+++ b/src/webenginewidgets/doc/snippets/push-notifications/commands
@@ -0,0 +1,19 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+
+//! [0]
+npm init -y
+npm install web-push express
+//! [0]
+
+//! [1]
+"start": "node server.js"
+//! [1]
+
+//! [2]
+./node_odules/.bin/web-push generate-vapid-keys
+//! [2]
+
+//! [3]
+npm start
+//! [3]
diff --git a/src/webenginewidgets/doc/snippets/qtwebengine_qwebengineview_snippet.cpp b/src/webenginewidgets/doc/snippets/qtwebengine_qwebengineview_snippet.cpp
index 5d89cb8bc..64531cf3a 100644
--- a/src/webenginewidgets/doc/snippets/qtwebengine_qwebengineview_snippet.cpp
+++ b/src/webenginewidgets/doc/snippets/qtwebengine_qwebengineview_snippet.cpp
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
void wrapInFunction()
{
diff --git a/src/webenginewidgets/doc/snippets/qtwebenginewidgets_build_snippet.qdoc b/src/webenginewidgets/doc/snippets/qtwebenginewidgets_build_snippet.qdoc
index f48932eae..f11f550ff 100644
--- a/src/webenginewidgets/doc/snippets/qtwebenginewidgets_build_snippet.qdoc
+++ b/src/webenginewidgets/doc/snippets/qtwebenginewidgets_build_snippet.qdoc
@@ -1,40 +1,11 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
//! [0]
QT += webenginewidgets
//! [0]
-
-//! [1]
-#include <QtWebEngineWidgets>
-//! [1]
-
//! [2]
-find_package(Qt6 COMPONENTS WebEngineWidgets REQUIRED)
-target_link_libraries(target PRIVATE Qt::WebEngineWidgets)
+find_package(Qt6 REQUIRED COMPONENTS WebEngineWidgets)
+target_link_libraries(target PRIVATE Qt6::WebEngineWidgets)
//! [2]
diff --git a/src/webenginewidgets/doc/snippets/simple/main.cpp b/src/webenginewidgets/doc/snippets/simple/main.cpp
index 39c07b84d..08613906b 100644
--- a/src/webenginewidgets/doc/snippets/simple/main.cpp
+++ b/src/webenginewidgets/doc/snippets/simple/main.cpp
@@ -1,65 +1,19 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the examples of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:BSD$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** BSD License Usage
-** Alternatively, you may use this file under the terms of the BSD license
-** as follows:
-**
-** "Redistribution and use in source and binary forms, with or without
-** modification, are permitted provided that the following conditions are
-** met:
-** * Redistributions of source code must retain the above copyright
-** notice, this list of conditions and the following disclaimer.
-** * Redistributions in binary form must reproduce the above copyright
-** notice, this list of conditions and the following disclaimer in
-** the documentation and/or other materials provided with the
-** distribution.
-** * Neither the name of The Qt Company Ltd nor the names of its
-** contributors may be used to endorse or promote products derived
-** from this software without specific prior written permission.
-**
-**
-** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
+//! [Minimal Example]
#include <QApplication>
-#include <QUrl>
#include <QWebEngineView>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- QWidget *parent = nullptr;
//! [Using QWebEngineView]
- QWebEngineView *view = new QWebEngineView(parent);
- view->load(QUrl("http://qt-project.org/"));
- view->show();
+ QWebEngineView view;
+ view.load(QUrl("https://qt-project.org/"));
+ view.resize(1024, 750);
+ view.show();
//! [Using QWebEngineView]
return app.exec();
}
+//! [Minimal Example]
diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc
index a9e0e69ea..c9bd76bf4 100644
--- a/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc
+++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-examples.qdoc
@@ -1,35 +1,10 @@
-/****************************************************************************
-**
-** Copyright (C) 2017 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2017 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\group webengine-widgetexamples
\title Qt WebEngine Widgets Examples
\brief Examples demonstrating the \QWE Widgets usage.
- \ingroup all-examples
Qt provides an integrated Web browser component based on Chromium, the popular
open source browser engine.
diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc
index cc1a33464..8eb28b797 100644
--- a/src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc
+++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-index.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtwebenginewidgets-index.html
@@ -34,19 +10,14 @@
\section1 Getting Started
- To include the definitions of the module's classes, use the
- following directive:
-
- \snippet qtwebengine_build_snippet.qdoc 1
-
To link against the module, add this line to your qmake project file:
- \snippet qtwebengine_build_snippet.qdoc 0
+ \snippet qtwebenginewidgets_build_snippet.qdoc 0
For build with CMake use the \c find_package() command to locate the needed module components
in the Qt6 package and \c target_link_libraries() to link against the module:
- \snippet qtwebengine_build_snippet.qdoc 2
+ \snippet qtwebenginewidgets_build_snippet.qdoc 2
\section1 Articles and Guides
diff --git a/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc
index a2775d641..ef5a1c4b5 100644
--- a/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc
+++ b/src/webenginewidgets/doc/src/qtwebenginewidgets-module.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\module QtWebEngineWidgets
@@ -34,14 +10,9 @@
\qtvariable webenginewidgets
\qtcmakepackage WebEngineWidgets
- The \QWEWidgets module provides a web browser engine as well as C++ classes to render
+ The \QWE Widgets module provides a web browser engine as well as C++ classes to render
and interact with web content.
- To include the definitions of the module's classes, use the
- following directive:
-
- \snippet qtwebenginewidgets_build_snippet.qdoc 1
-
\if !defined(qtforpython)
To link against the module using build with qmake,
add the following QT variable to your qmake .pro file:
@@ -53,4 +24,9 @@
\snippet qtwebenginewidgets_build_snippet.qdoc 2
\endif
+
+ The minimum amount of code needed to load and display an HTML page requires just
+ implementing the \c QWebEngineView class.
+
+ \snippet simple/main.cpp Minimal Example
*/
diff --git a/src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc b/src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc
index 9e8cc463c..37b73c010 100644
--- a/src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc
+++ b/src/webenginewidgets/doc/src/qtwebkitportingguide.qdoc
@@ -1,29 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2019 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2019 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\page qtwebenginewidgets-qtwebkitportingguide.html
diff --git a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
index 34aa53278..3153ec952 100644
--- a/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
+++ b/src/webenginewidgets/doc/src/qwebengineview_lgpl.qdoc
@@ -1,24 +1,8 @@
-/*
- Copyright (C) 2019 The Qt Company Ltd.
- Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
- Copyright (C) 2008 Holger Hans Peter Freyther
- Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
-
- 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.
-*/
+// Copyright (C) 2019 The Qt Company Ltd.
+// Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
+// Copyright (C) 2008 Holger Hans Peter Freyther
+// Copyright (C) 2009 Girish Ramakrishnan <girish@forwardbias.in>
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
// The documentation in this file was imported from QtWebKit and is thus constrained
// by its LGPL license. Documentation written from scratch for new methods should be
@@ -77,7 +61,7 @@
new windows, such as pop-up windows, you can subclass QWebEngineView and
reimplement the createWindow() function.
- \sa {WebEngine Widgets Simple Browser Example}, {WebEngine Content Manipulation Example}, {WebEngine Markdown Editor Example}
+ \sa {WebEngine Widgets Simple Browser Example}, {WebEngine Content Manipulation Example}
*/
@@ -124,9 +108,8 @@
\fn void QWebEngineView::setHtml(const QString &html, const QUrl &baseUrl)
Sets the content of the web view to the specified \a html content.
- External objects, such as stylesheets or images referenced in the HTML
- document, are located relative to \a baseUrl. For external objects to
- be loaded, \c baseUrl cannot be empty. For example, if \a html
+ \a baseUrl is optional and used to resolve relative URLs in the document,
+ such as referenced images or stylesheets. For example, if \a html
is retrieved from \c http://www.example.com/documents/overview.html, which
is the base URL, then an image referenced with the relative URL, \c diagram.png,
should be at \c{http://www.example.com/documents/diagram.png}.
@@ -160,7 +143,7 @@
is empty, it is assumed that the content is \c{text/plain,charset=US-ASCII}.
External objects referenced in the content are located relative to \a baseUrl.
- For external objects to be loaded, \c baseUrl cannot be empty.
+ For external objects with relative URLs to be loaded, \c baseUrl cannot be empty.
The data is loaded immediately; external objects are loaded asynchronously.
@@ -226,6 +209,7 @@
/*!
\fn QAction *QWebEngineView::pageAction(QWebEnginePage::WebAction action) const
Returns a pointer to a QAction that encapsulates the specified web action \a action.
+ This function will also set a default styled icon to the QAction if it lacks one.
*/
/*!
diff --git a/src/webenginewidgets/plugins/qwebengineview/CMakeLists.txt b/src/webenginewidgets/plugins/qwebengineview/CMakeLists.txt
index 3e6f324da..0e7644bf7 100644
--- a/src/webenginewidgets/plugins/qwebengineview/CMakeLists.txt
+++ b/src/webenginewidgets/plugins/qwebengineview/CMakeLists.txt
@@ -1,3 +1,6 @@
+# Copyright (C) 2022 The Qt Company Ltd.
+# SPDX-License-Identifier: BSD-3-Clause
+
qt_internal_add_plugin(QWebEngineViewPlugin
OUTPUT_NAME qwebengineview
PLUGIN_TYPE designer
diff --git a/src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.cpp b/src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.cpp
index dff041800..6ba64a178 100644
--- a/src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.cpp
+++ b/src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.cpp
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qwebengineview_plugin.h"
@@ -43,6 +7,7 @@
#include <QtDesigner/QExtensionManager>
#include <QtCore/qplugin.h>
+#include <QtQuick/QQuickWindow>
#include <QWebEngineView>
QT_BEGIN_NAMESPACE
diff --git a/src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.h b/src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.h
index 8c0960adc..a7150151d 100644
--- a/src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.h
+++ b/src/webenginewidgets/plugins/qwebengineview/qwebengineview_plugin.h
@@ -1,41 +1,5 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#ifndef QWEBENGINEVIEW_PLUGIN_H
#define QWEBENGINEVIEW_PLUGIN_H
diff --git a/src/webenginewidgets/qwebengine_accessible.cpp b/src/webenginewidgets/qwebengine_accessible.cpp
new file mode 100644
index 000000000..cbdd90104
--- /dev/null
+++ b/src/webenginewidgets/qwebengine_accessible.cpp
@@ -0,0 +1,102 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qwebengine_accessible_p.h"
+
+#include "qwebengineview.h"
+#include "qwebengineview_p.h"
+
+#include "web_contents_adapter.h"
+
+QT_BEGIN_NAMESPACE
+
+QWebEngineViewAccessible::QWebEngineViewAccessible(QWebEngineView *o) : QAccessibleWidget(o)
+{
+}
+
+bool QWebEngineViewAccessible::isValid() const
+{
+ if (!QAccessibleWidget::isValid())
+ return false;
+
+ if (!view() || !view()->d_func() || !view()->d_func()->page || !view()->d_func()->page->d_func())
+ return false;
+
+ return true;
+}
+
+QAccessibleInterface *QWebEngineViewAccessible::focusChild() const
+{
+ if (child(0) && child(0)->focusChild())
+ return child(0)->focusChild();
+ return const_cast<QWebEngineViewAccessible *>(this);
+}
+
+int QWebEngineViewAccessible::childCount() const
+{
+ return child(0) ? 1 : 0;
+}
+
+QAccessibleInterface *QWebEngineViewAccessible::child(int index) const
+{
+ if (index == 0 && isValid())
+ return view()->page()->d_func()->adapter->browserAccessible();
+ return nullptr;
+}
+
+int QWebEngineViewAccessible::indexOfChild(const QAccessibleInterface *c) const
+{
+ if (child(0) && c == child(0))
+ return 0;
+ return -1;
+}
+
+QWebEngineView *QWebEngineViewAccessible::view() const
+{
+ return static_cast<QWebEngineView *>(object());
+}
+
+QT_END_NAMESPACE
+
+namespace QtWebEngineCore {
+
+RenderWidgetHostViewQtDelegateWidgetAccessible::RenderWidgetHostViewQtDelegateWidgetAccessible(QWidget *o, QWebEngineView *view)
+ : QAccessibleWidget(o)
+ , m_view(view)
+{
+}
+
+bool RenderWidgetHostViewQtDelegateWidgetAccessible::isValid() const
+{
+ if (!viewAccessible() || !viewAccessible()->isValid())
+ return false;
+
+ return QAccessibleWidget::isValid();
+}
+
+QAccessibleInterface *RenderWidgetHostViewQtDelegateWidgetAccessible::focusChild() const
+{
+ return viewAccessible()->focusChild();
+}
+
+int RenderWidgetHostViewQtDelegateWidgetAccessible::childCount() const
+{
+ return viewAccessible()->childCount();
+}
+
+QAccessibleInterface *RenderWidgetHostViewQtDelegateWidgetAccessible::child(int index) const
+{
+ return viewAccessible()->child(index);
+}
+
+int RenderWidgetHostViewQtDelegateWidgetAccessible::indexOfChild(const QAccessibleInterface *c) const
+{
+ return viewAccessible()->indexOfChild(c);
+}
+
+QWebEngineViewAccessible *RenderWidgetHostViewQtDelegateWidgetAccessible::viewAccessible() const
+{
+ return static_cast<QWebEngineViewAccessible *>(QAccessible::queryAccessibleInterface(m_view));
+}
+
+} // namespace QtWebEngineCore
diff --git a/src/webenginewidgets/qwebengine_accessible_p.h b/src/webenginewidgets/qwebengine_accessible_p.h
new file mode 100644
index 000000000..99604d90d
--- /dev/null
+++ b/src/webenginewidgets/qwebengine_accessible_p.h
@@ -0,0 +1,60 @@
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef QWEBENGINE_ACCESSIBLE_H
+#define QWEBENGINE_ACCESSIBLE_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of other Qt classes. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QtCore/QPointer>
+#include <QtWidgets/QAccessibleWidget>
+
+QT_BEGIN_NAMESPACE
+class QWebEngineView;
+
+class QWebEngineViewAccessible : public QAccessibleWidget
+{
+public:
+ QWebEngineViewAccessible(QWebEngineView *o);
+
+ bool isValid() const override;
+ QAccessibleInterface *focusChild() const override;
+ int childCount() const override;
+ QAccessibleInterface *child(int index) const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+
+private:
+ QWebEngineView *view() const;
+};
+
+QT_END_NAMESPACE
+
+namespace QtWebEngineCore {
+
+class RenderWidgetHostViewQtDelegateWidgetAccessible : public QAccessibleWidget
+{
+public:
+ RenderWidgetHostViewQtDelegateWidgetAccessible(QWidget *o, QWebEngineView *view);
+
+ bool isValid() const override;
+ QAccessibleInterface *focusChild() const override;
+ int childCount() const override;
+ QAccessibleInterface *child(int index) const override;
+ int indexOfChild(const QAccessibleInterface *child) const override;
+
+private:
+ QWebEngineViewAccessible *viewAccessible() const;
+ QPointer<QWebEngineView> m_view;
+};
+} // namespace QtWebEngineCore
+
+#endif // QWEBENGINE_ACCESSIBLE_H
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
deleted file mode 100644
index 5a447ef1d..000000000
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.cpp
+++ /dev/null
@@ -1,519 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "render_widget_host_view_qt_delegate_widget.h"
-
-#include "render_widget_host_view_qt_delegate_client.h"
-
-#include <QtWebEngineCore/private/qwebenginepage_p.h>
-#include "qwebengineview.h"
-#include "qwebengineview_p.h"
-
-#include <QGuiApplication>
-#include <QMouseEvent>
-#include <QResizeEvent>
-#include <QSGImageNode>
-#include <QWindow>
-
-namespace QtWebEngineCore {
-
-class RenderWidgetHostViewQuickItem : public QQuickItem, public Compositor::Observer
-{
-public:
- RenderWidgetHostViewQuickItem(RenderWidgetHostViewQtDelegateClient *client) : m_client(client)
- {
- setFlag(ItemHasContents, true);
- // Mark that this item should receive focus when the parent QQuickWidget receives focus.
- setFocus(true);
-
- bind(client->compositorId());
- }
- ~RenderWidgetHostViewQuickItem() { unbind(); }
-
-protected:
- bool event(QEvent *event) override
- {
- if (event->type() == QEvent::ShortcutOverride)
- return m_client->forwardEvent(event);
-
- return QQuickItem::event(event);
- }
- void focusInEvent(QFocusEvent *event) override
- {
- m_client->forwardEvent(event);
- }
- void focusOutEvent(QFocusEvent *event) override
- {
- m_client->forwardEvent(event);
- }
- void inputMethodEvent(QInputMethodEvent *event) override
- {
- m_client->forwardEvent(event);
- }
- void itemChange(ItemChange change, const ItemChangeData &value) override
- {
- QQuickItem::itemChange(change, value);
- if (change == QQuickItem::ItemSceneChange) {
- for (const QMetaObject::Connection &c : qAsConst(m_windowConnections))
- disconnect(c);
- m_windowConnections.clear();
- if (value.window) {
- m_windowConnections.append(connect(
- value.window, &QQuickWindow::beforeRendering, this,
- &RenderWidgetHostViewQuickItem::onBeforeRendering, Qt::DirectConnection));
- }
- }
- }
- QSGNode *updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *) override
- {
- auto comp = compositor();
- if (!comp)
- return nullptr;
-
- QQuickWindow *win = QQuickItem::window();
-
- // Delete old node before swapFrame to decrement refcount of
- // QImage in software mode.
- delete oldNode;
- QSGImageNode *node = win->createImageNode();
- node->setOwnsTexture(true);
-
- comp->swapFrame();
-
- QSize texSize = comp->size();
- QSizeF texSizeInDips = QSizeF(texSize) / comp->devicePixelRatio();
- node->setRect(QRectF(QPointF(0, 0), texSizeInDips));
-
- if (comp->type() == Compositor::Type::Software) {
- QImage image = comp->image();
- node->setTexture(win->createTextureFromImage(image));
- } else if (comp->type() == Compositor::Type::OpenGL) {
-#if QT_CONFIG(opengl)
- QQuickWindow::CreateTextureOptions texOpts;
- if (comp->hasAlphaChannel())
- texOpts.setFlag(QQuickWindow::TextureHasAlphaChannel);
- int texId = comp->textureId();
- node->setTexture(QNativeInterface::QSGOpenGLTexture::fromNative(texId, win, texSize, texOpts));
- node->setTextureCoordinatesTransform(QSGImageNode::MirrorVertically);
-#else
- Q_UNREACHABLE();
-
-#endif
- } else {
- Q_UNREACHABLE();
- }
-
- return node;
- }
- void onBeforeRendering()
- {
- auto comp = compositor();
- if (!comp || comp->type() != Compositor::Type::OpenGL)
- return;
- comp->waitForTexture();
- }
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const override
- {
- return m_client->inputMethodQuery(query);
- }
- void readyToSwap() override
- {
- // Call update() on UI thread.
- QMetaObject::invokeMethod(this, &QQuickItem::update, Qt::QueuedConnection);
- }
-
-private:
- RenderWidgetHostViewQtDelegateClient *m_client;
- QList<QMetaObject::Connection> m_windowConnections;
-};
-
-RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent)
- : QQuickWidget(parent)
- , m_client(client)
- , m_rootItem(new RenderWidgetHostViewQuickItem(client))
- , m_isPopup(false)
-{
- setFocusPolicy(Qt::StrongFocus);
- setMouseTracking(true);
- setAttribute(Qt::WA_AcceptTouchEvents);
- setAttribute(Qt::WA_OpaquePaintEvent);
- setAttribute(Qt::WA_AlwaysShowToolTips);
-
- setContent(QUrl(), nullptr, m_rootItem.data());
-
- connectRemoveParentBeforeParentDelete();
-}
-
-RenderWidgetHostViewQtDelegateWidget::~RenderWidgetHostViewQtDelegateWidget()
-{
- QWebEngineViewPrivate::bindPageAndWidget(nullptr, this);
-}
-
-void RenderWidgetHostViewQtDelegateWidget::connectRemoveParentBeforeParentDelete()
-{
- disconnect(m_parentDestroyedConnection);
-
- if (QWidget *parent = parentWidget()) {
- m_parentDestroyedConnection = connect(parent, &QObject::destroyed,
- this,
- &RenderWidgetHostViewQtDelegateWidget::removeParentBeforeParentDelete);
- } else {
- m_parentDestroyedConnection = QMetaObject::Connection();
- }
-}
-
-void RenderWidgetHostViewQtDelegateWidget::removeParentBeforeParentDelete()
-{
- // Unset the parent, because parent is being destroyed, but the owner of this
- // RenderWidgetHostViewQtDelegateWidget is actually a RenderWidgetHostViewQt instance.
- setParent(nullptr);
-
- // If this widget represents a popup window, make sure to close it, so that if the popup was the
- // last visible top level window, the application event loop can quit if it deems it necessarry.
- if (m_isPopup)
- close();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::initAsPopup(const QRect& screenRect)
-{
- m_isPopup = true;
-
- // The keyboard events are supposed to go to the parent RenderHostView
- // so the WebUI popups should never have focus. Besides, if the parent view
- // loses focus, WebKit will cause its associated popups (including this one)
- // to be destroyed.
- setAttribute(Qt::WA_ShowWithoutActivating);
- setFocusPolicy(Qt::NoFocus);
- setWindowFlags(Qt::Popup | Qt::FramelessWindowHint | Qt::WindowDoesNotAcceptFocus);
-
- setGeometry(screenRect);
- show();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::closeEvent(QCloseEvent *event)
-{
- Q_UNUSED(event);
-
- // If a close event was received from the window manager (e.g. when moving the parent window,
- // clicking outside the popup area)
- // make sure to notify the Chromium WebUI popup and its underlying
- // RenderWidgetHostViewQtDelegate instance to be closed.
- if (m_isPopup)
- m_client->closePopup();
-}
-
-QRectF RenderWidgetHostViewQtDelegateWidget::viewGeometry() const
-{
- return QRectF(mapToGlobal(pos()), size());
-}
-
-QRect RenderWidgetHostViewQtDelegateWidget::windowGeometry() const
-{
- if (!window())
- return QRect();
- return window()->frameGeometry();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::setKeyboardFocus()
-{
- // The root item always has focus within the root focus scope:
- Q_ASSERT(m_rootItem->hasFocus());
-
- setFocus();
-}
-
-bool RenderWidgetHostViewQtDelegateWidget::hasKeyboardFocus()
-{
- // The root item always has focus within the root focus scope:
- Q_ASSERT(m_rootItem->hasFocus());
-
- return hasFocus();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::lockMouse()
-{
- grabMouse();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::unlockMouse()
-{
- releaseMouse();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::show()
-{
- m_rootItem->setVisible(true);
- // Check if we're attached to a QWebEngineView, we don't
- // want to show anything else than popups as top-level.
- if (parent() || m_isPopup) {
- QQuickWidget::show();
- }
-}
-
-void RenderWidgetHostViewQtDelegateWidget::hide()
-{
- m_rootItem->setVisible(false);
- QQuickWidget::hide();
-}
-
-bool RenderWidgetHostViewQtDelegateWidget::isVisible() const
-{
- return QQuickWidget::isVisible() && m_rootItem->isVisible();
-}
-
-QWindow* RenderWidgetHostViewQtDelegateWidget::window() const
-{
- const QWidget* root = QQuickWidget::window();
- return root ? root->windowHandle() : 0;
-}
-
-void RenderWidgetHostViewQtDelegateWidget::updateCursor(const QCursor &cursor)
-{
- QQuickWidget::setCursor(cursor);
-}
-
-void RenderWidgetHostViewQtDelegateWidget::resize(int width, int height)
-{
- QQuickWidget::resize(width, height);
-}
-
-void RenderWidgetHostViewQtDelegateWidget::move(const QPoint &screenPos)
-{
- Q_ASSERT(m_isPopup);
- QQuickWidget::move(screenPos);
-}
-
-void RenderWidgetHostViewQtDelegateWidget::inputMethodStateChanged(bool editorVisible, bool passwordInput)
-{
- QQuickWidget::setAttribute(Qt::WA_InputMethodEnabled, editorVisible && !passwordInput);
- qApp->inputMethod()->update(Qt::ImQueryInput | Qt::ImEnabled | Qt::ImHints);
- if (qApp->inputMethod()->isVisible() != editorVisible)
- qApp->inputMethod()->setVisible(editorVisible);
-}
-
-void RenderWidgetHostViewQtDelegateWidget::setInputMethodHints(Qt::InputMethodHints hints)
-{
- QQuickWidget::setInputMethodHints(hints);
-}
-
-void RenderWidgetHostViewQtDelegateWidget::setClearColor(const QColor &color)
-{
- QQuickWidget::setClearColor(color);
- // QQuickWidget is usually blended by punching holes into widgets
- // above it to simulate the visual stacking order. If we want it to be
- // transparent we have to throw away the proper stacking order and always
- // blend the complete normal widgets backing store under it.
- bool isTranslucent = color.alpha() < 255;
- setAttribute(Qt::WA_AlwaysStackOnTop, isTranslucent);
- setAttribute(Qt::WA_OpaquePaintEvent, !isTranslucent);
- update();
-}
-
-QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- return m_client->inputMethodQuery(query);
-}
-
-void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent)
-{
- QQuickWidget::resizeEvent(resizeEvent);
- m_client->visualPropertiesChanged();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::showEvent(QShowEvent *event)
-{
- QQuickWidget::showEvent(event);
- // We don't have a way to catch a top-level window change with QWidget
- // but a widget will most likely be shown again if it changes, so do
- // the reconnection at this point.
- for (const QMetaObject::Connection &c : qAsConst(m_windowConnections))
- disconnect(c);
- m_windowConnections.clear();
- if (QWindow *w = window()) {
- m_windowConnections.append(connect(w, SIGNAL(xChanged(int)), SLOT(onWindowPosChanged())));
- m_windowConnections.append(connect(w, SIGNAL(yChanged(int)), SLOT(onWindowPosChanged())));
- }
- m_client->visualPropertiesChanged();
- m_client->notifyShown();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::hideEvent(QHideEvent *event)
-{
- QQuickWidget::hideEvent(event);
- m_client->notifyHidden();
-}
-
-bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
-{
- bool handled = false;
-
- // Track parent to make sure we don't get deleted.
- switch (event->type()) {
- case QEvent::ParentChange:
- connectRemoveParentBeforeParentDelete();
- break;
- default:
- break;
- }
-
- // Mimic QWidget::event() by ignoring mouse, keyboard, touch and tablet events if the widget is
- // disabled.
- if (!isEnabled()) {
- switch (event->type()) {
- case QEvent::TabletPress:
- case QEvent::TabletRelease:
- case QEvent::TabletMove:
- case QEvent::MouseButtonPress:
- case QEvent::MouseButtonRelease:
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseMove:
- case QEvent::TouchBegin:
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- case QEvent::TouchCancel:
- case QEvent::ContextMenu:
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
-#ifndef QT_NO_WHEELEVENT
- case QEvent::Wheel:
-#endif
- return false;
- default:
- break;
- }
- }
-
- switch (event->type()) {
- case QEvent::FocusIn:
- case QEvent::FocusOut:
- // We forward focus events later, once they have made it to the m_rootItem.
- return QQuickWidget::event(event);
- case QEvent::DragEnter:
- case QEvent::DragLeave:
- case QEvent::DragMove:
- case QEvent::Drop:
- case QEvent::HoverEnter:
- case QEvent::HoverLeave:
- case QEvent::HoverMove:
- // Let the parent handle these events.
- return false;
- default:
- break;
- }
-
- if (event->type() == QEvent::MouseButtonDblClick) {
- // QWidget keeps the Qt4 behavior where the DblClick event would replace the Press event.
- // QtQuick is different by sending both the Press and DblClick events for the second press
- // where we can simply ignore the DblClick event.
- QMouseEvent *dblClick = static_cast<QMouseEvent *>(event);
- QMouseEvent press(QEvent::MouseButtonPress, dblClick->position(), dblClick->scenePosition(),
- dblClick->globalPosition(), dblClick->button(), dblClick->buttons(),
- dblClick->modifiers(), dblClick->source());
- press.setTimestamp(dblClick->timestamp());
- handled = m_client->forwardEvent(&press);
- } else
- handled = m_client->forwardEvent(event);
-
- if (!handled)
- return QQuickWidget::event(event);
- event->accept();
- return true;
-}
-
-void RenderWidgetHostViewQtDelegateWidget::unhandledWheelEvent(QWheelEvent *ev)
-{
- if (QWidget *p = parentWidget())
- qApp->sendEvent(p, ev);
-}
-
-void RenderWidgetHostViewQtDelegateWidget::onWindowPosChanged()
-{
- m_client->visualPropertiesChanged();
-}
-
-void RenderWidgetHostViewQtDelegateWidget::adapterClientChanged(WebContentsAdapterClient *client)
-{
- QWebEnginePage *page = static_cast<QWebEnginePagePrivate *>(client)->q_func();
- QWebEngineViewPrivate::bindPageAndWidget(page, this);
- connect(page, &QWebEnginePage::_q_aboutToDelete, this,
- [this]() { QWebEngineViewPrivate::bindPageAndWidget(nullptr, this); });
-}
-
-#if QT_CONFIG(accessibility)
-RenderWidgetHostViewQtDelegateWidgetAccessible::RenderWidgetHostViewQtDelegateWidgetAccessible(RenderWidgetHostViewQtDelegateWidget *o, QWebEngineView *view)
- : QAccessibleWidget(o)
- , m_view(view)
-{
-}
-
-bool RenderWidgetHostViewQtDelegateWidgetAccessible::isValid() const
-{
- if (!viewAccessible() || !viewAccessible()->isValid())
- return false;
-
- return QAccessibleWidget::isValid();
-}
-
-QAccessibleInterface *RenderWidgetHostViewQtDelegateWidgetAccessible::focusChild() const
-{
- return viewAccessible()->focusChild();
-}
-
-int RenderWidgetHostViewQtDelegateWidgetAccessible::childCount() const
-{
- return viewAccessible()->childCount();
-}
-
-QAccessibleInterface *RenderWidgetHostViewQtDelegateWidgetAccessible::child(int index) const
-{
- return viewAccessible()->child(index);
-}
-
-int RenderWidgetHostViewQtDelegateWidgetAccessible::indexOfChild(const QAccessibleInterface *c) const
-{
- return viewAccessible()->indexOfChild(c);
-}
-
-QWebEngineViewAccessible *RenderWidgetHostViewQtDelegateWidgetAccessible::viewAccessible() const
-{
- return static_cast<QWebEngineViewAccessible *>(QAccessible::queryAccessibleInterface(m_view));
-}
-#endif // QT_CONFIG(accessibility)
-
-} // namespace QtWebEngineCore
diff --git a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h b/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
deleted file mode 100644
index d1414a918..000000000
--- a/src/webenginewidgets/render_widget_host_view_qt_delegate_widget.h
+++ /dev/null
@@ -1,137 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** 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 The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/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 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.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 <QAccessibleWidget>
-#include <QQuickItem>
-#include <QQuickWidget>
-
-QT_BEGIN_NAMESPACE
-class QWebEnginePage;
-class QWebEngineView;
-class QWebEngineViewAccessible;
-class QWebEngineViewPrivate;
-QT_END_NAMESPACE
-
-namespace QtWebEngineCore {
-
-// Useful information keyboard and mouse QEvent propagation.
-// A RenderWidgetHostViewQtDelegateWidget instance initialized as a popup will receive
-// no keyboard focus (so all keyboard QEvents will be sent to the parent RWHVQD instance),
-// but will still receive mouse input (all mouse QEvent moves and clicks will be given to the popup
-// RWHVQD instance, and the mouse interaction area covers the surface of the whole parent
-// QWebEngineView, and not only the smaller surface that an HTML select popup would occupy).
-class RenderWidgetHostViewQtDelegateWidget : public QQuickWidget, public RenderWidgetHostViewQtDelegate {
- Q_OBJECT
-public:
- RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, QWidget *parent = nullptr);
- ~RenderWidgetHostViewQtDelegateWidget();
-
- void initAsPopup(const QRect&) override;
- QRectF viewGeometry() const override;
- QRect windowGeometry() const override;
- void setKeyboardFocus() override;
- bool hasKeyboardFocus() override;
- void lockMouse() override;
- void unlockMouse() override;
- void show() override;
- void hide() override;
- bool isVisible() const override;
- QWindow* window() const override;
- void updateCursor(const QCursor &) override;
- void resize(int width, int height) override;
- void move(const QPoint &screenPos) override;
- void inputMethodStateChanged(bool editorVisible, bool passwordInput) override;
- void setInputMethodHints(Qt::InputMethodHints) override;
- void setClearColor(const QColor &color) override;
- void unhandledWheelEvent(QWheelEvent *ev) override;
-
-protected:
- bool event(QEvent *event) override;
- void resizeEvent(QResizeEvent *resizeEvent) override;
- void showEvent(QShowEvent *) override;
- void hideEvent(QHideEvent *) override;
- void closeEvent(QCloseEvent *event) override;
-
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const override;
- void adapterClientChanged(WebContentsAdapterClient *client) override;
-
-private Q_SLOTS:
- void onWindowPosChanged();
- void connectRemoveParentBeforeParentDelete();
- void removeParentBeforeParentDelete();
-
-private:
- friend QWebEngineViewPrivate;
-
- RenderWidgetHostViewQtDelegateClient *m_client;
- QScopedPointer<QQuickItem> m_rootItem;
- bool m_isPopup;
- QColor m_clearColor;
- QList<QMetaObject::Connection> m_windowConnections;
- QWebEnginePage *m_page = nullptr;
- QMetaObject::Connection m_parentDestroyedConnection;
-};
-
-#if QT_CONFIG(accessibility)
-class RenderWidgetHostViewQtDelegateWidgetAccessible : public QAccessibleWidget
-{
-public:
- RenderWidgetHostViewQtDelegateWidgetAccessible(RenderWidgetHostViewQtDelegateWidget *o, QWebEngineView *view);
-
- bool isValid() const override;
- QAccessibleInterface *focusChild() const override;
- int childCount() const override;
- QAccessibleInterface *child(int index) const override;
- int indexOfChild(const QAccessibleInterface *child) const override;
-
-private:
- QWebEngineViewAccessible *viewAccessible() const;
- QWebEngineView *m_view;
-};
-#endif // QT_CONFIG(accessibility)
-
-} // namespace QtWebEngineCore
-
-#endif
diff --git a/src/webenginewidgets/ui/autofillpopupwidget.cpp b/src/webenginewidgets/ui/autofillpopupwidget.cpp
new file mode 100644
index 000000000..a4dc31beb
--- /dev/null
+++ b/src/webenginewidgets/ui/autofillpopupwidget.cpp
@@ -0,0 +1,201 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "autofillpopupwidget_p.h"
+#include "qwebengineview.h"
+#include "qwebengineview_p.h"
+
+#include "autofill_popup_controller.h"
+
+#include <QApplication>
+#include <QBoxLayout>
+#include <QEvent>
+#include <QKeyEvent>
+#include <QListView>
+#include <QMouseEvent>
+
+namespace QtWebEngineWidgetUI {
+
+AutofillPopupWidget::AutofillPopupWidget(QtWebEngineCore::AutofillPopupController *controller,
+ QWebEngineView *parent)
+ : QFrame(parent, Qt::Popup), m_controller(controller), m_webEngineView(parent)
+{
+ setAttribute(Qt::WA_WindowPropagation);
+ setAttribute(Qt::WA_X11NetWmWindowTypeCombo);
+
+ // we need a vertical layout
+ QBoxLayout *layout = new QBoxLayout(QBoxLayout::TopToBottom, this);
+ layout->setSpacing(0);
+ layout->setContentsMargins(QMargins());
+
+ m_listView = new QListView(m_webEngineView);
+ m_listView->setModel(m_controller->model());
+ m_listView->setTextElideMode(Qt::ElideMiddle);
+
+ // Based on QComboBoxPrivateContainer::setItemView
+ m_listView->setParent(this);
+ m_listView->setAttribute(Qt::WA_MacShowFocusRect, false);
+ layout->insertWidget(0, m_listView);
+ m_listView->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
+
+ m_listView->installEventFilter(this);
+ // Necessary for filtering QEvent::MouseMove:
+ m_listView->viewport()->installEventFilter(this);
+
+ m_listView->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ // TODO: Implement vertical scrollbar. Chromium also has it.
+ m_listView->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ m_listView->setMouseTracking(true);
+
+ m_listView->setSelectionMode(QAbstractItemView::SingleSelection);
+ m_listView->setEditTriggers(QAbstractItemView::NoEditTriggers);
+
+ // Some styles (Mac) have a margin at the top and bottom of the popup.
+ layout->insertSpacing(0, 0);
+ layout->addSpacing(0);
+
+ connect(m_controller, &QtWebEngineCore::AutofillPopupController::currentIndexChanged,
+ m_listView, &QListView::setCurrentIndex);
+}
+
+AutofillPopupWidget::~AutofillPopupWidget() { }
+
+// Based on QComboBox::showPopup()
+void AutofillPopupWidget::showPopup(QPoint pos, int width, bool autoselectFirstSuggestion)
+{
+ QStyle *const style = m_webEngineView->style();
+ QStyleOptionComboBox opt;
+ opt.initFrom(m_webEngineView);
+
+ if (autoselectFirstSuggestion)
+ m_controller->selectFirstSuggestion();
+
+ QRect listRect(pos, QSize(width, 0));
+
+ // Calculate height
+ {
+ int listHeight = 0;
+ int rowCount = m_controller->model()->rowCount();
+ for (int i = 0; i < rowCount; ++i) {
+ QModelIndex idx = m_controller->model()->index(i, 0);
+ listHeight += m_listView->visualRect(idx).height();
+ }
+ if (rowCount > 1)
+ listHeight += (rowCount - 1) * m_listView->spacing() * 2;
+
+ listRect.setHeight(listRect.height() + listHeight);
+ }
+
+ // Calculate height margin
+ {
+ int heightMargin = m_listView->spacing() * 2;
+
+ // Add the frame of the popup
+ const QMargins pm = contentsMargins();
+ heightMargin += pm.top() + pm.bottom();
+
+ // Add the frame of the list view
+ const QMargins vm = m_listView->contentsMargins();
+ heightMargin += vm.top() + vm.bottom();
+ listRect.setHeight(listRect.height() + heightMargin);
+ }
+
+ // Add space for margin at top and bottom if the style wants it
+ int styleMargin = style->pixelMetric(QStyle::PM_MenuVMargin, &opt, this) * 2;
+ listRect.setHeight(listRect.height() + styleMargin);
+
+ // Takes account of the mimium/maximum size of the popup
+ layout()->activate();
+ listRect.setSize(listRect.size().expandedTo(minimumSize()).boundedTo(maximumSize()));
+
+ setGeometry(listRect);
+ QFrame::show();
+}
+
+bool AutofillPopupWidget::eventFilter(QObject *object, QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::MouseMove:
+ if (isVisible()) {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
+ QModelIndex indexUnderMouse = m_listView->indexAt(mouseEvent->position().toPoint());
+ if (indexUnderMouse.isValid()
+ && indexUnderMouse.data(Qt::AccessibleDescriptionRole).toString()
+ != QLatin1String("separator")) {
+ m_controller->selectSuggestion(indexUnderMouse.row());
+ }
+ }
+ return true;
+ case QEvent::MouseButtonRelease: {
+ QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
+ if (mouseEvent->button() == Qt::LeftButton) {
+ m_controller->acceptSuggestion();
+ return true;
+ }
+ break;
+ }
+ default:
+ break;
+ }
+
+ return QFrame::eventFilter(object, event);
+}
+
+void AutofillPopupWidget::keyPressEvent(QKeyEvent *event)
+{
+ // AutofillPopupControllerImpl::HandleKeyPressEvent()
+ // chrome/browser/ui/autofill/autofill_popup_controller_impl.cc
+ switch (event->key()) {
+ case Qt::Key_Up:
+ m_controller->selectPreviousSuggestion();
+ return;
+ case Qt::Key_Down:
+ m_controller->selectNextSuggestion();
+ return;
+ case Qt::Key_PageUp:
+ m_controller->selectFirstSuggestion();
+ return;
+ case Qt::Key_PageDown:
+ m_controller->selectLastSuggestion();
+ return;
+ case Qt::Key_Escape:
+ m_webEngineView->d_ptr->hideAutofillPopup();
+ return;
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ m_controller->acceptSuggestion();
+ return;
+ case Qt::Key_Delete:
+ // Remove suggestion is not supported for datalist.
+ // Forward delete to view to be able to remove selected text.
+ break;
+ case Qt::Key_Tab:
+ m_controller->acceptSuggestion();
+ break;
+ default:
+ break;
+ }
+
+ QCoreApplication::sendEvent(m_webEngineView->focusWidget(), event);
+}
+
+void AutofillPopupWidget::keyReleaseEvent(QKeyEvent *event)
+{
+ // Do not forward release events of the overridden key presses.
+ switch (event->key()) {
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_PageUp:
+ case Qt::Key_PageDown:
+ case Qt::Key_Escape:
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ return;
+ default:
+ break;
+ }
+
+ QCoreApplication::sendEvent(m_webEngineView->focusWidget(), event);
+}
+
+} // namespace QtWebEngineWidgetUI
diff --git a/src/webenginewidgets/ui/autofillpopupwidget_p.h b/src/webenginewidgets/ui/autofillpopupwidget_p.h
new file mode 100644
index 000000000..79decc6ab
--- /dev/null
+++ b/src/webenginewidgets/ui/autofillpopupwidget_p.h
@@ -0,0 +1,58 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef AUTOFILLPOPUPWIDGET_P_H
+#define AUTOFILLPOPUPWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QFrame>
+
+namespace QtWebEngineCore {
+class AutofillPopupController;
+}
+
+QT_BEGIN_NAMESPACE
+class QListView;
+class QWebEngineView;
+class QWebEngineViewPrivate;
+QT_END_NAMESPACE
+
+namespace QtWebEngineWidgetUI {
+
+// Based on QComboBoxPrivateContainer
+class AutofillPopupWidget : public QFrame
+{
+ Q_OBJECT
+public:
+ AutofillPopupWidget(QtWebEngineCore::AutofillPopupController *controller,
+ QWebEngineView *parent);
+ ~AutofillPopupWidget();
+
+ void showPopup(QPoint pos, int width, bool autoselectFirstSuggestion);
+
+protected:
+ bool eventFilter(QObject *object, QEvent *event) override;
+ void keyPressEvent(QKeyEvent *event) override;
+ void keyReleaseEvent(QKeyEvent *event) override;
+
+private:
+ QtWebEngineCore::AutofillPopupController *m_controller;
+ QWebEngineView *m_webEngineView;
+ QListView *m_listView;
+
+ friend class QT_PREPEND_NAMESPACE(QWebEngineViewPrivate);
+};
+
+} // namespace QtWebEngineWidgetUI
+
+#endif // AUTOFILLPOPUPWIDGET_P_H
diff --git a/src/webenginewidgets/ui/touchhandlewidget.cpp b/src/webenginewidgets/ui/touchhandlewidget.cpp
new file mode 100644
index 000000000..88af0ff36
--- /dev/null
+++ b/src/webenginewidgets/ui/touchhandlewidget.cpp
@@ -0,0 +1,59 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "touchhandlewidget_p.h"
+#include "qwebengineview.h"
+
+#include <QBoxLayout>
+#include <QGraphicsOpacityEffect>
+#include <QLabel>
+#include <QWidget>
+
+namespace QtWebEngineWidgetUI {
+TouchHandleWidget::TouchHandleWidget(QWebEngineView *view, const QMap<int, QImage> &images)
+ : m_widget(new QWidget(view))
+ , m_label(new QLabel(m_widget))
+ , m_opacityEffect(new QGraphicsOpacityEffect(m_widget))
+ , m_images(images)
+{
+ m_widget->setAttribute(Qt::WA_AcceptTouchEvents, true);
+ m_widget->setAttribute(Qt::WA_TransparentForMouseEvents, true);
+}
+
+TouchHandleWidget::~TouchHandleWidget()
+{
+}
+
+void TouchHandleWidget::setImage(int orientation)
+{
+ const QImage &img = m_images[orientation];
+ m_label->setPixmap(QPixmap::fromImage(img));
+ m_label->setFrameStyle(QFrame::NoFrame);
+ m_label->resize(img.size());
+ m_label->setVisible(true);
+
+ QVBoxLayout layout;
+ layout.setSpacing(0);
+ layout.setContentsMargins(QMargins());
+ layout.addWidget(m_label);
+ layout.setParent(m_widget);
+ m_widget->setLayout(&layout);
+ m_widget->resize(img.size());
+}
+
+void TouchHandleWidget::setBounds(const QRect &bounds)
+{
+ m_widget->setGeometry(bounds);
+}
+
+void TouchHandleWidget::setVisible(bool visible)
+{
+ m_widget->setVisible(visible);
+}
+
+void TouchHandleWidget::setOpacity(float opacity)
+{
+ m_opacityEffect->setOpacity(opacity);
+ m_widget->setGraphicsEffect(m_opacityEffect);
+}
+} // namespace QtWebEngineWidgetUI
diff --git a/src/webenginewidgets/ui/touchhandlewidget_p.h b/src/webenginewidgets/ui/touchhandlewidget_p.h
new file mode 100644
index 000000000..9f181c935
--- /dev/null
+++ b/src/webenginewidgets/ui/touchhandlewidget_p.h
@@ -0,0 +1,50 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef TOUCHHANDLEWIDGET_P_H
+#define TOUCHHANDLEWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include "touch_handle_drawable_client.h"
+
+#include <QImage>
+#include <QMap>
+
+QT_BEGIN_NAMESPACE
+class QGraphicsOpacityEffect;
+class QLabel;
+class QWebEngineView;
+class QWidget;
+QT_END_NAMESPACE
+
+namespace QtWebEngineWidgetUI {
+class TouchHandleWidget : public QtWebEngineCore::TouchHandleDrawableDelegate
+{
+public:
+ TouchHandleWidget(QWebEngineView *view, const QMap<int, QImage> &images);
+ ~TouchHandleWidget();
+
+ void setImage(int orientation) override;
+ void setBounds(const QRect &bounds) override;
+ void setVisible(bool visible) override;
+ void setOpacity(float opacity) override;
+
+private:
+ QWidget *m_widget;
+ QLabel *m_label;
+ QGraphicsOpacityEffect *m_opacityEffect;
+ QMap<int, QImage> m_images;
+};
+} // namespace QtWebEngineWidgetUI
+
+#endif // TOUCHHANDLEWIDGET_P_H
diff --git a/src/webenginewidgets/ui/touchselectionmenuwidget.cpp b/src/webenginewidgets/ui/touchselectionmenuwidget.cpp
new file mode 100644
index 000000000..ff69fe84b
--- /dev/null
+++ b/src/webenginewidgets/ui/touchselectionmenuwidget.cpp
@@ -0,0 +1,117 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "touchselectionmenuwidget_p.h"
+#include "qwebengineview.h"
+
+#include "touch_selection_menu_controller.h"
+
+#include <QBoxLayout>
+#include <QEvent>
+
+namespace QtWebEngineWidgetUI {
+namespace {
+// The Widgets module is built with rtti in developer-build while Core is not.
+// The MOC will throw "undefined reference to typeinfo..." errors if we connect slots
+// from QtWebEngineCore via function pointers, because it expects rtti on them.
+// To workaround this we use lambdas.
+void connectButton(TouchSelectionMenuWidget::TouchButton *button, std::function<void()> callback)
+{
+ QObject::connect(button, &QPushButton::clicked, std::move(callback));
+}
+} // namespace
+
+TouchSelectionMenuWidget::TouchButton::TouchButton(QString name, QWidget *parent)
+ : QPushButton(name, parent)
+{
+ setAttribute(Qt::WA_AcceptTouchEvents, true);
+}
+
+TouchSelectionMenuWidget::TouchButton::~TouchButton()
+{
+}
+
+bool TouchSelectionMenuWidget::TouchButton::event(QEvent *ev)
+{
+ switch (ev->type()) {
+ case QEvent::TouchBegin:
+ ev->accept();
+ return true;
+ case QEvent::TouchEnd:
+ Q_EMIT clicked();
+ ev->accept();
+ return true;
+ default:
+ break;
+ }
+
+ return QPushButton::event(ev);
+}
+
+TouchSelectionMenuWidget::TouchSelectionMenuWidget(
+ QWebEngineView *view, QtWebEngineCore::TouchSelectionMenuController *controller)
+ : QWidget(view,
+ Qt::Window | Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint
+ | Qt::WindowDoesNotAcceptFocus)
+{
+ setAttribute(Qt::WA_AcceptTouchEvents, true);
+ setAttribute(Qt::WA_TransparentForMouseEvents, true);
+ setAttribute(Qt::WA_DeleteOnClose, true);
+
+ bool cutEnabled =
+ controller->isCommandEnabled(QtWebEngineCore::TouchSelectionMenuController::Cut);
+ bool copyEnabled =
+ controller->isCommandEnabled(QtWebEngineCore::TouchSelectionMenuController::Copy);
+ bool pasteEnabled =
+ controller->isCommandEnabled(QtWebEngineCore::TouchSelectionMenuController::Paste);
+
+ QSizePolicy policy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ QHBoxLayout *layout = new QHBoxLayout();
+
+ if (cutEnabled) {
+ TouchButton *button = new TouchButton(tr("Cut"), this);
+ button->setSizePolicy(policy);
+ layout->addWidget(button);
+ connectButton(button, [controller]() { controller->cut(); });
+ }
+
+ if (copyEnabled) {
+ TouchButton *button = new TouchButton(tr("Copy"), this);
+ button->setSizePolicy(policy);
+ layout->addWidget(button);
+ connectButton(button, [controller]() { controller->copy(); });
+ }
+
+ if (pasteEnabled) {
+ TouchButton *button = new TouchButton(tr("Paste"), this);
+ button->setSizePolicy(policy);
+ layout->addWidget(button);
+ connectButton(button, [controller]() { controller->paste(); });
+ }
+
+ TouchButton *button = new TouchButton(tr("..."), this);
+ button->setSizePolicy(policy);
+ layout->addWidget(button);
+ connectButton(button, [controller]() { controller->runContextMenu(); });
+
+ layout->setSpacing(2);
+ layout->setSizeConstraint(QLayout::SetMinimumSize);
+ layout->setContentsMargins(0, 0, 0, 0);
+ setLayout(layout);
+
+ nativeParentWidget()->installEventFilter(this);
+}
+
+TouchSelectionMenuWidget::~TouchSelectionMenuWidget()
+{
+}
+
+bool TouchSelectionMenuWidget::eventFilter(QObject *obj, QEvent *ev)
+{
+ // Close the menu if the window is moved
+ if (ev->type() == QEvent::Move)
+ close();
+
+ return QWidget::eventFilter(obj, ev);
+}
+} // QtWebEngineWidgetUI
diff --git a/src/webenginewidgets/ui/touchselectionmenuwidget_p.h b/src/webenginewidgets/ui/touchselectionmenuwidget_p.h
new file mode 100644
index 000000000..1f822023b
--- /dev/null
+++ b/src/webenginewidgets/ui/touchselectionmenuwidget_p.h
@@ -0,0 +1,52 @@
+// Copyright (C) 2022 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#ifndef TOUCHSELECTIONMENUWIDGET_P_H
+#define TOUCHSELECTIONMENUWIDGET_P_H
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists purely as an
+// implementation detail. This header file may change from version to
+// version without notice, or even be removed.
+//
+// We mean it.
+//
+
+#include <QPushButton>
+#include <QWidget>
+
+namespace QtWebEngineCore {
+class TouchSelectionMenuController;
+}
+
+QT_BEGIN_NAMESPACE
+class QWebEngineView;
+QT_END_NAMESPACE
+
+namespace QtWebEngineWidgetUI {
+class TouchSelectionMenuWidget : public QWidget
+{
+public:
+ class TouchButton : public QPushButton
+ {
+ public:
+ TouchButton(QString name, QWidget *parent);
+ ~TouchButton();
+
+ protected:
+ bool event(QEvent *ev) override;
+ };
+
+ TouchSelectionMenuWidget(QWebEngineView *view,
+ QtWebEngineCore::TouchSelectionMenuController *controller);
+ ~TouchSelectionMenuWidget();
+
+protected:
+ bool eventFilter(QObject *obj, QEvent *ev) override;
+};
+} // namespace QtWebEngineWidgetUI
+
+#endif // TOUCHSELECTIONMENUWIDGET_P_H
diff --git a/src/webenginewidgets/webenginewidgets.pro b/src/webenginewidgets/webenginewidgets.pro
deleted file mode 100644
index d4c3a25bb..000000000
--- a/src/webenginewidgets/webenginewidgets.pro
+++ /dev/null
@@ -1,26 +0,0 @@
-include($$QTWEBENGINE_OUT_ROOT/src/core/qtwebenginecore-config.pri)
-QT_FOR_CONFIG += webenginecore-private
-
-TARGET = QtWebEngineWidgets
-
-# For our export macros
-DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB
-
-QT += webenginecore widgets network quick
-QT_PRIVATE += quick-private gui-private core-private widgets-private quickwidgets webenginecore-private
-
-INCLUDEPATH += $$PWD api ../core ../core/api ../webenginequick/api
-
-SOURCES = \
- api/qwebenginenotificationpresenter.cpp \
- api/qwebengineview.cpp \
- render_widget_host_view_qt_delegate_widget.cpp
-
-HEADERS = \
- api/qtwebenginewidgetsglobal.h \
- api/qwebenginenotificationpresenter_p.h \
- api/qwebengineview.h \
- api/qwebengineview_p.h \
- render_widget_host_view_qt_delegate_widget.h
-
-load(qt_module)