summaryrefslogtreecommitdiffstats
path: root/src/core/render_widget_host_view_qt.cpp
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-09-14 10:07:07 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-09-14 18:54:49 +0200
commita3c77682ce67420ac3fba4d81847bbe170b387eb (patch)
treec22938dae751405e5f78881a7683ab3176c77a5c /src/core/render_widget_host_view_qt.cpp
parentd3882688a8fd70ccd4c42afd2485c3b5d3810547 (diff)
parent1c6d01b846f2152e7215c98cfa09e668c880da7e (diff)
Merge remote-tracking branch 'origin/5.15' into dev
Conflicts: src/3rdparty src/core/certificate_error_controller.cpp src/core/certificate_error_controller.h src/core/compositor/compositor.cpp src/core/compositor/compositor.h src/core/compositor/display_gl_output_surface.cpp src/core/content_browser_client_qt.cpp src/core/core_chromium.pri src/core/delegated_frame_host_client_qt.cpp src/core/ozone/gl_share_context_qt.h src/core/ozone/surface_factory_qt.cpp src/core/permission_manager_qt.cpp src/core/render_widget_host_view_qt.cpp src/core/render_widget_host_view_qt.h src/core/web_engine_context.cpp src/core/web_engine_settings.cpp src/core/web_event_factory.cpp tests/auto/widgets/qwebenginedownloadrequest/tst_qwebenginedownloadrequest.cpp Change-Id: Ice14c3c350b139e800c7c7011b7cef1fc7010669
Diffstat (limited to 'src/core/render_widget_host_view_qt.cpp')
-rw-r--r--src/core/render_widget_host_view_qt.cpp219
1 files changed, 118 insertions, 101 deletions
diff --git a/src/core/render_widget_host_view_qt.cpp b/src/core/render_widget_host_view_qt.cpp
index 9be6fac9a..fbb4c5bd6 100644
--- a/src/core/render_widget_host_view_qt.cpp
+++ b/src/core/render_widget_host_view_qt.cpp
@@ -56,17 +56,18 @@
#include "components/viz/common/frame_sinks/begin_frame_source.h"
#include "components/viz/common/surfaces/frame_sink_id_allocator.h"
#include "components/viz/host/host_frame_sink_manager.h"
+#include "content/browser/compositor/image_transport_factory.h"
#include "content/browser/frame_host/frame_tree.h"
#include "content/browser/frame_host/render_frame_host_impl.h"
#include "content/browser/renderer_host/input/synthetic_gesture_target.h"
#include "content/browser/renderer_host/render_view_host_delegate.h"
#include "content/browser/renderer_host/render_view_host_impl.h"
-#include "content/common/content_switches_internal.h"
#include "content/browser/renderer_host/render_widget_host_input_event_router.h"
+#include "content/common/content_switches_internal.h"
#include "content/common/cursors/webcursor.h"
#include "content/common/input_messages.h"
#include "third_party/skia/include/core/SkColor.h"
-#include "third_party/blink/public/platform/web_cursor_info.h"
+#include "ui/base/cursor/cursor.h"
#include "ui/events/blink/blink_event_util.h"
#include "ui/events/event.h"
#include "ui/events/gesture_detection/gesture_configuration.h"
@@ -78,7 +79,7 @@
#endif
#if defined(USE_AURA)
-#include "ui/base/cursor/cursor.h"
+#include "ui/base/cursor/cursor_size.h"
#include "ui/base/cursor/cursors_aura.h"
#include "ui/base/resource/resource_bundle.h"
#endif
@@ -118,6 +119,33 @@ static inline ui::GestureProvider::Config QtGestureProviderConfig() {
return config;
}
+// An minimal override to support progressing flings
+class FlingingCompositor : public ui::Compositor
+{
+ RenderWidgetHostViewQt *m_rwhv;
+public:
+ FlingingCompositor(RenderWidgetHostViewQt *rwhv,
+ const viz::FrameSinkId &frame_sink_id,
+ ui::ContextFactory *context_factory,
+ scoped_refptr<base::SingleThreadTaskRunner> task_runner,
+ bool enable_pixel_canvas,
+ bool use_external_begin_frame_control = false,
+ bool force_software_compositor = false)
+ : ui::Compositor(frame_sink_id, context_factory,
+ task_runner, enable_pixel_canvas,
+ use_external_begin_frame_control,
+ force_software_compositor)
+ , m_rwhv(rwhv)
+ {}
+
+ void BeginMainFrame(const viz::BeginFrameArgs &args) override
+ {
+ if (args.type != viz::BeginFrameArgs::MISSED && !m_rwhv->is_currently_scrolling_viewport())
+ m_rwhv->host()->ProgressFlingIfNeeded(args.frame_time);
+ ui::Compositor::BeginMainFrame(args);
+ }
+};
+
RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget)
: content::RenderWidgetHostViewBase::RenderWidgetHostViewBase(widget)
, m_taskRunner(base::ThreadTaskRunnerHandle::Get())
@@ -138,11 +166,10 @@ RenderWidgetHostViewQt::RenderWidgetHostViewQt(content::RenderWidgetHost *widget
content::ImageTransportFactory *imageTransportFactory = content::ImageTransportFactory::GetInstance();
ui::ContextFactory *contextFactory = imageTransportFactory->GetContextFactory();
- ui::ContextFactoryPrivate *contextFactoryPrivate = imageTransportFactory->GetContextFactoryPrivate();
- m_uiCompositor.reset(new ui::Compositor(
- contextFactoryPrivate->AllocateFrameSinkId(),
+ m_uiCompositor.reset(new FlingingCompositor(
+ this,
+ contextFactory->AllocateFrameSinkId(),
contextFactory,
- contextFactoryPrivate,
m_taskRunner,
false /* enable_pixel_canvas */));
m_uiCompositor->SetAcceleratedWidget(gfx::kNullAcceleratedWidget); // null means offscreen
@@ -320,17 +347,30 @@ void RenderWidgetHostViewQt::UpdateBackgroundColor()
m_uiCompositor->SetBackgroundColor(color);
content::RenderViewHost *rvh = content::RenderViewHost::From(host());
- host()->Send(new RenderViewObserverQt_SetBackgroundColor(rvh->GetRoutingID(), color));
+ if (color == SK_ColorTRANSPARENT)
+ host()->owner_delegate()->SetBackgroundOpaque(false);
+ else
+ host()->Send(new RenderViewObserverQt_SetBackgroundColor(rvh->GetRoutingID(), color));
}
// Return value indicates whether the mouse is locked successfully or not.
-bool RenderWidgetHostViewQt::LockMouse(bool)
+blink::mojom::PointerLockResult RenderWidgetHostViewQt::LockMouse(bool request_unadjusted_movement)
{
+ if (request_unadjusted_movement)
+ return blink::mojom::PointerLockResult::kUnsupportedOptions;
+
delegateClient()->resetPreviousMousePosition();
m_delegate->lockMouse();
m_isMouseLocked = true;
qApp->setOverrideCursor(Qt::BlankCursor);
- return true;
+ return blink::mojom::PointerLockResult::kSuccess;
+}
+
+blink::mojom::PointerLockResult RenderWidgetHostViewQt::ChangeMouseLock(bool request_unadjusted_movement)
+{
+ if (request_unadjusted_movement)
+ return blink::mojom::PointerLockResult::kUnsupportedOptions;
+ return blink::mojom::PointerLockResult::kSuccess;
}
void RenderWidgetHostViewQt::UnlockMouse()
@@ -348,134 +388,134 @@ void RenderWidgetHostViewQt::UpdateCursor(const content::WebCursor &webCursor)
void RenderWidgetHostViewQt::DisplayCursor(const content::WebCursor &webCursor)
{
- const content::CursorInfo &cursorInfo = webCursor.info();
+ const ui::Cursor &cursorInfo = webCursor.cursor();
Qt::CursorShape shape = Qt::ArrowCursor;
#if defined(USE_AURA)
- ui::CursorType auraType = ui::CursorType::kNull;
+ ui::mojom::CursorType auraType = ui::mojom::CursorType::kNull;
#endif
- switch (cursorInfo.type) {
- case ui::CursorType::kNull:
- case ui::CursorType::kPointer:
+ switch (cursorInfo.type()) {
+ case ui::mojom::CursorType::kNull:
+ case ui::mojom::CursorType::kPointer:
shape = Qt::ArrowCursor;
break;
- case ui::CursorType::kCross:
+ case ui::mojom::CursorType::kCross:
shape = Qt::CrossCursor;
break;
- case ui::CursorType::kHand:
+ case ui::mojom::CursorType::kHand:
shape = Qt::PointingHandCursor;
break;
- case ui::CursorType::kIBeam:
+ case ui::mojom::CursorType::kIBeam:
shape = Qt::IBeamCursor;
break;
- case ui::CursorType::kWait:
+ case ui::mojom::CursorType::kWait:
shape = Qt::WaitCursor;
break;
- case ui::CursorType::kHelp:
+ case ui::mojom::CursorType::kHelp:
shape = Qt::WhatsThisCursor;
break;
- case ui::CursorType::kEastResize:
- case ui::CursorType::kWestResize:
- case ui::CursorType::kEastWestResize:
- case ui::CursorType::kEastPanning:
- case ui::CursorType::kWestPanning:
- case ui::CursorType::kMiddlePanningHorizontal:
+ case ui::mojom::CursorType::kEastResize:
+ case ui::mojom::CursorType::kWestResize:
+ case ui::mojom::CursorType::kEastWestResize:
+ case ui::mojom::CursorType::kEastPanning:
+ case ui::mojom::CursorType::kWestPanning:
+ case ui::mojom::CursorType::kMiddlePanningHorizontal:
shape = Qt::SizeHorCursor;
break;
- case ui::CursorType::kNorthResize:
- case ui::CursorType::kSouthResize:
- case ui::CursorType::kNorthSouthResize:
- case ui::CursorType::kNorthPanning:
- case ui::CursorType::kSouthPanning:
- case ui::CursorType::kMiddlePanningVertical:
+ case ui::mojom::CursorType::kNorthResize:
+ case ui::mojom::CursorType::kSouthResize:
+ case ui::mojom::CursorType::kNorthSouthResize:
+ case ui::mojom::CursorType::kNorthPanning:
+ case ui::mojom::CursorType::kSouthPanning:
+ case ui::mojom::CursorType::kMiddlePanningVertical:
shape = Qt::SizeVerCursor;
break;
- case ui::CursorType::kNorthEastResize:
- case ui::CursorType::kSouthWestResize:
- case ui::CursorType::kNorthEastSouthWestResize:
- case ui::CursorType::kNorthEastPanning:
- case ui::CursorType::kSouthWestPanning:
+ case ui::mojom::CursorType::kNorthEastResize:
+ case ui::mojom::CursorType::kSouthWestResize:
+ case ui::mojom::CursorType::kNorthEastSouthWestResize:
+ case ui::mojom::CursorType::kNorthEastPanning:
+ case ui::mojom::CursorType::kSouthWestPanning:
shape = Qt::SizeBDiagCursor;
break;
- case ui::CursorType::kNorthWestResize:
- case ui::CursorType::kSouthEastResize:
- case ui::CursorType::kNorthWestSouthEastResize:
- case ui::CursorType::kNorthWestPanning:
- case ui::CursorType::kSouthEastPanning:
+ case ui::mojom::CursorType::kNorthWestResize:
+ case ui::mojom::CursorType::kSouthEastResize:
+ case ui::mojom::CursorType::kNorthWestSouthEastResize:
+ case ui::mojom::CursorType::kNorthWestPanning:
+ case ui::mojom::CursorType::kSouthEastPanning:
shape = Qt::SizeFDiagCursor;
break;
- case ui::CursorType::kColumnResize:
+ case ui::mojom::CursorType::kColumnResize:
shape = Qt::SplitHCursor;
break;
- case ui::CursorType::kRowResize:
+ case ui::mojom::CursorType::kRowResize:
shape = Qt::SplitVCursor;
break;
- case ui::CursorType::kMiddlePanning:
- case ui::CursorType::kMove:
+ case ui::mojom::CursorType::kMiddlePanning:
+ case ui::mojom::CursorType::kMove:
shape = Qt::SizeAllCursor;
break;
- case ui::CursorType::kProgress:
+ case ui::mojom::CursorType::kProgress:
shape = Qt::BusyCursor;
break;
- case ui::CursorType::kDndNone:
- case ui::CursorType::kDndMove:
+ case ui::mojom::CursorType::kDndNone:
+ case ui::mojom::CursorType::kDndMove:
shape = Qt::DragMoveCursor;
break;
- case ui::CursorType::kDndCopy:
- case ui::CursorType::kCopy:
+ case ui::mojom::CursorType::kDndCopy:
+ case ui::mojom::CursorType::kCopy:
shape = Qt::DragCopyCursor;
break;
- case ui::CursorType::kDndLink:
- case ui::CursorType::kAlias:
+ case ui::mojom::CursorType::kDndLink:
+ case ui::mojom::CursorType::kAlias:
shape = Qt::DragLinkCursor;
break;
#if defined(USE_AURA)
- case ui::CursorType::kVerticalText:
- auraType = ui::CursorType::kVerticalText;
+ case ui::mojom::CursorType::kVerticalText:
+ auraType = ui::mojom::CursorType::kVerticalText;
break;
- case ui::CursorType::kCell:
- auraType = ui::CursorType::kCell;
+ case ui::mojom::CursorType::kCell:
+ auraType = ui::mojom::CursorType::kCell;
break;
- case ui::CursorType::kContextMenu:
- auraType = ui::CursorType::kContextMenu;
+ case ui::mojom::CursorType::kContextMenu:
+ auraType = ui::mojom::CursorType::kContextMenu;
break;
- case ui::CursorType::kZoomIn:
- auraType = ui::CursorType::kZoomIn;
+ case ui::mojom::CursorType::kZoomIn:
+ auraType = ui::mojom::CursorType::kZoomIn;
break;
- case ui::CursorType::kZoomOut:
- auraType = ui::CursorType::kZoomOut;
+ case ui::mojom::CursorType::kZoomOut:
+ auraType = ui::mojom::CursorType::kZoomOut;
break;
#else
- case ui::CursorType::kVerticalText:
- case ui::CursorType::kCell:
- case ui::CursorType::kContextMenu:
- case ui::CursorType::kZoomIn:
- case ui::CursorType::kZoomOut:
+ case ui::mojom::CursorType::kVerticalText:
+ case ui::mojom::CursorType::kCell:
+ case ui::mojom::CursorType::kContextMenu:
+ case ui::mojom::CursorType::kZoomIn:
+ case ui::mojom::CursorType::kZoomOut:
// FIXME: Support on OS X
break;
#endif
- case ui::CursorType::kNoDrop:
- case ui::CursorType::kNotAllowed:
+ case ui::mojom::CursorType::kNoDrop:
+ case ui::mojom::CursorType::kNotAllowed:
shape = Qt::ForbiddenCursor;
break;
- case ui::CursorType::kNone:
+ case ui::mojom::CursorType::kNone:
shape = Qt::BlankCursor;
break;
- case ui::CursorType::kGrab:
+ case ui::mojom::CursorType::kGrab:
shape = Qt::OpenHandCursor;
break;
- case ui::CursorType::kGrabbing:
+ case ui::mojom::CursorType::kGrabbing:
shape = Qt::ClosedHandCursor;
break;
- case ui::CursorType::kCustom:
- if (cursorInfo.custom_image.colorType() == SkColorType::kN32_SkColorType) {
- QImage cursor = toQImage(cursorInfo.custom_image, QImage::Format_ARGB32);
- m_delegate->updateCursor(QCursor(QPixmap::fromImage(cursor), cursorInfo.hotspot.x(), cursorInfo.hotspot.y()));
+ case ui::mojom::CursorType::kCustom:
+ if (cursorInfo.custom_bitmap().colorType() == SkColorType::kN32_SkColorType) {
+ QImage cursor = toQImage(cursorInfo.custom_bitmap(), QImage::Format_ARGB32);
+ m_delegate->updateCursor(QCursor(QPixmap::fromImage(cursor), cursorInfo.custom_hotspot().x(), cursorInfo.custom_hotspot().y()));
return;
}
break;
}
#if defined(USE_AURA)
- if (auraType != ui::CursorType::kNull) {
+ if (auraType != ui::mojom::CursorType::kNull) {
int resourceId;
gfx::Point hotspot;
// GetCursorDataFor only knows hotspots for 1x and 2x cursor images, in physical pixels.
@@ -541,18 +581,6 @@ void RenderWidgetHostViewQt::DisplayTooltipText(const base::string16 &tooltip_te
m_adapterClient->setToolTip(toQt(tooltip_text));
}
-void RenderWidgetHostViewQt::DidCreateNewRendererCompositorFrameSink(viz::mojom::CompositorFrameSinkClient *frameSinkClient)
-{
- // Not used with viz
- NOTREACHED();
-}
-
-void RenderWidgetHostViewQt::SubmitCompositorFrame(const viz::LocalSurfaceId &local_surface_id, viz::CompositorFrame frame, base::Optional<viz::HitTestRegionList> hit_test_region_list)
-{
- // Not used with viz
- NOTREACHED();
-}
-
void RenderWidgetHostViewQt::GetScreenInfo(content::ScreenInfo *results)
{
*results = m_screenInfo;
@@ -830,12 +858,6 @@ content::MouseWheelPhaseHandler *RenderWidgetHostViewQt::GetMouseWheelPhaseHandl
return &m_mouseWheelPhaseHandler;
}
-void RenderWidgetHostViewQt::SetNeedsBeginFrames(bool needs_begin_frames)
-{
- // Not used with viz
- NOTREACHED();
-}
-
content::RenderFrameHost *RenderWidgetHostViewQt::getFocusedFrameHost()
{
content::RenderViewHostImpl *viewHost = content::RenderViewHostImpl::From(host());
@@ -866,11 +888,6 @@ ui::TextInputType RenderWidgetHostViewQt::getTextInputType() const
return ui::TEXT_INPUT_TYPE_NONE;
}
-void RenderWidgetHostViewQt::SetWantsAnimateOnlyBeginFrames()
-{
- m_delegatedFrameHost->SetWantsAnimateOnlyBeginFrames();
-}
-
viz::SurfaceId RenderWidgetHostViewQt::GetCurrentSurfaceId() const
{
return m_delegatedFrameHost->GetCurrentSurfaceId();