summaryrefslogtreecommitdiffstats
path: root/src/core/web_contents_view_qt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/web_contents_view_qt.cpp')
-rw-r--r--src/core/web_contents_view_qt.cpp156
1 files changed, 54 insertions, 102 deletions
diff --git a/src/core/web_contents_view_qt.cpp b/src/core/web_contents_view_qt.cpp
index 1ab09895f..023f9e99f 100644
--- a/src/core/web_contents_view_qt.cpp
+++ b/src/core/web_contents_view_qt.cpp
@@ -1,70 +1,38 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the QtWebEngine module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 3 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL3 included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 3 requirements
-** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 2.0 or (at your option) the GNU General
-** Public license version 3 or any later version approved by the KDE Free
-** Qt Foundation. The licenses are as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-2.0.html and
-** https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "web_contents_view_qt.h"
-#include "profile_adapter.h"
-#include "content_browser_client_qt.h"
#include "render_widget_host_view_qt.h"
#include "render_widget_host_view_qt_delegate.h"
-#include "render_widget_host_view_qt.h"
#include "touch_selection_controller_client_qt.h"
#include "type_conversion.h"
-#include "web_contents_adapter_client.h"
#include "web_contents_adapter.h"
-#include "web_engine_context.h"
-#include "web_contents_delegate_qt.h"
+#include "web_contents_adapter_client.h"
-#include "components/spellcheck/spellcheck_buildflags.h"
-#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/browser/renderer_host/render_widget_host_impl.h"
#include "content/browser/web_contents/web_contents_impl.h"
#include "content/public/browser/context_menu_params.h"
#include "content/public/browser/web_contents_delegate.h"
+#include "third_party/blink/public/common/context_menu_data/context_menu_data.h"
#include "third_party/blink/public/common/context_menu_data/edit_flags.h"
-#include "third_party/blink/public/common/context_menu_data/media_type.h"
+#include "third_party/blink/public/mojom/context_menu/context_menu.mojom.h"
+
#include "ui/gfx/image/image_skia.h"
-#include <QtGui/qpixmap.h>
+#include <QtGui/QPixmap>
+#include <QtWebEngineCore/private/qwebenginecontextmenurequest_p.h>
namespace QtWebEngineCore {
+WebContentsViewQt::WebContentsViewQt(content::WebContents *webContents)
+ : m_webContents(webContents)
+ , m_client(nullptr)
+ , m_factoryClient(nullptr)
+ , m_contextMenuRequest(
+ new QWebEngineContextMenuRequest(new QWebEngineContextMenuRequestPrivate()))
+{
+}
+
void WebContentsViewQt::setFactoryClient(WebContentsAdapterClient* client)
{
if (m_factoryClient)
@@ -122,12 +90,13 @@ gfx::NativeView WebContentsViewQt::GetNativeView() const
return nullptr;
}
-void WebContentsViewQt::GetContainerBounds(gfx::Rect* out) const
+gfx::Rect WebContentsViewQt::GetContainerBounds() const
{
if (m_client) {
const QRectF r(m_client->viewportRect());
- *out = gfx::Rect(r.x(), r.y(), r.width(), r.height());
+ return gfx::Rect(r.x(), r.y(), r.width(), r.height());
}
+ return gfx::Rect();
}
void WebContentsViewQt::Focus()
@@ -147,51 +116,42 @@ void WebContentsViewQt::SetInitialFocus()
void WebContentsViewQt::FocusThroughTabTraversal(bool reverse)
{
content::WebContentsImpl *web_contents = static_cast<content::WebContentsImpl*>(m_webContents);
- if (web_contents->ShowingInterstitialPage()) {
- web_contents->GetInterstitialPage()->FocusThroughTabTraversal(reverse);
- return;
- }
- content::RenderWidgetHostView *fullscreen_view = web_contents->GetFullscreenRenderWidgetHostView();
- if (fullscreen_view) {
- fullscreen_view->Focus();
- return;
- }
web_contents->GetRenderViewHost()->SetInitialFocus(reverse);
}
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeNone,
- blink::ContextMenuDataMediaType::kNone)
+ blink::mojom::ContextMenuDataMediaType::kNone)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeImage,
- blink::ContextMenuDataMediaType::kImage)
+ blink::mojom::ContextMenuDataMediaType::kImage)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeVideo,
- blink::ContextMenuDataMediaType::kVideo)
+ blink::mojom::ContextMenuDataMediaType::kVideo)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeAudio,
- blink::ContextMenuDataMediaType::kAudio)
+ blink::mojom::ContextMenuDataMediaType::kAudio)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeCanvas,
- blink::ContextMenuDataMediaType::kCanvas)
+ blink::mojom::ContextMenuDataMediaType::kCanvas)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypeFile,
- blink::ContextMenuDataMediaType::kFile)
+ blink::mojom::ContextMenuDataMediaType::kFile)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaTypePlugin,
- blink::ContextMenuDataMediaType::kPlugin)
+ blink::mojom::ContextMenuDataMediaType::kPlugin)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaInError,
- blink::WebContextMenuData::kMediaInError)
+ blink::ContextMenuData::kMediaInError)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaPaused,
- blink::WebContextMenuData::kMediaPaused)
-ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaMuted, blink::WebContextMenuData::kMediaMuted)
-ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaLoop, blink::WebContextMenuData::kMediaLoop)
+ blink::ContextMenuData::kMediaPaused)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaMuted, blink::ContextMenuData::kMediaMuted)
+ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaLoop, blink::ContextMenuData::kMediaLoop)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanSave,
- blink::WebContextMenuData::kMediaCanSave)
+ blink::ContextMenuData::kMediaCanSave)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaHasAudio,
- blink::WebContextMenuData::kMediaHasAudio)
+ blink::ContextMenuData::kMediaHasAudio)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanToggleControls,
- blink::WebContextMenuData::kMediaCanToggleControls)
+ blink::ContextMenuData::kMediaCanToggleControls)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaControls,
- blink::WebContextMenuData::kMediaControls)
+ blink::ContextMenuData::kMediaControls)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanPrint,
- blink::WebContextMenuData::kMediaCanPrint)
+ blink::ContextMenuData::kMediaCanPrint)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::MediaCanRotate,
- blink::WebContextMenuData::kMediaCanRotate)
+ blink::ContextMenuData::kMediaCanRotate)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanUndo, blink::kCanUndo)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanRedo, blink::kCanRedo)
@@ -203,33 +163,24 @@ ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanSelectAll, blink::kCanSelect
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanTranslate, blink::kCanTranslate)
ASSERT_ENUMS_MATCH(QWebEngineContextMenuRequest::CanEditRichly, blink::kCanEditRichly)
-
-WebContentsViewQt::WebContentsViewQt(content::WebContents* webContents)
-: m_webContents(webContents)
- , m_client(nullptr)
- , m_factoryClient(nullptr)
- , m_contextMenuRequest(
- new QWebEngineContextMenuRequest(new QWebEngineContextMenuRequestPrivate()))
-{ }
-
-
+// static
void WebContentsViewQt::update(QWebEngineContextMenuRequest *request,
const content::ContextMenuParams &params, bool spellcheckEnabled)
{
auto *re = request->d.data();
re->m_position = QPoint(params.x, params.y);
re->m_filteredLinkUrl = toQt(params.link_url);
- re->m_linkText = toQt(params.link_text.data());
- re->m_altText = toQt(params.alt_text.data());
- re->m_titleText = toQt(params.title_text.data());
+ re->m_linkText = toQt(params.link_text);
+ re->m_altText = toQt(params.alt_text);
+ re->m_titleText = toQt(params.title_text);
re->m_unfilteredLinkUrl = toQt(params.unfiltered_link_url);
- re->m_selectedText = toQt(params.selection_text.data());
+ re->m_selectedText = toQt(params.selection_text);
re->m_mediaUrl = toQt(params.src_url);
re->m_mediaType = (QWebEngineContextMenuRequest::MediaType)params.media_type;
re->m_hasImageContent = params.has_image_contents;
re->m_mediaFlags = (QWebEngineContextMenuRequest::MediaFlags)params.media_flags;
re->m_editFlags = (QWebEngineContextMenuRequest::EditFlags)params.edit_flags;
- re->m_suggestedFileName = toQt(params.suggested_filename.data());
+ re->m_suggestedFileName = toQt(params.suggested_filename);
re->m_isEditable = params.is_editable;
#if QT_CONFIG(webengine_spellchecker)
re->m_misspelledWord = toQt(params.misspelled_word);
@@ -250,7 +201,7 @@ void WebContentsViewQt::update(QWebEngineContextMenuRequest *request,
#endif
}
-void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *,
+void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost &,
const content::ContextMenuParams &params)
{
if (auto rwhv =
@@ -263,24 +214,25 @@ void WebContentsViewQt::ShowContextMenu(content::RenderFrameHost *,
m_client->contextMenuRequested(m_contextMenuRequest.get());
}
-Qt::DropActions toQtDropActions(blink::WebDragOperationsMask ops)
+static Qt::DropActions toQtDropActions(blink::DragOperationsMask ops)
{
Qt::DropActions result;
- if (ops & blink::kWebDragOperationCopy)
+ if (ops & blink::kDragOperationCopy)
result |= Qt::CopyAction;
- if (ops & blink::kWebDragOperationLink)
+ if (ops & blink::kDragOperationLink)
result |= Qt::LinkAction;
- if (ops & blink::kWebDragOperationMove || ops & blink::kWebDragOperationDelete)
+ if (ops & blink::kDragOperationMove)
result |= Qt::MoveAction;
return result;
}
void WebContentsViewQt::StartDragging(const content::DropData &drop_data,
- blink::WebDragOperationsMask allowed_ops,
+ blink::DragOperationsMask allowed_ops,
const gfx::ImageSkia &image,
const gfx::Vector2d &image_offset,
- const content::DragEventSourceInfo &event_info,
- content::RenderWidgetHostImpl* source_rwh)
+ const gfx::Rect &drag_obj_rect,
+ const blink::mojom::DragEventSourceInfo &event_info,
+ content::RenderWidgetHostImpl *source_rwh)
{
#if QT_CONFIG(draganddrop)
Q_UNUSED(event_info);
@@ -304,10 +256,10 @@ void WebContentsViewQt::StartDragging(const content::DropData &drop_data,
#endif // QT_CONFIG(draganddrop)
}
-void WebContentsViewQt::UpdateDragCursor(blink::WebDragOperation dragOperation)
+void WebContentsViewQt::UpdateDragCursor(ui::mojom::DragOperation dragOperation)
{
#if QT_CONFIG(draganddrop)
- m_client->webContentsAdapter()->updateDragAction(dragOperation);
+ m_client->webContentsAdapter()->updateDragAction(int(dragOperation));
#endif // QT_CONFIG(draganddrop)
}