summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre Rossi <pierre.rossi@digia.com>2013-07-10 16:27:48 +0200
committerPierre Rossi <pierre.rossi@gmail.com>2013-07-31 13:39:50 +0200
commit67d042d04f2b6cbe98f4eba2a50ed0d374165cae (patch)
treeff24cf732fa98750400a29354219ffbd70c84e1c
parent519367a98334b658a93ed1ba096dba92858445c7 (diff)
Split out the Widgets and QtQuick integration
This is the first step to making proper Qt Modules out of QtWebEngine. The Widgets integration becomes a proper C++ Qt Module while we make the QtQuick side a QML plugin for now (could probably be promoted if the need arises). Code-wise, this means the introduction of a WebContentsAdapterClient interface that is subclassed by the private implementation of our API classes for delegation of things that are UI specific. Functionality from WebContents and the like is exposed via the WebContentsAdapter. Change-Id: I4ca3395b9fe8502a24e36002cfd5af44067bb6e8 Reviewed-by: Jocelyn Turcotte <jocelyn.turcotte@digia.com>
-rw-r--r--.qmake.conf5
-rw-r--r--build/qmake/mkspecs/features/default_pre.prf9
-rw-r--r--examples/common.pri1
-rw-r--r--examples/examples.pro4
-rw-r--r--examples/qtquick/main.cpp13
-rw-r--r--examples/qtquick/qtquick.pro7
-rw-r--r--examples/widgets/widgets.pro2
-rw-r--r--lib/lib.pro18
-rw-r--r--lib/qtwebengineglobal.h62
-rw-r--r--lib/quick/plugin.cpp (renamed from lib/qquickwebcontentsview_p.h)25
-rw-r--r--lib/quick/qmldir3
-rw-r--r--lib/quick/qquickwebcontentsview.cpp (renamed from lib/qquickwebcontentsview.cpp)103
-rw-r--r--lib/quick/qquickwebcontentsview_p.h (renamed from lib/qquickwebcontentsview.h)12
-rw-r--r--lib/quick/qquickwebcontentsview_p_p.h67
-rw-r--r--lib/quick/quick.pro28
-rw-r--r--lib/quick/render_widget_host_view_qt_delegate_quick.cpp (renamed from lib/render_widget_host_view_qt_delegate_quick.cpp)39
-rw-r--r--lib/quick/render_widget_host_view_qt_delegate_quick.h (renamed from lib/render_widget_host_view_qt_delegate_quick.h)4
-rw-r--r--lib/render_widget_host_view_qt.cpp9
-rw-r--r--lib/render_widget_host_view_qt.h5
-rw-r--r--lib/render_widget_host_view_qt_delegate.cpp86
-rw-r--r--lib/render_widget_host_view_qt_delegate.h28
-rw-r--r--lib/web_contents_adapter.cpp144
-rw-r--r--lib/web_contents_adapter.h78
-rw-r--r--lib/web_contents_adapter_client.h64
-rw-r--r--lib/web_contents_delegate_qt.cpp8
-rw-r--r--lib/web_contents_delegate_qt.h12
-rw-r--r--lib/web_contents_view_qt.cpp15
-rw-r--r--lib/web_contents_view_qt.h15
-rw-r--r--lib/web_event_factory.cpp5
-rw-r--r--lib/widgets/Api/qwebcontentsview.cpp (renamed from lib/qwebcontentsview.cpp)114
-rw-r--r--lib/widgets/Api/qwebcontentsview.h (renamed from lib/qwebcontentsview.h)9
-rw-r--r--lib/widgets/Api/qwebcontentsview_p.h (renamed from lib/qwebcontentsview_p.h)17
-rw-r--r--lib/widgets/render_widget_host_view_qt_delegate_widget.cpp (renamed from lib/render_widget_host_view_qt_delegate_widget.cpp)29
-rw-r--r--lib/widgets/render_widget_host_view_qt_delegate_widget.h (renamed from lib/render_widget_host_view_qt_delegate_widget.h)6
-rw-r--r--lib/widgets/widgets.pro33
-rw-r--r--qtwebengine.pro6
-rw-r--r--sync.profile26
37 files changed, 822 insertions, 289 deletions
diff --git a/.qmake.conf b/.qmake.conf
index 716685d2..a094e83c 100644
--- a/.qmake.conf
+++ b/.qmake.conf
@@ -1,6 +1,5 @@
-# The qmake generated module files belong into our build/qmake dir
-MODULE_QMAKE_OUTDIR = $$shadowed($$PWD/build/qmake)
-QMAKEPATH += $$PWD/build/qmake $$MODULE_QMAKE_OUTDIR
+QMAKEPATH += $$PWD/build/qmake
load(qt_build_config)
+# All modules share the same version number. We plan on following Qt's releases for now.
MODULE_VERSION = 5.2.0
diff --git a/build/qmake/mkspecs/features/default_pre.prf b/build/qmake/mkspecs/features/default_pre.prf
index ee1100dd..b3c0495f 100644
--- a/build/qmake/mkspecs/features/default_pre.prf
+++ b/build/qmake/mkspecs/features/default_pre.prf
@@ -9,4 +9,13 @@ isEmpty(CHROMIUM_SRC_DIR): CHROMIUM_SRC_DIR=$$QTWEBENGINE_ROOT/chromium
INCLUDEPATH += $$CHROMIUM_SRC_DIR
+# Used for our export macros
+!contains(_PRO_FILE_PWD_, $$QTWEBENGINE_ROOT/examples): DEFINES += BUILDING_CHROMIUM
+
+# Location of sync.profile
+MODULE_BASE_DIR = $$QTWEBENGINE_ROOT
+
+# We have to disable RTTI for now since that's how chromium builds on linux
+unix:!macx:QMAKE_CXXFLAGS += -fno-rtti
+
load(functions)
diff --git a/examples/common.pri b/examples/common.pri
index b5fe6b5a..dac92e86 100644
--- a/examples/common.pri
+++ b/examples/common.pri
@@ -8,7 +8,6 @@ HEADERS += common/util.h
RESOURCES += $$absolute_path(common/common_resources.qrc)
-LIBS += -L$$LIBPATH -lQt5WebEngine
QMAKE_RPATHDIR += $$LIBPATH
# Quick hack for now as we mess with that for the gyp generation step.
diff --git a/examples/examples.pro b/examples/examples.pro
index 4613dc8d..eb04ac0e 100644
--- a/examples/examples.pro
+++ b/examples/examples.pro
@@ -1,4 +1,4 @@
TEMPLATE=subdirs
-SUBDIRS += qtquick \
- widgets
+SUBDIRS += qtquick
+qtHaveModule(widgets): SUBDIRS += widgets
diff --git a/examples/qtquick/main.cpp b/examples/qtquick/main.cpp
index ca92eb72..982c1eb7 100644
--- a/examples/qtquick/main.cpp
+++ b/examples/qtquick/main.cpp
@@ -40,14 +40,17 @@
****************************************************************************/
#include "quickwindow.h"
-#include "qquickwebcontentsview.h"
-#include <QApplication>
+#ifndef QT_NO_WIDGETS
+#include <QtWidgets/QApplication>
+typedef QApplication Application;
+#else
+#include <QtGui/QGuiApplication>
+typedef QGuiApplication Application;
+#endif
int main(int argc, char **argv)
{
- QApplication app(argc, argv);
-
- QQuickWebContentsView::registerType();
+ Application app(argc, argv);
ApplicationEngine appEngine;
diff --git a/examples/qtquick/qtquick.pro b/examples/qtquick/qtquick.pro
index 88412e8b..3b3e98cf 100644
--- a/examples/qtquick/qtquick.pro
+++ b/examples/qtquick/qtquick.pro
@@ -9,5 +9,8 @@ SOURCES = quickwindow.cpp main.cpp
OTHER_FILES += quickwindow.qml
RESOURCES += resources.qrc
-QT += quick \
- widgets # QApplication is required to get native styling with QtQuickControls
+
+QT += qml quick
+qtHaveModule(widgets) {
+ QT += widgets # QApplication is required to get native styling with QtQuickControls
+}
diff --git a/examples/widgets/widgets.pro b/examples/widgets/widgets.pro
index 3d0d17d7..cf016402 100644
--- a/examples/widgets/widgets.pro
+++ b/examples/widgets/widgets.pro
@@ -6,4 +6,4 @@ include(../common.pri)
HEADERS = widgetwindow.h
SOURCES = widgetwindow.cpp main.cpp
-QT += widgets
+QT += webenginewidgets
diff --git a/lib/lib.pro b/lib/lib.pro
index 38fac7b0..3627c984 100644
--- a/lib/lib.pro
+++ b/lib/lib.pro
@@ -7,7 +7,7 @@ GYPINCLUDES += ../qtwebengine.gypi
TEMPLATE = lib
-TARGET = Qt5WebEngine
+TARGET = Qt5WebEngineCore
# Defining keywords such as 'signal' clashes with the chromium code base.
DEFINES += QT_NO_KEYWORDS
@@ -18,8 +18,6 @@ PER_CONFIG_DEFINES = QTWEBENGINEPROCESS_PATH=\\\"$$getOutDir()/%config/$$QTWEBEN
# Keep Skia happy
CONFIG(release, debug|release): DEFINES += NDEBUG
-QT += widgets quick
-
RESOURCES += lib_resources.qrc
# We need this to find the include files generated for the .pak resource files.
INCLUDEPATH += $$absolute_path(../resources, $$PWD)
@@ -27,13 +25,11 @@ INCLUDEPATH += $$absolute_path(../resources, $$PWD)
SOURCES = \
backing_store_qt.cpp \
content_browser_client_qt.cpp \
- qquickwebcontentsview.cpp \
- qwebcontentsview.cpp \
render_widget_host_view_qt.cpp \
- render_widget_host_view_qt_delegate_quick.cpp \
- render_widget_host_view_qt_delegate_widget.cpp \
+ render_widget_host_view_qt_delegate.cpp \
resource_context_qt.cpp \
url_request_context_getter_qt.cpp \
+ web_contents_adapter.cpp \
web_contents_delegate_qt.cpp \
web_contents_view_qt.cpp \
web_engine_context.cpp \
@@ -43,16 +39,12 @@ HEADERS = \
backing_store_qt.h \
browser_context_qt.h \
content_browser_client_qt.h \
- qquickwebcontentsview.h \
- qquickwebcontentsview_p.h \
- qwebcontentsview.h \
- qwebcontentsview_p.h \
render_widget_host_view_qt.h \
render_widget_host_view_qt_delegate.h \
- render_widget_host_view_qt_delegate_quick.h \
- render_widget_host_view_qt_delegate_widget.h \
resource_context_qt.h \
url_request_context_getter_qt.h \
+ web_contents_adapter.h \
+ web_contents_adapter_client.h \
web_contents_delegate_qt.h \
web_contents_view_qt.h \
web_engine_context.h \
diff --git a/lib/qtwebengineglobal.h b/lib/qtwebengineglobal.h
new file mode 100644
index 00000000..373fa2e3
--- /dev/null
+++ b/lib/qtwebengineglobal.h
@@ -0,0 +1,62 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef QTWEBENGINEGLOBAL_H
+#define QTWEBENGINEGLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#ifndef QT_STATIC
+# if !defined(QT_BUILD_WEBENGINEWIDGETS_LIB) && defined(BUILDING_CHROMIUM)
+# define QWEBENGINE_EXPORT Q_DECL_EXPORT
+# else
+# define QWEBENGINE_EXPORT Q_DECL_IMPORT
+# endif
+# if defined(QT_BUILD_WEBENGINEWIDGETS_LIB)
+# define QWEBENGINEWIDGETS_EXPORT Q_DECL_EXPORT
+# else
+# define QWEBENGINEWIDGETS_EXPORT Q_DECL_IMPORT
+# endif
+#else
+# define QWEBENGINEWIDGETS_EXPORT
+# define QWEBENGINE_EXPORT
+#endif
+
+#endif // QTWEBENGINEGLOBAL_H
diff --git a/lib/qquickwebcontentsview_p.h b/lib/quick/plugin.cpp
index 24580538..b2e332c9 100644
--- a/lib/qquickwebcontentsview_p.h
+++ b/lib/quick/plugin.cpp
@@ -39,21 +39,26 @@
**
****************************************************************************/
-#ifndef QQUICKWEBCONTENTSVIEWPRIVATE_H
-#define QQUICKWEBCONTENTSVIEWPRIVATE_H
+#include <QtQml/qqmlextensionplugin.h>
-#include "web_contents_view_qt.h"
+#include "qquickwebcontentsview_p.h"
-class QQuickWebContentsView;
+QT_BEGIN_NAMESPACE
-class QQuickWebContentsViewPrivate : public WebContentsViewQtClient
+class QtWebEnginePlugin : public QQmlExtensionPlugin
{
- QQuickWebContentsView *q_ptr;
- Q_DECLARE_PUBLIC(QQuickWebContentsView)
+ Q_OBJECT
+ Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QQmlExtensionInterface/1.0")
public:
- QQuickWebContentsViewPrivate();
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtWebEngine"));
+ Q_UNUSED(uri);
- RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt *view) Q_DECL_OVERRIDE;
+ qmlRegisterType<QQuickWebContentsView>(uri, 1, 0, "WebContentsView");
+ }
};
-#endif // QQUICKWEBCONTENTSVIEWPRIVATE_H
+QT_END_NAMESPACE
+
+#include "plugin.moc"
diff --git a/lib/quick/qmldir b/lib/quick/qmldir
new file mode 100644
index 00000000..e24f55ed
--- /dev/null
+++ b/lib/quick/qmldir
@@ -0,0 +1,3 @@
+module QtWebEngine
+plugin qtwebengineplugin
+typeinfo plugins.qmltypes
diff --git a/lib/qquickwebcontentsview.cpp b/lib/quick/qquickwebcontentsview.cpp
index 5a56ecdd..34107adc 100644
--- a/lib/qquickwebcontentsview.cpp
+++ b/lib/quick/qquickwebcontentsview.cpp
@@ -39,34 +39,54 @@
**
****************************************************************************/
-#include "qquickwebcontentsview.h"
#include "qquickwebcontentsview_p.h"
+#include "qquickwebcontentsview_p_p.h"
-#include "content/public/browser/navigation_entry.h"
-#include "content/public/browser/web_contents.h"
-
-#include "content_browser_client_qt.h"
+#include "web_contents_adapter.h"
#include "render_widget_host_view_qt_delegate_quick.h"
-#include "web_contents_delegate_qt.h"
#include <QUrl>
-void QQuickWebContentsView::registerType()
+
+QQuickWebContentsViewPrivate::QQuickWebContentsViewPrivate()
+ : adapter(new WebContentsAdapter(this))
+{
+}
+
+RenderWidgetHostViewQtDelegate *QQuickWebContentsViewPrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt *rwhv)
+{
+ Q_Q(QQuickWebContentsView);
+ // Parent the RWHVQtDelegate directly, this might have to be changed to handle popups and fullscreen.
+ RenderWidgetHostViewQtDelegateQuick *viewDelegate = new RenderWidgetHostViewQtDelegateQuick(q);
+ viewDelegate->resetView(rwhv);
+ viewDelegate->setSize(QSizeF(q->width(), q->height()));
+ return viewDelegate;
+}
+
+void QQuickWebContentsViewPrivate::titleChanged(const QString &title)
+{
+ Q_Q(QQuickWebContentsView);
+ Q_UNUSED(title);
+ Q_EMIT q->titleChanged();
+}
+
+void QQuickWebContentsViewPrivate::urlChanged(const QUrl &url)
+{
+ Q_Q(QQuickWebContentsView);
+ Q_UNUSED(url);
+ Q_EMIT q->urlChanged();
+}
+
+void QQuickWebContentsViewPrivate::loadingStateChanged()
{
- // FIXME: Do a proper plugin.
- qmlRegisterType<QQuickWebContentsView>("QtWebEngine", 1, 0, "WebContentsView");
+ Q_Q(QQuickWebContentsView);
+ Q_EMIT q->loadingStateChanged();
}
QQuickWebContentsView::QQuickWebContentsView()
: d_ptr(new QQuickWebContentsViewPrivate)
{
d_ptr->q_ptr = this;
-
- Q_D(QQuickWebContentsView);
- WebContentsDelegateQt* delegate = d->webContentsDelegate.get();
- connect(delegate, SIGNAL(titleChanged(QString)), this, SIGNAL(titleChanged(QString)));
- connect(delegate, SIGNAL(urlChanged(QUrl)), this, SIGNAL(urlChanged()));
- connect(delegate, SIGNAL(loadingStateChanged()), this, SIGNAL(loadingStateChanged()));
}
QQuickWebContentsView::~QQuickWebContentsView()
@@ -76,79 +96,61 @@ QQuickWebContentsView::~QQuickWebContentsView()
QUrl QQuickWebContentsView::url() const
{
Q_D(const QQuickWebContentsView);
- GURL gurl = d->webContentsDelegate->web_contents()->GetVisibleURL();
- return QUrl(QString::fromStdString(gurl.spec()));
+ return d->adapter->activeUrl();
}
void QQuickWebContentsView::setUrl(const QUrl& url)
{
Q_D(QQuickWebContentsView);
- GURL gurl(url.toString().toStdString());
-
- content::NavigationController::LoadURLParams params(gurl);
- params.transition_type = content::PageTransitionFromInt(content::PAGE_TRANSITION_TYPED | content::PAGE_TRANSITION_FROM_ADDRESS_BAR);
- d->webContentsDelegate->web_contents()->GetController().LoadURLWithParams(params);
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->load(url);
}
void QQuickWebContentsView::goBack()
{
Q_D(QQuickWebContentsView);
- d->webContentsDelegate->web_contents()->GetController().GoToOffset(-1);
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->navigateHistory(-1);
}
void QQuickWebContentsView::goForward()
{
Q_D(QQuickWebContentsView);
- d->webContentsDelegate->web_contents()->GetController().GoToOffset(1);
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->navigateHistory(1);
}
void QQuickWebContentsView::reload()
{
Q_D(QQuickWebContentsView);
- d->webContentsDelegate->web_contents()->GetController().Reload(false);
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->reload();
}
void QQuickWebContentsView::stop()
{
Q_D(QQuickWebContentsView);
- content::NavigationController& controller = d->webContentsDelegate->web_contents()->GetController();
-
- int index = controller.GetPendingEntryIndex();
- if (index != -1)
- controller.RemoveEntryAtIndex(index);
-
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->stop();
}
bool QQuickWebContentsView::isLoading() const
{
Q_D(const QQuickWebContentsView);
- return d->webContentsDelegate->web_contents()->IsLoading();
+ return d->adapter->isLoading();
}
QString QQuickWebContentsView::title() const
{
Q_D(const QQuickWebContentsView);
- content::NavigationEntry* entry = d->webContentsDelegate->web_contents()->GetController().GetVisibleEntry();
- if (!entry)
- return QString();
- return QString::fromUtf16(entry->GetTitle().data());
+ return d->adapter->pageTitle();
}
bool QQuickWebContentsView::canGoBack() const
{
Q_D(const QQuickWebContentsView);
- return d->webContentsDelegate->web_contents()->GetController().CanGoBack();
+ return d->adapter->canGoBack();
}
bool QQuickWebContentsView::canGoForward() const
{
Q_D(const QQuickWebContentsView);
- return d->webContentsDelegate->web_contents()->GetController().CanGoForward();
+ return d->adapter->canGoForward();
}
void QQuickWebContentsView::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
@@ -160,18 +162,3 @@ void QQuickWebContentsView::geometryChanged(const QRectF &newGeometry, const QRe
child->setSize(newGeometry.size());
}
}
-
-QQuickWebContentsViewPrivate::QQuickWebContentsViewPrivate()
-{
- WebContentsViewQt* contents_view = static_cast<WebContentsViewQt*>(webContentsDelegate->web_contents()->GetView());
- contents_view->SetClient(this);
-}
-
-RenderWidgetHostViewQtDelegate *QQuickWebContentsViewPrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt *view)
-{
- Q_Q(QQuickWebContentsView);
- // Parent the RWHV directly, this might have to be changed to handle popups and fullscreen.
- RenderWidgetHostViewQtDelegateQuick *viewDelegate = new RenderWidgetHostViewQtDelegateQuick(view, q);
- viewDelegate->setSize(QSizeF(q->width(), q->height()));
- return viewDelegate;
-}
diff --git a/lib/qquickwebcontentsview.h b/lib/quick/qquickwebcontentsview_p.h
index 2c19bce0..61aca128 100644
--- a/lib/qquickwebcontentsview.h
+++ b/lib/quick/qquickwebcontentsview_p.h
@@ -39,15 +39,15 @@
**
****************************************************************************/
-#ifndef QQUICKWEBCONTESTSVIEW_H
-#define QQUICKWEBCONTESTSVIEW_H
+#ifndef QQUICKWEBCONTESTSVIEW_P_H
+#define QQUICKWEBCONTESTSVIEW_P_H
#include <QQuickItem>
#include <QScopedPointer>
class QQuickWebContentsViewPrivate;
-class Q_DECL_EXPORT QQuickWebContentsView : public QQuickItem {
+class QQuickWebContentsView : public QQuickItem {
Q_OBJECT
Q_PROPERTY(QUrl url READ url WRITE setUrl NOTIFY urlChanged)
Q_PROPERTY(bool loading READ isLoading NOTIFY loadingStateChanged)
@@ -56,8 +56,6 @@ class Q_DECL_EXPORT QQuickWebContentsView : public QQuickItem {
Q_PROPERTY(bool canGoForward READ canGoForward NOTIFY loadingStateChanged)
public:
- static void registerType();
-
QQuickWebContentsView();
~QQuickWebContentsView();
@@ -75,7 +73,7 @@ public Q_SLOTS:
void stop();
Q_SIGNALS:
- void titleChanged(QString);
+ void titleChanged();
void urlChanged();
void loadingStateChanged();
@@ -90,4 +88,4 @@ private:
QML_DECLARE_TYPE(QQuickWebContentsView)
-#endif // QQUICKWEBCONTESTSVIEW_H
+#endif // QQUICKWEBCONTESTSVIEW_P_H
diff --git a/lib/quick/qquickwebcontentsview_p_p.h b/lib/quick/qquickwebcontentsview_p_p.h
new file mode 100644
index 00000000..6c9c32c4
--- /dev/null
+++ b/lib/quick/qquickwebcontentsview_p_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QQUICKWEBCONTENTSVIEW_P_P_H
+#define QQUICKWEBCONTENTSVIEW_P_P_H
+
+#include "web_contents_adapter_client.h"
+
+#include <QScopedPointer>
+
+class QQuickWebContentsView;
+class WebContentsAdapter;
+
+class QQuickWebContentsViewPrivate : public WebContentsAdapterClient
+{
+ QQuickWebContentsView *q_ptr;
+ Q_DECLARE_PUBLIC(QQuickWebContentsView)
+public:
+ QQuickWebContentsViewPrivate();
+
+ virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt*) Q_DECL_OVERRIDE;
+ virtual void titleChanged(const QString&) Q_DECL_OVERRIDE;
+ virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE;
+ virtual void loadingStateChanged() Q_DECL_OVERRIDE;
+
+ QScopedPointer<WebContentsAdapter> adapter;
+};
+
+#endif // QQUICKWEBCONTENTSVIEW_P_P_H
diff --git a/lib/quick/quick.pro b/lib/quick/quick.pro
new file mode 100644
index 00000000..e2eec55d
--- /dev/null
+++ b/lib/quick/quick.pro
@@ -0,0 +1,28 @@
+CXX_MODULE = qml
+TARGET = qtwebengineplugin
+TARGETPATH = QtWebEngine
+IMPORT_VERSION = 1.0
+
+QT += qml quick
+
+INCLUDEPATH += ../
+
+# FIXME: all this should eventually be turned into QT += webenginecore
+macx:LIBPATH = $$getOutDir()/$$getConfigDir()
+else:LIBPATH = $$getOutDir()/$$getConfigDir()/lib
+LIBS += -lQt5WebEngineCore -L$$LIBPATH
+QMAKE_RPATHDIR += $$LIBPATH
+
+#DESTDIR = $$LIBPATH
+
+SOURCES = \
+ qquickwebcontentsview.cpp \
+ plugin.cpp \
+ render_widget_host_view_qt_delegate_quick.cpp
+
+HEADERS = \
+ qquickwebcontentsview_p.h \
+ qquickwebcontentsview_p_p.h \
+ render_widget_host_view_qt_delegate_quick.h
+
+load(qml_plugin)
diff --git a/lib/render_widget_host_view_qt_delegate_quick.cpp b/lib/quick/render_widget_host_view_qt_delegate_quick.cpp
index fabd4174..d15bac21 100644
--- a/lib/render_widget_host_view_qt_delegate_quick.cpp
+++ b/lib/quick/render_widget_host_view_qt_delegate_quick.cpp
@@ -41,18 +41,11 @@
#include "render_widget_host_view_qt_delegate_quick.h"
-#include "backing_store_qt.h"
-#include "render_widget_host_view_qt.h"
-
-#include "content/browser/renderer_host/render_view_host_impl.h"
-
#include <QQuickWindow>
#include <QWindow>
-RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(RenderWidgetHostViewQt* view, QQuickItem *parent)
+RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(QQuickItem *parent)
: QQuickPaintedItem(parent)
- , RenderWidgetHostViewQtDelegate(view)
- , m_backingStore(0)
{
setAcceptedMouseButtons(Qt::AllButtons);
}
@@ -101,10 +94,7 @@ void RenderWidgetHostViewQtDelegateQuick::update(const QRect& rect)
void RenderWidgetHostViewQtDelegateQuick::paint(QPainter *painter)
{
- if (!m_backingStore)
- return;
-
- m_backingStore->paintToTarget(painter, boundingRect());
+ RenderWidgetHostViewQtDelegate::paint(painter, boundingRect());
}
void RenderWidgetHostViewQtDelegateQuick::updatePolish()
@@ -112,63 +102,62 @@ void RenderWidgetHostViewQtDelegateQuick::updatePolish()
// paint will be called from the scene graph thread and this doesn't play well
// with chromium's use of TLS while getting the backing store.
// updatePolish() should be called from the GUI thread right before the rendering thread starts.
- m_backingStore = m_view->GetBackingStore();
+ fetchBackingStore();
}
void RenderWidgetHostViewQtDelegateQuick::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
QQuickPaintedItem::geometryChanged(newGeometry, oldGeometry);
-
- m_view->GetRenderWidgetHost()->WasResized();
+ notifyResize();
}
void RenderWidgetHostViewQtDelegateQuick::focusInEvent(QFocusEvent *event)
{
- m_view->handleFocusEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::focusOutEvent(QFocusEvent *event)
{
- m_view->handleFocusEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::mousePressEvent(QMouseEvent *event)
{
setFocus(true);
- m_view->handleMouseEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::mouseMoveEvent(QMouseEvent *event)
{
- m_view->handleMouseEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::mouseReleaseEvent(QMouseEvent *event)
{
- m_view->handleMouseEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::mouseDoubleClickEvent(QMouseEvent *event)
{
- m_view->handleMouseEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::keyPressEvent(QKeyEvent *event)
{
- m_view->handleKeyEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::keyReleaseEvent(QKeyEvent *event)
{
- m_view->handleKeyEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::wheelEvent(QWheelEvent *event)
{
- m_view->handleWheelEvent(event);
+ forwardEvent(event);
}
void RenderWidgetHostViewQtDelegateQuick::touchEvent(QTouchEvent *event)
{
- m_view->handleTouchEvent(event);
+ forwardEvent(event);
}
diff --git a/lib/render_widget_host_view_qt_delegate_quick.h b/lib/quick/render_widget_host_view_qt_delegate_quick.h
index 1b77de50..38ddf014 100644
--- a/lib/render_widget_host_view_qt_delegate_quick.h
+++ b/lib/quick/render_widget_host_view_qt_delegate_quick.h
@@ -67,7 +67,7 @@ class RenderWidgetHostViewQtDelegateQuick : public QQuickPaintedItem, public Ren
{
Q_OBJECT
public:
- RenderWidgetHostViewQtDelegateQuick(RenderWidgetHostViewQt* view, QQuickItem *parent = 0);
+ RenderWidgetHostViewQtDelegateQuick(QQuickItem *parent);
virtual QRectF screenRect() const;
virtual void setKeyboardFocus();
@@ -95,8 +95,6 @@ protected:
void updatePolish();
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry);
-private:
- BackingStoreQt* m_backingStore;
};
#endif
diff --git a/lib/render_widget_host_view_qt.cpp b/lib/render_widget_host_view_qt.cpp
index 2bf9d431..ed648f8e 100644
--- a/lib/render_widget_host_view_qt.cpp
+++ b/lib/render_widget_host_view_qt.cpp
@@ -61,7 +61,6 @@
RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget)
: m_host(content::RenderWidgetHostImpl::From(widget))
- , m_delegate(0)
{
m_host->SetView(this);
}
@@ -70,6 +69,11 @@ RenderWidgetHostViewQt::~RenderWidgetHostViewQt()
{
}
+void RenderWidgetHostViewQt::SetDelegate(RenderWidgetHostViewQtDelegate* delegate)
+{
+ m_delegate.reset(delegate);
+}
+
bool RenderWidgetHostViewQt::handleEvent(QEvent* event) {
switch(event->type()) {
@@ -335,8 +339,7 @@ void RenderWidgetHostViewQt::RenderProcessGone(base::TerminationStatus, int)
void RenderWidgetHostViewQt::Destroy()
{
- delete m_delegate;
- m_delegate = 0;
+ m_delegate.reset();
}
void RenderWidgetHostViewQt::SetTooltipText(const string16&)
diff --git a/lib/render_widget_host_view_qt.h b/lib/render_widget_host_view_qt.h
index 7a29e1d4..05713d2b 100644
--- a/lib/render_widget_host_view_qt.h
+++ b/lib/render_widget_host_view_qt.h
@@ -44,6 +44,7 @@
#include "shared/shared_globals.h"
+#include "base/memory/scoped_ptr.h"
#include "content/browser/renderer_host/render_widget_host_view_base.h"
#include <qglobal.h>
@@ -63,7 +64,7 @@ public:
RenderWidgetHostViewQt(content::RenderWidgetHost* widget);
~RenderWidgetHostViewQt();
- void SetDelegate(RenderWidgetHostViewQtDelegate* delegate) { m_delegate = delegate; }
+ void SetDelegate(RenderWidgetHostViewQtDelegate* delegate);
bool handleEvent(QEvent* event);
BackingStoreQt* GetBackingStore();
@@ -150,7 +151,7 @@ private:
bool IsPopup() const;
content::RenderWidgetHostImpl *m_host;
- RenderWidgetHostViewQtDelegate *m_delegate;
+ scoped_ptr<RenderWidgetHostViewQtDelegate> m_delegate;
gfx::Size m_requestedSize;
};
diff --git a/lib/render_widget_host_view_qt_delegate.cpp b/lib/render_widget_host_view_qt_delegate.cpp
new file mode 100644
index 00000000..b6ae928b
--- /dev/null
+++ b/lib/render_widget_host_view_qt_delegate.cpp
@@ -0,0 +1,86 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "render_widget_host_view_qt_delegate.h"
+
+#include "backing_store_qt.h"
+#include "render_widget_host_view_qt.h"
+
+#include "content/browser/renderer_host/render_view_host_impl.h"
+#include <QPainter>
+
+RenderWidgetHostViewQtDelegate::RenderWidgetHostViewQtDelegate()
+ : m_view(0), m_backingStore(0)
+{
+}
+
+RenderWidgetHostViewQtDelegate::~RenderWidgetHostViewQtDelegate()
+{
+}
+
+void RenderWidgetHostViewQtDelegate::resetView(RenderWidgetHostViewQt* view)
+{
+ m_view.reset(view);
+}
+
+void RenderWidgetHostViewQtDelegate::paint(QPainter *painter, const QRectF &boundingRect)
+{
+ if (m_backingStore)
+ m_backingStore->paintToTarget(painter, boundingRect);
+}
+
+void RenderWidgetHostViewQtDelegate::fetchBackingStore()
+{
+ Q_ASSERT(m_view);
+ m_backingStore = m_view->GetBackingStore();
+}
+
+void RenderWidgetHostViewQtDelegate::notifyResize()
+{
+ Q_ASSERT(m_view);
+ m_view->GetRenderWidgetHost()->WasResized();
+}
+
+bool RenderWidgetHostViewQtDelegate::forwardEvent(QEvent *event)
+{
+ Q_ASSERT(m_view);
+ return (m_view && m_view->handleEvent(event));
+}
diff --git a/lib/render_widget_host_view_qt_delegate.h b/lib/render_widget_host_view_qt_delegate.h
index ac57e578..b58fefcc 100644
--- a/lib/render_widget_host_view_qt_delegate.h
+++ b/lib/render_widget_host_view_qt_delegate.h
@@ -42,19 +42,21 @@
#ifndef RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_H
#define RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_H
-#include "base/memory/scoped_ptr.h"
+#include "qtwebengineglobal.h"
-#include "render_widget_host_view_qt.h"
#include <QRect>
+#include <QScopedPointer>
+class BackingStoreQt;
+class QEvent;
+class QPainter;
class QWindow;
+class RenderWidgetHostViewQt;
+
+class QWEBENGINE_EXPORT RenderWidgetHostViewQtDelegate {
-class RenderWidgetHostViewQtDelegate {
-protected:
- scoped_ptr<RenderWidgetHostViewQt> m_view;
- RenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt* view) : m_view(view) { Q_ASSERT(m_view); }
public:
- virtual ~RenderWidgetHostViewQtDelegate() {}
+ virtual ~RenderWidgetHostViewQtDelegate();
virtual QRectF screenRect() const = 0;
virtual void setKeyboardFocus() = 0;
virtual bool hasKeyboardFocus() = 0;
@@ -63,6 +65,18 @@ public:
virtual bool isVisible() const = 0;
virtual QWindow* window() const = 0;
virtual void update(const QRect& rect = QRect()) = 0;
+ void resetView(RenderWidgetHostViewQt*);
+
+protected:
+ RenderWidgetHostViewQtDelegate();
+ void paint(QPainter*, const QRectF& boundingRect);
+ void fetchBackingStore();
+ void notifyResize();
+ bool forwardEvent(QEvent*);
+
+private:
+ QScopedPointer<RenderWidgetHostViewQt> m_view;
+ BackingStoreQt *m_backingStore;
};
#endif
diff --git a/lib/web_contents_adapter.cpp b/lib/web_contents_adapter.cpp
new file mode 100644
index 00000000..a815628a
--- /dev/null
+++ b/lib/web_contents_adapter.cpp
@@ -0,0 +1,144 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include "web_contents_adapter.h"
+
+#include "content_browser_client_qt.h"
+#include "browser_context_qt.h"
+#include "web_contents_adapter_client.h"
+#include "web_contents_delegate_qt.h"
+#include "web_contents_view_qt.h"
+#include "web_engine_context.h"
+
+#include "content/public/browser/web_contents.h"
+#include "content/public/browser/navigation_entry.h"
+
+// Used to maintain a WebEngineContext for as long as we need one
+class WebContentsAdapterPrivate {
+public:
+ WebContentsAdapterPrivate() : engineContext(WebEngineContext::current()) { }
+ scoped_refptr<WebEngineContext> engineContext;
+};
+
+
+WebContentsAdapter::WebContentsAdapter(WebContentsAdapterClient *adapterClient)
+// This has to be the first thing we do.
+ : d(new WebContentsAdapterPrivate())
+{
+ content::BrowserContext* browserContext = ContentBrowserClientQt::Get()->browser_context();
+ webContentsDelegate.reset(new WebContentsDelegateQt(browserContext, NULL, MSG_ROUTING_NONE, gfx::Size()));
+ webContentsDelegate->m_viewClient = adapterClient;
+ WebContentsViewQt* contentsView = static_cast<WebContentsViewQt*>(webContentsDelegate->web_contents()->GetView());
+ contentsView->SetClient(adapterClient);
+}
+
+WebContentsAdapter::~WebContentsAdapter()
+{
+}
+
+bool WebContentsAdapter::canGoBack() const
+{
+ return webContents()->GetController().CanGoBack();
+}
+
+bool WebContentsAdapter::canGoForward() const
+{
+ return webContents()->GetController().CanGoForward();
+}
+bool WebContentsAdapter::isLoading() const
+{
+ return webContents()->IsLoading();
+}
+
+void WebContentsAdapter::navigateHistory(int offset)
+{
+ webContents()->GetController().GoToOffset(offset);
+ webContents()->GetView()->Focus();
+}
+
+void WebContentsAdapter::stop()
+{
+ content::NavigationController& controller = webContents()->GetController();
+
+ int index = controller.GetPendingEntryIndex();
+ if (index != -1)
+ controller.RemoveEntryAtIndex(index);
+
+ webContents()->GetView()->Focus();
+}
+
+void WebContentsAdapter::reload()
+{
+ webContents()->GetController().Reload(/*checkRepost = */false);
+ webContents()->GetView()->Focus();
+}
+
+void WebContentsAdapter::load(const QUrl &url)
+{
+ QString urlString = url.toString();
+ GURL gurl(urlString.toStdString());
+ if (!gurl.has_scheme())
+ gurl = GURL(std::string("http://") + urlString.toStdString());
+
+ content::NavigationController::LoadURLParams params(gurl);
+ params.transition_type = content::PageTransitionFromInt(content::PAGE_TRANSITION_TYPED | content::PAGE_TRANSITION_FROM_ADDRESS_BAR);
+ webContents()->GetController().LoadURLWithParams(params);
+ webContents()->GetView()->Focus();
+}
+
+QUrl WebContentsAdapter::activeUrl() const
+{
+ GURL gurl = webContents()->GetVisibleURL();
+ return QUrl(QString::fromStdString(gurl.spec()));
+}
+
+QString WebContentsAdapter::pageTitle() const
+{
+ content::NavigationEntry* entry = webContents()->GetController().GetVisibleEntry();
+ if (!entry)
+ return QString();
+ return QString::fromUtf16(entry->GetTitle().data());
+}
+
+content::WebContents *WebContentsAdapter::webContents() const
+{
+ Q_ASSERT(webContentsDelegate);
+ return webContentsDelegate->web_contents();
+}
diff --git a/lib/web_contents_adapter.h b/lib/web_contents_adapter.h
new file mode 100644
index 00000000..dc65cd0f
--- /dev/null
+++ b/lib/web_contents_adapter.h
@@ -0,0 +1,78 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef WEB_CONTENTS_ADAPTER_H
+#define WEB_CONTENTS_ADAPTER_H
+
+#include "qtwebengineglobal.h"
+
+#include <QScopedPointer>
+#include <QString>
+#include <QUrl>
+
+namespace content {
+class WebContents;
+}
+class WebContentsAdapterClient;
+class WebContentsDelegateQt;
+class WebContentsAdapterPrivate;
+
+class QWEBENGINE_EXPORT WebContentsAdapter {
+
+public:
+ WebContentsAdapter(WebContentsAdapterClient* adapterClient);
+ ~WebContentsAdapter();
+
+ bool canGoBack() const;
+ bool canGoForward() const;
+ bool isLoading() const;
+ void navigateHistory(int);
+ void stop();
+ void reload();
+ void load(const QUrl&);
+ QUrl activeUrl() const;
+ QString pageTitle() const;
+
+private:
+ inline content::WebContents* webContents() const;
+ QScopedPointer<WebContentsDelegateQt> webContentsDelegate;
+ QScopedPointer<WebContentsAdapterPrivate> d;
+};
+#endif // WEB_CONTENTS_ADAPTER_H
diff --git a/lib/web_contents_adapter_client.h b/lib/web_contents_adapter_client.h
new file mode 100644
index 00000000..c44b87bb
--- /dev/null
+++ b/lib/web_contents_adapter_client.h
@@ -0,0 +1,64 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the QtWebEngine module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef WEB_CONTENTS_ADAPTER_CLIENT_H
+#define WEB_CONTENTS_ADAPTER_CLIENT_H
+
+#include "qtwebengineglobal.h"
+
+#include <QString>
+#include <QUrl>
+
+
+class RenderWidgetHostViewQt;
+class RenderWidgetHostViewQtDelegate;
+class WebContentsDelegateQt;
+
+class QWEBENGINE_EXPORT WebContentsAdapterClient {
+public:
+ virtual ~WebContentsAdapterClient() { }
+
+ virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt*) = 0;
+ virtual void titleChanged(const QString&) = 0;
+ virtual void urlChanged(const QUrl&) = 0;
+ virtual void loadingStateChanged() = 0;
+};
+
+#endif // WEB_CONTENTS_ADAPTER_CLIENT_H
diff --git a/lib/web_contents_delegate_qt.cpp b/lib/web_contents_delegate_qt.cpp
index 5b6c39fb..72a50ac1 100644
--- a/lib/web_contents_delegate_qt.cpp
+++ b/lib/web_contents_delegate_qt.cpp
@@ -41,6 +41,8 @@
#include "web_contents_delegate_qt.h"
+#include "web_contents_adapter_client.h"
+
#include "content/public/browser/navigation_controller.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/notification_source.h"
@@ -59,6 +61,7 @@ static const int kTestWindowWidth = 800;
static const int kTestWindowHeight = 600;
WebContentsDelegateQt::WebContentsDelegateQt(content::BrowserContext* browser_context, content::SiteInstance* site_instance, int routing_id, const gfx::Size& initial_size)
+ : m_viewClient(0)
{
content::WebContents::CreateParams create_params(browser_context, site_instance);
create_params.routing_id = routing_id;
@@ -82,15 +85,16 @@ WebContentsDelegateQt::WebContentsDelegateQt(content::BrowserContext* browser_co
void WebContentsDelegateQt::NavigationStateChanged(const content::WebContents* source, unsigned changed_flags)
{
if (changed_flags & content::INVALIDATE_TYPE_URL) {
+ Q_ASSERT(m_viewClient);
GURL gurl = web_contents()->GetVisibleURL();
QUrl url(QString::fromStdString(gurl.spec()));
- Q_EMIT urlChanged(url);
+ m_viewClient->urlChanged(url);
}
}
void WebContentsDelegateQt::LoadingStateChanged(content::WebContents* source)
{
- Q_EMIT loadingStateChanged();
+ m_viewClient->loadingStateChanged();
}
content::WebContents* WebContentsDelegateQt::web_contents()
diff --git a/lib/web_contents_delegate_qt.h b/lib/web_contents_delegate_qt.h
index dac00b98..85fffcba 100644
--- a/lib/web_contents_delegate_qt.h
+++ b/lib/web_contents_delegate_qt.h
@@ -52,11 +52,10 @@ namespace content {
class BrowserContext;
class SiteInstance;
}
+class WebContentsAdapterClient;
-class WebContentsDelegateQt : public QObject
- , public content::WebContentsDelegate
+class WebContentsDelegateQt : public content::WebContentsDelegate
{
- Q_OBJECT
public:
WebContentsDelegateQt(content::BrowserContext*, content::SiteInstance*, int routing_id, const gfx::Size& initial_size);
content::WebContents* web_contents();
@@ -64,13 +63,10 @@ public:
virtual void NavigationStateChanged(const content::WebContents* source, unsigned changed_flags);
virtual void LoadingStateChanged(content::WebContents* source);
-Q_SIGNALS:
- void titleChanged(const QString& title);
- void urlChanged(const QUrl& url);
- void loadingStateChanged();
-
private:
scoped_ptr<content::WebContents> m_webContents;
+ WebContentsAdapterClient *m_viewClient;
+ friend class WebContentsAdapter;
};
#endif
diff --git a/lib/web_contents_view_qt.cpp b/lib/web_contents_view_qt.cpp
index 2a44da7a..ba588754 100644
--- a/lib/web_contents_view_qt.cpp
+++ b/lib/web_contents_view_qt.cpp
@@ -47,14 +47,6 @@
#include "content/browser/renderer_host/render_view_host_impl.h"
-WebContentsViewQtClient::WebContentsViewQtClient()
-// This has to be the first thing we do.
- : context(WebEngineContext::current())
-{
- content::BrowserContext* browser_context = ContentBrowserClientQt::Get()->browser_context();
- webContentsDelegate.reset(new WebContentsDelegateQt(browser_context, NULL, MSG_ROUTING_NONE, gfx::Size()));
-}
-
content::RenderWidgetHostView* WebContentsViewQt::CreateViewForWidget(content::RenderWidgetHost* render_widget_host)
{
RenderWidgetHostViewQt *view = new RenderWidgetHostViewQt(render_widget_host);
@@ -67,14 +59,13 @@ content::RenderWidgetHostView* WebContentsViewQt::CreateViewForWidget(content::R
void WebContentsViewQt::SetPageTitle(const string16& title)
{
QString string = QString::fromUtf16(title.data());
- Q_EMIT m_client->webContentsDelegate->titleChanged(string);
+ m_client->titleChanged(string);
}
void WebContentsViewQt::GetContainerBounds(gfx::Rect* out) const
{
- content::RenderWidgetHostView* rwhv = m_client->webContentsDelegate->web_contents()->GetRenderWidgetHostView();
- if (rwhv)
- *out = rwhv->GetViewBounds();
+ const QRectF r(m_viewDelegate->screenRect());
+ *out = gfx::Rect(r.x(), r.y(), r.width(), r.height());
}
void WebContentsViewQt::Focus()
diff --git a/lib/web_contents_view_qt.h b/lib/web_contents_view_qt.h
index c7853add..0eb0cb08 100644
--- a/lib/web_contents_view_qt.h
+++ b/lib/web_contents_view_qt.h
@@ -48,20 +48,11 @@
#include "content/port/browser/render_view_host_delegate_view.h"
#include "content/port/browser/web_contents_view_port.h"
+#include "web_contents_adapter_client.h"
#include "render_widget_host_view_qt.h"
#include "web_contents_delegate_qt.h"
#include "web_engine_context.h"
-class WebContentsViewQtClient {
-public:
- WebContentsViewQtClient();
- virtual ~WebContentsViewQtClient() { }
- virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt *view) = 0;
-
- scoped_refptr<WebEngineContext> context;
- scoped_ptr<WebContentsDelegateQt> webContentsDelegate;
-};
-
class WebContentsViewQt
: public content::WebContentsViewPort
, public content::RenderViewHostDelegateView
@@ -71,7 +62,7 @@ public:
: m_client(0)
{ }
- void SetClient(WebContentsViewQtClient* client) { m_client = client; }
+ void SetClient(WebContentsAdapterClient* client) { m_client = client; }
virtual content::RenderWidgetHostView *CreateViewForWidget(content::RenderWidgetHost* render_widget_host);
@@ -122,7 +113,7 @@ public:
#endif // defined(OS_MACOSX)
private:
- WebContentsViewQtClient* m_client;
+ WebContentsAdapterClient* m_client;
RenderWidgetHostViewQtDelegate* m_viewDelegate;
};
diff --git a/lib/web_event_factory.cpp b/lib/web_event_factory.cpp
index 388e0f9b..40b6b5e6 100644
--- a/lib/web_event_factory.cpp
+++ b/lib/web_event_factory.cpp
@@ -43,13 +43,14 @@
#include "web_event_factory.h"
#include "third_party/WebKit/Source/core/platform/WindowsKeyboardCodes.h"
-#include <QApplication>
#include <QElapsedTimer>
#include <QEvent>
#include <QKeyEvent>
#include <QMouseEvent>
#include <QWheelEvent>
+static const int wheelScrollLines = 3; // FIXME: Still not available in QStyleHints in 5.1
+
using namespace WebKit;
static int windowsKeyCodeForKeyEvent(unsigned int keycode, bool isKeypad)
@@ -593,8 +594,6 @@ WebKit::WebMouseWheelEvent WebEventFactory::toWebWheelEvent(QWheelEvent *ev)
// Use the same single scroll step as QTextEdit (in QTextEditPrivate::init [h,v]bar->setSingleStep)
static const float cDefaultQtScrollStep = 20.f;
- const int wheelScrollLines = qApp->wheelScrollLines(); // can be hardcoded to 3 if we don't want to depend on QtWidgets
-
webEvent.deltaX = webEvent.wheelTicksX * wheelScrollLines * cDefaultQtScrollStep;
webEvent.deltaY = webEvent.wheelTicksY * wheelScrollLines * cDefaultQtScrollStep;
diff --git a/lib/qwebcontentsview.cpp b/lib/widgets/Api/qwebcontentsview.cpp
index fced1e1b..612f7699 100644
--- a/lib/qwebcontentsview.cpp
+++ b/lib/widgets/Api/qwebcontentsview.cpp
@@ -42,30 +42,57 @@
#include "qwebcontentsview.h"
#include "qwebcontentsview_p.h"
-#include "content/public/browser/web_contents.h"
-
-#include "content_browser_client_qt.h"
#include "render_widget_host_view_qt_delegate_widget.h"
-#include "web_contents_delegate_qt.h"
-#include "web_engine_context.h"
+#include "web_contents_adapter.h"
#include <QStackedLayout>
#include <QUrl>
+QWebContentsViewPrivate::QWebContentsViewPrivate()
+ : m_isLoading(false)
+ , adapter(new WebContentsAdapter(this))
+{
+}
+
+void QWebContentsViewPrivate::titleChanged(const QString &title)
+{
+ Q_EMIT q_ptr->titleChanged(title);
+}
+
+void QWebContentsViewPrivate::urlChanged(const QUrl &url)
+{
+ Q_EMIT q_ptr->urlChanged(url);
+}
+
+void QWebContentsViewPrivate::loadingStateChanged()
+{
+ Q_Q(QWebContentsView);
+ const bool wasLoading = m_isLoading;
+ m_isLoading = adapter->isLoading();
+ if (m_isLoading != wasLoading) {
+ if (m_isLoading)
+ Q_EMIT q->loadStarted();
+ else
+ Q_EMIT q->loadFinished(true);
+ }
+}
+
+RenderWidgetHostViewQtDelegate *QWebContentsViewPrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt* rwhv)
+{
+ Q_Q(QWebContentsView);
+ RenderWidgetHostViewQtDelegateWidget *viewDelegate = new RenderWidgetHostViewQtDelegateWidget(q);
+ viewDelegate->resetView(rwhv);
+ // Parent the RWHVQtDelegate directly, this might have to be changed to handle popups and fullscreen.
+ q->layout()->addWidget(viewDelegate);
+ return viewDelegate;
+}
QWebContentsView::QWebContentsView()
: d_ptr(new QWebContentsViewPrivate)
{
- d_ptr->q_ptr = this;
-
- Q_D(QWebContentsView);
+ d_ptr->q_ptr=this;
// This causes the child RenderWidgetHostViewQtDelegateWidgets to fill this widget.
setLayout(new QStackedLayout);
-
- WebContentsDelegateQt* delegate = d->webContentsDelegate.get();
- connect(delegate, SIGNAL(titleChanged(const QString&)), this, SIGNAL(titleChanged(const QString&)));
- connect(delegate, SIGNAL(urlChanged(const QUrl&)), this, SIGNAL(urlChanged(const QUrl&)));
- connect(delegate, SIGNAL(loadingStateChanged()), this, SLOT(_q_onLoadingStateChanged()));
}
QWebContentsView::~QWebContentsView()
@@ -75,90 +102,43 @@ QWebContentsView::~QWebContentsView()
void QWebContentsView::load(const QUrl& url)
{
Q_D(QWebContentsView);
- QString urlString = url.toString();
- GURL gurl(urlString.toStdString());
- if (!gurl.has_scheme())
- gurl = GURL(std::string("http://") + urlString.toStdString());
-
- content::NavigationController::LoadURLParams params(gurl);
- params.transition_type = content::PageTransitionFromInt(content::PAGE_TRANSITION_TYPED | content::PAGE_TRANSITION_FROM_ADDRESS_BAR);
- d->webContentsDelegate->web_contents()->GetController().LoadURLWithParams(params);
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->load(url);
}
bool QWebContentsView::canGoBack() const
{
Q_D(const QWebContentsView);
- return d->webContentsDelegate->web_contents()->GetController().CanGoBack();
+ return d->adapter->canGoBack();
}
bool QWebContentsView::canGoForward() const
{
Q_D(const QWebContentsView);
- return d->webContentsDelegate->web_contents()->GetController().CanGoForward();
+ return d->adapter->canGoForward();
}
void QWebContentsView::back()
{
Q_D(QWebContentsView);
- d->webContentsDelegate->web_contents()->GetController().GoToOffset(-1);
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->navigateHistory(-1);
}
void QWebContentsView::forward()
{
Q_D(QWebContentsView);
- d->webContentsDelegate->web_contents()->GetController().GoToOffset(1);
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->navigateHistory(1);
}
void QWebContentsView::reload()
{
Q_D(QWebContentsView);
- d->webContentsDelegate->web_contents()->GetController().Reload(false);
- d->webContentsDelegate->web_contents()->GetView()->Focus();
+ d->adapter->reload();
}
void QWebContentsView::stop()
{
Q_D(QWebContentsView);
- content::NavigationController& controller = d->webContentsDelegate->web_contents()->GetController();
-
- int index = controller.GetPendingEntryIndex();
- if (index != -1)
- controller.RemoveEntryAtIndex(index);
-
- d->webContentsDelegate->web_contents()->GetView()->Focus();
-
-}
-
-QWebContentsViewPrivate::QWebContentsViewPrivate()
- : m_isLoading(false)
-{
- WebContentsViewQt* contents_view = static_cast<WebContentsViewQt*>(webContentsDelegate->web_contents()->GetView());
- contents_view->SetClient(this);
-}
-
-void QWebContentsViewPrivate::_q_onLoadingStateChanged()
-{
- Q_Q(QWebContentsView);
- bool isLoading = webContentsDelegate->web_contents()->IsLoading();
- if (m_isLoading != isLoading) {
- m_isLoading = isLoading;
- if (m_isLoading)
- Q_EMIT q->loadStarted();
- else
- Q_EMIT q->loadFinished(true);
- }
-}
-
-RenderWidgetHostViewQtDelegate *QWebContentsViewPrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt *view)
-{
- Q_Q(QWebContentsView);
- RenderWidgetHostViewQtDelegateWidget *viewDelegate = new RenderWidgetHostViewQtDelegateWidget(view, q);
- // Parent the RWHV directly, this might have to be changed to handle popups and fullscreen.
- q->layout()->addWidget(viewDelegate);
- return viewDelegate;
+ d->adapter->stop();
}
#include "moc_qwebcontentsview.cpp"
diff --git a/lib/qwebcontentsview.h b/lib/widgets/Api/qwebcontentsview.h
index b9753c71..92f41c6a 100644
--- a/lib/qwebcontentsview.h
+++ b/lib/widgets/Api/qwebcontentsview.h
@@ -42,12 +42,14 @@
#ifndef QWEBCONTESTSVIEW_H
#define QWEBCONTESTSVIEW_H
+#include <qtwebengineglobal.h>
+
#include <QWidget>
#include <QScopedPointer>
class QWebContentsViewPrivate;
-class Q_DECL_EXPORT QWebContentsView : public QWidget {
+class QWEBENGINEWIDGETS_EXPORT QWebContentsView : public QWidget {
Q_OBJECT
public:
QWebContentsView();
@@ -70,10 +72,7 @@ Q_SIGNALS:
void urlChanged(const QUrl& url);
private:
- Q_DECLARE_PRIVATE(QWebContentsView)
- Q_PRIVATE_SLOT(d_func(), void _q_onLoadingStateChanged());
-
- // Hides QObject::d_ptr allowing us to use the convenience macros.
+ Q_DECLARE_PRIVATE(QWebContentsView);
QScopedPointer<QWebContentsViewPrivate> d_ptr;
};
diff --git a/lib/qwebcontentsview_p.h b/lib/widgets/Api/qwebcontentsview_p.h
index 123d028e..ba3739c4 100644
--- a/lib/qwebcontentsview_p.h
+++ b/lib/widgets/Api/qwebcontentsview_p.h
@@ -42,24 +42,29 @@
#ifndef QWEBCONTESTSVIEWPRIVATE_H
#define QWEBCONTESTSVIEWPRIVATE_H
-#include "web_contents_view_qt.h"
+#include "web_contents_adapter_client.h"
#include <QScopedPointer>
class QWebContentsView;
+class RenderWidgetHostViewQtDelegate;
+class WebContentsAdapter;
-class QWebContentsViewPrivate : public WebContentsViewQtClient
+class QWebContentsViewPrivate : public WebContentsAdapterClient
{
- QWebContentsView *q_ptr;
Q_DECLARE_PUBLIC(QWebContentsView)
+ QWebContentsView *q_ptr;
+
public:
QWebContentsViewPrivate();
- RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt *view) Q_DECL_OVERRIDE;
-
- void _q_onLoadingStateChanged();
+ virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQt *) Q_DECL_OVERRIDE;
+ virtual void titleChanged(const QString&) Q_DECL_OVERRIDE;
+ virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE;
+ virtual void loadingStateChanged() Q_DECL_OVERRIDE;
bool m_isLoading;
+ QScopedPointer<WebContentsAdapter> adapter;
};
#endif
diff --git a/lib/render_widget_host_view_qt_delegate_widget.cpp b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp
index 5baf6a3b..d90190ed 100644
--- a/lib/render_widget_host_view_qt_delegate_widget.cpp
+++ b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -41,18 +41,12 @@
#include "render_widget_host_view_qt_delegate_widget.h"
-#include "backing_store_qt.h"
-#include "render_widget_host_view_qt.h"
-
-#include "content/browser/renderer_host/render_view_host_impl.h"
-
#include <QResizeEvent>
+#include <QPainter>
#include <QPaintEvent>
-RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQt* view, QWidget *parent)
+RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(QWidget *parent)
: QWidget(parent)
- , RenderWidgetHostViewQtDelegate(view)
- , m_painter(0)
{
setFocusPolicy(Qt::ClickFocus);
setAttribute(Qt::WA_AcceptTouchEvents);
@@ -101,27 +95,20 @@ void RenderWidgetHostViewQtDelegateWidget::update(const QRect& rect)
void RenderWidgetHostViewQtDelegateWidget::paintEvent(QPaintEvent * event)
{
- if (BackingStoreQt *backingStore = m_view->GetBackingStore()) {
- QPainter painter(this);
- backingStore->paintToTarget(&painter, event->rect());
- }
-}
-
-QPainter* RenderWidgetHostViewQtDelegateWidget::painter()
-{
- if (!m_painter)
- m_painter = new QPainter(this);
- return m_painter;
+ QPainter painter(this);
+ fetchBackingStore();
+ paint(&painter, event->rect());
}
void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent)
{
- m_view->GetRenderWidgetHost()->WasResized();
+ Q_UNUSED(resizeEvent);
+ notifyResize();
}
bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
{
- if (!m_view || !m_view->handleEvent(event))
+ if (!forwardEvent(event))
return QWidget::event(event);
return true;
}
diff --git a/lib/render_widget_host_view_qt_delegate_widget.h b/lib/widgets/render_widget_host_view_qt_delegate_widget.h
index 40e50889..fbde05ce 100644
--- a/lib/render_widget_host_view_qt_delegate_widget.h
+++ b/lib/widgets/render_widget_host_view_qt_delegate_widget.h
@@ -52,7 +52,7 @@ class QWindow;
class RenderWidgetHostViewQtDelegateWidget : public QWidget, public RenderWidgetHostViewQtDelegate
{
public:
- RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQt* view, QWidget *parent = 0);
+ RenderWidgetHostViewQtDelegateWidget(QWidget *parent = 0);
virtual QRectF screenRect() const;
virtual void setKeyboardFocus();
@@ -63,15 +63,11 @@ public:
virtual QWindow* window() const;
virtual void update(const QRect& rect = QRect());
- QPainter* painter();
-
protected:
void paintEvent(QPaintEvent * event);
bool event(QEvent *event);
void resizeEvent(QResizeEvent *resizeEvent);
-private:
- QPainter* m_painter;
};
#endif
diff --git a/lib/widgets/widgets.pro b/lib/widgets/widgets.pro
new file mode 100644
index 00000000..351264d5
--- /dev/null
+++ b/lib/widgets/widgets.pro
@@ -0,0 +1,33 @@
+# Use Qt5 module system
+load(qt_build_config)
+
+TEMPLATE = lib
+TARGET = QtWebEngineWidgets
+
+MODULE = webenginewidgets
+
+# For our export macros
+DEFINES += QT_BUILD_WEBENGINEWIDGETS_LIB
+
+QT += widgets
+
+# FIXME: all this should eventually be turned into QT += webenginecore
+macx:LIBPATH = $$getOutDir()/$$getConfigDir()
+else:LIBPATH = $$getOutDir()/$$getConfigDir()/lib
+LIBS += -L$$LIBPATH -lQt5WebEngineCore
+QMAKE_RPATHDIR += $$LIBPATH
+
+DESTDIR = $$LIBPATH
+
+INCLUDEPATH += ../
+
+SOURCES = \
+ Api/qwebcontentsview.cpp\
+ render_widget_host_view_qt_delegate_widget.cpp
+
+HEADERS = \
+ Api/qwebcontentsview.h \
+ Api/qwebcontentsview_p.h \
+ render_widget_host_view_qt_delegate_widget.h
+
+load(qt_module)
diff --git a/qtwebengine.pro b/qtwebengine.pro
index c15cb191..49108691 100644
--- a/qtwebengine.pro
+++ b/qtwebengine.pro
@@ -9,7 +9,11 @@ SUBDIRS = resources \
lib \
process \
build \ # This is where we use the generated qt_generated.gypi and run gyp
- examples \
+ # Now build the API libraries
+ lib/quick
+qtHaveModule(widgets): SUBDIRS += lib/widgets
+
+SUBDIRS += examples
# Ninja executable location needs to be determined early for extra targets. Should be fetched from cache most of the time anyway.
NINJA_EXECUTABLE = $$findNinja()
diff --git a/sync.profile b/sync.profile
index 24a6cba8..da470758 100644
--- a/sync.profile
+++ b/sync.profile
@@ -1,7 +1,23 @@
-# A list of Qt dependencies to build QtWebEngine.
+%modules = ( # path to module name map
+ "QtWebEngineWidgets" => "$basedir/lib/widgets",
+);
+%moduleheaders = ( # restrict the module headers to those found in relative path
+ "QtWebEngineWidgets" => "Api",
+);
+%classnames = (
+);
+
+# Module dependencies.
+# Every module that is required to build this module should have one entry.
+# Each of the module version specifiers can take one of the following values:
+# - A specific Git revision.
+# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch)
+#
%dependencies = (
- "qtbase" => "refs/heads/stable",
- "qtxmlpatterns" => "refs/heads/stable",
- "qtjsbackend" => "refs/heads/stable",
- "qtdeclartive" => "refs/heads/stable",
+ "qtbase" => "refs/heads/stable",
+ "qtdeclarative" => "refs/heads/stable",
+ "qtjsbackend" => "refs/heads/stable",
+ "qtxmlpatterns" => "refs/heads/stable",
+# FIXME: take examples out into their own module to avoid a potential circular dependency later ?
+ "qtquickcontrols" => "refs/heads/stable",
);