From 0dca1220141c1aa0ce983e27f1f09425f47f062d Mon Sep 17 00:00:00 2001 From: Michal Klocek Date: Wed, 29 Jul 2020 15:30:44 +0200 Subject: Merge all webenginecontextmenudata wrappers into one class MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce new class qwebenginecontextmenurequest in core which merges: * qquickwebenginecontextmenurequest * qwebenginecontextmenudata * implictly shared webenginecontextdata Unfortunately new class has to be QObject, since we want to reuse it qml. Q_GADGET can be used only as a value type, however we need to know if request is accepted or not in qml, therefore it must be passed as pointer. Since we use QObject now, class is no longer implicitly shared, however we only allocate request once and reuse the object for every new request (it is still copied in qml just to keep it aligned with other request handlers) [ChangleLog] QWebEngineContextMenuRequest is replacement for QWebEngineContextMenuData Change-Id: Ib387ec2065361a4bacc20675ca7352ab75a0e436 Reviewed-by: Michael BrĂ¼ning --- src/core/web_contents_view_qt.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/core/web_contents_view_qt.h') diff --git a/src/core/web_contents_view_qt.h b/src/core/web_contents_view_qt.h index 3dcb648bf..218bebf13 100644 --- a/src/core/web_contents_view_qt.h +++ b/src/core/web_contents_view_qt.h @@ -45,6 +45,8 @@ #include "api/qtwebenginecoreglobal_p.h" +QT_FORWARD_DECLARE_CLASS(QWebEngineContextMenuRequest) + namespace content { class WebContents; } @@ -59,12 +61,7 @@ class WebContentsViewQt public: static inline WebContentsViewQt *from(WebContentsView *view) { return static_cast(view); } - WebContentsViewQt(content::WebContents* webContents) - : m_webContents(webContents) - , m_client(nullptr) - , m_factoryClient(nullptr) - { } - + WebContentsViewQt(content::WebContents* webContents); void setFactoryClient(WebContentsAdapterClient* client); void setClient(WebContentsAdapterClient* client); WebContentsAdapterClient *client() { return m_client; } @@ -128,10 +125,15 @@ public: void LostFocus(content::RenderWidgetHostImpl *render_widget_host) override; void TakeFocus(bool reverse) override; +private: + static void update(QWebEngineContextMenuRequest *request, + const content::ContextMenuParams ¶ms, bool spellcheckEnabled); + private: content::WebContents *m_webContents; WebContentsAdapterClient *m_client; WebContentsAdapterClient *m_factoryClient; + std::unique_ptr m_contextMenuRequest; }; } // namespace QtWebEngineCore -- cgit v1.2.3