summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2013-10-31 17:06:30 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-06 17:34:20 +0100
commitfb62607e950ac711f7366b378d8d5f952d4fd1b3 (patch)
tree5ceb5adaee848f63ec9f27188068e496fb099b8e
parentfbf3e79512358a3eb1e6589b10ac01917b2e94d0 (diff)
Make RenderWidgetHostViewQtDelegate a pure interface.
RenderWidgetHostViewQtDelegate acts as a bidirectional interface to avoid exporting Chromium symbols outside of the core dynamic library. The problem is that, other than this, from the top layer point of view, its responsibilities are the same as RenderWidgetHostViewQt, and it would be better not to split its logic without properly defined responsibilities. Using it as a base class and interfacing through its protected methods is also cumbersome and make the destination of calls on the upper layer difficult to discern. Use instead a dual pure interface mechanism like WebContentsAdapter and pass the callback client interface directly in WebContentsAdapterClient::CreateRenderWidgetHostViewQtDelegate. This allows RenderWidgetHostViewQtDelegate to be solely what it should be, an interface. Change-Id: I4e55439ae7f9539cc9e360f0756fbf391405f3b7 Reviewed-by: Zeno Albisser <zeno.albisser@digia.com>
-rw-r--r--lib/lib.pro1
-rw-r--r--lib/quick/qquickwebengineview.cpp6
-rw-r--r--lib/quick/qquickwebengineview_p_p.h2
-rw-r--r--lib/quick/render_widget_host_view_qt_delegate_quick.cpp14
-rw-r--r--lib/quick/render_widget_host_view_qt_delegate_quick.h35
-rw-r--r--lib/render_widget_host_view_qt.cpp169
-rw-r--r--lib/render_widget_host_view_qt.h16
-rw-r--r--lib/render_widget_host_view_qt_delegate.cpp117
-rw-r--r--lib/render_widget_host_view_qt_delegate.h35
-rw-r--r--lib/web_contents_adapter_client.h3
-rw-r--r--lib/web_contents_view_qt.cpp3
-rw-r--r--lib/widgets/Api/qwebenginepage.cpp4
-rw-r--r--lib/widgets/Api/qwebenginepage_p.h2
-rw-r--r--lib/widgets/render_widget_host_view_qt_delegate_widget.cpp13
-rw-r--r--lib/widgets/render_widget_host_view_qt_delegate_widget.h5
-rw-r--r--qtwebengine.gypi5
16 files changed, 179 insertions, 251 deletions
diff --git a/lib/lib.pro b/lib/lib.pro
index d6a546597..c25920b16 100644
--- a/lib/lib.pro
+++ b/lib/lib.pro
@@ -42,7 +42,6 @@ SOURCES = \
download_manager_delegate_qt.cpp \
javascript_dialog_manager_qt.cpp \
render_widget_host_view_qt.cpp \
- render_widget_host_view_qt_delegate.cpp \
resource_context_qt.cpp \
url_request_context_getter_qt.cpp \
web_contents_adapter.cpp \
diff --git a/lib/quick/qquickwebengineview.cpp b/lib/quick/qquickwebengineview.cpp
index 4b58c6c04..0fad5c985 100644
--- a/lib/quick/qquickwebengineview.cpp
+++ b/lib/quick/qquickwebengineview.cpp
@@ -57,13 +57,13 @@ QQuickWebEngineViewPrivate::QQuickWebEngineViewPrivate()
adapter->initialize(this);
}
-RenderWidgetHostViewQtDelegate *QQuickWebEngineViewPrivate::CreateRenderWidgetHostViewQtDelegate(CompositingMode mode)
+RenderWidgetHostViewQtDelegate *QQuickWebEngineViewPrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client, CompositingMode mode)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
if (mode == DelegatedCompositing)
- return new RenderWidgetHostViewQtDelegateQuick;
+ return new RenderWidgetHostViewQtDelegateQuick(client);
#endif
- return new RenderWidgetHostViewQtDelegateQuickPainted;
+ return new RenderWidgetHostViewQtDelegateQuickPainted(client);
}
void QQuickWebEngineViewPrivate::titleChanged(const QString &title)
diff --git a/lib/quick/qquickwebengineview_p_p.h b/lib/quick/qquickwebengineview_p_p.h
index e32ac5c63..99f0c943e 100644
--- a/lib/quick/qquickwebengineview_p_p.h
+++ b/lib/quick/qquickwebengineview_p_p.h
@@ -58,7 +58,7 @@ public:
Q_DECLARE_PUBLIC(QQuickWebEngineView)
QQuickWebEngineViewPrivate();
- virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(CompositingMode mode) Q_DECL_OVERRIDE;
+ virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client, CompositingMode mode) Q_DECL_OVERRIDE;
virtual void titleChanged(const QString&) Q_DECL_OVERRIDE;
virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE;
virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE;
diff --git a/lib/quick/render_widget_host_view_qt_delegate_quick.cpp b/lib/quick/render_widget_host_view_qt_delegate_quick.cpp
index b77503f2c..8989759f6 100644
--- a/lib/quick/render_widget_host_view_qt_delegate_quick.cpp
+++ b/lib/quick/render_widget_host_view_qt_delegate_quick.cpp
@@ -42,8 +42,8 @@
#include "render_widget_host_view_qt_delegate_quick.h"
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
-RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(QQuickItem *parent)
- : RenderWidgetHostViewQtDelegateQuickBase<QQuickItem>(parent)
+RenderWidgetHostViewQtDelegateQuick::RenderWidgetHostViewQtDelegateQuick(RenderWidgetHostViewQtDelegateClient *client, QQuickItem *parent)
+ : RenderWidgetHostViewQtDelegateQuickBase<QQuickItem>(client, parent)
{
setFlag(ItemHasContents);
}
@@ -60,13 +60,13 @@ void RenderWidgetHostViewQtDelegateQuick::update(const QRect&)
QSGNode *RenderWidgetHostViewQtDelegateQuick::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *)
{
- return RenderWidgetHostViewQtDelegate::updatePaintNode(oldNode, QQuickItem::window());
+ return m_client->updatePaintNode(oldNode, QQuickItem::window());
}
#endif // QT_VERSION
-RenderWidgetHostViewQtDelegateQuickPainted::RenderWidgetHostViewQtDelegateQuickPainted(QQuickItem *parent)
- : RenderWidgetHostViewQtDelegateQuickBase<QQuickPaintedItem>(parent)
+RenderWidgetHostViewQtDelegateQuickPainted::RenderWidgetHostViewQtDelegateQuickPainted(RenderWidgetHostViewQtDelegateClient *client, QQuickItem *parent)
+ : RenderWidgetHostViewQtDelegateQuickBase<QQuickPaintedItem>(client, parent)
{
}
@@ -84,7 +84,7 @@ void RenderWidgetHostViewQtDelegateQuickPainted::update(const QRect& rect)
void RenderWidgetHostViewQtDelegateQuickPainted::paint(QPainter *painter)
{
- RenderWidgetHostViewQtDelegate::paint(painter, boundingRect());
+ m_client->paint(painter, boundingRect());
}
void RenderWidgetHostViewQtDelegateQuickPainted::updatePolish()
@@ -92,5 +92,5 @@ void RenderWidgetHostViewQtDelegateQuickPainted::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.
- fetchBackingStore();
+ m_client->fetchBackingStore();
}
diff --git a/lib/quick/render_widget_host_view_qt_delegate_quick.h b/lib/quick/render_widget_host_view_qt_delegate_quick.h
index c9f688958..80f5baca8 100644
--- a/lib/quick/render_widget_host_view_qt_delegate_quick.h
+++ b/lib/quick/render_widget_host_view_qt_delegate_quick.h
@@ -56,8 +56,9 @@ template<typename ItemBaseT>
class RenderWidgetHostViewQtDelegateQuickBase : public ItemBaseT, public RenderWidgetHostViewQtDelegate
{
public:
- RenderWidgetHostViewQtDelegateQuickBase(QQuickItem *parent = 0)
+ RenderWidgetHostViewQtDelegateQuickBase(RenderWidgetHostViewQtDelegateClient *client, QQuickItem *parent = 0)
: ItemBaseT(parent)
+ , m_client(client)
{
this->setAcceptedMouseButtons(Qt::AllButtons);
this->setAcceptHoverEvents(true);
@@ -126,58 +127,58 @@ public:
void focusInEvent(QFocusEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void focusOutEvent(QFocusEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void mousePressEvent(QMouseEvent *event)
{
this->setFocus(true);
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void mouseMoveEvent(QMouseEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void mouseReleaseEvent(QMouseEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void mouseDoubleClickEvent(QMouseEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void keyPressEvent(QKeyEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void keyReleaseEvent(QKeyEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void wheelEvent(QWheelEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void touchEvent(QTouchEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void hoverMoveEvent(QHoverEvent *event)
{
- forwardEvent(event);
+ m_client->forwardEvent(event);
}
void inputMethodStateChanged(bool editorVisible)
@@ -192,15 +193,17 @@ public:
QVariant inputMethodQuery(Qt::InputMethodQuery query) const
{
- return forwardInputMethodQuery(query);
+ return m_client->inputMethodQuery(query);
}
protected:
void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry)
{
ItemBaseT::geometryChanged(newGeometry, oldGeometry);
- notifyResize();
+ m_client->notifyResize();
}
+
+ RenderWidgetHostViewQtDelegateClient *m_client;
};
#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
@@ -208,7 +211,7 @@ class RenderWidgetHostViewQtDelegateQuick : public RenderWidgetHostViewQtDelegat
{
Q_OBJECT
public:
- RenderWidgetHostViewQtDelegateQuick(QQuickItem *parent = 0);
+ RenderWidgetHostViewQtDelegateQuick(RenderWidgetHostViewQtDelegateClient *client, QQuickItem *parent = 0);
virtual WId nativeWindowIdForCompositor() const;
virtual void update(const QRect& rect = QRect());
@@ -221,7 +224,7 @@ class RenderWidgetHostViewQtDelegateQuickPainted : public RenderWidgetHostViewQt
{
Q_OBJECT
public:
- RenderWidgetHostViewQtDelegateQuickPainted(QQuickItem *parent = 0);
+ RenderWidgetHostViewQtDelegateQuickPainted(RenderWidgetHostViewQtDelegateClient *client, QQuickItem *parent = 0);
virtual WId nativeWindowIdForCompositor() const;
virtual void update(const QRect& rect = QRect());
diff --git a/lib/render_widget_host_view_qt.cpp b/lib/render_widget_host_view_qt.cpp
index 8c5ba0502..b6a1d2905 100644
--- a/lib/render_widget_host_view_qt.cpp
+++ b/lib/render_widget_host_view_qt.cpp
@@ -42,6 +42,7 @@
#include "render_widget_host_view_qt.h"
#include "backing_store_qt.h"
+#include "delegated_frame_node.h"
#include "render_widget_host_view_qt_delegate.h"
#include "type_conversion.h"
#include "web_event_factory.h"
@@ -140,6 +141,7 @@ static void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event, WebKi
RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost* widget)
: m_host(content::RenderWidgetHostImpl::From(widget))
, m_gestureRecognizer(ui::GestureRecognizer::Create(this))
+ , m_backingStore(0)
, m_adapterClient(0)
, m_anchorPositionWithinSelection(0)
, m_cursorPositionWithinSelection(0)
@@ -155,7 +157,6 @@ RenderWidgetHostViewQt::~RenderWidgetHostViewQt()
void RenderWidgetHostViewQt::setDelegate(RenderWidgetHostViewQtDelegate* delegate)
{
m_delegate.reset(delegate);
- delegate->setView(this);
}
void RenderWidgetHostViewQt::setAdapterClient(WebContentsAdapterClient *adapterClient)
@@ -167,44 +168,6 @@ void RenderWidgetHostViewQt::setAdapterClient(WebContentsAdapterClient *adapterC
InitAsChild(0);
}
-bool RenderWidgetHostViewQt::handleEvent(QEvent* event) {
-
- switch(event->type()) {
- case QEvent::MouseButtonDblClick:
- case QEvent::MouseButtonPress:
- Focus(); // Fall through.
- case QEvent::MouseButtonRelease:
- case QEvent::MouseMove:
- handleMouseEvent(static_cast<QMouseEvent*>(event));
- break;
- case QEvent::KeyPress:
- case QEvent::KeyRelease:
- handleKeyEvent(static_cast<QKeyEvent*>(event));
- break;
- case QEvent::Wheel:
- handleWheelEvent(static_cast<QWheelEvent*>(event));
- break;
- case QEvent::TouchBegin:
- Focus(); // Fall through.
- case QEvent::TouchUpdate:
- case QEvent::TouchEnd:
- handleTouchEvent(static_cast<QTouchEvent*>(event));
- break;
- case QEvent::HoverEnter:
- case QEvent::HoverLeave:
- case QEvent::HoverMove:
- handleHoverEvent(static_cast<QHoverEvent*>(event));
- break;
- case QEvent::FocusIn:
- case QEvent::FocusOut:
- handleFocusEvent(static_cast<QFocusEvent*>(event));
- break;
- default:
- return false;
- }
- return true;
-}
-
void RenderWidgetHostViewQt::releaseAndAckDelegatedFrame()
{
cc::CompositorFrameAck ack;
@@ -678,6 +641,108 @@ bool RenderWidgetHostViewQt::DispatchCancelTouchEvent(ui::TouchEvent *)
return false;
}
+void RenderWidgetHostViewQt::paint(QPainter *painter, const QRectF& boundingRect)
+{
+ if (m_backingStore)
+ m_backingStore->paintToTarget(painter, boundingRect);
+}
+
+QSGNode *RenderWidgetHostViewQt::updatePaintNode(QSGNode *oldNode, QQuickWindow *window)
+{
+#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
+ if (!m_pendingFrameData) {
+ delete oldNode;
+ return 0;
+ }
+ DelegatedFrameNode *frameNode = static_cast<DelegatedFrameNode *>(oldNode);
+ if (!frameNode)
+ frameNode = new DelegatedFrameNode(window);
+
+ frameNode->commit(m_pendingFrameData.get());
+
+ content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
+ base::Bind(&RenderWidgetHostViewQt::releaseAndAckDelegatedFrame, this->AsWeakPtr()));
+
+ return frameNode;
+#else
+ return 0;
+#endif // QT_VERSION
+}
+
+void RenderWidgetHostViewQt::fetchBackingStore()
+{
+ m_backingStore = GetBackingStore();
+}
+
+void RenderWidgetHostViewQt::notifyResize()
+{
+ GetRenderWidgetHost()->WasResized();
+}
+
+bool RenderWidgetHostViewQt::forwardEvent(QEvent *event)
+{
+ switch (event->type()) {
+ case QEvent::MouseButtonDblClick:
+ case QEvent::MouseButtonPress:
+ Focus(); // Fall through.
+ case QEvent::MouseButtonRelease:
+ case QEvent::MouseMove:
+ handleMouseEvent(static_cast<QMouseEvent*>(event));
+ break;
+ case QEvent::KeyPress:
+ case QEvent::KeyRelease:
+ handleKeyEvent(static_cast<QKeyEvent*>(event));
+ break;
+ case QEvent::Wheel:
+ handleWheelEvent(static_cast<QWheelEvent*>(event));
+ break;
+ case QEvent::TouchBegin:
+ Focus(); // Fall through.
+ case QEvent::TouchUpdate:
+ case QEvent::TouchEnd:
+ handleTouchEvent(static_cast<QTouchEvent*>(event));
+ break;
+ case QEvent::HoverEnter:
+ case QEvent::HoverLeave:
+ case QEvent::HoverMove:
+ handleHoverEvent(static_cast<QHoverEvent*>(event));
+ break;
+ case QEvent::FocusIn:
+ case QEvent::FocusOut:
+ handleFocusEvent(static_cast<QFocusEvent*>(event));
+ break;
+ default:
+ return false;
+ }
+ return true;
+}
+
+QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) const
+{
+ switch (query) {
+ case Qt::ImEnabled:
+ return QVariant(m_currentInputType != ui::TEXT_INPUT_TYPE_NONE);
+ case Qt::ImCursorRectangle:
+ return m_cursorRect;
+ case Qt::ImFont:
+ return QVariant();
+ case Qt::ImCursorPosition:
+ return static_cast<uint>(m_cursorPositionWithinSelection);
+ case Qt::ImAnchorPosition:
+ return static_cast<uint>(m_anchorPositionWithinSelection);
+ case Qt::ImSurroundingText:
+ return toQt(selection_text_);
+ case Qt::ImCurrentSelection:
+ return toQt(GetSelectedText());
+ case Qt::ImMaximumTextLength:
+ return QVariant(); // No limit.
+ case Qt::ImHints:
+ return int(toQtInputMethodHints(m_currentInputType));
+ default:
+ return QVariant();
+ }
+}
+
void RenderWidgetHostViewQt::ProcessAckedTouchEvent(const content::TouchEventWithLatencyInfo &touch, content::InputEventAckState ack_result) {
ScopedVector<ui::TouchEvent> events;
if (!content::MakeUITouchEventsFromWebTouchEvents(touch, &events, content::LOCAL_COORDINATES))
@@ -756,32 +821,6 @@ bool RenderWidgetHostViewQt::IsPopup() const
return popup_type_ != WebKit::WebPopupTypeNone;
}
-QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) const
-{
- switch (query) {
- case Qt::ImEnabled:
- return QVariant(m_currentInputType != ui::TEXT_INPUT_TYPE_NONE);
- case Qt::ImCursorRectangle:
- return m_cursorRect;
- case Qt::ImFont:
- return QVariant();
- case Qt::ImCursorPosition:
- return static_cast<uint>(m_cursorPositionWithinSelection);
- case Qt::ImAnchorPosition:
- return static_cast<uint>(m_anchorPositionWithinSelection);
- case Qt::ImSurroundingText:
- return toQt(selection_text_);
- case Qt::ImCurrentSelection:
- return toQt(GetSelectedText());
- case Qt::ImMaximumTextLength:
- return QVariant(); // No limit.
- case Qt::ImHints:
- return int(toQtInputMethodHints(m_currentInputType));
- default:
- return QVariant();
- }
-}
-
void RenderWidgetHostViewQt::handleMouseEvent(QMouseEvent* event)
{
int eventType = event->type();
diff --git a/lib/render_widget_host_view_qt.h b/lib/render_widget_host_view_qt.h
index 12f7d3184..24c845556 100644
--- a/lib/render_widget_host_view_qt.h
+++ b/lib/render_widget_host_view_qt.h
@@ -42,6 +42,7 @@
#ifndef RENDER_WIDGET_HOST_VIEW_QT_H
#define RENDER_WIDGET_HOST_VIEW_QT_H
+#include "render_widget_host_view_qt_delegate.h"
#include "shared/shared_globals.h"
#include "base/memory/scoped_ptr.h"
@@ -67,7 +68,6 @@ class QVariant;
class QWheelEvent;
QT_END_NAMESPACE
-class RenderWidgetHostViewQtDelegate;
class WebContentsAdapterClient;
struct MultipleMouseClickHelper
@@ -90,6 +90,7 @@ class RenderWidgetHostViewQt
: public content::RenderWidgetHostViewBase
, public ui::GestureConsumer
, public ui::GestureEventHelper
+ , public RenderWidgetHostViewQtDelegateClient
, public base::SupportsWeakPtr<RenderWidgetHostViewQt>
{
public:
@@ -98,8 +99,6 @@ public:
void setDelegate(RenderWidgetHostViewQtDelegate *delegate);
void setAdapterClient(WebContentsAdapterClient *adapterClient);
- bool handleEvent(QEvent* event);
- cc::DelegatedFrameData *pendingDelegatedFrame() const { return m_pendingFrameData.get(); }
void releaseAndAckDelegatedFrame();
BackingStoreQt* GetBackingStore();
@@ -166,6 +165,14 @@ public:
virtual bool DispatchLongPressGestureEvent(ui::GestureEvent *event) Q_DECL_OVERRIDE;
virtual bool DispatchCancelTouchEvent(ui::TouchEvent *event) Q_DECL_OVERRIDE;
+ // Overridden from RenderWidgetHostViewQtDelegateClient.
+ virtual void paint(QPainter *, const QRectF& boundingRect) Q_DECL_OVERRIDE;
+ virtual QSGNode *updatePaintNode(QSGNode *, QQuickWindow *) Q_DECL_OVERRIDE;
+ virtual void fetchBackingStore() Q_DECL_OVERRIDE;
+ virtual void notifyResize() Q_DECL_OVERRIDE;
+ virtual bool forwardEvent(QEvent *) Q_DECL_OVERRIDE;
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
+
void handleMouseEvent(QMouseEvent*);
void handleKeyEvent(QKeyEvent*);
void handleWheelEvent(QWheelEvent*);
@@ -173,8 +180,6 @@ public:
void handleHoverEvent(QHoverEvent*);
void handleFocusEvent(QFocusEvent*);
- QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
-
#if defined(OS_MACOSX)
virtual void SetTakesFocusOnlyOnMouseDown(bool flag) { QT_NOT_YET_IMPLEMENTED }
virtual void SetActive(bool active) { QT_NOT_YET_IMPLEMENTED }
@@ -204,6 +209,7 @@ private:
WebKit::WebTouchEvent m_accumTouchEvent;
scoped_ptr<RenderWidgetHostViewQtDelegate> m_delegate;
+ BackingStoreQt *m_backingStore;
uint32 m_pendingOutputSurfaceId;
scoped_ptr<cc::DelegatedFrameData> m_pendingFrameData;
diff --git a/lib/render_widget_host_view_qt_delegate.cpp b/lib/render_widget_host_view_qt_delegate.cpp
deleted file mode 100644
index 25a9e69b0..000000000
--- a/lib/render_widget_host_view_qt_delegate.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
-** Contact: http://www.qt-project.org/legal
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and Digia. For licensing terms and
-** conditions see http://qt.digia.com/licensing. For further information
-** use the contact form at http://qt.digia.com/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Digia gives you certain additional
-** rights. These rights are described in the Digia Qt LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "render_widget_host_view_qt_delegate.h"
-
-#include "backing_store_qt.h"
-#include "delegated_frame_node.h"
-#include "render_widget_host_view_qt.h"
-#include "type_conversion.h"
-
-#include "content/browser/renderer_host/render_view_host_impl.h"
-
-#include <QVariant>
-
-RenderWidgetHostViewQtDelegate::RenderWidgetHostViewQtDelegate()
- : m_view(0), m_backingStore(0)
-{
-}
-
-RenderWidgetHostViewQtDelegate::~RenderWidgetHostViewQtDelegate()
-{
-}
-
-void RenderWidgetHostViewQtDelegate::paint(QPainter *painter, const QRectF &boundingRect)
-{
- if (m_backingStore)
- m_backingStore->paintToTarget(painter, boundingRect);
-}
-
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
-QSGNode *RenderWidgetHostViewQtDelegate::updatePaintNode(QSGNode *oldNode, QQuickWindow *window)
-{
- cc::DelegatedFrameData *frameData = m_view->pendingDelegatedFrame();
- if (!frameData) {
- delete oldNode;
- return 0;
- }
- DelegatedFrameNode *frameNode = static_cast<DelegatedFrameNode *>(oldNode);
- if (!frameNode)
- frameNode = new DelegatedFrameNode(window);
-
- frameNode->commit(frameData);
-
- content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE,
- base::Bind(&RenderWidgetHostViewQt::releaseAndAckDelegatedFrame, m_view->AsWeakPtr()));
-
- return frameNode;
-}
-#endif // QT_VERSION
-
-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)
-{
- return (m_view && m_view->handleEvent(event));
-}
-
-void RenderWidgetHostViewQtDelegate::setView(RenderWidgetHostViewQt* view)
-{
- m_view = view;
-}
-
-QVariant RenderWidgetHostViewQtDelegate::forwardInputMethodQuery(Qt::InputMethodQuery query) const
-{
- if (!m_view)
- return QVariant();
-
- return m_view->inputMethodQuery(query);
-}
diff --git a/lib/render_widget_host_view_qt_delegate.h b/lib/render_widget_host_view_qt_delegate.h
index 3486e3f8d..2f1401b6d 100644
--- a/lib/render_widget_host_view_qt_delegate.h
+++ b/lib/render_widget_host_view_qt_delegate.h
@@ -45,11 +45,8 @@
#include "qtwebengineglobal.h"
#include <QRect>
-#include <QScopedPointer>
#include <QtGui/qwindowdefs.h>
-class BackingStoreQt;
-
QT_BEGIN_NAMESPACE
class QCursor;
class QEvent;
@@ -60,13 +57,22 @@ class QVariant;
class QWindow;
QT_END_NAMESPACE
-class RenderWidgetHostViewQt;
class WebContentsAdapterClient;
-class QWEBENGINE_EXPORT RenderWidgetHostViewQtDelegate {
+class QWEBENGINE_EXPORT RenderWidgetHostViewQtDelegateClient {
+public:
+ virtual ~RenderWidgetHostViewQtDelegateClient() { }
+ virtual void paint(QPainter *, const QRectF& boundingRect) = 0;
+ virtual QSGNode *updatePaintNode(QSGNode *, QQuickWindow *) = 0;
+ virtual void fetchBackingStore() = 0;
+ virtual void notifyResize() = 0;
+ virtual bool forwardEvent(QEvent *) = 0;
+ virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const = 0;
+};
+class QWEBENGINE_EXPORT RenderWidgetHostViewQtDelegate {
public:
- virtual ~RenderWidgetHostViewQtDelegate();
+ virtual ~RenderWidgetHostViewQtDelegate() { }
virtual void initAsChild(WebContentsAdapterClient*) = 0;
virtual void initAsPopup(const QRect&) = 0;
virtual QRectF screenRect() const = 0;
@@ -81,23 +87,6 @@ public:
virtual void updateCursor(const QCursor &) = 0;
virtual void resize(int width, int height) = 0;
virtual void inputMethodStateChanged(bool editorVisible) = 0;
-
-protected:
- RenderWidgetHostViewQtDelegate();
- void paint(QPainter*, const QRectF& boundingRect);
-#if (QT_VERSION >= QT_VERSION_CHECK(5, 2, 0))
- QSGNode *updatePaintNode(QSGNode *, QQuickWindow *);
-#endif
- void fetchBackingStore();
- void notifyResize();
- bool forwardEvent(QEvent*);
- QVariant forwardInputMethodQuery(Qt::InputMethodQuery query) const;
-
-private:
- void setView(RenderWidgetHostViewQt*);
- RenderWidgetHostViewQt *m_view;
- BackingStoreQt *m_backingStore;
- friend class RenderWidgetHostViewQt;
};
#endif // RENDER_WIDGET_HOST_VIEW_QT_DELEGATE_H
diff --git a/lib/web_contents_adapter_client.h b/lib/web_contents_adapter_client.h
index 7019315e3..98db89f42 100644
--- a/lib/web_contents_adapter_client.h
+++ b/lib/web_contents_adapter_client.h
@@ -49,6 +49,7 @@
class RenderWidgetHostViewQt;
class RenderWidgetHostViewQtDelegate;
+class RenderWidgetHostViewQtDelegateClient;
class WebContentsAdapter;
class WebContentsDelegateQt;
@@ -101,7 +102,7 @@ public:
virtual ~WebContentsAdapterClient() { }
- virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(CompositingMode mode) = 0;
+ virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client, CompositingMode mode) = 0;
virtual void titleChanged(const QString&) = 0;
virtual void urlChanged(const QUrl&) = 0;
virtual void iconChanged(const QUrl&) = 0;
diff --git a/lib/web_contents_view_qt.cpp b/lib/web_contents_view_qt.cpp
index abf311a83..fa6c0e94b 100644
--- a/lib/web_contents_view_qt.cpp
+++ b/lib/web_contents_view_qt.cpp
@@ -80,8 +80,7 @@ content::RenderWidgetHostView* WebContentsViewQt::CreateViewForPopupWidget(conte
compositingMode = WebContentsAdapterClient::ForcedGpuProcessCompositing;
Q_ASSERT(m_factoryClient);
- RenderWidgetHostViewQtDelegate* viewDelegate = m_factoryClient->CreateRenderWidgetHostViewQtDelegate(compositingMode);
- view->setDelegate(viewDelegate);
+ view->setDelegate(m_factoryClient->CreateRenderWidgetHostViewQtDelegate(view, compositingMode));
if (m_client)
view->setAdapterClient(m_client);
diff --git a/lib/widgets/Api/qwebenginepage.cpp b/lib/widgets/Api/qwebenginepage.cpp
index e37c6126d..bde316f77 100644
--- a/lib/widgets/Api/qwebenginepage.cpp
+++ b/lib/widgets/Api/qwebenginepage.cpp
@@ -58,9 +58,9 @@ QWebEnginePagePrivate::~QWebEnginePagePrivate()
delete history;
}
-RenderWidgetHostViewQtDelegate *QWebEnginePagePrivate::CreateRenderWidgetHostViewQtDelegate(CompositingMode mode)
+RenderWidgetHostViewQtDelegate *QWebEnginePagePrivate::CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client, CompositingMode mode)
{
- return new RenderWidgetHostViewQtDelegateWidget(mode);
+ return new RenderWidgetHostViewQtDelegateWidget(client, mode);
}
void QWebEnginePagePrivate::titleChanged(const QString &title)
diff --git a/lib/widgets/Api/qwebenginepage_p.h b/lib/widgets/Api/qwebenginepage_p.h
index 89534b20d..8822cd094 100644
--- a/lib/widgets/Api/qwebenginepage_p.h
+++ b/lib/widgets/Api/qwebenginepage_p.h
@@ -64,7 +64,7 @@ public:
QWebEnginePagePrivate();
~QWebEnginePagePrivate();
- virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(CompositingMode mode) Q_DECL_OVERRIDE;
+ virtual RenderWidgetHostViewQtDelegate* CreateRenderWidgetHostViewQtDelegate(RenderWidgetHostViewQtDelegateClient *client, CompositingMode mode) Q_DECL_OVERRIDE;
virtual void titleChanged(const QString&) Q_DECL_OVERRIDE;
virtual void urlChanged(const QUrl&) Q_DECL_OVERRIDE;
virtual void iconChanged(const QUrl&) Q_DECL_OVERRIDE;
diff --git a/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp
index 1eb52378c..ee730db2b 100644
--- a/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp
+++ b/lib/widgets/render_widget_host_view_qt_delegate_widget.cpp
@@ -51,8 +51,9 @@
#include <QWindow>
#include <QtWidgets/QApplication>
-RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(WebContentsAdapterClient::CompositingMode mode, QWidget *parent)
+RenderWidgetHostViewQtDelegateWidget::RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, WebContentsAdapterClient::CompositingMode mode, QWidget *parent)
: QWidget(parent)
+ , m_client(client)
{
setFocusPolicy(Qt::ClickFocus);
setMouseTracking(true);
@@ -160,25 +161,25 @@ void RenderWidgetHostViewQtDelegateWidget::inputMethodStateChanged(bool editorVi
QVariant RenderWidgetHostViewQtDelegateWidget::inputMethodQuery(Qt::InputMethodQuery query) const
{
- return forwardInputMethodQuery(query);
+ return m_client->inputMethodQuery(query);
}
void RenderWidgetHostViewQtDelegateWidget::paintEvent(QPaintEvent * event)
{
QPainter painter(this);
- fetchBackingStore();
- paint(&painter, event->rect());
+ m_client->fetchBackingStore();
+ m_client->paint(&painter, event->rect());
}
void RenderWidgetHostViewQtDelegateWidget::resizeEvent(QResizeEvent *resizeEvent)
{
Q_UNUSED(resizeEvent);
- notifyResize();
+ m_client->notifyResize();
}
bool RenderWidgetHostViewQtDelegateWidget::event(QEvent *event)
{
- if (!forwardEvent(event))
+ if (!m_client->forwardEvent(event))
return QWidget::event(event);
return true;
}
diff --git a/lib/widgets/render_widget_host_view_qt_delegate_widget.h b/lib/widgets/render_widget_host_view_qt_delegate_widget.h
index b8a1ba115..fe5102213 100644
--- a/lib/widgets/render_widget_host_view_qt_delegate_widget.h
+++ b/lib/widgets/render_widget_host_view_qt_delegate_widget.h
@@ -56,7 +56,7 @@ QT_END_NAMESPACE
class RenderWidgetHostViewQtDelegateWidget : public QWidget, public RenderWidgetHostViewQtDelegate
{
public:
- RenderWidgetHostViewQtDelegateWidget(WebContentsAdapterClient::CompositingMode mode, QWidget *parent = 0);
+ RenderWidgetHostViewQtDelegateWidget(RenderWidgetHostViewQtDelegateClient *client, WebContentsAdapterClient::CompositingMode mode, QWidget *parent = 0);
virtual void initAsChild(WebContentsAdapterClient* container);
virtual void initAsPopup(const QRect&);
@@ -79,6 +79,9 @@ protected:
void resizeEvent(QResizeEvent *resizeEvent);
QVariant inputMethodQuery(Qt::InputMethodQuery query) const;
+
+private:
+ RenderWidgetHostViewQtDelegateClient *m_client;
};
#endif
diff --git a/qtwebengine.gypi b/qtwebengine.gypi
index 28ae73d7a..5c278ffd2 100644
--- a/qtwebengine.gypi
+++ b/qtwebengine.gypi
@@ -41,6 +41,11 @@
'<(qtwebengine_src_dir)',
'<(chromium_src_dir)',
],
+ # Chromium code defines those in common.gypi, do the same for our code that include Chromium headers.
+ 'defines': [
+ '__STDC_CONSTANT_MACROS',
+ '__STDC_FORMAT_MACROS',
+ ],
'msvs_settings': {
'VCLinkerTool': {
'SubSystem': '2', # Set /SUBSYSTEM:WINDOWS