From 5dc3a3fb5e3286a9643fece7c7f94cec7fc29f3e Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Sat, 4 Sep 2021 11:31:59 +0200 Subject: Adaptations for Chromium 92 Change-Id: I1849c130ca75615802744275f6e4212a755c39b4 Reviewed-by: Michal Klocek --- src/core/render_widget_host_view_qt.cpp | 43 +++++++++++++++++++++------------ 1 file changed, 27 insertions(+), 16 deletions(-) (limited to 'src/core/render_widget_host_view_qt.cpp') diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 4e2ab2ea9..791e9d75e 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -597,6 +597,11 @@ void RenderWidgetHostViewQt::DisplayCursor(const content::WebCursor &webCursor) if (updateCursorFromResource(cursorInfo.type())) return; break; + case ui::mojom::CursorType::kEastWestNoResize: + case ui::mojom::CursorType::kNorthEastSouthWestNoResize: + case ui::mojom::CursorType::kNorthSouthNoResize: + case ui::mojom::CursorType::kNorthWestSouthEastNoResize: + // Use forbidden cursor matching webcursor_mac.mm and win_cursor_factory.cc case ui::mojom::CursorType::kNoDrop: case ui::mojom::CursorType::kNotAllowed: shape = Qt::ForbiddenCursor; @@ -664,12 +669,12 @@ void RenderWidgetHostViewQt::Destroy() delete this; } -void RenderWidgetHostViewQt::SetTooltipText(const std::u16string &tooltip_text) +void RenderWidgetHostViewQt::UpdateTooltipUnderCursor(const std::u16string &tooltip_text) { - DisplayTooltipText(tooltip_text); + UpdateTooltip(tooltip_text); } -void RenderWidgetHostViewQt::DisplayTooltipText(const std::u16string &tooltip_text) +void RenderWidgetHostViewQt::UpdateTooltip(const std::u16string &tooltip_text) { if (host()->delegate() && m_adapterClient) m_adapterClient->setToolTip(toQt(tooltip_text)); @@ -748,15 +753,22 @@ void RenderWidgetHostViewQt::OnTextSelectionChanged(content::TextInputManager *t Q_UNUSED(text_input_manager); Q_UNUSED(updated_view); - const content::TextInputManager::TextSelection *selection = GetTextInputManager()->GetTextSelection(updated_view); - if (!selection) - return; + // We obtain the TextSelection from focused RWH which is obtained from the + // frame tree. + content::RenderWidgetHostViewBase *focused_view = + GetFocusedWidget() ? GetFocusedWidget()->GetView() : nullptr; + + if (!focused_view) + return; #if defined(USE_OZONE) - if (!selection->selected_text().empty() && selection->user_initiated()) { - // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. - ui::ScopedClipboardWriter clipboard_writer(ui::ClipboardBuffer::kSelection); - clipboard_writer.WriteText(selection->selected_text()); + if (ui::Clipboard::IsSupportedClipboardBuffer(ui::ClipboardBuffer::kSelection)) { + const content::TextInputManager::TextSelection *selection = GetTextInputManager()->GetTextSelection(focused_view); + if (selection->selected_text().length() && selection->user_initiated()) { + // Set the ClipboardBuffer::kSelection to the ui::Clipboard. + ui::ScopedClipboardWriter clipboard_writer(ui::ClipboardBuffer::kSelection); + clipboard_writer.WriteText(selection->selected_text()); + } } #endif // defined(USE_OZONE) @@ -988,9 +1000,8 @@ void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostVi { DCHECK(!static_cast(view)->IsRenderWidgetHostViewChildFrame()); RenderWidgetHostViewQt *viewQt = static_cast(view); - base::Optional color = viewQt->GetBackgroundColor(); - if (color) - SetBackgroundColor(*color); + CopyBackgroundColorIfPresentFrom(*viewQt); + m_delegatedFrameHost->TakeFallbackContentFrom(viewQt->m_delegatedFrameHost.get()); host()->GetContentRenderingTimeoutFrom(viewQt->host()); } @@ -1029,7 +1040,7 @@ void RenderWidgetHostViewQt::OnRenderFrameMetadataChangedAfterActivation(base::T m_adapterClient->updateContentsSize(toQt(m_lastContentsSize)); } -void RenderWidgetHostViewQt::synchronizeVisualProperties(const base::Optional &childSurfaceId) +void RenderWidgetHostViewQt::synchronizeVisualProperties(const absl::optional &childSurfaceId) { if (childSurfaceId) m_dfhLocalSurfaceIdAllocator.UpdateFromChild(*childSurfaceId); @@ -1062,9 +1073,9 @@ ui::Compositor *RenderWidgetHostViewQt::GetCompositor() return m_uiCompositor.get(); } -base::Optional RenderWidgetHostViewQt::GetDisplayFeature() +absl::optional RenderWidgetHostViewQt::GetDisplayFeature() { - return base::nullopt; + return absl::nullopt; } void RenderWidgetHostViewQt::SetDisplayFeatureForTesting(const content::DisplayFeature *) -- cgit v1.2.3