diff options
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r-- | src/core/render_widget_host_view_qt.cpp | 97 |
1 files changed, 53 insertions, 44 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp index 3641398f6..e706c5869 100644 --- a/src/core/render_widget_host_view_qt.cpp +++ b/src/core/render_widget_host_view_qt.cpp @@ -58,6 +58,7 @@ #include "content/browser/browser_main_loop.h" #include "content/browser/frame_host/render_frame_host_impl.h" #include "content/browser/frame_host/frame_tree.h" +#include "content/browser/renderer_host/cursor_manager.h" #include "content/browser/renderer_host/render_view_host_impl.h" #include "content/common/cursors/webcursor.h" #include "content/common/input_messages.h" @@ -65,8 +66,8 @@ #include "content/public/browser/browser_thread.h" #include "content/public/common/content_switches.h" #include "third_party/skia/include/core/SkColor.h" -#include "third_party/WebKit/public/platform/WebColor.h" -#include "third_party/WebKit/public/platform/WebCursorInfo.h" +#include "third_party/blink/public/platform/web_color.h" +#include "third_party/blink/public/platform/web_cursor_info.h" #include "ui/base/clipboard/scoped_clipboard_writer.h" #include "ui/base/resource/resource_bundle.h" #include "ui/events/blink/blink_event_util.h" @@ -255,7 +256,7 @@ public: , dpiScale(dpiScale) { // ACTION_DOWN and ACTION_UP must be accesssed through pointer_index 0 - Q_ASSERT((action != ACTION_DOWN && action != ACTION_UP) || index == 0); + Q_ASSERT((action != Action::DOWN && action != Action::UP) || index == 0); } uint32_t GetUniqueEventId() const override { return eventId; } @@ -292,7 +293,7 @@ public: float GetHistoricalTouchMajor(size_t pointer_index, size_t historical_index) const override { return 0; } float GetHistoricalX(size_t pointer_index, size_t historical_index) const override { return 0; } float GetHistoricalY(size_t pointer_index, size_t historical_index) const override { return 0; } - ToolType GetToolType(size_t pointer_index) const override { return ui::MotionEvent::TOOL_TYPE_FINGER; } + ToolType GetToolType(size_t pointer_index) const override { return ui::MotionEvent::ToolType::FINGER; } int GetButtonState() const override { return 0; } private: @@ -319,7 +320,8 @@ bool isAccessibilityEnabled() { } RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget) - : m_host(content::RenderWidgetHostImpl::From(widget)) + : content::RenderWidgetHostViewBase::RenderWidgetHostViewBase(widget) + , m_host(content::RenderWidgetHostImpl::From(widget)) , m_gestureProvider(QtGestureProviderConfig(), this) , m_sendMotionActionDown(false) , m_touchMotionStarted(false) @@ -344,7 +346,7 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget { auto* task_runner = base::ThreadTaskRunnerHandle::Get().get(); m_beginFrameSource.reset(new viz::DelayBasedBeginFrameSource( - base::MakeUnique<viz::DelayBasedTimeSource>(task_runner), 0)); + std::make_unique<viz::DelayBasedTimeSource>(task_runner), 0)); m_host->SetView(this); #ifndef QT_NO_ACCESSIBILITY @@ -410,11 +412,6 @@ void RenderWidgetHostViewQt::InitAsFullscreen(content::RenderWidgetHostView*) { } -content::RenderWidgetHostImpl* RenderWidgetHostViewQt::GetRenderWidgetHostImpl() const -{ - return m_host; -} - void RenderWidgetHostViewQt::SetSize(const gfx::Size& size) { int width = size.width(); @@ -431,11 +428,12 @@ void RenderWidgetHostViewQt::SetBounds(const gfx::Rect& screenRect) SetSize(screenRect.size()); } -gfx::Vector2dF RenderWidgetHostViewQt::GetLastScrollOffset() const { - return m_lastScrollOffset; +gfx::Vector2d RenderWidgetHostViewQt::GetOffsetFromRootSurface() +{ + return gfx::Vector2d(); } -gfx::Size RenderWidgetHostViewQt::GetPhysicalBackingSize() const +gfx::Size RenderWidgetHostViewQt::GetCompositorViewportPixelSize() const { if (!m_delegate || !m_delegate->window() || !m_delegate->window()->screen()) return gfx::Size(); @@ -554,6 +552,11 @@ void RenderWidgetHostViewQt::UnlockMouse() void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor) { + DisplayCursor(webCursor); +} + +void RenderWidgetHostViewQt::DisplayCursor(const content::WebCursor &webCursor) +{ content::CursorInfo cursorInfo; webCursor.GetCursorInfo(&cursorInfo); Qt::CursorShape shape = Qt::ArrowCursor; @@ -620,6 +623,12 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor) case blink::WebCursorInfo::kTypeProgress: shape = Qt::BusyCursor; break; + case blink::WebCursorInfo::kTypeCopy: + shape = Qt::DragCopyCursor; + break; + case blink::WebCursorInfo::kTypeAlias: + shape = Qt::DragLinkCursor; + break; #if defined(USE_AURA) case blink::WebCursorInfo::kTypeVerticalText: auraType = ui::CursorType::kVerticalText; @@ -630,12 +639,6 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor) case blink::WebCursorInfo::kTypeContextMenu: auraType = ui::CursorType::kContextMenu; break; - case blink::WebCursorInfo::kTypeAlias: - auraType = ui::CursorType::kAlias; - break; - case blink::WebCursorInfo::kTypeCopy: - auraType = ui::CursorType::kCopy; - break; case blink::WebCursorInfo::kTypeZoomIn: auraType = ui::CursorType::kZoomIn; break; @@ -646,8 +649,6 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor) case blink::WebCursorInfo::kTypeVerticalText: case blink::WebCursorInfo::kTypeCell: case blink::WebCursorInfo::kTypeContextMenu: - case blink::WebCursorInfo::kTypeAlias: - case blink::WebCursorInfo::kTypeCopy: case blink::WebCursorInfo::kTypeZoomIn: case blink::WebCursorInfo::kTypeZoomOut: // FIXME: Support on OS X @@ -740,13 +741,13 @@ void RenderWidgetHostViewQt::Destroy() void RenderWidgetHostViewQt::SetTooltipText(const base::string16 &tooltip_text) { - if (m_adapterClient) - m_adapterClient->setToolTip(toQt(tooltip_text)); + DisplayTooltipText(tooltip_text); } -bool RenderWidgetHostViewQt::HasAcceleratedSurface(const gfx::Size&) +void RenderWidgetHostViewQt::DisplayTooltipText(const base::string16 &tooltip_text) { - return false; + if (m_adapterClient) + m_adapterClient->setToolTip(toQt(tooltip_text)); } void RenderWidgetHostViewQt::DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient *frameSink) @@ -800,9 +801,9 @@ void RenderWidgetHostViewQt::SubmitCompositorFrame(const viz::LocalSurfaceId &lo m_adapterClient->updateContentsSize(toQt(m_lastContentsSize)); } -void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo* results) +void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo *results) const { - QWindow* window = m_delegate->window(); + QWindow *window = m_delegate->window(); if (!window) return; GetScreenInfoFromNativeWindow(window, results); @@ -886,13 +887,13 @@ void RenderWidgetHostViewQt::OnTextSelectionChanged(content::TextInputManager *t if (!selection) return; -#if defined(USE_X11) +#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::CLIPBOARD_TYPE_SELECTION); clipboard_writer.WriteText(selection->selected_text()); } -#endif // defined(USE_X11) +#endif // defined(USE_OZONE) m_imState |= ImStateFlags::TextSelectionUpdated; if (m_imState == ImStateFlags::AllFlags @@ -1149,10 +1150,12 @@ QVariant RenderWidgetHostViewQt::inputMethodQuery(Qt::InputMethodQuery query) case Qt::ImCursorRectangle: { if (text_input_manager_) { if (auto *region = text_input_manager_->GetSelectionRegion()) { - gfx::Rect caretRect = gfx::RectBetweenSelectionBounds(region->anchor, region->focus); - if (caretRect.width() == 0) - caretRect.set_width(1); // IME API on Windows expects a width > 0 - return toQt(caretRect); + if (region->focus.GetHeight() > 0) { + gfx::Rect caretRect = gfx::RectBetweenSelectionBounds(region->anchor, region->focus); + if (caretRect.width() == 0) + caretRect.set_width(1); // IME API on Windows expects a width > 0 + return toQt(caretRect); + } } } return QVariant(); @@ -1206,7 +1209,8 @@ void RenderWidgetHostViewQt::processMotionEvent(const ui::MotionEvent &motionEve return; blink::WebTouchEvent touchEvent = ui::CreateWebTouchEventFromMotionEvent(motionEvent, - result.moved_beyond_slop_region); + result.moved_beyond_slop_region, + false /*hovering, FIXME ?*/); m_host->ForwardTouchEventWithLatencyInfo(touchEvent, CreateLatencyInfo(touchEvent)); } @@ -1340,7 +1344,7 @@ void RenderWidgetHostViewQt::handleInputMethodEvent(QInputMethodEvent *ev) if (format.underlineStyle() != QTextCharFormat::NoUnderline) underlineColor = format.underlineColor(); - underlines.push_back(ui::ImeTextSpan(ui::ImeTextSpan::Type::kComposition, start, end, toSk(underlineColor), /*thick*/ false, SK_ColorTRANSPARENT)); + underlines.push_back(ui::ImeTextSpan(ui::ImeTextSpan::Type::kComposition, start, end, ui::ImeTextSpan::Thickness::kThin, toSk(underlineColor), SK_ColorTRANSPARENT)); break; } case QInputMethodEvent::Cursor: @@ -1569,7 +1573,7 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) if (touchPoints.isEmpty()) touchPoints = m_previousTouchPoints; clearPreviousTouchMotionState(); - MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::ACTION_CANCEL, + MotionEventQt cancelEvent(touchPoints, eventTimestamp, ui::MotionEvent::Action::CANCEL, ev->modifiers(), dpiScale()); processMotionEvent(cancelEvent); return; @@ -1604,18 +1608,18 @@ void RenderWidgetHostViewQt::handleTouchEvent(QTouchEvent *ev) switch (touchPoints[i].state()) { case Qt::TouchPointPressed: if (m_sendMotionActionDown) { - action = ui::MotionEvent::ACTION_DOWN; + action = ui::MotionEvent::Action::DOWN; m_sendMotionActionDown = false; } else { - action = ui::MotionEvent::ACTION_POINTER_DOWN; + action = ui::MotionEvent::Action::POINTER_DOWN; } break; case Qt::TouchPointMoved: - action = ui::MotionEvent::ACTION_MOVE; + action = ui::MotionEvent::Action::MOVE; break; case Qt::TouchPointReleased: - action = touchPoints.size() > 1 ? ui::MotionEvent::ACTION_POINTER_UP : - ui::MotionEvent::ACTION_UP; + action = touchPoints.size() > 1 ? ui::MotionEvent::Action::POINTER_UP : + ui::MotionEvent::Action::UP; break; default: // Ignore Qt::TouchPointStationary @@ -1733,8 +1737,6 @@ bool RenderWidgetHostViewQt::OnBeginFrameDerivedImpl(const viz::BeginFrameArgs& m_beginFrameSource->OnUpdateVSyncParameters(args.frame_time, args.interval); if (m_rendererCompositorFrameSink) m_rendererCompositorFrameSink->OnBeginFrame(args); - else // FIXME: is this else part ever needed? - m_host->Send(new ViewMsg_BeginFrame(m_host->GetRoutingID(), args)); return true; } @@ -1775,4 +1777,11 @@ viz::SurfaceId RenderWidgetHostViewQt::GetCurrentSurfaceId() const return viz::SurfaceId(); } +void RenderWidgetHostViewQt::TakeFallbackContentFrom(content::RenderWidgetHostView *view) +{ + DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewChildFrame()); + DCHECK(!static_cast<RenderWidgetHostViewBase*>(view)->IsRenderWidgetHostViewGuest()); + SetBackgroundColor(view->background_color()); +} + } // namespace QtWebEngineCore |